Skip to content

[SM90] Support paged MQA next_n=4 and block_kv=32 - #7

Merged
zyongye merged 1 commit into
vllm-project:devfrom
zyongye:codex/port-indexer-next-n-4
Sep 14, 2026
Merged

zyongye merged 1 commit into
vllm-project:devfrom
zyongye:codex/port-indexer-next-n-4

Conversation

@zyongye

@zyongye zyongye commented Sep 14, 2026

Copy link
Copy Markdown
Member

Summary

  • Port deepseek-ai/DeepGEMM commit 12cb7c0 from nv_dev.
  • Support SM90 indexer/paged-MQA next_n=4 with two-CTA clusters while keeping the per-CTA WGMMA/register footprint at next_n=2.
  • Support 32-token KV pages with a fixed 64-token compute tile and bounded physical-page loads.
  • Adapt scheduler metadata and tests to the fork's current runtime/API layout.

Validation

  • MAX_JOBS=4 DG_USE_LOCAL_VERSION=0 python setup.py build
  • SM90a NVCC compile smoke tests for next_n=4, block_kv=32 and the existing next_n=1, block_kv=64 specialization
  • SM90 metadata-kernel NVCC compile smoke test
  • PYTHONPATH=../build/lib.linux-aarch64-cpython-312 DG_MQA_NUM_CASES=1 python -c 'from test_attention import test_paged_mqa_logits; test_paged_mqa_logits()' (GB200/SM100 regression smoke test)

SM90 runtime validation was not available on this host; the available GPUs are GB200 (SM100).

Upstream source: deepseek-ai@12cb7c0

Extend the SM90 FP8 paged MQA logits kernel and host wrapper to cover
block_kv=32 and next_n=4 on post-deepseek-ai#304 code.

Kernel (deep_gemm/include/deep_gemm/impls/sm90_fp8_paged_mqa_logits.cuh):
  - Keep MMA tile at kComputeBlockKV=64 and let block_kv vary (32 or
    64). Each WGMMA iteration covers kNumBlocksPerMMA = 64 / block_kv
    physical blocks with one TMA copy each.
  - Load block_table entries with a loop of scalar __ldg's so
    block_table_stride no longer has to be a multiple of
    kNumBlocksPerMMA.
  - Add kNumKVMulticast template parameter for next_n=4; compute
    kNextNPerCTA = kNextN / kNumKVMulticast and split Q rows across
    two CTAs in a cluster via cta_rank_in_cluster, keeping smem and
    register budgets within SM90 limits (WGMMA N=256 otherwise
    exceeds kNumMathRegisters=104).
  - Use cute::cluster_id_in_grid().x for the scheduler index.

Host wrapper (csrc/jit_kernels/impls/smxx_fp8_fp4_paged_mqa_logits.hpp):
  - Select num_kv_multicast = 2 when SM90+next_n=4 else 1. Build
    Q/weights TMA descriptors with next_n_per_cta * num_heads box,
    size smem from next_n_per_cta, launch with
    cluster_dim=num_kv_multicast.
  - Emit the extra kNumKVMulticast template arg only for SM90; SM100
    instantiation is unchanged.

Other:
  - Add utils::shfl_sync helper in common/utils.cuh.
  - tests/test_attention.py: extend enumerate_paged_mqa_logits to
    cover block_kv=32 and next_n=4 on SM90; call
    get_paged_mqa_logits_metadata with num_clusters = num_sms /
    num_kv_multicast; initialize block_table with torch.zeros so
    unused slots hold a valid block id.
(cherry picked from commit 12cb7c0)
Signed-off-by: Yongye Zhu <[email protected]>
@zyongye
zyongye force-pushed the codex/port-indexer-next-n-4 branch from f14a358 to 001ed5f Compare September 14, 2026 20:46
@zyongye
zyongye merged commit 9a86ae2 into vllm-project:dev Sep 14, 2026
1 check passed
@zyongye
zyongye deleted the codex/port-indexer-next-n-4 branch September 14, 2026 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant