Skip to content

[SM120] Restore MQA logits support on SM120 GPUs - #109

Merged
zcnrex merged 1 commit into
sgl-project:devfrom
ormandj:sm120-mqa-logits-new-api
Oct 22, 2026
Merged

zcnrex merged 1 commit into
sgl-project:devfrom
ormandj:sm120-mqa-logits-new-api

Conversation

@ormandj

@ormandj ormandj commented Oct 19, 2026

Copy link
Copy Markdown

Motivation

#103 removed the SM120 dense and paged MQA logits kernels, which served the old attention API. Since then, fp8_fp4_mqa_logits and fp8_fp4_paged_mqa_logits have no SM120 path on dev.

Modifications

  • Kernels and host launcher: restored from deepseek-ai/DeepGEMM nv_dev at b64107f2, which has fixes made after Merge upstream main (26/09/30 release + #471) into dev #103's copy:
    • the next Q tile follows the scheduler's actual next task;
    • a shared-memory fence orders reads before a stage is reused;
    • paged KV accepts 32-, 128- and 256-token pages as well as 64.
  • SM120 on the new API:
    • FP32 logits;
    • compressed, uncleaned dense logits;
    • FP8 with one float scale per KV token, FP4 with MX scales;
    • paged requests varlen or fixed next_n.
  • Limits:
  • Other architectures: SM90 and SM100 are unchanged.
  • Tests: test_attention.py covers SM120:
    • FP8 and MXFP4 dense logits, plus short-query cases with nonzero starts;
    • paged logits, varlen and fixed next_n 1-5, all four page sizes, with empty contexts and a batch whose contexts are all empty.

Validation

On four RTX PRO 6000 Blackwell (SM120, CUDA 13.0):

  • tests/test_attention.py passes: 96 dense, 36 short-query and 1,680 paged cases (480 varlen), plus the all-empty paged case.
  • Performance: dense kernel time against the pre-Merge upstream main (26/09/30 release + #471) into dev #103 kernels (cbe1727e) at 2K/8K queries x 8K/64K keys and 32/64 heads, timed with CUDA events (median of 15 per shape, two runs):
    • FP8 is within -0.1% to +2.6%;
    • MXFP4 is within -0.7% to +0.9%.

Developed with AI assistance.

sgl-project#103 removed the SM120 dense and paged MQA logits kernels, which served the
old attention API. This restores them on the new API from deepseek-ai/DeepGEMM
nv_dev at b64107f, which carries fixes made after sgl-project#103's copy: the next Q tile
follows the scheduler's actual next task, a shared-memory fence orders reads
before a stage is reused, and paged KV accepts 32-, 128- and 256-token pages.

On SM120 logits are FP32 and dense logits compressed and uncleaned; FP8 keeps
one float scale per KV token and FP4 uses MX scales; paged requests may be
varlen or fixed next_n. test_attention.py covers SM120.

Co-authored-by: Yuanhang Sun <yuasun@nvidia.com>
Co-authored-by: Gabriel Wu <13583761+lucifer1004@users.noreply.github.com>
Co-authored-by: Barry Kang <43644113+Barry-Delaney@users.noreply.github.com>
@zcnrex

zcnrex commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

Tested on B200 (SM100, CUDA 13.0) to check that SM90/SM100 are unaffected. SM120 itself is not tested here.

Setup: this PR's head 51ceada merged cleanly onto current dev (d0a3af7), built with build_sgl_deep_gemm.sh.

  • tests/test_attention.py: exits 0, with 1789 timed cases and no errors or assertion failures. This covers dense, short-query, all-empty paged, paged and sparse MQA logits on SM100.
  • sglang DSA/DSV4 indexer suite (13 test files, run on the [Refactor] [NVIDIA] attention: Migrate DSA/DSV4 indexers to DeepGEMM 0.2.5.post2 sglang#44350 branch, which moves the indexers onto the fp8_fp4_* API): 524 passed, 29 skipped. That matches plain dev exactly. The skips are AMD/Hopper-only cases and the SM100 metadata-format comparison.
  • The shared host checks in csrc/apis/attention.hpp keep the same conditions for arch_major 9 and 10. Only == 12 branches are added.

🤖 Generated with Claude Code

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.

2 participants