Repository navigation
ggml-hrx: fix Qwen MoE fused router gfx1151 launch geometry (engine#108) - #12
Merged
bong-water-water-bong merged 1 commit intoSep 26, 2026
Conversation
The fused decode router kernel (qwen3_moe_router_projection_top8_fused_decode_f32) hardcoded experts_per_wave=4 when computing its launch workgroup count (expert_tiles = expert_count / experts_per_wave), but the kernel body dispatches its per-wave projection work via the qwen3_moe.router.fused.experts_per_wave template family, which resolves to 2 on gfx1151 (priority 20, the two-expert variant) and only falls back to 4 on generic gfx11 targets (priority 1). On gfx1151 this launched half the workgroups the projection body actually needs, so half the experts logits were never written - top-8 routing then selected from partially uninitialized logits, producing wrong output (garbled completions) whenever the fused router path was hit. This is the second of the two bugs #108 reports; PR #7 fixed the first (route-ids binding length) but this one was never actually committed, despite being described as fixed. Fix: compute experts_per_wave via the same template.apply the projection body already uses, instead of a hardcoded constant, so the launch geometry always matches what the kernel body assumes.
bong-water-water-bong
merged commit Sep 26, 2026
1e775cd
into
1bit/hrx-vulkan-patched
1 check passed
bong-water-water-bong
deleted the
fix/moe-router-experts-per-wave-launch-geometry
branch
September 26, 2026 09:03
bong-water-water-bong
added a commit
that referenced
this pull request
Oct 20, 2026
…ops (#118) fused_context_claim kept GATED_DELTA_NET on HRX whenever any source was produced by an op. The test-backend-ops GATED_DELTA_NET cases build q and k as L2_NORMs of leaves and v from a leaf. While L2_NORM had no standalone HRX path those cases were skipped; gpu-kernels #12 added one, the GDN node was then claimed through its L2_NORM inputs, no dispatch matches such a graph, and 31 cases failed with "graph_compute: unsupported HRX node 0: GATED_DELTA_NET" (hw-gate run 39510505298, engine #480: ops 618/649). The model graphs (qwen35, qwen35moe, qwen3next) feed v from a view of the delta-net conv and q, k from L2_NORMs of views of it, so the claim now also requires v produced by an op and q, k produced by ops whose L2_NORM, if any, reads an op output. Co-authored-by: bong-water-water-bong <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the second (and last remaining) bug in 1bit-MONSTER/engine#108.
PR #7 fixed the route-ids binding-length crash. That PR's description also claimed the second bug (wrong output once decode no longer crashes) was fixed by the same PR — it wasn't; the diff that actually merged only touched
dispatch-moe-router.cpp's binding length. This PR is that missing second fix.Root cause:
qwen3_moe_router_projection_top8_fused_decode_f32's launch config hardcodedexperts_per_wave = 4when computingexpert_tiles = expert_count / experts_per_wave(the kernel's workgroup count). But the kernel body dispatches its per-wave projection work through theqwen3_moe.router.fused.experts_per_wavetemplate family, which resolves to 2 on gfx1151 (priority(20), the two-expert specialization) and only falls back to 4 on generic gfx11 targets (priority(1)). On gfx1151 this launched half the workgroups the projection body actually needs, so half the experts' router logits were never written — top-8 routing then selected from partially uninitialized logits, producing garbled completions whenever the fused router path was hit (i.e. whenever HRX0 runs the dense/router side of a Qwen MoE model).Fix: compute
experts_per_wavevia the sametemplate.apply<@qwen3_moe.router.fused.experts_per_wave>()the projection body already uses, instead of a hardcoded constant, so the launch geometry always matches what the kernel body assumes. One line.Verified on gfx1151 (Strix Halo), Qwen3-Coder-30B-A3B-Instruct-Q4_K_M,
-dev HRX0,Vulkan0 -ts 1,0 -ot exps=Vulkan0(dense on HRX0, experts on Vulkan0 — the exact #108 repro):cache_prompt:false.GGML_HRX_DISABLE_DISPATCH=moe_routerreproduces the issue's documented fallback behavior exactly ("Compute error."), confirming the fused dispatch is genuinely what's being exercised and fixed, not bypassed.-dev HRX0(unaffected by this bug either way) unchanged.