返回全部动态

llama.cpp 修复 Metal mul_mm_id 激活超 f16 范围导致的 NaN

原标题:b10994

llama.cpp Releases一手来源开源质量 80

AI 摘要

llama.cpp 修复了 Metal 后端 mul_mm_id 算子在激活值超出 f16 范围(65504)时产生 NaN 的问题。原因是 simdgroup MMA 将 src1 窄化为 half 导致 inf 并污染整个 8x8 累加器,修复方式是按 2 的幂对 src1 重新缩放并在存储时还原,保证结果精确且对现有模型比特级一致。该缺陷曾导致 Mistral Small 4 在 Metal 上 prefill 超过 32 token 时输出全 NaN,修复后已恢复正常,性能开销约 1.14% 中位数。

以上摘要由 AI 生成,可能存在误差。事实请以原文为准。

正文节选

<details open> metal: fix NaN in mul_mm_id when activations exceed f16 range (#26223) * test-backend-ops: reproduce MUL_MAT_ID NaN for activations beyond f16 The Metal mul_mm_id path narrows src1 to `half` for the simdgroup MMA (`S1 = half` in every instantiation; ggml-metal.metal:10582 and :10595, mirrored at :10643/:10654 in the tensor-ops path). f16 saturates at 65504, so a model whose activations exceed that produces inf, and `simdgroup_multiply_accumulate` then turns the whole 8x8 accumu


发布时间:2026-09-16 15:23
抓取时间:2026-09-16 16:12
来源机构:ggml-org
阅读原文github.com