mirror of
https://github.com/deepseek-ai/DeepGEMM.git
synced 2026-11-05 00:47:26 +00:00
[PR #314] [MERGED] fix: SM90 paged MQA logits IMA on next_n=4 (nv_dev rebase) #360
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#360
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/314
Author: @Barry-Delaney
Created: 4/22/2026
Status: ✅ Merged
Merged: 4/22/2026
Merged by: @RayWang96
Base:
nv_dev← Head:user/jinshik/nv_dev_rebase📝 Commits (6)
d30fc36Fix sync issue of TMEM alloc/dealloc (#292)7f2a703[Public release 26/04] Introducing Mega MoE, FP4 Indexer and other features/fixes (#304)f6d98f2Enable bf16 bias output for FP8 GEMM on SM10012cb7c0SM90 paged MQA logits: support kv_block=32 and next_n=4a97b74dFix SM90 paged MQA logits for post-#304 metadata API mismatch6033584Sync with upstream main and integrate NV SM90/bf16-bias improvements📊 Changes
110 files changed (+12337 additions, -3431 deletions)
View changed files
📝
CMakeLists.txt(+4 -5)📝
README.md(+76 -44)📝
csrc/apis/attention.hpp(+297 -138)📝
csrc/apis/einsum.hpp(+35 -34)📝
csrc/apis/gemm.hpp(+71 -67)📝
csrc/apis/hyperconnection.hpp(+7 -7)📝
csrc/apis/layout.hpp(+46 -23)➕
csrc/apis/mega.hpp(+216 -0)📝
csrc/apis/runtime.hpp(+20 -0)📝
csrc/indexing/main.cu(+6 -1)📝
csrc/jit/cache.hpp(+1 -1)📝
csrc/jit/compiler.hpp(+70 -61)📝
csrc/jit/device_runtime.hpp(+46 -7)📝
csrc/jit/handle.hpp(+72 -18)➕
csrc/jit/include_parser.hpp(+80 -0)📝
csrc/jit/kernel_runtime.hpp(+77 -30)📝
csrc/jit_kernels/heuristics/common.hpp(+34 -319)➕
csrc/jit_kernels/heuristics/config.hpp(+171 -0)➕
csrc/jit_kernels/heuristics/mega_moe.hpp(+211 -0)➕
csrc/jit_kernels/heuristics/runtime.hpp(+62 -0)...and 80 more files
📄 Description
Summary
Rebases
nv_devonto upstreammain(brings in#292,#304), re-applies the two NV-side feature commits, and fixes a SM90 IMA introduced by the#304metadata API change.Commits
f6d98f212cb7c0block_kv=32/next_n=4a97b74dnext_n=4post-#304f6d98f2— bf16 bias output for FP8 GEMM on SM100sm100_fp8_gemm_1d1d/sm100_fp8_fp4_gemm_1d1dwith accumulation can now produce FP32 or BF16 matching the bias/C dtype. Adds bf16 bias coverage toenumerate_normalintests/generators.py.12cb7c0— SM90 paged MQA logits:block_kv=32/next_n=4kComputeBlockKV = 64; physicalblock_kv ∈ {32, 64}→kNumBlocksPerMMA = 64 / block_kvTMA copies per WGMMA.kNumKVMulticasttemplate fornext_n = 4: 2-CTA cluster splits Q across CTAs (kNextNPerCTA = kNextN / kNumKVMulticast) to fit SM90 smem/register budgets. WGMMAN=256otherwise exceedskNumMathRegisters=104.test_attention.pymatrix.a97b74d— SM90 paged MQA logits IMA onnext_n=4post-#304Symptom — IMA in
sm90_fp8_paged_mqa_logitswhen runningnext_n=4on the rebased tree.Root cause —
#304's metadata kernel hard-codes:kNumNextNAtomsnext_n=4next_n=4Metadata schedules 2× the tasks under the 2-atom scheme; SM90 scheduler decodes each entry as 1-atom →
q_idx = q_atom_idx / 1overrunsbatch_size→ reads pastcontext_lens.Fix
num_next_n_atomsas a runtime parameter; host computes arch-aware (SM90 multicast → 1, SM100 → 2 fornext_n=4).schedule_metasize tonum_sms / num_kv_multicast + 1for the SM90 cluster grid.get_paged_mqa_logits_metadata'sblock_kvassertion to{32, 64}(SM90block_kv=32is supported after12cb7c0).SM100 behavior unchanged — its
num_next_n_atomsvalue equals the previously hard-coded formula.Upstream (already reviewed upstream)
d30fc36Fix sync issue of TMEM alloc/dealloc (#292)7f2a703[Public release 26/04] Mega MoE, FP4 Indexer and other features/fixes (#304)Testing
test_attention.pytest_bf16.pytest_einsum.pytest_fp8_fp4.pytest_hyperconnection.pytest_layout.pytest_lazy_init.pytest_legacy.pytest_mega_moe.pycompute-sanitizer(SM90 paged MQA path)test_attention.pypaged MQA logits coversblock_kv ∈ {32,64} × next_n ∈ {1,2,4} × L ∈ {8k,32k} × dtype ∈ {float,bf16}on H200, andis_fp4 ∈ {T,F} × bf16 ∈ {T,F} × block_kv ∈ {32,64} × next_n ∈ {1..6}on GB200.test_mega_moe.pyfails withcuda:N out of rangeon both arch allocations (pre-existing multi-GPU test, not touched by this PR).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.