Skip to content

[ROCm][MiniMax-M3] Cross-layer lightning-indexer top-k sharing - #47269

Merged
tjtanaa merged 1 commit into
vllm-project:mainfrom
Fangzhou-Ai:m3-index-topk-freq
Jul 1, 2026
Merged

tjtanaa merged 1 commit into
vllm-project:mainfrom
Fangzhou-Ai:m3-index-topk-freq

Conversation

@Fangzhou-Ai

Copy link
Copy Markdown
Collaborator

Summary

Adds opt-in cross-layer sharing of the lightning-indexer top-k block selection for MiniMax-M3 sparse attention. When use_index_cache is set, only 1 of every index_topk_freq sparse-attention layers recomputes the indexer score + top-k selection; the rest reuse the selection the preceding compute layer wrote into the shared topk_indices_buffer in the same forward pass.

Adjacent sparse layers select nearly the same blocks, so this cuts the indexer score/top-k cost ~freq× with negligible accuracy impact. self.skip_index_topk is computed once per layer at construction (static → cudagraph-capture-safe).

Disabled by default. Enable via:

--hf-overrides '{"use_index_cache": true, "index_topk_freq": 4}'

Why this isn't a duplicate

Searched open PRs for MiniMax-M3 index/top-k/index_topk_freq — no PR adds cross-layer indexer top-k sharing. Related M3 ROCm PRs (#46419 AITER MoE, #46474/#46545 shared-expert fusion) touch different paths.

Test plan / results

amd/MiniMax-M3-MXFP4, MI355X (gfx950), TP=4, 8k1k:

  • Accuracy — GSM8K (lm_eval, 5-shot, full 1319Q): 0.9515 flex / 0.9522 strict, unchanged vs the recompute-every-layer baseline (index cache off).
  • Perf — Mean TPOT ~−10% at conc=1, ~−4% at high concurrency (official 8k1k sweep, index_topk_freq=4).
  • python -m py_compile on the changed file passes; no lines >88 chars.

Notes

  • Scope: vllm/models/minimax_m3/amd/model.py only. The NVIDIA twin (nvidia/model.py) can take the same change as a follow-up.
  • Fully backward compatible (no-op unless use_index_cache is enabled).

AI assistance (Claude) was used to develop and validate this change; a human reviewed every line.

Add opt-in cross-layer sharing of the lightning-indexer top-k block
selection for MiniMax-M3 sparse attention. When `use_index_cache` is set,
only 1 of every `index_topk_freq` sparse-attention layers recomputes the
indexer score + top-k; the remaining layers reuse the selection the
preceding compute layer wrote into the shared `topk_indices_buffer` this
same forward pass. Adjacent sparse layers select nearly identical blocks,
so this cuts the indexer cost ~`freq`x with negligible accuracy impact.

`self.skip_index_topk` is computed once per layer at construction (static),
so it is cudagraph-capture-safe. Disabled by default; enable via
`--hf-overrides '{"use_index_cache": true, "index_topk_freq": 4}'`.

Validated on amd/MiniMax-M3-MXFP4, MI355X (gfx950), TP=4, 8k1k:
- GSM8K (lm_eval, 5-shot, full 1319Q): 0.9515 flex / 0.9522 strict
  (unchanged vs the recompute-every-layer baseline).
- Mean TPOT: ~-10% at conc=1, ~-4% at high concurrency.

The NVIDIA MiniMax-M3 twin (vllm/models/minimax_m3/nvidia/model.py) can
take the same change as a follow-up.

This change was developed with AI assistance (Claude).

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Fangzhou Ai <fangzhouai@gmail.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.

@tjtanaa tjtanaa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@tjtanaa tjtanaa added the ready ONLY add when PR is ready to merge/full CI is needed label Jul 1, 2026
@tjtanaa
tjtanaa enabled auto-merge (squash) July 1, 2026 08:53
@tjtanaa
tjtanaa merged commit 4e5ca89 into vllm-project:main Jul 1, 2026
59 of 60 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in AMD Jul 1, 2026
Fangzhou-Ai added a commit to SemiAnalysisAI/InferenceX that referenced this pull request Jul 2, 2026
…om entry

Addresses Claude review: the new entry was inserted inside the
minimaxm3-fp4-mi355x-atom entry (#1967), dropping its config-keys header and
producing duplicate mapping keys. Restore the atom entry and append the vllm
entry at the end of the file per repo convention. Also pin the image to the
latest nightly containing vllm-project/vllm#47269.
philippesic pushed a commit to philippesic/vllm-semantic-cache that referenced this pull request Jul 19, 2026
…project#47269)

Signed-off-by: Fangzhou Ai <fangzhouai@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants