Repository navigation
[2/2] test: cover TurboQuant MUL_MAT_ID at real MoE model shapes - #335
Merged
TheTom merged 2 commits intoSep 3, 2026
Merged
Conversation
ggml_cuda_mul_mat_id() has an AMD-only fast path that calls ggml_cuda_mul_mat_vec_f() directly for non-quantized experts. Unlike the non-id path, it never consulted ggml_cuda_should_use_mmvf(), which is the predicate for what that kernel actually requires: an even column count and strides aligned to twice the type size. An expert matrix with an odd k therefore reached the kernel and tripped its GGML_ASSERT(ncols % 2 == 0). test-backend-ops hits this on an f32 MUL_MAT_ID case with n=1 and k=3, so the entire MUL_MAT_ID suite aborted on AMD before reaching any later type, including every TurboQuant case. Consult the predicate, and fall through to the sorted-routing path below when it declines. `test-backend-ops -o MUL_MAT_ID` now completes on an MI210 with 979/979 passing, where before it dumped core after 11 cases. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01NxP6x5bmUDYFvmouceN2mR
The existing TQ3_1S/TQ4_1S MUL_MAT_ID sweep uses 4 experts with k=256, which is nothing like a real router. Qwen3.6-35B-A3B (qwen35moe) has 256 experts with 8 used per token, gate/up of [2048 x 512] and down of [512 x 2048]. Expert counts in the hundreds change how the routing is built and how few slots each expert ends up with, and these are the dimensions the decode matvec and the MMQ prefill path actually see in service. n spans both sides of MMVQ_MAX_BATCH_SIZE so both paths are covered rather than one. This matters because the MoE decode matvec carries most of the TurboQuant decode work and had no coverage at model scale. Adds 12 cases; the MUL_MAT_ID suite runs in about 47s on an MI210. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01NxP6x5bmUDYFvmouceN2mR
This was referenced Aug 31, 2026
TheTom
merged commit Sep 3, 2026
a66580c
into
TheTom:feature/turboquant-kv-cache
12 of 28 checks passed
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.
Overview
The existing TQ3_1S/TQ4_1S MUL_MAT_ID sweep runs 4 experts with
k=256. That is nothing like a real router. Qwen3.6-35B-A3B (qwen35moe) has 256 experts with 8 used per token, gate/up of[2048 x 512]and down of[512 x 2048].Expert counts in the hundreds change how the routing is built and how few slots each expert ends up with, and those are the dimensions the MoE decode matvec and the MMQ prefill path actually see in service.
nspans both sides ofMMVQ_MAX_BATCH_SIZEso both paths are covered rather than just one.Adds 12 cases (2 types x 2 projections x n in {1, 9, 32}).
Additional information
This closes a real gap rather than a theoretical one. AGENTS.md already records that the MUL_MAT_ID sweep used
n=16only and so never touched MoE decode, and that a green run "means the cases that ran passed, not that your change was exercised". Between that and the abort fixed in #334, the TurboQuant MoE path has had effectively no exercised coverage at model scale on AMD — which matters because the MoE decode matvec is where most of the TurboQuant decode work lives.Verified on an MI210 (gfx90a), ROCm 7.2.3, on top of #334:
test-backend-ops -o MUL_MAT_IDgives 979/979 passing, up from 967/967 with #334 alone. The suite takes about 47s.Requirements