Environment
- Device: iPad Pro M5
- iPadOS version: 26.2
- llama.rn version: 0.9.3
- React Native version: 0.76.x
- Model tested: Llama-3.2-3B-Instruct-Q8_0.gguf
Description
Metal GPU initialization fails on iPad M5 with a shader compilation error related to bfloat and half type mismatch in MetalPerformancePrimitives framework.
The model loads successfully on CPU fallback, but GPU acceleration is not working.
Error Message
lm_ggml_metal_init: picking default device: Apple M5 GPU
lm_ggml_metal_init: the device does not have a precompiled Metal library - this is unexpected
lm_ggml_metal_init: will try to compile it on the fly
lm_ggml_metal_library_init: default.metallib not found, loading from source
error: static_assert failed due to requirement 'tensor_ops_detail::_is_same_v<bfloat, half>'
"Input types must match cooperative tensor types"
static_assert(tensor_ops_detail::_is_same_v<_leftType, leftValueType>, "Input types must match cooperative tensor types");
lm_ggml_metal_init: error: failed to initialize the Metal library
lm_ggml_backend_metal_device_init: error: failed to allocate context
llama_init_from_model: failed to initialize the context: failed to initialize Metal backend
Configuration Used
const params = {
model: MODEL_PATH,
use_mlock: true,
n_ctx: 2048,
n_batch: 512,
n_gpu_layers: 99,
cache_type_k: 'f16',
cache_type_v: 'f16',
flash_attn: false,
};
Steps to Reproduce
- Install llama.rn 0.9.3 on a React Native project
- Build and run on iPad M5 (iPadOS 18)
- Try to initialize a model with
n_gpu_layers > 0
- Observe the Metal compilation error
Related
Additional Context
- The fix seems to work on macOS but not on iPadOS
- CPU fallback works correctly
Environment
Description
Metal GPU initialization fails on iPad M5 with a shader compilation error related to
bfloatandhalftype mismatch in MetalPerformancePrimitives framework.The model loads successfully on CPU fallback, but GPU acceleration is not working.
Error Message
Configuration Used
Steps to Reproduce
n_gpu_layers > 0Related
Additional Context