Repository navigation
[DeepSeek-V4] Fuse UE8M0 scale rounding into FP8 group quantization - #26766
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
2427af2 to
8c755e9
Compare
|
Hi, could you ping me on slack? My name is Yuhao Yang. |
Co-authored-by: Yuhao Yang <47235274+yhyang201@users.noreply.github.com> Change-Id: I206d621f90d11b1e2ae42db8ae92b0bd782d5ced
8c755e9 to
e008659
Compare
|
Reason for the second commit: #28307 |
The row-major + SCALE_UE8M0 path quantized with an exact FP32 scale and only rounded the output scale_inv to power-of-2. This caused a scale mismatch: FP8 values quantized with one scale, GEMM dequants with another, amplifying error ~14x (31% average relative error). On Blackwell (SM100) where DeepGEMM uses native UE8M0 hardware scaling, this mismatch fully exposed, dropping EAGLE accept_length from 2.76 (H200) to 2.69 (B300). Hopper (SM90) was less affected because it uses FP32 scale post-correction. Fix: use calculate_fp8_scales<SCALE_UE8M0=true> for all UE8M0 paths, which computes the rounded scale first then quantizes with it. This matches the official DeepSeek-V4 kernel.py act_quant(scale_fmt="ue8m0"). Results (DSV4-Flash EAGLE spec decode, GSM8K 200 prompts): H200 (SM90): 2.76 → 2.76 (unchanged) B300 (SM100): 2.69 → 2.77 (+0.08) Change-Id: Ic011b2dd16a6eb5d41955b2a705e623aaf03b6b4
bc52c46 to
fdc448b
Compare
|
@yuhao318 Please add acc results on harder benchmarks like AIME25 |
|
/rerun-failed-ci |
AIME25 Accuracy ReportModel: DeepSeek-V4-Flash
|
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-test test/registered/models_e2e/test_deepseek_v4_flash_fp4_b200.py test/registered/models_e2e/test_deepseek_v4_flash_fp4_megamoe_b200.py test/registered/cp/test_deepseek_v4_flash_fp4_b200_cp.py |
|
Results for 🚀 |
|
/reurn-test test/registered/jit/test_per_token_group_quant_8bit_v2.py |
|
/rerun-test test/registered/4-gpu-models/test_deepseek_v3_cutedsl_4gpu.py test/registered/models_e2e/test_deepseek_v3_fp4.py |
|
Results for 🚀 🚀 |
main advanced 15+ commits since the last merge (sgl-project#28598 base), making the PR CONFLICTING and blocking pr-test. Resolve the one content conflict in python/sglang/srt/layers/quantization/fp8_kernel.py by taking main's version (byte-identical): main added the row-major UE8M0 scale path (sgl-project#26766 DSV4 UE8M0 fusion) as a superset of our column-major+tma-aligned path, and hardcodes //128 which is correct for UE8M0 (group fixed at 128). Everything else auto-merged from main.
…gl-project#26766) Co-authored-by: liqichao <liqichao@baidu.com> Co-authored-by: yhyang201 <yhyang201@gmail.com>
Motivation
This PR optimizes the DeepSeek-V4
wo_aFP8 path by removing the separatedeep_gemm.ceil_to_ue8m0call after activation quantization.The original path launches quantization first, then rounds the generated FP8 scales to UE8M0/power-of-two format:
The optimized path emits the rounded power-of-two scale directly from the per-token group quantization kernel:
Performance Test
DeepSeek-V4-Flash, TP=4, 32K input / 1K output, 128 requests, max concurrency 4.
Output token throughput increased by 7.8%.


Accuracy Tests
GSM8K score: 0.928
Update: precision fix on Blackwell (B300/B200)
The initial fused kernel in this PR had a precision issue on Blackwell: in the
SCALE_UE8M0 && !IS_COLUMN_MAJORbranch, activations were quantized with theexact FP32 scale while only the output scale was rounded to UE8M0 (power-of-2).
Since quantization and dequantization then used mismatched scales, EAGLE
speculative decoding accept_length dropped from 2.76 to 2.69 on B300/B200.
Thanks to @yhyang201 for catching this and providing the fix. The special branch
is removed and all UE8M0 paths now go through
calculate_fp8_scales<SCALE_UE8M0=true>,which computes the rounded (power-of-2) scale first and quantizes with it — matching
the official DeepSeek-V4
kernel.pyact_quant(scale_fmt="ue8m0"). The row-majorUE8M0 test now asserts the scales are exact powers of 2 and the fp8 codes match the
ceil_to_ue8m0reference.CI States
Latest PR Test (Base): 🚫 Run #27789934317
Latest PR Test (Extra): ✅ Run #27791183010