Repository navigation
[SM12x] Re-enable the FP8 wo_a GEMM on sm120/sm121 - #34018
zhendonghua wants to merge 1 commit into
Conversation
DeepGEMM ships sm120 kernels, so the blanket "SM120 lacks tcgen05" disable no longer applies to wo_a. Gate it behind an explicit opt-in and route sm12x through the ue8m0 path, which is the only scale format DeepGEMM's sm120 FP8 GEMM accepts. Co-Authored-By: Claude Opus 5 <[email protected]>
81a2660 to
c3ffe8c
Compare
| supported = deep_gemm_wrapper.DEEPGEMM_SCALE_UE8M0 or ( | ||
| deep_gemm_wrapper.ENABLE_JIT_DEEPGEMM | ||
| and is_sm90_supported() | ||
| and (is_sm90_supported() or is_sm120_supported()) |
There was a problem hiding this comment.
This still goes through the global deepgemm jit gate, which is disabled on sm120, so sm120 can’t actually reach this path
Maybe give the sm12x wo_a path its own check instead?
|
SM120 validation at current head
This validates the SM120 implementation once the global gate is enabled. The stock-main SM120 reachability condition still needs to be resolved in this PR or made an explicit dependency on #29927. |
|
Thanks @zhendonghua. Closing this because you have 13 PRs open and none updated in 7 days, over our soft cap of 5 for idle PRs. Reopen the two or three you most want reviewed - a short active set moves faster than a long idle one. Some directories moved recently, so an older branch may need retargeting: |
Motivation
On SM120/SM121
server_args.pydisables a block of features with the rationale "SM120 lacks tcgen05/TMEM: disable features that depend on DeepGEMM". Forwo_a(the first stage of DeepSeek-V4's o-projection) the consequence is that the FP8 weights already present in the checkpoint are dequantised to bf16 at load and the projection then runs as a generic bf16 WMMA GEMM.The hardware half of that rationale is correct — sm120/sm121 really have no tcgen05/TMEM (
grep tcgen05hits onlyimpls/sm100_*.cuh). The implication is what went stale: DeepGEMM no longer requires tcgen05. The installed package ships nineimpls/sm120_*.cuh—sm120_fp8_fp4_gemm_1d1d,sm120_bmk_bnk_mn,sm120_tf32_hc_prenorm_gemm,sm120_{fp8,fp4}_{paged_,}mqa_logits, … — all built on the SM120 warp-level MMA path instead.Measured on 2× DGX Spark (GB10 / sm_121, TP=2),
deepseek-ai/DeepSeek-V4-Flash-0731+ DSPARK, the bf16 fallback costs 48 calls/step at ~174 µs = 12.7 ms/step, about 15% of the decode step.Modifications
Opt-in only; default behaviour on every arch is unchanged.
SGLANG_OPT_FP8_WO_A_GEMM=1(is_set()guard).is_sm120_supported().wo_atakes the whole sm100 branch on sm12x: the dedicated ue8m0 activation quant,transform_sf_into_required_layoutfor the weight scales, andrecipe=(1, 1, 128).Point 3 is not cosmetic. Two constraints were found by offline probing at the real shapes (T=6, G=4, D=4096, R=1024):
fp8_einsum,fp8_gemm_nt×G,m_grouped_fp8_gemm_nt_contiguous) aborts withcudaErrorLaunchFailure; every ue8m0 variant works.recipemust match the weight-scale layout. The transformed[G, R, D/128] int32layout pairs with(1, 1, 128); the untransformed[G, R/128, D/128] fp32layout pairs with(1, 128, 128). Crossing them tripsAssertion (utils/layout.hpp:97): sf.size(-2) == ceil_div(mn, gran_mn).Splitting the branch (ue8m0 weights +
(1,128,128)) reproduces that assert, which is why sm12x reuses the sm100 branch intact rather than a hybrid.Offline microbenchmark, exclusive GPU, same shapes:
m_grouped_fp8_gemm_nt_contiguous(ue8m0, M padded 6→128)fp8_einsum+ recipe (1,1,128)The resulting kernel is
deep_gemm::sm120_fp8_fp4_gemm_1d1d_impl<0u, 6u, 4096u, 128u, 128u, 4u, …>— the same instantiation vLLM launches for this projection on the same hardware.Accuracy Tests
GSM8K 5-shot,
--num-questions 200 --parallel 16, 2× DGX Spark TP=2:An earlier n=1000 run on an older base gave 0.943 (baseline) vs 0.946 (this change). Note accuracy is not comparable across different
--num-questions— the first 200 questions are easier than the first 1000 (same build: 0.970 @ n=200 vs 0.943 @ n=1000).Benchmarking and Profiling
sglang.bench_one_batch_server, bs=1,SGLANG_SIMULATE_ACC_LEN=5so the accept length is pinned and the comparison is pure step cost (acc_length: 5.00confirmed in both arms). Same container, same clocks (unlocked), RoCE/RDMA available to both.Kernel-level attribution from a 20-step profile (same container, same conditions), which separates the two changes:
deep_gemm sm120_fp8_fp4_gemm_1d1dhc_pre)Net for this PR alone: −7.45 ms of bf16 WMMA for +3.29 ms of FP8 GEMM ≈ −4.2 ms/step.
Test environment caveat
DSPARK on sm120/sm121 cannot boot on stock flashinfer today: the draft's index width is
ceil_align(swa_window + gamma, 64), which is 192 for every gamma in [1, 64], whileflashinfer 0.6.15.post1 only instantiates decode top-k widths
{128, 512, 1024}. Both knownfixes are still open — flashinfer-ai/flashinfer#4309 (adds the 192 instantiation) and
#33407 (dispatch fallback in SGLang). The numbers above were collected with
flashinfer#4309 carried as a local patch;
SGLANG_SM120_FLASHMLA_BACKEND=tritonis the onlystock alternative and it routes all sparse-MLA calls through Triton, which costs throughput
on the hot path (measured 4.8x slower end to end here), so it is not a usable baseline.
On tests
No unit test is included. The change is arch-gated to sm120/sm121, and CI has no such runner,
so a test would not execute where the behaviour differs. Validation was done on hardware
instead: GSM8K for accuracy and a kernel-level profile (reported above) to confirm the intended
kernels actually run rather than inferring it from throughput. Happy to add a test if there is
a preferred pattern for arch-gated paths.
Checklist
Open question for maintainers
The same SM120 block also force-disables
SGLANG_OPT_DEEPGEMM_HC_PRENORMand pushes the DSA indexer onto the torch / TileLang paths (SGLANG_FP8_PAGED_MQA_LOGITS_TORCH=True,SGLANG_OPT_USE_TILELANG_INDEXER=True). DeepGEMM shipssm120_tf32_hc_prenorm_gemm.cuhandsm120_{fp8,fp4}_{paged_,}mqa_logits.cuhfor exactly those. If the tcgen05 premise is stale forwo_a, those three deserve a re-audit too — happy to test them on this hardware. Tracking under #19637 rather than widening this PR.Also note
deep_gemm_wrapper/configurer.pygates onsm_version == 120, which misses sm_121 (GB10 reports 121), whileserver_args.pyusesis_sm120_supported()which returns True there. The two disagree; this PR uses the helper consistently but does not changeconfigurer.py.CI States
Latest PR Test (Base): ❌ Run #31215115097
Latest PR Test (Extra): ❌ Run #31215114872