Repository navigation
[Perf] minimax-m3: Split the score-only prefill indexer over the KV range - #45452
Open
thanhhao98 wants to merge 4 commits into
Open
thanhhao98 wants to merge 4 commits into
thanhhao98 wants to merge 4 commits into
Conversation
…ange The MiniMax-M3 prefill indexer launches one CTA per (query tile, index head), and each CTA loops over the request's whole causal prefix. A short extend over a long cached context therefore runs on a handful of CTAs, and every running decode request waits for that prefill forward. Without the index value no softmax state spans K tiles, so the score-only kernel takes a third grid axis that splits each CTA's causal K range into contiguous tile ranges; every block score is still computed and written once, by the same arithmetic. The split count targets 8 CTAs per SM, capped at the number of K tiles; num_kv_splits overrides it, and the index-value path keeps one split.
thanhhao98
marked this pull request as ready for review
October 22, 2026 03:37
thanhhao98
requested review from
BBuf,
DarkSharpness,
HaiShaw,
HydraQYH,
celve and
yuan-luo
as code owners
October 22, 2026 03:37
nvpohanh
reviewed
Oct 22, 2026
nvpohanh
approved these changes
Oct 22, 2026
4 of 5 tasks
…it-kv-score # Conflicts: # python/sglang/kernels/ops/attention/minimax_sparse/prefill/flash_with_topk_idx.py
This branch has not been deployed
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.
Motivation
The MiniMax-M3 score-only prefill indexer (
_flash_attn_fwd_with_block_score_kernel) runs one CTA per (query tile, index head) over the whole prefix, so a short turn over a long context runs on a few CTAs while running decodes wait. In an nsys capture on GB300, a 305-token turn over 80,512 cached tokens ran on 3 CTAs and spent 148 of the 169 ms prefill window in this kernel.Modifications
flash_prefill_with_topk_indexaims for about 8 CTAs per SM, capped at the K tiles; the newnum_kv_splitsargument overrides it.Accuracy Tests
test_minimax_sparse_prefill_topk_idx.py(10 pass on GB300): scores and top-k ids bit-identical to one split (short turns, mixed batch, 16K chunk, fp8 K, lse, 2/7/4096 splits); one case also checks the scores against an fp32 reference.--max-tokens 32768.The 5-question gap is inside one binomial SE of the difference between two temperature-1.0 runs (±0.66 points); the block scores are bit-identical to one split.
Speed Tests and Profiling
Score + top-k, bf16, one layer, one TP4 rank, one request, GB300, cold L2 (
marker.do_bench, like the newbench_minimax_prefill_index_score.py):End to end: InferenceX AgentX c24 on one 4× GB300 tray, the two arms back to back, both with EAGLE3 #43804 at synthetic acceptance length 2.78, #45451 and fp8 KV. The with-PR arm is this PR's first revision, at 4 CTAs per SM; 8 matches it on short turns and is faster on long chunks.
Checklist
CI States
Latest PR Test (Base): ❌ Run #40295111261
Latest PR Test (Extra): ❌ Run #40295111103
Latest PR Test (AMD ROCm 10): ❌ Run #40295111065