Vulkan backend: garbage output for Qwen3 & Gemma architectures (Qwen2.5 works) — QK-norm suspect #2
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The llama.cpp Vulkan backend (Mesa panvk, Mali-G610, panthor) produces garbage output for Qwen3- and Gemma-generation architectures, while Qwen2.5-era dense models work perfectly. Isolated cleanly; not this repo's driver/shader patches.
Evidence (same build, same prompts,
-ngl 99vs-ngl 0)sos\nsos\n...)<think>\nOkay...)????), q4 and q8 KV<unused49>)Tokyo)Ruled out
q8_0andq4_0KV.Suspect
A newer-architecture op computed wrong on the Vulkan backend. Both Qwen3 and Gemma add query-key RMSNorm (per-head QK normalization); Gemma also has logit soft-capping and non-standard attention scaling. Prime suspect: QK-norm on Vulkan (wrong shape/reduction), since it is the op common to both failing families and absent from Qwen2.5.
Repro / bisect
Run any Qwen3 or Gemma GGUF with
-ngl 99(garbage) vs-ngl 0(correct). To localize: dump per-op intermediate tensors GPU vs CPU (orGGML_VULKAN_CHECK_RESULTS) and find the first diverging node — expect it at the QK-norm / attention block.Impact
Blocks the GPU champion (this repo) for all modern models — Qwen3, Gemma, and every MoE — and therefore the Cataract heterogeneous-prefill plan (its MoE centerpiece is garbage on the GPU but correct on the NPU). A fix is upstream-worthy and high-leverage: it reopens the entire llama.cpp Vulkan backend to Qwen3/Gemma on any GPU, not just Mali/panvk. Arguably higher value than further shader tuning.