Skip to content

[SM12x] Re-enable the FP8 wo_a GEMM on sm120/sm121 - #34018

Closed
zhendonghua wants to merge 1 commit into
sgl-project:mainfrom
zhendonghua:sm12x-fp8-wo-a
Closed

zhendonghua wants to merge 1 commit into
sgl-project:mainfrom
zhendonghua:sm12x-fp8-wo-a

Conversation

@zhendonghua

@zhendonghua zhendonghua commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

On SM120/SM121 server_args.py disables a block of features with the rationale "SM120 lacks tcgen05/TMEM: disable features that depend on DeepGEMM". For wo_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 tcgen05 hits only impls/sm100_*.cuh). The implication is what went stale: DeepGEMM no longer requires tcgen05. The installed package ships nine impls/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.

  1. The SM120 feature-disable block honours an explicit SGLANG_OPT_FP8_WO_A_GEMM=1 (is_set() guard).
  2. The existing opt-in gate accepts sm12x via is_sm120_supported().
  3. wo_a takes the whole sm100 branch on sm12x: the dedicated ue8m0 activation quant, transform_sf_into_required_layout for the weight scales, and recipe=(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):

  • sm12x accepts only ue8m0 scales. Every fp32-scale variant I tried (fp8_einsum, fp8_gemm_nt ×G, m_grouped_fp8_gemm_nt_contiguous) aborts with cudaErrorLaunchFailure; every ue8m0 variant works.
  • recipe must match the weight-scale layout. The transformed [G, R, D/128] int32 layout pairs with (1, 1, 128); the untransformed [G, R/128, D/128] fp32 layout pairs with (1, 128, 128). Crossing them trips Assertion (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:

µs/call
bf16 einsum (current fallback) 152–154
m_grouped_fp8_gemm_nt_contiguous (ue8m0, M padded 6→128) 73.4
dedicated quant + fp8_einsum + recipe (1,1,128) 26.0

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:

Accuracy Invalid
baseline 0.970 0.000
this PR + #34019 0.980 0.000

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=5 so the accept length is pinned and the comparison is pure step cost (acc_length: 5.00 confirmed in both arms). Same container, same clocks (unlocked), RoCE/RDMA available to both.

in / out baseline this PR + MHC default
1024 / 512 58.48 tok/s 72.67 tok/s +24.3%
8192 / 1024 61.88 tok/s 66.76 tok/s +7.9%

Kernel-level attribution from a 20-step profile (same container, same conditions), which separates the two changes:

kernel family baseline patched attributable to
bf16 SM80-WMMA 20.18 ms / 136 calls 12.74 ms / 93 calls this PR (wo_a's 43 calls move out)
deep_gemm sm120_fp8_fp4_gemm_1d1d 0 3.29 ms / 43 calls this PR
fp32 cuBLAS (hc_pre) 9.54 ms / 93 calls 0.86 ms / 8 calls MHC default (separate PR)
decode step 70.31 ms 63.19 ms −10.1%

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], while
flashinfer 0.6.15.post1 only instantiates decode top-k widths {128, 512, 1024}. Both known
fixes 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=triton is the only
stock 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_PRENORM and pushes the DSA indexer onto the torch / TileLang paths (SGLANG_FP8_PAGED_MQA_LOGITS_TORCH=True, SGLANG_OPT_USE_TILELANG_INDEXER=True). DeepGEMM ships sm120_tf32_hc_prenorm_gemm.cuh and sm120_{fp8,fp4}_{paged_,}mqa_logits.cuh for exactly those. If the tcgen05 premise is stale for wo_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.py gates on sm_version == 120, which misses sm_121 (GB10 reports 121), while server_args.py uses is_sm120_supported() which returns True there. The two disagree; this PR uses the helper consistently but does not change configurer.py.


CI States

Latest PR Test (Base): ❌ Run #31215115097
Latest PR Test (Extra): ❌ Run #31215114872

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]>
@zhendonghua
zhendonghua marked this pull request as ready for review August 7, 2026 20:21

@mmangkad mmangkad left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we combine this with #34019 since they touch the same sm12x setup?

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())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@ormandj

ormandj commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

SM120 validation at current head c3ffe8cfd3cf6cf9c30fc470cf7b76754954f3f0:

  • Hardware: 2× RTX PRO 6000 Blackwell Max-Q, SM120, TP2, PCIe Gen4 x16.
  • Model: DeepSeek-V4-Flash-0731.
  • The path was reachable because the tested stack also included [SM120] DeepSeek-V4: DeepGEMM paged-MQA indexer +FP4 MoE+ page-split  #29927 at e5ea881c5dd487acef17d58ba1a9d2b7ecfeee91, whose SM120 capability probe enabled the global DeepGEMM JIT gate. On stock main, the unresolved reachability observation above remains valid.
  • A matched 127-step Nsight comparison reduced complete target-plus-draft step span by 4.73%–4.74% and GPU busy time by 5.12%–5.17%.
  • The 43 target-layer BF16 W_o_A calls, previously taking 1.1421 ms/step, were replaced by the SM120 FP8 sequence taking 0.6369 ms/step.
  • The same build completed decode C1–C32, five cold-prefill requests at 8K/32K/64K/128K, and GSM8K with 1,262/1,319 correct and zero request errors.

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.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

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:
sgl-kernel/ -> python/sglang/kernels/aot/, python/sglang/jit_kernel/
-> python/sglang/kernels/jit/, docs/ -> docs/docs/ (.mdx),
bench_serving.py -> benchmark/serving.py, test/srt/ -> test/registered/.

@github-actions github-actions Bot closed this Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants