mirror of
https://github.com/deepseek-ai/DeepGEMM.git
synced 2026-11-05 00:47:26 +00:00
[PR #340] Add SM90 FP8 paged MQA logits support for next_n=3 #373
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
deepseek-ai/DeepGEMM#373
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/deepseek-ai/DeepGEMM/pull/340
Author: @yangsiqt
Created: 5/28/2026
Status: 🔄 Open
Base:
main← Head:fix-sm90-nextn3-paged-mqa-logits📝 Commits (2)
be546e7Support SM90 paged MQA logits NextN=38ceef6bTest SM90 paged MQA logits NextN=3📊 Changes
4 files changed (+197 additions, -104 deletions)
View changed files
📝
csrc/jit_kernels/impls/sm90_fp8_mqa_logits.hpp(+13 -6)📝
deep_gemm/include/deep_gemm/impls/sm90_fp8_paged_mqa_logits.cuh(+180 -94)📝
deep_gemm/include/deep_gemm/scheduler/sm90_paged_mqa_logits.cuh(+3 -3)📝
tests/test_attention.py(+1 -1)📄 Description
Summary
This PR adds SM90/Hopper support for FP8 paged MQA logits with
next_n=3,which is required by vLLM MTP speculative decoding when
num_speculative_tokens=2. The unmodified SM90 path rejects this case withthe existing
next_n == 1 or next_n == 2assertion.The change is limited to the SM90 non-varlen path. Existing
next_n=1/2,SM100 behavior, and the public Python API remain unchanged.
Related issue: https://github.com/vllm-project/vllm/issues/43457
Implementation
The SM90 kernel uses a two-token WGMMA atom.
next_n=3is implemented as apair plus a single-token tail instead of introducing a three-token WGMMA shape:
and tail computations reuse each loaded KV tile.
the existing producer/consumer barrier lifecycle.
the valid third-token row is reduced and stored.
map the atom to the correct output token offset.
SM90 varlen
next_n=3andnext_n>3remain out of scope.Validation
next_n=3.B=16,17,256,257,H=64,D=128,L=512,FP32 logits, and 20 repeated calls per shape. Repeated outputs are bitwise
identical; simulated-reference differences are
7.73e-9to8.21e-9.tests/test_attention.py::test_paged_mqa_logitspasses all 36/36 SM90 cases:next_n=1/2/3, FP32/BF16 logits,H=32/64,D=128,B=256/4096, andaverage KV lengths
8192/65536subject to the test's 32M-token cap.compute-sanitizer --tool memcheckreports0 errorsforB=16,17,32,33,next_n=3,L=512, with three repeated calls.Standalone Performance
CUDA-event benchmark:
B=256,H=64,D=128,BLOCK_KV=64, FP32 logits,20 warmups, 100 timed iterations, five repeats. Values are median milliseconds
per call; JIT compilation is excluded.
T(next_n=3) / T(next_n=2)is1.517xatL=4096and1.512xatL=8192; existingnext_n=1/2performance remains within 1% of upstream.NCU Profile
A separate same-machine comparison used one H20, CUDA 12.8,
PyTorch 2.11.0+cu128, and Nsight Compute 2025.1. The table reports FP32 NCU
Duration and patched
next_n=3hardware metrics.For
next_n=3, NCU reports 96 registers/thread and 185.4 KB dynamic sharedmemory per block. The kernel is compute/pipeline-bound rather than DRAM-bound;
its occupancy, eligible-warps, and barrier-stall profile matches the prior
implementation. Same-run main-versus-patched ratios are used here because
absolute NCU durations from different profiler or toolchain configurations are
not directly comparable. DeepGEMM recommends NVCC 12.9 or newer for best
performance; the primary CUDA-event results above use CUDA 12.9.
Integration Context
An earlier revision was exercised end to end with vLLM on 2x H20 using TP=2
and
num_speculative_tokens=2: the server initialized,/v1/completionsreturned
200 OK, no DeepGEMMnext_nassertion occurred, and speculativedecode metrics were emitted. This is included as consumer-path validation;
the refreshed commit's correctness and performance conclusions use the
standalone results above.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.