[AMD] [GLM5] Opt-in prefill-only FP8 dense projection GEMM for MLA q_b/o_proj (gfx950) - #31955
Closed
Raiden-Makoto wants to merge 1 commit into
Closed
Raiden-Makoto wants to merge 1 commit into
Raiden-Makoto wants to merge 1 commit into
Conversation
…x950) Opt-in (SGLANG_DSA_FP8_PROJ_GEMM, default off): run the bf16 dense MLA q_b_proj/o_proj on the aiter FP8 a8w8 block-scale bpreshuffle CK GEMM for prefill (M > 512) while decode (small-M cuda-graph batch sizes) stays bf16. At load time UnquantizedLinearMethod repacks the bf16 weight into a private FP8 e4m3 (+128x128 UE8M0 scale, bpreshuffle) copy; the bf16 weight is kept as layer.weight so decode runs the original bf16 GEMM. apply() gates on token count: M > 512 takes the FP8 path, M <= 512 falls through to bf16. Only 128-aligned projections are marked (q_b [.,2048], o_proj [6144,.]); fused_qkv_a (out 2624) is not 128-aligned and kv_b_proj is the absorbed-bmm path. gfx950-gated; no effect off-arch or with the flag unset. Adds quant_weight_ue8m0() helper to fp8_utils.
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Raiden-Makoto
added a commit
to Raiden-Makoto/squidward
that referenced
this pull request
Jul 21, 2026
Raiden-Makoto
marked this pull request as ready for review
July 21, 2026 15:45
Raiden-Makoto
requested review from
Alisehen,
AniZpZ,
BBuf,
Edwardf0t1,
FlamingoPg,
Fridge003,
HaiShaw,
OrangeRedeng,
b8zhong,
ch-wan,
fzyzcjy,
ispobock and
merrymercy
as code owners
July 21, 2026 15:45
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Contributor
Author
|
Closing for #32888 and other optimizations to come. |
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.
Motivation
On gfx950 (MI355X), the GLM-5.2 MLA dense projections
q_b_proj/o_projare quark-excluded and run in bf16. For prefill (large M) these are dense-GEMM bound. Running them on the aiter FP8a8w8_blockscale_bpreshuffleCK GEMM for prefill only — while decode (small-M cuda-graph batch sizes) stays bf16 — reduces the dense-GEMM section without regressing decode.Opt-in via
SGLANG_DSA_FP8_PROJ_GEMM(default off), gfx950-gated. No effect off-arch or with the flag unset.The tuned
a8w8_blockscale_bpreshuffleGLM-5.2 configs are merged in aiter (ROCm/aiter#4243), so aiter selects the tuned tiles automatically — no config override needed. Untuned, the small-M FP8 GEMM regresses vs bf16, which is why the path is prefill-only (M > 512).Modifications
layers/quantization/unquant.py:UnquantizedLinearMethodgains an opt-in FP8 path for layers tagged_fp8_proj_gemm. At load, the bf16 weight is repacked into a private FP8 e4m3 (+128×128 UE8M0 scale, bpreshuffle) copy;layer.weightstays bf16.apply()gates on token count: M > 512 → FP8 CK GEMM (aiter_w8a8_block_fp8_linear), M ≤ 512 → bf16.models/deepseek_v2.py: markq_b_proj/o_projwith_fp8_proj_gemm(128-aligned;fused_qkv_aout=2624 is not 128-aligned,kv_b_projis the absorbed-bmm path).layers/quantization/fp8_utils.py: addquant_weight_ue8m0()helper.Accuracy Tests
GSM8K (400 questions, 5-shot),
SGLANG_DSA_FP8_PROJ_GEMM=1, TP4, MI355X:Pass bar ≥ 0.92.
Speed Benchmarks
sglang.bench_serving(random, input=1024, output=1024, num-prompts=conc×4), TP4 MI355X, graphs-on. Each value is the mean of 3 reps after dropping the single obvious outlier per point (run-to-run / RNG noise). Baseline = flag off (bf16); Feature =SGLANG_DSA_FP8_PROJ_GEMM=1.A. Baseline (flag off)*:
B. Feature on (Δ vs baseline):
TTFT improves monotonically with concurrency (−0.9% → −5.6%) as more prefill GEMM amortizes the FP8 path; ITL, E2EL, and output-throughput deltas are within run-to-run noise (decode stays bf16).
*Baseline and Feature both measured with #30519, #30715, #31323, #31324, and the tuned aiter MoE configs for GLM-5.2.
Checklist
CI States
Latest PR Test (Base): ❌ Run #29845180487
Latest PR Test (Extra): ❌ Run #29845180047