ollama - ✅(Solved) Fix Apple M5 + macOS 26.3.1: 500 Internal Server Error, Metal compiler failed to build request even with OLLAMA_NUM_GPU=0 [2 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

Error: 500 Internal Server Error: llama runner process has terminated: %!w(<nil>)

Fix Action

Fix / Workaround

  • Is this a known regression for Apple M5 + macOS 26.3.1 in the current Metal / GGML backend?
  • Is there any workaround to run models on this machine (even CPU-only) until a fix is available?

PR fix notes

PR #14604: fix(metal): resolve static_assert crash on Apple M5

Description (problem / solution / changelog)

Fixed #14432, also resolves #13460

The Issue

This PR addresses a critical Metal backend crash on Apple M5 MTLGPUFamilyApple10 devices. The bf16xf16 mixed-precision matrix kernels trigger a static_assert failure in the Metal Performance Primitives header because the M5 hardware requires strict type matching for cooperative tensor operations.

The Fix

To align with upstream llama.cpp logic and ensure stability across different build environments, this PR implements the following:

  • Cleaned up Metal Shaders: Removed the incompatible kernel_mul_mm_bf16_f16 and its indirect variant kernel_mul_mm_id_bf16_f16 templates from both source and embedded .metal files to prevent the strict M5 compiler from asserting.
  • Graph Fallback: Updated ggml_metal_device_supports_op in ggml-metal-device.m to explicitly return false for BF16 x F16 multiplications. This tells the graph scheduler to safely handle this via a cast node or CPU fallback, rather than forcing it onto the Metal backend.
  • Dylib Fix: Added null-checks during pipeline initialization in ggml-metal-ops.cpp and ggml-metal-device.cpp. This prevents silent GPU discovery failures and null pointer crashes when the project is compiled with GGML_METAL=ON and attempts to look up the removed kernels.

Verification

  • Successfully tested on M5 running macOS 26.3 (25D125).
  • Tested models: llama3.2:3b and gemma3:270m-it-bf16.
  • Verified that models run perfectly on the GPU with this patch under both EMBED_LIBRARY=1 and EMBED_LIBRARY=OFF (dylib) build configurations without silent CPU fallbacks.

Logs

olama run llama3.2:3b

➜  ollama git:(fix-m5-metal-static-assert) ✗ ./ollama run llama3.2:3b
>>> hello
Hello! How can I assist you today?

>>> /bye

ollama serve

➜  ollama git:(fix-m5-metal-static-assert) ✗ ./ollama serve
time=2026-03-03T22:20:53.291-05:00 level=INFO source=routes.go:1743 msg="server config" env="map[HTTPS_PROXY: HTTP_PROXY: NO_PROXY: OLLAMA_CONTEXT_LENGTH:0 OLLAMA_DEBUG:INFO OLLAMA_EDITOR: OLLAMA_FLASH_ATTENTION:false OLLAMA_GPU_OVERHEAD:0 OLLAMA_HOST:http://0.0.0.0:11434 OLLAMA_KEEP_ALIVE:5m0s OLLAMA_KV_CACHE_TYPE: OLLAMA_LLM_LIBRARY: OLLAMA_LOAD_TIMEOUT:5m0s OLLAMA_MAX_LOADED_MODELS:0 OLLAMA_MAX_QUEUE:512 OLLAMA_MODELS:/Users/vya/.ollama/models OLLAMA_MULTIUSER_CACHE:false OLLAMA_NEW_ENGINE:false OLLAMA_NOHISTORY:false OLLAMA_NOPRUNE:false OLLAMA_NO_CLOUD:false OLLAMA_NUM_PARALLEL:1 OLLAMA_ORIGINS:[http://localhost https://localhost http://localhost:* https://localhost:* http://127.0.0.1 https://127.0.0.1 http://127.0.0.1:* https://127.0.0.1:* http://0.0.0.0 https://0.0.0.0 http://0.0.0.0:* https://0.0.0.0:* app://* file://* tauri://* vscode-webview://* vscode-file://*] OLLAMA_REMOTES:[ollama.com] OLLAMA_SCHED_SPREAD:false http_proxy: https_proxy: no_proxy:]"
time=2026-03-03T22:20:53.291-05:00 level=INFO source=routes.go:1745 msg="Ollama cloud disabled: false"
time=2026-03-03T22:20:53.293-05:00 level=INFO source=images.go:477 msg="total blobs: 16"
time=2026-03-03T22:20:53.293-05:00 level=INFO source=images.go:484 msg="total unused blobs removed: 0"
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode)

[GIN-debug] HEAD   /                         --> github.com/ollama/ollama/server.(*Server).GenerateRoutes.func1 (5 handlers)
[GIN-debug] GET    /                         --> github.com/ollama/ollama/server.(*Server).GenerateRoutes.func2 (5 handlers)
[GIN-debug] HEAD   /api/version              --> github.com/ollama/ollama/server.(*Server).GenerateRoutes.func3 (5 handlers)
[GIN-debug] GET    /api/version              --> github.com/ollama/ollama/server.(*Server).GenerateRoutes.func4 (5 handlers)
[GIN-debug] GET    /api/status               --> github.com/ollama/ollama/server.(*Server).StatusHandler-fm (5 handlers)
[GIN-debug] POST   /api/pull                 --> github.com/ollama/ollama/server.(*Server).PullHandler-fm (5 handlers)
[GIN-debug] POST   /api/push                 --> github.com/ollama/ollama/server.(*Server).PushHandler-fm (5 handlers)
[GIN-debug] HEAD   /api/tags                 --> github.com/ollama/ollama/server.(*Server).ListHandler-fm (5 handlers)
[GIN-debug] GET    /api/tags                 --> github.com/ollama/ollama/server.(*Server).ListHandler-fm (5 handlers)
[GIN-debug] POST   /api/show                 --> github.com/ollama/ollama/server.(*Server).ShowHandler-fm (5 handlers)
[GIN-debug] DELETE /api/delete               --> github.com/ollama/ollama/server.(*Server).DeleteHandler-fm (5 handlers)
[GIN-debug] POST   /api/me                   --> github.com/ollama/ollama/server.(*Server).WhoamiHandler-fm (5 handlers)
[GIN-debug] POST   /api/signout              --> github.com/ollama/ollama/server.(*Server).SignoutHandler-fm (5 handlers)
[GIN-debug] DELETE /api/user/keys/:encodedKey --> github.com/ollama/ollama/server.(*Server).SignoutHandler-fm (5 handlers)
[GIN-debug] POST   /api/create               --> github.com/ollama/ollama/server.(*Server).CreateHandler-fm (5 handlers)
[GIN-debug] POST   /api/blobs/:digest        --> github.com/ollama/ollama/server.(*Server).CreateBlobHandler-fm (5 handlers)
[GIN-debug] HEAD   /api/blobs/:digest        --> github.com/ollama/ollama/server.(*Server).HeadBlobHandler-fm (5 handlers)
[GIN-debug] POST   /api/copy                 --> github.com/ollama/ollama/server.(*Server).CopyHandler-fm (5 handlers)
[GIN-debug] GET    /api/experimental/aliases --> github.com/ollama/ollama/server.(*Server).ListAliasesHandler-fm (5 handlers)
[GIN-debug] POST   /api/experimental/aliases --> github.com/ollama/ollama/server.(*Server).CreateAliasHandler-fm (5 handlers)
[GIN-debug] DELETE /api/experimental/aliases --> github.com/ollama/ollama/server.(*Server).DeleteAliasHandler-fm (5 handlers)
[GIN-debug] GET    /api/ps                   --> github.com/ollama/ollama/server.(*Server).PsHandler-fm (5 handlers)
[GIN-debug] POST   /api/generate             --> github.com/ollama/ollama/server.(*Server).GenerateHandler-fm (5 handlers)
[GIN-debug] POST   /api/chat                 --> github.com/ollama/ollama/server.(*Server).ChatHandler-fm (5 handlers)
[GIN-debug] POST   /api/embed                --> github.com/ollama/ollama/server.(*Server).EmbedHandler-fm (5 handlers)
[GIN-debug] POST   /api/embeddings           --> github.com/ollama/ollama/server.(*Server).EmbeddingsHandler-fm (5 handlers)
[GIN-debug] POST   /v1/chat/completions      --> github.com/ollama/ollama/server.(*Server).ChatHandler-fm (7 handlers)
[GIN-debug] POST   /v1/completions           --> github.com/ollama/ollama/server.(*Server).GenerateHandler-fm (7 handlers)
[GIN-debug] POST   /v1/embeddings            --> github.com/ollama/ollama/server.(*Server).EmbedHandler-fm (7 handlers)
[GIN-debug] GET    /v1/models                --> github.com/ollama/ollama/server.(*Server).ListHandler-fm (6 handlers)
[GIN-debug] GET    /v1/models/:model         --> github.com/ollama/ollama/server.(*Server).ShowHandler-fm (7 handlers)
[GIN-debug] POST   /v1/responses             --> github.com/ollama/ollama/server.(*Server).ChatHandler-fm (7 handlers)
[GIN-debug] POST   /v1/images/generations    --> github.com/ollama/ollama/server.(*Server).GenerateHandler-fm (7 handlers)
[GIN-debug] POST   /v1/images/edits          --> github.com/ollama/ollama/server.(*Server).GenerateHandler-fm (7 handlers)
[GIN-debug] POST   /v1/messages              --> github.com/ollama/ollama/server.(*Server).ChatHandler-fm (7 handlers)
time=2026-03-03T22:20:53.294-05:00 level=INFO source=routes.go:1798 msg="Listening on [::]:11434 (version 0.0.0)"
time=2026-03-03T22:20:53.297-05:00 level=INFO source=runner.go:67 msg="discovering available GPUs..."
time=2026-03-03T22:20:53.299-05:00 level=INFO source=server.go:430 msg="starting runner" cmd="/Users/vya/Projects/ollama/ollama runner --ollama-engine --port 56232"
time=2026-03-03T22:21:01.210-05:00 level=INFO source=types.go:42 msg="inference compute" id=0 filter_id=0 library=Metal compute=0.0 name=Metal description="Apple M5" libdirs="" driver=0.0 pci_id="" type=discrete total="11.8 GiB" available="11.8 GiB"
time=2026-03-03T22:21:01.210-05:00 level=INFO source=routes.go:1848 msg="vram-based default context" total_vram="11.8 GiB" default_num_ctx=4096
[GIN] 2026/03/03 - 22:21:01 | 200 |      83.459µs |       127.0.0.1 | HEAD     "/"
[GIN] 2026/03/03 - 22:21:01 | 200 |   71.371083ms |       127.0.0.1 | POST     "/api/show"
[GIN] 2026/03/03 - 22:21:01 | 200 |      59.816ms |       127.0.0.1 | POST     "/api/show"
ggml_metal_device_init: testing tensor API for f16 support
ggml_metal_device_init: testing tensor API for bfloat support
ggml_metal_library_init: using embedded metal library
ggml_metal_library_init: loaded in 0.006 sec
ggml_metal_rsets_init: creating a residency set collection (keep_alive = 180 s)
ggml_metal_device_init: GPU name:   Apple M5
ggml_metal_device_init: GPU family: MTLGPUFamilyApple10  (1010)
ggml_metal_device_init: GPU family: MTLGPUFamilyCommon3 (3003)
ggml_metal_device_init: GPU family: MTLGPUFamilyMetal4  (5002)
ggml_metal_device_init: simdgroup reduction   = true
ggml_metal_device_init: simdgroup matrix mul. = true
ggml_metal_device_init: has unified memory    = true
ggml_metal_device_init: has bfloat            = true
ggml_metal_device_init: has tensor            = true
ggml_metal_device_init: use residency sets    = true
ggml_metal_device_init: use shared buffers    = true
ggml_metal_device_init: recommendedMaxWorkingSetSize  = 12713.12 MB
llama_model_load_from_file_impl: using device Metal (Apple M5) (unknown id) - 12123 MiB free
llama_model_loader: loaded meta data with 30 key-value pairs and 255 tensors from /Users/vya/.ollama/models/blobs/sha256-dde5aa3fc5ffc17176b5e8bdc82f587b24b2678c6c66101bf7da77af9f7ccdff (version GGUF V3 (latest))
llama_model_loader: Dumping metadata keys/values. Note: KV overrides do not apply in this output.
llama_model_loader: - kv   0:                       general.architecture str              = llama
llama_model_loader: - kv   1:                               general.type str              = model
llama_model_loader: - kv   2:                               general.name str              = Llama 3.2 3B Instruct
llama_model_loader: - kv   3:                           general.finetune str              = Instruct
llama_model_loader: - kv   4:                           general.basename str              = Llama-3.2
llama_model_loader: - kv   5:                         general.size_label str              = 3B
llama_model_loader: - kv   6:                               general.tags arr[str,6]       = ["facebook", "meta", "pytorch", "llam...
llama_model_loader: - kv   7:                          general.languages arr[str,8]       = ["en", "de", "fr", "it", "pt", "hi", ...
llama_model_loader: - kv   8:                          llama.block_count u32              = 28
llama_model_loader: - kv   9:                       llama.context_length u32              = 131072
llama_model_loader: - kv  10:                     llama.embedding_length u32              = 3072
llama_model_loader: - kv  11:                  llama.feed_forward_length u32              = 8192
llama_model_loader: - kv  12:                 llama.attention.head_count u32              = 24
llama_model_loader: - kv  13:              llama.attention.head_count_kv u32              = 8
llama_model_loader: - kv  14:                       llama.rope.freq_base f32              = 500000.000000
llama_model_loader: - kv  15:     llama.attention.layer_norm_rms_epsilon f32              = 0.000010
llama_model_loader: - kv  16:                 llama.attention.key_length u32              = 128
llama_model_loader: - kv  17:               llama.attention.value_length u32              = 128
llama_model_loader: - kv  18:                          general.file_type u32              = 15
llama_model_loader: - kv  19:                           llama.vocab_size u32              = 128256
llama_model_loader: - kv  20:                 llama.rope.dimension_count u32              = 128
llama_model_loader: - kv  21:                       tokenizer.ggml.model str              = gpt2
llama_model_loader: - kv  22:                         tokenizer.ggml.pre str              = llama-bpe
llama_model_loader: - kv  23:                      tokenizer.ggml.tokens arr[str,128256]  = ["!", "\"", "#", "$", "%", "&", "'", ...
llama_model_loader: - kv  24:                  tokenizer.ggml.token_type arr[i32,128256]  = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
llama_model_loader: - kv  25:                      tokenizer.ggml.merges arr[str,280147]  = ["Ġ Ġ", "Ġ ĠĠĠ", "ĠĠ ĠĠ", "...
llama_model_loader: - kv  26:                tokenizer.ggml.bos_token_id u32              = 128000
llama_model_loader: - kv  27:                tokenizer.ggml.eos_token_id u32              = 128009
llama_model_loader: - kv  28:                    tokenizer.chat_template str              = {{- bos_token }}\n{%- if custom_tools ...
llama_model_loader: - kv  29:               general.quantization_version u32              = 2
llama_model_loader: - type  f32:   58 tensors
llama_model_loader: - type q4_K:  168 tensors
llama_model_loader: - type q6_K:   29 tensors
print_info: file format = GGUF V3 (latest)
print_info: file type   = Q4_K - Medium
print_info: file size   = 1.87 GiB (5.01 BPW) 
load: printing all EOG tokens:
load:   - 128001 ('<|end_of_text|>')
load:   - 128008 ('<|eom_id|>')
load:   - 128009 ('<|eot_id|>')
load: special tokens cache size = 256
load: token to piece cache size = 0.7999 MB
print_info: arch             = llama
print_info: vocab_only       = 1
print_info: no_alloc         = 0
print_info: model type       = ?B
print_info: model params     = 3.21 B
print_info: general.name     = Llama 3.2 3B Instruct
print_info: vocab type       = BPE
print_info: n_vocab          = 128256
print_info: n_merges         = 280147
print_info: BOS token        = 128000 '<|begin_of_text|>'
print_info: EOS token        = 128009 '<|eot_id|>'
print_info: EOT token        = 128001 '<|end_of_text|>'
print_info: EOM token        = 128008 '<|eom_id|>'
print_info: LF token         = 198 'Ċ'
print_info: EOG token        = 128001 '<|end_of_text|>'
print_info: EOG token        = 128008 '<|eom_id|>'
print_info: EOG token        = 128009 '<|eot_id|>'
print_info: max token length = 256
llama_model_load: vocab only - skipping tensors
time=2026-03-03T22:21:01.620-05:00 level=INFO source=server.go:430 msg="starting runner" cmd="/Users/vya/Projects/ollama/ollama runner --model /Users/vya/.ollama/models/blobs/sha256-dde5aa3fc5ffc17176b5e8bdc82f587b24b2678c6c66101bf7da77af9f7ccdff --port 56239"
time=2026-03-03T22:21:01.622-05:00 level=INFO source=sched.go:489 msg="system memory" total="16.0 GiB" free="5.9 GiB" free_swap="0 B"
time=2026-03-03T22:21:01.623-05:00 level=INFO source=sched.go:496 msg="gpu memory" id=0 library=Metal available="11.3 GiB" free="11.8 GiB" minimum="512.0 MiB" overhead="0 B"
time=2026-03-03T22:21:01.623-05:00 level=INFO source=server.go:497 msg="loading model" "model layers"=29 requested=-1
time=2026-03-03T22:21:01.623-05:00 level=INFO source=device.go:240 msg="model weights" device=Metal size="1.9 GiB"
time=2026-03-03T22:21:01.623-05:00 level=INFO source=device.go:251 msg="kv cache" device=Metal size="448.0 MiB"
time=2026-03-03T22:21:01.623-05:00 level=INFO source=device.go:262 msg="compute graph" device=Metal size="256.5 MiB"
time=2026-03-03T22:21:01.623-05:00 level=INFO source=device.go:272 msg="total memory" size="2.6 GiB"
time=2026-03-03T22:21:01.634-05:00 level=INFO source=runner.go:965 msg="starting go runner"
ggml_metal_device_init: testing tensor API for f16 support
ggml_metal_device_init: testing tensor API for bfloat support
ggml_metal_library_init: using embedded metal library
ggml_metal_library_init: loaded in 7.081 sec
ggml_metal_rsets_init: creating a residency set collection (keep_alive = 180 s)
ggml_metal_device_init: GPU name:   Apple M5
ggml_metal_device_init: GPU family: MTLGPUFamilyApple10  (1010)
ggml_metal_device_init: GPU family: MTLGPUFamilyCommon3 (3003)
ggml_metal_device_init: GPU family: MTLGPUFamilyMetal4  (5002)
ggml_metal_device_init: simdgroup reduction   = true
ggml_metal_device_init: simdgroup matrix mul. = true
ggml_metal_device_init: has unified memory    = true
ggml_metal_device_init: has bfloat            = true
ggml_metal_device_init: has tensor            = true
ggml_metal_device_init: use residency sets    = true
ggml_metal_device_init: use shared buffers    = true
ggml_metal_device_init: recommendedMaxWorkingSetSize  = 12713.12 MB
time=2026-03-03T22:21:01.635-05:00 level=INFO source=ggml.go:104 msg=system Metal.0.EMBED_LIBRARY=1 CPU.0.NEON=1 CPU.0.ARM_FMA=1 CPU.0.FP16_VA=1 CPU.0.DOTPROD=1 CPU.0.LLAMAFILE=1 CPU.0.ACCELERATE=1 compiler=cgo(clang)
time=2026-03-03T22:21:08.750-05:00 level=INFO source=runner.go:1001 msg="Server listening on 127.0.0.1:56239"
time=2026-03-03T22:21:08.751-05:00 level=INFO source=runner.go:895 msg=load request="{Operation:commit LoraPath:[] Parallel:1 BatchSize:512 FlashAttention:Auto KvSize:4096 KvCacheType: NumThreads:4 GPULayers:29[ID:0 Layers:29(0..28)] MultiUserCache:false ProjectorPath: MainGPU:0 UseMmap:true}"
llama_model_load_from_file_impl: using device Metal (Apple M5) (unknown id) - 12123 MiB free
time=2026-03-03T22:21:08.751-05:00 level=INFO source=server.go:1350 msg="waiting for llama runner to start responding"
time=2026-03-03T22:21:08.752-05:00 level=INFO source=server.go:1384 msg="waiting for server to become available" status="llm server loading model"
llama_model_loader: loaded meta data with 30 key-value pairs and 255 tensors from /Users/vya/.ollama/models/blobs/sha256-dde5aa3fc5ffc17176b5e8bdc82f587b24b2678c6c66101bf7da77af9f7ccdff (version GGUF V3 (latest))
llama_model_loader: Dumping metadata keys/values. Note: KV overrides do not apply in this output.
llama_model_loader: - kv   0:                       general.architecture str              = llama
llama_model_loader: - kv   1:                               general.type str              = model
llama_model_loader: - kv   2:                               general.name str              = Llama 3.2 3B Instruct
llama_model_loader: - kv   3:                           general.finetune str              = Instruct
llama_model_loader: - kv   4:                           general.basename str              = Llama-3.2
llama_model_loader: - kv   5:                         general.size_label str              = 3B
llama_model_loader: - kv   6:                               general.tags arr[str,6]       = ["facebook", "meta", "pytorch", "llam...
llama_model_loader: - kv   7:                          general.languages arr[str,8]       = ["en", "de", "fr", "it", "pt", "hi", ...
llama_model_loader: - kv   8:                          llama.block_count u32              = 28
llama_model_loader: - kv   9:                       llama.context_length u32              = 131072
llama_model_loader: - kv  10:                     llama.embedding_length u32              = 3072
llama_model_loader: - kv  11:                  llama.feed_forward_length u32              = 8192
llama_model_loader: - kv  12:                 llama.attention.head_count u32              = 24
llama_model_loader: - kv  13:              llama.attention.head_count_kv u32              = 8
llama_model_loader: - kv  14:                       llama.rope.freq_base f32              = 500000.000000
llama_model_loader: - kv  15:     llama.attention.layer_norm_rms_epsilon f32              = 0.000010
llama_model_loader: - kv  16:                 llama.attention.key_length u32              = 128
llama_model_loader: - kv  17:               llama.attention.value_length u32              = 128
llama_model_loader: - kv  18:                          general.file_type u32              = 15
llama_model_loader: - kv  19:                           llama.vocab_size u32              = 128256
llama_model_loader: - kv  20:                 llama.rope.dimension_count u32              = 128
llama_model_loader: - kv  21:                       tokenizer.ggml.model str              = gpt2
llama_model_loader: - kv  22:                         tokenizer.ggml.pre str              = llama-bpe
llama_model_loader: - kv  23:                      tokenizer.ggml.tokens arr[str,128256]  = ["!", "\"", "#", "$", "%", "&", "'", ...
llama_model_loader: - kv  24:                  tokenizer.ggml.token_type arr[i32,128256]  = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
llama_model_loader: - kv  25:                      tokenizer.ggml.merges arr[str,280147]  = ["Ġ Ġ", "Ġ ĠĠĠ", "ĠĠ ĠĠ", "...
llama_model_loader: - kv  26:                tokenizer.ggml.bos_token_id u32              = 128000
llama_model_loader: - kv  27:                tokenizer.ggml.eos_token_id u32              = 128009
llama_model_loader: - kv  28:                    tokenizer.chat_template str              = {{- bos_token }}\n{%- if custom_tools ...
llama_model_loader: - kv  29:               general.quantization_version u32              = 2
llama_model_loader: - type  f32:   58 tensors
llama_model_loader: - type q4_K:  168 tensors
llama_model_loader: - type q6_K:   29 tensors
print_info: file format = GGUF V3 (latest)
print_info: file type   = Q4_K - Medium
print_info: file size   = 1.87 GiB (5.01 BPW) 
load: printing all EOG tokens:
load:   - 128001 ('<|end_of_text|>')
load:   - 128008 ('<|eom_id|>')
load:   - 128009 ('<|eot_id|>')
load: special tokens cache size = 256
load: token to piece cache size = 0.7999 MB
print_info: arch             = llama
print_info: vocab_only       = 0
print_info: no_alloc         = 0
print_info: n_ctx_train      = 131072
print_info: n_embd           = 3072
print_info: n_embd_inp       = 3072
print_info: n_layer          = 28
print_info: n_head           = 24
print_info: n_head_kv        = 8
print_info: n_rot            = 128
print_info: n_swa            = 0
print_info: is_swa_any       = 0
print_info: n_embd_head_k    = 128
print_info: n_embd_head_v    = 128
print_info: n_gqa            = 3
print_info: n_embd_k_gqa     = 1024
print_info: n_embd_v_gqa     = 1024
print_info: f_norm_eps       = 0.0e+00
print_info: f_norm_rms_eps   = 1.0e-05
print_info: f_clamp_kqv      = 0.0e+00
print_info: f_max_alibi_bias = 0.0e+00
print_info: f_logit_scale    = 0.0e+00
print_info: f_attn_scale     = 0.0e+00
print_info: n_ff             = 8192
print_info: n_expert         = 0
print_info: n_expert_used    = 0
print_info: n_expert_groups  = 0
print_info: n_group_used     = 0
print_info: causal attn      = 1
print_info: pooling type     = 0
print_info: rope type        = 0
print_info: rope scaling     = linear
print_info: freq_base_train  = 500000.0
print_info: freq_scale_train = 1
print_info: n_ctx_orig_yarn  = 131072
print_info: rope_yarn_log_mul= 0.0000
print_info: rope_finetuned   = unknown
print_info: model type       = 3B
print_info: model params     = 3.21 B
print_info: general.name     = Llama 3.2 3B Instruct
print_info: vocab type       = BPE
print_info: n_vocab          = 128256
print_info: n_merges         = 280147
print_info: BOS token        = 128000 '<|begin_of_text|>'
print_info: EOS token        = 128009 '<|eot_id|>'
print_info: EOT token        = 128001 '<|end_of_text|>'
print_info: EOM token        = 128008 '<|eom_id|>'
print_info: LF token         = 198 'Ċ'
print_info: EOG token        = 128001 '<|end_of_text|>'
print_info: EOG token        = 128008 '<|eom_id|>'
print_info: EOG token        = 128009 '<|eot_id|>'
print_info: max token length = 256
load_tensors: loading model tensors, this can take a while... (mmap = true)
load_tensors: offloading 28 repeating layers to GPU
load_tensors: offloading output layer to GPU
load_tensors: offloaded 29/29 layers to GPU
load_tensors:   CPU_Mapped model buffer size =   308.23 MiB
load_tensors: Metal_Mapped model buffer size =  1918.35 MiB
llama_context: constructing llama_context
llama_context: n_seq_max     = 1
llama_context: n_ctx         = 4096
llama_context: n_ctx_seq     = 4096
llama_context: n_batch       = 512
llama_context: n_ubatch      = 512
llama_context: causal_attn   = 1
llama_context: flash_attn    = auto
llama_context: kv_unified    = false
llama_context: freq_base     = 500000.0
llama_context: freq_scale    = 1
llama_context: n_ctx_seq (4096) < n_ctx_train (131072) -- the full capacity of the model will not be utilized
ggml_metal_init: allocating
ggml_metal_init: picking default device: Apple M5
ggml_metal_init: use fusion         = true
ggml_metal_init: use concurrency    = true
ggml_metal_init: use graph optimize = true
llama_context:        CPU  output buffer size =     0.50 MiB
llama_kv_cache:      Metal KV buffer size =   448.00 MiB
llama_kv_cache: size =  448.00 MiB (  4096 cells,  28 layers,  1/1 seqs), K (f16):  224.00 MiB, V (f16):  224.00 MiB
llama_context: Flash Attention was auto, set to enabled
llama_context:      Metal compute buffer size =   256.50 MiB
llama_context:        CPU compute buffer size =    14.01 MiB
llama_context: graph nodes  = 875
llama_context: graph splits = 2
time=2026-03-03T22:21:10.007-05:00 level=INFO source=server.go:1388 msg="llama runner started in 8.38 seconds"
time=2026-03-03T22:21:10.007-05:00 level=INFO source=sched.go:565 msg="loaded runners" count=1
time=2026-03-03T22:21:10.007-05:00 level=INFO source=server.go:1350 msg="waiting for llama runner to start responding"
time=2026-03-03T22:21:10.007-05:00 level=INFO source=server.go:1388 msg="llama runner started in 8.38 seconds"
[GIN] 2026/03/03 - 22:21:10 | 200 |  8.662964167s |       127.0.0.1 | POST     "/api/generate"
[GIN] 2026/03/03 - 22:21:13 | 200 |  578.595292ms |       127.0.0.1 | POST     "/api/chat"

Changed files

  • ml/backend/ggml/ggml/src/ggml-metal/ggml-metal-device.cpp (modified, +12/-0)
  • ml/backend/ggml/ggml/src/ggml-metal/ggml-metal-device.m (modified, +3/-0)
  • ml/backend/ggml/ggml/src/ggml-metal/ggml-metal-embed.metal (modified, +0/-6)
  • ml/backend/ggml/ggml/src/ggml-metal/ggml-metal-ops.cpp (modified, +12/-0)
  • ml/backend/ggml/ggml/src/ggml-metal/ggml-metal.metal (modified, +0/-6)

Code Example

ollama pull llama3.1:8b

---

OLLAMA_NUM_GPU=0 ollama run llama3.1:8b

---

Error: 500 Internal Server Error: llama runner process has terminated: %!w(<nil>)

---

log stream --predicate 'process == "ollama"' --info | grep -iE 'Error|Metal|fault|assert|panic'

---

2026-04-09 17:49:22.708860+0800 0xa1b5     Activity    0x68f85              1940   0    ollama: (Metal) Metal Compiling Shader
2026-04-09 17:49:23.640608+0800 0xa1b5     Error       0x68f85              1940   0    ollama: (Metal) Compiler failed to build request

2026-04-09 17:49:23.799570+0800 0xa1cc     Error       0x0                  1998   0    ollama: (libCoreFSCache.dylib) flock failed to lock list file (<private>): errno = 35
2026-04-09 17:49:23.799940+0800 0xa1cc     Error       0x0                  1998   0    ollama: (libCoreFSCache.dylib) flock failed to lock list file (<private>): errno = 35

# more lines with MTLCompilerService and Metal Compiling Shader ...

---

OLLAMA_NUM_GPU=0 ollama run llama3.1:8b

---

ollama rm llama3.1:8b
  ollama pull llama3.1:8b

---
RAW_BUFFERClick to expand / collapse

What is the issue?

Describe the bug

On a MacBook Pro with Apple M5 chip and macOS 26.3.1, any attempt to run a model fails with:

Error: 500 Internal Server Error: llama runner process has terminated: %!w(<nil>)

This happens even when forcing CPU-only mode with OLLAMA_NUM_GPU=0. The system logs show repeated Metal shader compilation failures right before the runner terminates.


Environment

  • Device: MacBook Pro (Apple M5, 24 GB RAM)
  • OS: macOS 26.3.1 (from sw_vers):
    • ProductVersion: 26.3.1
    • ProductVersionExtra: (a)
    • BuildVersion: 25D771280a
  • Ollama version: ollama --version0.20.4
  • Install method: Homebrew / official install script / .dmg (please specify)

Steps to reproduce

On this machine:

  1. Install Ollama 0.20.4
  2. Pull a model, e.g.:
    ollama pull llama3.1:8b
  3. Try to run the model in CPU-only mode:
    OLLAMA_NUM_GPU=0 ollama run llama3.1:8b

Expected behavior

The model should start and respond (especially in CPU-only mode with OLLAMA_NUM_GPU=0).

Actual behavior

The command immediately fails with:

Error: 500 Internal Server Error: llama runner process has terminated: %!w(<nil>)

No additional error details are printed in the terminal.


Relevant logs

From:

log stream --predicate 'process == "ollama"' --info | grep -iE 'Error|Metal|fault|assert|panic'

I see (excerpt):

2026-04-09 17:49:22.708860+0800 0xa1b5     Activity    0x68f85              1940   0    ollama: (Metal) Metal Compiling Shader
2026-04-09 17:49:23.640608+0800 0xa1b5     Error       0x68f85              1940   0    ollama: (Metal) Compiler failed to build request

2026-04-09 17:49:23.799570+0800 0xa1cc     Error       0x0                  1998   0    ollama: (libCoreFSCache.dylib) flock failed to lock list file (<private>): errno = 35
2026-04-09 17:49:23.799940+0800 0xa1cc     Error       0x0                  1998   0    ollama: (libCoreFSCache.dylib) flock failed to lock list file (<private>): errno = 35

# more lines with MTLCompilerService and Metal Compiling Shader ...

The 500 error (llama runner process has terminated: %!w(<nil>)) appears every time right after the Metal compiler failure.


What I have already tried

  • Fully reinstalling Ollama (removing ~/.ollama, caches, logs) and installing 0.20.4 again
  • Rebooting the machine
  • Forcing CPU-only mode:
    OLLAMA_NUM_GPU=0 ollama run llama3.1:8b
  • Deleting and re-pulling the model:
    ollama rm llama3.1:8b
    ollama pull llama3.1:8b

All of the above still result in the same 500 error and the Metal compiler failure in the logs.


Questions

  • Is this a known regression for Apple M5 + macOS 26.3.1 in the current Metal / GGML backend?
  • Is there any workaround to run models on this machine (even CPU-only) until a fix is available?

Relevant log output

OS

No response

GPU

No response

CPU

No response

Ollama version

No response

extent analysis

TL;DR

The issue is likely related to Metal shader compilation failures on Apple M5 chip with macOS 26.3.1, and a potential workaround is to disable Metal acceleration or use a different backend.

Guidance

  • The error message and logs suggest that the Metal compiler is failing to build requests, which is causing the llama runner process to terminate.
  • Try setting the OLLAMA_METAL_ENABLED environment variable to 0 to disable Metal acceleration and force CPU-only mode: OLLAMA_METAL_ENABLED=0 OLLAMA_NUM_GPU=0 ollama run llama3.1:8b
  • If the above workaround does not work, try checking for any updates to the Metal backend or GGML library that may resolve the compilation issues.
  • Verify that the issue is not specific to the llama3.1:8b model by trying to run other models and seeing if they exhibit the same behavior.

Example

No code snippet is provided as the issue seems to be related to environment variables and backend configuration.

Notes

The issue may be specific to the Apple M5 chip and macOS 26.3.1, and may require updates to the Metal backend or GGML library to resolve. Additionally, the OLLAMA_METAL_ENABLED environment variable may not be officially supported or documented, so use with caution.

Recommendation

Apply the workaround by setting OLLAMA_METAL_ENABLED=0 and OLLAMA_NUM_GPU=0 to disable Metal acceleration and force CPU-only mode, as this may allow the model to run until a fix is available for the Metal compiler issues.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING