Eval bug: Laguna repeats <assistant> on Metal for ubatches >= 32 tokens (ffn_moe_down input exceeds F16 range)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- cpp
- Domain
- backend, performance
Research direction
The issue identifies src/llama-graph.cpp, build_moe_ffn, and the condition that currently enables src1 rescaling for Mistral4 and Mellum. Read that condition and compare Laguna's behavior with those architectures; the report says adding Laguna locally makes default Metal output match CPU. Done means the ubatch 32 reproduction no longer repeats <assistant> and agrees with CPU output.
Written by the indexing model from the issue text.
Description
Name and Version
version: 0.7.0-dev (build 11669, commit 620d2225c)
built with AppleClang 21.0.0.21000334 for Darwin arm64
The build_moe_ffn code involved is unchanged on master as of 2026-10-20.
Operating systems
Mac (macOS 26.7.1)
GGML backends
Metal
Hardware
Apple M4 Max, 64 GB
Models
poolside/Laguna-XS-2.1-GGUF Q4_K_M (arch laguna)
Problem description & steps to reproduce
On Metal, Laguna-XS-2.1 generates only a repeating <assistant> token (id 23) when the prompt is evaluated in a ubatch of 32 or more tokens. A ubatch of 31 or fewer, --cpu-moe, and CPU-only runs all give correct output.
llama-completion -m Laguna-XS-2.1-Q4_K_M.gguf -no-cnv --temp 0 -n 16 -c 4096 \
-p $'<system>You are a helpful, conversationally-fluent assistant. Answer questions clearly and concisely, and think step by step before replying.</system>\n<user>Hi</user>\n<assistant><think>'
The prompt is 42 tokens.
| Run | Output |
|---|---|
default, -ub 32 |
<assistant><assistant><assistant>… |
-ub 31 |
Okay, the user said "Hi". I need to respond appropriately. Let me |
--cpu-moe |
correct (same as above) |
-ngl 0 --device none |
correct |
The 32-token threshold matches ggml_metal_op_mul_mat_id_use_mm (ne21 >= 32). At that size the mul_mm_id kernel stages src1 in half precision.
Since #29029 (0f8a414b7), the src1 rescale in that kernel runs only when GGML_PREC_F32 is set on src1. build_moe_ffn sets it only for LLM_ARCH_MISTRAL4 || LLM_ARCH_MELLUM (#30584, the fix for the same symptom in #30579).
Laguna's ffn_moe_down input also exceeds F16 range. A -ngl sweep fits accumulated overflow across layers rather than a single bad layer: -ngl 2 is correct, while -ngl 3 and higher loop.
Fix, verified locally: in src/llama-graph.cpp build_moe_ffn, add || arch == LLM_ARCH_LAGUNA to that condition. With this change, Metal output at the default ubatch matches CPU.
First Bad Commit
Probably 0f8a414b7 (#29029), which made the rescale opt-in. Not bisected.
Relevant log output
No crash or error is logged; the output is wrong as shown in the table above.
- Dominant language
- C++
- Stars
- 131k
- Forks
- 24.4k
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 504
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ggml-org/llama.cpp
-
Misc. bug: Sarvam 30B MoE converter labels byte-fallback tokens <0x00>–<0xFF> NORMAL instead of BYTEOpenbug-unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Misc. bug: Missing range check on grammar_triggers[].type allows remote SIGABRT in llama-serverOpenbug-unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
All issues in ggml-org/llama.cpp
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
metasequoiaime/msime#9113 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
tone-3000/tone3000-plugin#257 · 1 comment ·
Maintainers usually reply within 1 day
-
Locked plugin flip-flops position on every refresh after being disabledPossibly taken @Illustar0 claimed this today. Openissue report
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
ModOrganizer2/modorganizer#2449 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
Maintainers usually reply within 1 day
-
enhancement P5
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
open-astro/AlpacaBridge#1468 ·
Maintainers usually reply within 1 day