Skip to content

[HIP] [gfx950] Context-parallel block selection for the MiniMax-M3 indexer - #6359

Merged
valarLip merged 2 commits into
ROCm:mainfrom
ukannika:ukannika/minimax-m3-indexer-cp
Oct 13, 2026
Merged

valarLip merged 2 commits into
ROCm:mainfrom
ukannika:ukannika/minimax-m3-indexer-cp

Conversation

@ukannika

Copy link
Copy Markdown
Contributor

Summary

Adds pa_sparse_block_topk_cp, a context-parallel block selector for the
MiniMax-M3 lightning indexer, and gives the decode scoring pass rank/world
parameters so a rank can score a shard of the context instead of all of it.
Nomination, cross-rank exchange and merge happen in one kernel launch with no
collective and no barrier.

Motivation

The indexer's index cache is replicated on every tensor-parallel rank, so each
rank re-reads the whole of it every decode step. That read is the only part of
the indexer that scales with context.

Tensor parallelism does not help, because it splits the head axis and the cache
is shared by all heads (MQA: one index KV head feeding four index query heads).
Inverting the split does. Each rank projects every index head but scores
1/world of the 128-token blocks, which turns the replicated read into
1/world of the bytes.

Performance

MI355X (gfx950), 4 ranks, 4 index heads, top-16, fp8 e4m3 index cache, 128-token
blocks. Decode scoring, whole-context pass against the slowest rank's shard,
measured cold (argument rotation on, since in a real model every indexer layer
owns its own index cache and no layer's shard is still resident when the next
layer's score pass starts).

Scoring kernel

Configuration Without CP CP enabled Improvement
batch 8, 8K 5.65us 4.31us 1.31x
batch 8, 16K 6.18us 4.58us 1.35x
batch 8, 32K 10.82us 5.34us 2.02x
batch 8, 64K 17.84us 6.67us 2.67x
batch 8, 128K 29.11us 9.46us 3.08x
batch 16, 8K 6.31us 4.55us 1.38x
batch 16, 16K 9.83us 5.40us 1.82x
batch 16, 32K 18.73us 6.53us 2.87x
batch 16, 64K 31.11us 10.93us 2.85x
batch 16, 128K 52.49us 16.72us 3.14x
batch 32, 8K 9.18us 5.40us 1.70x
batch 32, 16K 16.14us 6.54us 2.47x
batch 32, 32K 30.56us 11.29us 2.71x
batch 32, 64K 51.56us 18.33us 2.81x
batch 32, 128K 94.76us 29.39us 3.22x
batch 64, 8K 15.61us 6.49us 2.41x
batch 64, 16K 26.80us 10.09us 2.66x
batch 64, 32K 50.94us 16.80us 3.03x
batch 64, 64K 92.97us 31.74us 2.93x
batch 64, 128K 177.99us 50.15us 3.55x
batch 128, 8K 25.16us 9.42us 2.67x
batch 128, 16K 47.12us 16.16us 2.92x
batch 128, 32K 90.40us 26.64us 3.39x
batch 128, 64K 174.34us 49.50us 3.52x
batch 128, 128K 344.76us 93.75us 3.68x

Reproduced with:

python op_tests/test_msa_block_select.py --cp-only -H 4 -w 4 \
    -b 8 16 32 64 128 -c 8192 16384 32768 65536 131072

@ukannika
ukannika requested a review from a team October 10, 2026 05:08
@github-actions github-actions Bot changed the title [HIP][gfx950] Context-parallel block selection for the MiniMax-M3 indexer [HIP] [gfx950] Context-parallel block selection for the MiniMax-M3 indexer Oct 10, 2026
@github-actions github-actions Bot added the HIP label Oct 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 6359 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

@ChuanLi1101

Copy link
Copy Markdown
Contributor

test_msa_block_select.py only checks the score shard, one rank at a time on one GPU. pa_sparse_block_topk_cp is never called, and the 8-GPU job was skipped. There is no barrier: a lane spins on the generation in the top 8 bits of the block id, so ranks that do not make the same number of calls hang. One multi-rank run should show the selected blocks match the single-GPU top-k, per head.

@valarLip

Copy link
Copy Markdown
Collaborator

@ukannika let @kaiyang-1 know once this one validated in vllm

@ukannika

Copy link
Copy Markdown
Contributor Author

@ukannika let @kaiyang-1 know once this one validated in vllm

Added op_tests/multigpu_tests/test_msa_block_select_cp.py: it spawns and sets up the IPC candidate buffers, calls pa_sparse_block_topk_cp, and asserts the selected blocks — plus the sparse_bt/sparse_ctx page table they expand into — match a single-GPU pa_sparse_block_topk over the full context, per owned head and per row. Each case sweeps every context against every batch (16, 32, 64, 128, 64, 16, 128) through one candidate buffer and one cp_gen, since the double buffer and the generation tag only do anything once a call has a predecessor whose candidates are still in the buffer.

context world=2, H=2 world=2, H=4 world=4, H=4
16k pass pass pass
32k pass pass pass
64k pass pass pass
128k pass pass pass
256k pass pass pass
512k pass pass pass
1M pass pass pass

TP8 case currently not supported and added a check on host side.

Here's the e2e results updated in this PR: vllm-project/vllm#57909
seeing 3 to 15% throughput uplift for conc >= 15

@ChuanLi1101 ChuanLi1101 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. The new test calls pa_sparse_block_topk_cp and checks each owned head against the single-GPU top-k, including the page table. That covers the comment. Please add the ci:multi-gpu label so the 8-GPU job runs this file. LGTM.

@ChuanLi1101

Copy link
Copy Markdown
Contributor

@ukannika Lingpeng asked to let @kaiyang-1 know once this is validated in vLLM. The #57909 numbers are already on this thread. Please ping @kaiyang-1.

@ukannika ukannika added the ci:multi-gpu Trigger multi-GPU op tests on PR label Oct 13, 2026

@kaiyang-1 kaiyang-1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@valarLip
valarLip merged commit c09dc31 into ROCm:main Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:multi-gpu Trigger multi-GPU op tests on PR HIP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants