Repository navigation
perf(ds41): batch-invariant verify keeps the MoE kernel where it matches decode - #815
Merged
Merged
Conversation
…hes decode #813 made batch-invariant MUL_MAT_ID (the DS4.1 DSpark verify) run every token through the single-token MMVQ path, one launch per token, so verify would match decode bit for bit. That also replaced the multi-token MoE kernel (and its gfx1151 expert prefetch) for formats where the MoE kernel already matched decode, and cost 10% of code decode on an R9700 + Ryzen AI Max+ PRO 495 with --profile ds41-gorgon (49.5 -> 44.8 tok/s, identical text). The MoE kernel computes each (token, row) like the generic single-column kernel with one wave per row: same per-lane K walk, one warp reduction. Batch-invariant MUL_MAT_ID now keeps it when the decode launch is that kernel and the batch fits the MoE kernel's per-type width (mmvq_moe_matches_single_column): ROCmFP2, MXFP4, and on the gfx1151 table Q2_K and Q8_0. Multi-wave tables and the specialized single-column launches (gfx1151 fixed-K ROCmFP, the FP4 unroll, the multi-row IQ kernels on AMD) still take the single-token kernel, now in one launch: the tokens become the sample dimension and each block reads its token's expert ids (ids_tokenwise_samples). Expert-bias fusions keep the per-token loop, since the kernel offsets biases by sample. test_ds41_mmid_width_invariance gains ROCmFP2 (type 107) as a contract format, is registered with ctest at five tokens (the DSpark verify width) and runs in the ROCm GPU job. Measured (R9700 + Ryzen AI Max+ PRO 495, ds41-gorgon, ROCMFP2S, two fresh servers each): code decode 44.7-44.9 -> 49.0-49.4 tok/s, 2K decode 30.6-31.0 -> 32.5-32.6, outputs byte-identical. test_ds41_mmid_width_invariance 5 64: every contract case identical in batch-invariant mode on gfx1201 and gfx1151. Co-Authored-By: Claude Opus 5.5 <[email protected]>
davide221
added a commit
to dusterbloom/lucebox-hub
that referenced
this pull request
Oct 7, 2026
# Conflicts: # .github/workflows/ci.yml
This was referenced Oct 7, 2026
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.
Summary
#813 cost DS4.1 about 10% of code decode on an R9700 + Ryzen AI Max+ PRO 495 (
--profile ds41-gorgon). The cause is batch-invariant verify: it ran every drafted token through the single-token MMVQ path, one launch per token. That also replaced the multi-token MoE kernel, and its gfx1151 expert prefetch, for formats where the MoE kernel already matches decode bit for bit.This PR keeps the exactness and gets the speed back. Code decode goes from 44.8 to 49.0-49.4 tok/s, and the output text is byte-identical.
Changes
mmvq_moe_matches_single_columnkeeps it in batch-invariant mode when the decode launch is that kernel and the batch fits the MoE kernel's per-type width. In practice that covers:ids_tokenwise_samples, which the kernel already had). This one launch replaces one launch per token. Expert-bias fusions keep the per-token loop, because the kernel offsets biases by sample.mmvq_rocmfp2_fixed_k/mmvq_rocmfp3_fixed_know hold the gfx1151 fixed-K shapes, used by both the dispatcher and the new check, so the two can't drift apart.test_ds41_mmid_width_invariancegains ROCmFP2 (type 107, the ROCMFP2S experts) as a contract format. It is registered with ctest at 5 tokens, the DSpark verify width, and runs in the ROCm GPU job on both runners.Measurements
R9700 32 GB (PCIe Gen3 x4) + Ryzen AI Max+ PRO 495 192 GB,
--profile ds41-gorgon, ROCMFP2S, Q2_K-expert DSpark drafter, greedy, two fresh servers per build:LUCE_DS4_TP_HEAD4_TAIL2=1(#813's other default change, the route order) made no difference: 44.7 vs 44.9.Validation
test_ds41_mmid_width_invariance 5 64on gfx1201 and gfx1151🤖 Generated with Claude Code