[GH-ISSUE #15813] Metal backend crash on Apple M5 - bfloat/half type mismatch in MPPTensorOpsMatMul2d (v0.21.2) #56589

Open
opened 2026-04-29 11:04:00 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @egalarza007 on GitHub (Apr 25, 2026).
Original GitHub issue: https://github.com/ollama/ollama/issues/15813

Description

Ollama fails to run any model on Apple M5 hardware. The Metal shader compilation
fails with a bfloat/half type mismatch in MetalPerformancePrimitives.

Environment

  • Ollama version: 0.21.2
  • macOS: Sequoia 15.3+ (Apple M5)
  • GPU: Apple M5 (MTLGPUFamilyApple10)
  • VRAM: ~19GB available

Error

From ~/.ollama/logs/server.log:

ggml_metal_init: the device does not have a precompiled Metal library - this is unexpected
ggml_metal_init: will try to compile it on the fly
ggml_metal_library_init: error: Error Domain=MTLLibraryErrorDomain Code=3
static_assert failed due to requirement '__tensor_ops_detail::__is_same_v<bfloat, half>'
"Input types must match cooperative tensor types"
ggml_metal_init: error: failed to initialize the Metal library
ggml_backend_metal_device_init: error: failed to allocate context
llama_init_from_model: failed to initialize the context: failed to initialize Metal backend
panic: unable to create llama context

The server reports the GPU as MTLGPUFamilyApple10 (1010) which is M5-specific.
The embedded Metal library does not have a precompiled library for this GPU family,
and on-the-fly compilation fails due to a bfloat16/half type mismatch in the
MetalPerformancePrimitives framework.

Impact

All models fail with: 500 Internal Server Error: llama runner process has terminated
OLLAMA_NO_METAL=1 is silently ignored in v0.21.2.

Workaround

Setting GGML_METAL_BF16_DISABLE=1 before starting the server allows models to
load and run (CPU fallback, no GPU acceleration):

GGML_METAL_BF16_DISABLE=1 ollama serve

Expected Behavior

Ollama should either:

  1. Ship a precompiled Metal library for MTLGPUFamilyApple10 (M5), or
  2. Correctly fall back to CPU when Metal compilation fails, or
  3. Honor OLLAMA_NO_METAL=1 to explicitly disable Metal
Originally created by @egalarza007 on GitHub (Apr 25, 2026). Original GitHub issue: https://github.com/ollama/ollama/issues/15813 ## Description Ollama fails to run any model on Apple M5 hardware. The Metal shader compilation fails with a bfloat/half type mismatch in MetalPerformancePrimitives. ## Environment - Ollama version: 0.21.2 - macOS: Sequoia 15.3+ (Apple M5) - GPU: Apple M5 (MTLGPUFamilyApple10) - VRAM: ~19GB available ## Error From ~/.ollama/logs/server.log: ggml_metal_init: the device does not have a precompiled Metal library - this is unexpected ggml_metal_init: will try to compile it on the fly ggml_metal_library_init: error: Error Domain=MTLLibraryErrorDomain Code=3 static_assert failed due to requirement '__tensor_ops_detail::__is_same_v<bfloat, half>' "Input types must match cooperative tensor types" ggml_metal_init: error: failed to initialize the Metal library ggml_backend_metal_device_init: error: failed to allocate context llama_init_from_model: failed to initialize the context: failed to initialize Metal backend panic: unable to create llama context The server reports the GPU as MTLGPUFamilyApple10 (1010) which is M5-specific. The embedded Metal library does not have a precompiled library for this GPU family, and on-the-fly compilation fails due to a bfloat16/half type mismatch in the MetalPerformancePrimitives framework. ## Impact All models fail with: 500 Internal Server Error: llama runner process has terminated OLLAMA_NO_METAL=1 is silently ignored in v0.21.2. ## Workaround Setting GGML_METAL_BF16_DISABLE=1 before starting the server allows models to load and run (CPU fallback, no GPU acceleration): GGML_METAL_BF16_DISABLE=1 ollama serve ## Expected Behavior Ollama should either: 1. Ship a precompiled Metal library for MTLGPUFamilyApple10 (M5), or 2. Correctly fall back to CPU when Metal compilation fails, or 3. Honor OLLAMA_NO_METAL=1 to explicitly disable Metal
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#56589