Repository navigation
Conversation
When a batch is a pure prefill whose longest sequence fits in index_topk, sparse MLA runs dense MHA and never reads the indexer's top-k. The CUDA sparse_attn_indexer op returns early for such batches (vllm-project#48407), and vllm-project#51298 turned that on for the deepseek_v32 path, on CUDA only. The ROCm path still ran the K gather, MQA logits and top-k for every such batch. Enable the same per-layer flag on ROCm (is_cuda() -> is_cuda_alike()) and apply the CUDA op's check in the ROCm fused attention before calling the indexer: main-model indexer layers only (not MTP), no PCP, no decode tokens in the MLA metadata, not under FULL cudagraph or stream capture, and only when the layer takes the dense-MHA branch. The indexer K cache is still written by fused_norm_rope, so later steps read the same cache. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: whx-sjtu <56632993+whx-sjtu@users.noreply.github.com>
whx-sjtu
marked this pull request as ready for review
October 16, 2026 02:45
whx-sjtu
requested review from
dllehr-amd,
hongxiayang and
tjtanaa
as code owners
October 16, 2026 02:45
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.
Overview
On ROCm, the
deepseek_v32path (DeepSeek-V3.2, GLM-5.x) now skips the sparse indexer's scoring for pure short prefills that run on dense MHA, as CUDA already does (#48407, #51298). Builds on the ROCm dense-MHA prefill from #49263.Claims
index_topk, MTP layers, FULL cudagraph and capture still score. Other platforms are unchanged.Validation
test_mla_short_prefill_indexer.py: 35 passed, 8 skipped (CUDA-only) on MI355X, 7 new. pre-commit clean.test_rocm_fused_v32_dense_prefill_matches_mqa(existing, AMD V1 Attention CI): passed, auto and fp8 KV. Its dense run skips one step whose keys a later 2049+-token decode scores.Per-run numbers, probes, profile and reproduction
Image
vllm/vllm-openai-rocm:nightly(AITER 0.1.25) running main at 7f730b4 and this branch from source, MI355X.GLM-5.1-FP8 (78 indexer layers, no spec decode), median TTFT in ms:
gsm8k flexible: main 0.9462 / 0.9409, PR 0.9439 / 0.9484. 1K c32 total throughput 16616 → 17042 tok/s (+2.6%, within noise).
GLM-5.2-MXFP4 (21 indexer layers plus the MTP layer; TTFT runs use MTP3 with synthetic acceptance 3.0), median TTFT in ms, runs in order A B B A A B:
GLM-5.2 gsm8k with real MTP3: strict 0.9356 → 0.9356, flexible 0.9356 → 0.9363, acceptance length 3.310 → 3.311. At concurrency 1 (250 questions, every prefill a pure short prefill): 0.952 → 0.944 (stderr 0.014). A probe on TP rank 0 counted indexer-layer calls on pure dense-MHA prefills: main scored 8382 of 8382, the PR 382 of 8404, all on the MTP layer.
Why 1K gains more than 1900 (GLM-5.1-FP8, TP rank 0). Prefill runs eagerly, and on main the host needs about 148 ms to issue a step at either length. A probe timed the forward without a profiler (median of 20, ms). Host times move by up to 10 ms between sessions with node load; a first main session under heavy load (1K host issue 187 ms) was repeated:
At 1K the GPU finishes within a few ms of the last launch, so the step is host-bound and the indexer's host work shows up in TTFT. At 1900 the GPU runs 12-28 ms past the host; host + tail stays at 159-162 ms in every run, and only the indexer's GPU time is saved. A torch profiler trace per step: the PR removes 312 kernels (4 per layer), 1.43 ms of GPU time at 1K and 2.17 ms at 1900; on main the indexer op costs 190-198 us of host time but 24-34 us of GPU time per call (host time inflated by the profiler).
Details
DeepseekV32MLAAttention._fused_attention, which already holds the MLA metadata. CUDA passes the layer name into its op only because the op cannot see that metadata.DeepseekV32Attentionmoves fromis_cuda()tois_cuda_alike().fused_norm_rope; only scoring is dropped.Design notes
rocm_aiter_sparse_attn_indexerwould mirror CUDA but add an argument to an op that DeepSeek-V4 shares; the model already has the MLA metadata and the dense-MHA decision.skip_k_cache_insert=True.fused_norm_ropewrites the indexer keys and clears the top-k buffer before the decision.Not a duplicate: no open or closed PR skips indexer scoring on ROCm.
Duplicate search
gh pr list --repo vllm-project/vllm --state all --searchwith "short prefill indexer ROCm", "skip indexer ROCm", "indexer scoring ROCm", "dense mha indexer ROCm", "short prefill topk ROCm", "rocm_aiter_sparse_attn_indexer", "dense_mha_metadata_layer_name", "short prefill skip indexer", "GLM ROCm indexer prefill", "ROCm DSv3.2 indexer". Nearest: #56944 and #60601 (shard indexer prefill rows across TP), #61504 (sparse MLA decode indptr), #60294 (aitermqa_logitsfor indexer prefill); none skips scoring.AI assistance (Claude) was used for the implementation, the measurements and this description.
Pull Request Checklist
I used vLLM's
/pr-checklistskill. (Mandatory for agents, optional for humans).AI assistance was used during the creation of this PR.
Design Fit: Minimizes impact on core components, reuses existing functionality, and justifies added complexity.
Testing and Validation: Validates the change and ensures any added tests are meaningful and reliable, with CI coverage or documented CI resource constraints and validation performed outside CI.
Code Quality and Style: Keeps code and comments clear and concise, and updates relevant documentation and examples.
Pull Request Contents: Includes a brief summary and relevant links, supports claims with evidence, explains root causes and implementation trade-offs, and follows the contributing guide.