[Attention][DSA] Route SM100 sparse-indexer decode through varlen paged MQA logits - #47469
Open
zyongye wants to merge 1 commit into
Open
[Attention][DSA] Route SM100 sparse-indexer decode through varlen paged MQA logits#47469zyongye wants to merge 1 commit into
zyongye wants to merge 1 commit into
Conversation
…ed MQA logits On SM100, unify all indexer decode (plain / uniform-spec / variable-spec) onto the DeepGEMM varlen paged MQA logits kernel, selected by passing per-row `indices`. Variable-length decode no longer pads to max_decode_len; it flattens into per-token rows (next_n == 1) with an adjacency-grouped run id, so the kernel does no padded work. - deep_gemm wrappers: optional `indices` kwarg on get_paged_mqa_logits_metadata and fp8_fp4_paged_mqa_logits, forwarded only when set so non-varlen callers are byte-identical. - indexer builder: add use_varlen (cuda + sm_10x + deep_gemm); relax require_uniform / use_native so variable-length decode stays a decode; build per-row indices (arange / i//max_decode_len / repeat_interleave) into a preallocated buffer; new DecodeMetadata.indices field. - sparse_attn_indexer: thread indices into the decode kernel call (FP8 + FP4). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Yongye Zhu <yongye@inferact.ai> Signed-off-by: Yongye Zhu <zyy1102000@gmail.com>
Contributor
|
This pull request has merge conflicts that must be resolved before it can be |
LucasWilkinson
approved these changes
Jul 15, 2026
LucasWilkinson
left a comment
Collaborator
There was a problem hiding this comment.
LGTM thanks for doing this!
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.
Purpose
On SM100 (Blackwell datacenter), route all DeepSeek sparse-attention indexer
decode through the DeepGEMM varlen paged MQA logits kernel, selected by
passing a per-row
indicesrun-id toget_paged_mqa_logits_metadata/fp8_fp4_paged_mqa_logits.Today, variable-length decode on SM100 (spec/MTP with non-uniform accepted
lengths) hits the native multi-atom path, which pads to
(B, max_decode_len)and masks — wasted compute. The varlen path flattens decode into per-token rows
(
next_n == 1) with an adjacency-grouped request id, so the kernel does nopadded work. Plain
next_n==1and uniform spec decode are unified onto the samepath (cheap: plain decode needs no expansion, just
indices = arange(B)).Changes
vllm/utils/deep_gemm.py: optionalindiceskwarg onget_paged_mqa_logits_metadataandfp8_fp4_paged_mqa_logits, forwarded tothe DeepGEMM impl only when set, so every existing non-varlen caller is
byte-identical.
vllm/v1/attention/backends/mla/indexer.py: adduse_varlen(cuda +
sm_10x+ DeepGEMM); relaxrequire_uniform/use_nativesovariable-length decode stays a decode instead of being split to prefill; build
per-row
indices(arangefor plain,i // max_decode_lenfor uniform —static/cudagraph-safe,
repeat_interleavefor the eager variable case) into apreallocated buffer; new
DecodeMetadata.indicesfield.vllm/model_executor/layers/sparse_attn_indexer.py: threadindicesintothe decode kernel call (FP8 and FP4 caches).
Off-SM100 (native / flatten) and XPU/ROCm paths are unchanged (
use_varlenisFalse there,
indicesstaysNone).storage_block_sizeis 64 for V3.2 andblock_size // compress_ratio = 64for V4, satisfying the kernel'sblock_kv ∈ {32, 64}constraint.Not duplicating existing work
Searched open PRs (
varlen indexer,paged mqa logits,sparse attn indexer,indexer varlen decode). The nearest are different backends/areas:[ROCm][DSv3.2] Eliminate per-decode FillFunctor launches in sparse-MLA hot loop #44527 (ROCm FillFunctor) — ROCm/AITER, not the SM100 DeepGEMM varlen path.
None implement the SM100 varlen paged-MQA-logits
indicesdecode path.Testing
GSM8K with uniform decode and MTP passed.
Note
This change was written with AI assistance (Claude). It has not yet been
runtime-tested end-to-end; opening as a draft to track the verification above.