Skip to content

[ROCm][Perf][MiniMax-M3.1] Score DSpark 7 decode locally below 3 requests instead of via indexer CP - #65432

Merged
shen-shanshan merged 4 commits into
vllm-project:mainfrom
Fangzhou-Ai:rocm-m31-indexer-cp-min-reqs
Nov 4, 2026
Merged

shen-shanshan merged 4 commits into
vllm-project:mainfrom
Fangzhou-Ai:rocm-m31-indexer-cp-min-reqs

Conversation

@Fangzhou-Ai

Copy link
Copy Markdown
Collaborator

Purpose

With indexer_decode_cp at TP4 (#64448), every DSpark 7 decode step scores through the context-parallel
push kernel (m3_nvfp4_index_score_push_cp), whatever the batch size. Its two cross-rank handshakes (index-q
exchange, then score push plus a four-rank done barrier) cost a fixed ~13 us per layer that does not shrink with
the batch, so at 1-2 requests the kernel spends its time waiting, while the single-head scorer
(m3_nvfp4_index_score_decode_r8h1, each rank scores its own head over the whole context, no cross-rank traffic)
takes 6-9 us. This PR scores steps of fewer than CP_MIN_REQS = 3 requests (8 rows each) with the single-head
scorer, which is the path the scorer already takes when CP is off. Steps of 3 or more requests, and DSpark 3 (4 rows
per request), are unchanged.

Not covered by an existing PR: #64448 (merged) enables CP for DSpark 7 at any batch size; #65087/#65267 only touch the top-k.

Root cause (kernel level)

Per-layer kernel durations from the torch profiler (rank 0, 120 decode steps per window, 150K-token real-text
contexts, DBO off, VLLM_ROCM_USE_SKINNY_GEMM=0), before / after this change:

N requests scorer before scorer after
1 m3_nvfp4_index_score_push_cp 15.8 us avg (p50 13.0) m3_nvfp4_index_score_decode_r8h1 7.0 us
2 m3_nvfp4_index_score_push_cp 14.9 us avg (p50 13.3) m3_nvfp4_index_score_decode_r8h1 9.7 us

(58 sparse layers per step: 0.92 -> 0.41 ms/step at N=1 and 0.87 -> 0.57 ms/step at N=2.)

Isolated, four ranks, CUDA-graph replay of 8 back-to-back calls with the L2 flushed before each replay, max_seq_len
1M as in the captured graph, 8 rows per request, context lengths uniform in [0.7, 1.3] x the stated mean; CP vs
single-head scorer, us per call. The scores of the two kernels are bit-identical in all 28 cells.

requests 30K: CP / single-head 150K: CP / single-head 400K: CP / single-head 800K: CP / single-head
1 14.2 / 6.2 14.2 / 6.4 14.1 / 9.2 14.9 / 16.4
2 15.0 / 7.4 14.4 / 9.0 15.1 / 13.1 18.4 / 23.7
3 14.6 / 8.7 14.5 / 11.3 15.4 / 17.6 19.8 / 29.6
4 14.8 / 7.0 15.0 / 15.1 18.8 / 26.1 24.7 / 48.9
6 16.0 / 8.2 15.3 / 18.3 23.8 / 33.0 35.0 / 64.5
8 15.7 / 8.6 18.8 / 22.0 25.7 / 45.5 43.8 / 82.1
16 15.8 / 13.3 24.1 / 36.0 45.6 / 85.9 85.3 / 160.4

CP is a fixed ~14-15 us up to 4 requests; the single-head scorer grows with the pages it reads (one head, all
blocks) and loses once a step reads ~4-5K index pages in total (4 requests at 150K, 2-3 at 400K). The gate is on the
request count because under CUDA graphs max_seq_len is the model maximum, so the batch's context is not known when
the graph is captured. 3 requests at 150K would also win (11.3 vs 14.5 us) but loses at 400K (17.6 vs 15.4 us) and
showed no end-to-end gain, so the gate stops at 2 requests.

End-to-end (decode step p50, ms; same server flags, only this change differs)

MI355X x4, TP4, amd/MiniMax-M3.1-Flash-Quark-MXFP4, NVFP4 KV and NVFP4 indexer with indexer_decode_cp,
DSpark 7 with synthetic acceptance 4.04, DBO off, VLLM_ROCM_USE_SKINNY_GEMM=0, 150K-token prompts, N concurrent
decodes (decode_bench.py <port> 150000 N: p50 of the gap between streamed chunks once all N streams are
decoding, 900 output tokens, 3 passes per server, median of the passes). "base" is the mean of two server instances
(range in brackets); the change was measured on a third instance. The change was run with CP_MIN_REQS = 4 (one
request more than this PR gates), which only affects the N=3 row; at N=3 this PR keeps CP, i.e. is the base.
Steps of 4 or more requests take the same code path as base, so their rows are a measure of server-to-server
noise (within +-0.6%).

Random-token prompts:

N base (S1_base,S3_base) cp_gate_only (S6_cp) cp_gate_only vs base
1 10.27 [10.23-10.30] 9.83 -4.2%
2 10.86 [10.84-10.87] 10.61 -2.3%
3 12.34 [12.34-12.35] 12.38 +0.3%
4 12.75 [12.72-12.77] 12.70 -0.4%
5 14.35 [14.32-14.38] 14.28 -0.5%
6 14.64 [14.57-14.71] 14.64 +0.0%
8 16.14 [16.11-16.18] 16.05 -0.6%
12 17.67 [17.54-17.80] 17.62 -0.3%
16 19.52 [19.52-19.52] 19.46 -0.3%

Real-text prompts (python sources; the model's attention is not uniform):

N base (S1_base,S3_base) cp_gate_only (S6_cp) cp_gate_only vs base
1 11.23 [11.21-11.25] 10.88 -3.1%
2 12.50 [12.44-12.56] 12.11 -3.1%
4 14.81 [14.80-14.82] 14.80 -0.0%
5 16.64 [16.57-16.71] 16.69 +0.3%
8 18.93 [18.92-18.94] 18.92 -0.0%
12 20.57 [20.51-20.62] 20.56 -0.0%
16 22.46 [22.43-22.49] 22.48 +0.1%

Correctness

  • The scorer is not changed. The scores of the CP kernel and the single-head scorer are bit-identical (existing
    test_index_decode_cp_push_matches_single_head and the 28-cell sweep above), so the top-k ids and the attention
    output are bit-identical to the CP path: this change only picks which of the two bit-identical scorers runs.
  • New test_decode_cp_gate (8 cases, unit test of _decode_cp).
  • pytest tests/kernels/attention/test_minimax_m3_nvfp4_index.py: 182 passed (174 existing + 8 new) on MI355X.
  • End-to-end sanity: "What is 17*23?" answers 391 at TP4 on a tree with this change (stacked with [ROCm][Perf][MiniMax-M3.1] Four-wave decode top-k for the NVFP4 indexer #65087 and a
    split-count change; greedy; the synthetic-acceptance recipe garbles some of the surrounding text with or without them).

Limitations

  • Measured at 150K contexts (and 30K-800K in the isolated sweep) on MI355X, TP4, DSpark 7 only. DSpark 3 keeps
    CP at every batch size; the crossover for 4-row requests was not measured.
  • The gate is conservative for short contexts: at 30K the single-head scorer also wins at 3-16 requests (4 requests 7.0 vs
    14.8 us, 16 requests 13.3 vs 15.8 us). A context-aware choice would need it inside the kernel or two graphs per batch size.
  • Requests of ~800K tokens or more at 1-2 requests are slower with the single-head scorer than with CP (800K:
    16.4 vs 14.9 us at 1 request, 23.7 vs 18.4 us at 2). Contexts that long are rare in the target agentic workload
    (30K-500K, mean ~150K).
  • DBO on (the recipe): not measured for this change alone. Decode steps do not split under the recipe thresholds, so
    CP is used outside microbatches exactly as before; stacked with two other changes the step was 2-8% lower at N=1..16.
  • Server-to-server variation of the decode step is +-0.6% within one machine state; the shared machine also had
    MoE kernel changes land between runs, so only runs from a frozen copy of the install (same state) are compared.

Related: #64448 (DSpark 7 CP), #57909 (indexer CP), #65087 (top-k, independent).

Test command and config (from /home/fai/profile_m31/run): DBO=0 VLLM_ROCM_USE_SKINNY_GEMM=0 ./serve.sh 16 0,1,2,3 8000 20000
= vllm serve amd/MiniMax-M3.1-Flash-Quark-MXFP4 --tensor-parallel-size 4 --attention-config '{"indexer_kv_dtype":"nvfp4","indexer_decode_cp":true}' --block-size 128 --kv-cache-dtype nvfp4 --max-model-len 1048576 --max-num-batched-tokens 32768 --max-num-seqs 32 --moe-backend aiter --enable-prefix-caching --disable-hybrid-kv-cache-manager --gpu-memory-utilization 0.85 --speculative-config '{"method":"dspark", "num_speculative_tokens":7,"attention_backend":"TRITON_ATTN","kv_cache_dtype":"fp8","draft_sample_method":"probabilistic", "rejection_sample_method":"synthetic","synthetic_acceptance_length":4.04}' (+ the InferenceX recipe env:
VLLM_USE_V2_MODEL_RUNNER=1 VLLM_ROCM_USE_AITER=1 VLLM_ROCM_USE_AITER_MOE=1 VLLM_ROCM_QUICK_REDUCE_QUANTIZATION=INT4),
then OUT_TOKENS=900 python decode_bench.py 8000 150000 1 2 3 4 5 6 8 12 16.

🤖 Generated with Claude Code

…ests instead of via indexer CP

The context-parallel decode scorer (m3_nvfp4_index_score_push_cp) pays two
cross-rank handshakes per layer, a fixed ~13 us that does not shrink with the
batch. At 1-2 requests (8 rows each) the single-head scorer
(m3_nvfp4_index_score_decode_r8h1, each rank scores its own head, no cross-rank
traffic) takes 6-9 us per layer against 14-15 us for CP, and its scores are
bit-identical. DSpark 7 steps with fewer than CP_MIN_REQS = 3 requests now take
that path; larger steps and DSpark 3 are unchanged.

Decode step p50 at 150K contexts, TP4 DSpark 7, DBO off: -4.2% at 1 request
and -2.3% at 2 (random tokens), -3.1% at both (real text).

Signed-off-by: Fangzhou Ai <fangzhou.ai@amd.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@mergify mergify Bot added minimax rocm Related to AMD ROCm dflash labels Nov 3, 2026
@github-project-automation github-project-automation Bot moved this to Todo in AMD Nov 3, 2026
@Fangzhou-Ai Fangzhou-Ai added the ready ONLY add when PR is ready to merge/full CI is needed label Nov 3, 2026
@Fangzhou-Ai

Copy link
Copy Markdown
Collaborator Author

/ci run

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

✅ Triggered Buildkite CI #99596 for commit a50d1f531b61.

@micah-wil micah-wil left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM with small nits

@ChuanLi1101 ChuanLi1101 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. Gating DSpark-7 indexer CP below 3 requests onto the single-head scorer matches the measured handshake cost, and the CP path stays for N>=3. Micah’s nits are non-blocking.

…er gate test cases

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Fangzhou Ai <fangzhou.ai@amd.com>
@Fangzhou-Ai

Copy link
Copy Markdown
Collaborator Author

Thanks for the review. Addressed in 975a922: shortened the CP_MIN_REQS comment (the per-layer measurements stay in the PR description) and cut the gate test to the three cases you suggested, tied to CP_MIN_REQS.

@Fangzhou-Ai

Copy link
Copy Markdown
Collaborator Author

/ci run

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

✅ Triggered Buildkite CI #99832 for commit 278857f88ac0.

ℹ️ This PR is 74 commits behind upstream main. Merged upstream main into this branch as 278857f88ac0 before starting CI. Pull the branch before pushing more changes.

@shen-shanshan
shen-shanshan merged commit ca8bd4c into vllm-project:main Nov 4, 2026
70 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Sprint - DFlash Nov 4, 2026
@github-project-automation github-project-automation Bot moved this from Todo to Done in AMD Nov 4, 2026
yeshihai pushed a commit to yeshihai/vllm that referenced this pull request Nov 8, 2026
…ests instead of via indexer CP (vllm-project#65432)

Signed-off-by: Fangzhou Ai <fangzhou.ai@amd.com>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-authored-by: vllm-agent <claw@inferact.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dflash minimax ready ONLY add when PR is ready to merge/full CI is needed rocm Related to AMD ROCm

Projects

Status: Done
Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants