Repository navigation
feat: add sm120 support for DeepGEMM - #56
Merged
Merged
Conversation
Fridge003
reviewed
Jul 14, 2026
This was referenced Jul 14, 2026
…ped GEMM, einsum, prenorm) Cherry-pick of deepseek-ai/DeepGEMM nv_dev commit 2073ddb (PR deepseek-ai#324) onto sgl/dev. Stage 1 scope: dense + m-grouped FP8/FP4/BF16 GEMM, einsum, TF32 HC prenorm. Conflict resolutions: - scheduler/gemm.cuh: merged Scheduler template (dev kEnsureZeroPadding/kKAlignment/ kSFKSpan + sm120 kSplitKFactor). - heuristics/runtime.hpp: per-arch MK-alignment policy; preserved dev SM100 tuning {224,32,32}. - gemm.hpp: kept dev m-grouped calls (ensure_zero_padding) + added sm120 arch-12 arms. - Deferred to follow-ups: k-grouped GEMM (arch-12 -> UNREACHABLE, needs dev psum-SF API), MQA-logits (attention.hpp kept dev; smxx_*_mqa_logits.hpp removed; sm120 mqa .cuh orphaned). - Tests: took dev's harness; sm120 arch-12 test gating to be re-added.
…kbone - gemm.hpp k_grouped_fp8_gemm_nt_contiguous: define arch_major; stub arch-12 k-grouped (deferred to stage 2 per dev psum-SF API divergence). - sm120_fp8_fp4_gemm_1d1d.cuh: reorder Scheduler<> args to dev's param order (kEnsureZeroPadding, kKAlignment, kSFKSpan) so it matches the merged scheduler template. tvm-ffi _C.so now compiles clean with all sm120 apis edits.
New csrc/jit_kernels/impls/sm120_mqa_logits.hpp: SM120FP8MQALogitsRuntime + sm120_fp8_mqa_logits,
SM120FP4MQALogitsRuntime + sm120_fp4_mqa_logits, and a unified sm120_mqa_logits(is_fp4, ...)
mirroring dev's sm100_mqa_logits. Sourced from nv_dev's SM120 dense-MQA launchers, arch-branches
dropped per dev's per-arch convention.
attention.hpp: include sm120_mqa_logits.hpp; relax fp8/fp4 asserts to arch 12; block_kv=128 on
SM120; arch-12 dispatch arm in fp8_fp4_mqa_logits.
Validated on RTX PRO 6000: FP8 dense MQA head_dim=128 deterministic + runs.
KNOWN ISSUE (pre-existing nv_dev kernel): in-context compute race in sm120_fp8_mqa_logits.cuh
at head_dim in {32,64} (head_dim=128 clean). Needs kernel-level debug before enabling 32/64.
kSwizzleMode was hardcoded to 128 while the TMA descriptor uses swizzle_mode = head_dim
(and kSwizzleAlignment = head_dim*8 = the swizzle span). For head_dim in {32,64} the kernel
read smem with a 128B swizzle over a 32/64B-swizzled layout, mis-addressing reads into other
(valid, already-written) pipeline stages -> racecheck-clean but timing-dependent -> nondet
logits at deep KV pipelines. Set kSwizzleMode = kHeadDim (SwizzleContext supports B32/B64/B128).
Validated on RTX PRO 6000: dev test_mqa_logits PASSES all configs; head_dim 32/64/128 all
deterministic + numdiff ~6e-4. Pre-existing nv_dev kernel bug (upstream should take this too).
Same bug as the dense FP8 MQA kernel: kSwizzleMode hardcoded to 128 while the TMA descriptor uses swizzle_mode = head_dim. Set kSwizzleMode = kHeadDim. (FP4 paged is head_dim=128-only with kSwizzleMode=64 = packed kSMEMKBytes, so unaffected.) Validated by analogy to the dense fix; exercised once paged MQA is wired (stage 3b).
- scheduler/sm120_paged_mqa_logits.cuh: SM120PagedMQALogitsScheduler + sm120_paged_mqa_logits_metadata (dev per-arch style; atom scheduler carried from nv_dev, sm120-named). - sm120_fp8/fp4_paged_mqa_logits.cuh: point at the sm120-named scheduler. - csrc/jit_kernels/impls/sm120_paged_mqa_logits.hpp: SM120 paged host launchers (metadata split_kv=128, fp8, fp4). - attention.hpp: arch-12 wiring for get_paged_mqa_logits_metadata + fp8_fp4_paged_mqa_logits (split_kv=128, block_kv=64, relaxed fp8/fp4 asserts). - test_attention.py: enable is_fp4 on arch 12 (head_dim=128) for dense + paged MQA. Validated on RTX PRO 6000: dev test_mqa_logits (FP8+FP4 dense) and test_paged_mqa_logits (FP8+FP4 paged, next_n 1 and 2) all PASS. Note: paged uses the atom scheduler; converting to dev's q_token model (option Y) remains an optional follow-up refactor.
Add sm120_paged_mqa_logits(is_fp4, ...) with the exact same signature as dev's sm100_paged_mqa_logits (routes to sm120_fp8/fp4_paged_mqa_logits internally; SM120's atom scheduler ignores num_q_tokens_total/splits_per_chunk). attention.hpp now dispatches SM100 and SM120 paged identically. Dense/metadata entries already mirror sm100. Revalidated: test_paged_mqa_logits (FP8+FP4) PASS.
- attention.hpp: arch-12 branch for fp8_gemm_nt_skip_head_mid (-> sm120_fp8_fp4_gemm_1d1d) +
its missing include. Validated (test_gemm_skip_head_mid PASS).
- test gating for SM120 (consumer Blackwell): einsum tolerance 1e-10->1e-7 (FP32 accum order,
not a DG bug); skip cuBLASLt FP8 perf-baseline + test_cublaslt_gemm (limited FP8/kernel-naming
on SM120); guard empty-scores average; skip k-grouped (stub).
Full SM120 suite PASS: test_{layout,lazy_init,bf16,fp8_fp4,einsum,hyperconnection} + attention
(skip_head_mid/mqa/paged, FP8+FP4). Heavy attention sub-tests need isolation (memory), each
passes standalone. test_legacy N/A (Triton path); mega_moe* are SM90/SM100-specific.
…/tests/ Per sglang maintainer: tests/ should stay aligned with the deepgemm main branch (reduces rebase complexity). Revert the cherry-pick's auto-merged SM120 changes to tests/test_bf16.py and tests/test_einsum.py back to origin/dev. All SM120 test gating (FP4 enable, einsum 1e-7 tolerance, cuBLAS/k-grouped skips) lives only under sgl_deep_gemm/tests/.
zcnrex
pushed a commit
to zcnrex/DeepGEMM
that referenced
this pull request
Aug 31, 2026
Co-authored-by: Ray Wang <[email protected]>
Helicoplacoidea
pushed a commit
to Helicoplacoidea/DeepGEMM
that referenced
this pull request
Aug 31, 2026
Co-authored-by: Ray Wang <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.