You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] Metal reports MUL_MAT support for F8_E5M2 weights but has no kernel for it #2381
master-1106-532d2c1 (current master), ggml submodule eeda9ec (the sd.cpp branch of leejet/ggml).
Operating System & Version
macOS 27.0.1, Apple M4 Max
GGML backends
Metal
Command-line arguments used
None. This was found by reading the code; see "What actually happened" for what was run.
Steps to reproduce
Run a model that has F8_E5M2 weights in a matrix multiplication on the Metal backend.
What you expected to happen
ggml_metal_device_supports_op returns false for MUL_MAT with F8_E5M2 weights, as it does for F8_E4M3. Then sd.cpp's fallback (ggml_ext_prepare_linear_weight) casts the weight to BF16 on the GPU before the matmul, and the weight stays FP8 in memory.
What actually happened
The Metal backend reports support it doesn't have:
ggml-metal-device.m, the matmul support check (around line 1530) refuses F8_E4M3, NVFP4 and TQ1_0, but not F8_E5M2.
kernels/*.metal has no kernel_mul_mm_f8_e5m2_* or kernel_mul_mv_f8_e5m2_*. It only has the copy kernels (kernel_cpy_f8_e5m2_f16, kernel_cpy_f8_e5m2_bf16).
We hit exactly this failure before F8_E4M3 was refused there (leejet/ggml cd93ab15f, from llama.cpp #27512). The model was ComfyUI's t5xxl_fp8_e4m3fn_scaled.safetensors on Metal, and the process stopped with:
kernel_mul_mm_f8_e4m3_f32 not found
F8_E5M2 goes through the same path. We don't have an E5M2 model to confirm it at runtime. Converting one at load time with --type f8_e5m2 stops earlier, in ggml.c:8091: GGML_ASSERT(result == nrows * row_size) (inside convert_tensor), which looks like a separate issue.
Additional context
The fix is one line in src/ggml-metal/ggml-metal-device.m:
if (!has_simdgroup_reduction||op->src[0]->type==GGML_TYPE_F8_E4M3||op->src[0]->type==GGML_TYPE_F8_E5M2||// addedop->src[0]->type==GGML_TYPE_NVFP4||op->src[0]->type==GGML_TYPE_TQ1_0) {
return false;
}
Activity