perf(ds4): batch heterogeneous MoE prefill by expert - #640
Merged
davide221 merged 8 commits intoAug 25, 2026
Conversation
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 5 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
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
Accelerates DeepSeek-V4 heterogeneous prefill by batching owner-local routed experts into grouped
ggml_mul_mat_idgraphs instead of issuing a serial graph for every active expert.DFLASH_MOE_GROUPED_MMID_PREFILL=0andDFLASH_MOE_EXPERT_MAJOR_MIN_TOKENS=512as rollback controls.Classification: primarily a performance PR. It also contains the masked-route correctness fix discovered during qualification, but that fix supports the optimization rather than changing the PR's main purpose.
Fresh main-snapshot requalification
Freshly remeasured on Lucebox6 against recorded
mainsnapshotf686c447f067a04ea100a996e4c826e8cc4decc1, using the same ROCmFP2 model, placement, chunk size, cache-cold requests, two warmups, and five measured samples per cell.chunk=512chunk=2048The current positive result is the short/medium 401-token workload: 1.89x the recorded-main-snapshot throughput. #640 alone is not a current wide-context win; at 2048 tokens it regresses. The stacked #647 scheduling PR recovers that wide result while adding another 7.0% at 401 tokens.
All retained responses produced SHA-256
cd5cb9fb5ac3c4f4007e8b41d117da21622439cd05c1728f3e82f90e4f869dad, and every retained request was cache-cold.Evidence:
/home/cheese/pr640-pr647-fusion-live-main-short401-20260825T121700Z6a9d6b586ac04fc153b9af2b87a5175c01fe3178d9808c9817f7b89f87ac8d21/home/cheese/pr640-pr647-fusion-live-main-requal2-20260825T112300Zb73afed6803e26ed111f521eb0690cf9d8056e30c5f890b0067a5604d181e66aOriginal matched qualification
The original same-session qualification against
mainatac22a3edmeasured:chunk=512chunk=2048These remain valid historical matched-session results for those exact heads and machine state. The fresh table above is the relevant comparison to the newer recorded main snapshot; absolute rates must not be mixed across sessions.
Correctness and validation
test_deepseek4_mmid_grouped_cuda: PASS across 72 cases on physical gfx1201 and gfx1151, including wide masked ROCmFP2/ROCmFP3 routes;test_deepseek4_unit: PASS on physical gfx1201 and gfx1151;git diff --check: clean;