Skip to content

[Attention][DSA] Route SM100 sparse-indexer decode through varlen paged MQA logits - #47469

Open
zyongye wants to merge 1 commit into
vllm-project:mainfrom
zyongye:feat/dsv4_varlen_decode
Open

[Attention][DSA] Route SM100 sparse-indexer decode through varlen paged MQA logits#47469
zyongye wants to merge 1 commit into
vllm-project:mainfrom
zyongye:feat/dsv4_varlen_decode

Conversation

@zyongye

@zyongye zyongye commented Jul 2, 2026

Copy link
Copy Markdown
Member

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 indices run-id to get_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 no
padded work. Plain next_n==1 and uniform spec decode are unified onto the same
path (cheap: plain decode needs no expansion, just indices = arange(B)).

Changes

  • vllm/utils/deep_gemm.py: optional indices kwarg on
    get_paged_mqa_logits_metadata and fp8_fp4_paged_mqa_logits, forwarded to
    the DeepGEMM impl only when set, so every existing non-varlen caller is
    byte-identical.
  • vllm/v1/attention/backends/mla/indexer.py: add use_varlen
    (cuda + sm_10x + DeepGEMM); relax require_uniform / use_native so
    variable-length decode stays a decode instead of being split to prefill; build
    per-row indices (arange for plain, i // max_decode_len for uniform —
    static/cudagraph-safe, repeat_interleave for the eager variable case) into a
    preallocated buffer; new DecodeMetadata.indices field.
  • vllm/model_executor/layers/sparse_attn_indexer.py: thread indices into
    the decode kernel call (FP8 and FP4 caches).

Off-SM100 (native / flatten) and XPU/ROCm paths are unchanged (use_varlen is
False there, indices stays None). storage_block_size is 64 for V3.2 and
block_size // compress_ratio = 64 for V4, satisfying the kernel's
block_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:

None implement the SM100 varlen paged-MQA-logits indices decode 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.

…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>

@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.

@zyongye zyongye added the ready ONLY add when PR is ready to merge/full CI is needed label Jul 7, 2026
@mergify

mergify Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @zyongye.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase label Jul 14, 2026

@LucasWilkinson LucasWilkinson 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 thanks for doing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-rebase ready ONLY add when PR is ready to merge/full CI is needed v1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants