Repository navigation
[AMD] [GLM5] Add opt-in PTPC FP8 KDA projections on gfx950 - #38764
Open
Raiden-Makoto wants to merge 17 commits into
Open
Raiden-Makoto wants to merge 17 commits into
Raiden-Makoto wants to merge 17 commits into
Conversation
4 of 5 tasks
Raiden-Makoto
force-pushed
the
RM/glm53-flash-kda-ptpc
branch
3 times, most recently
from
September 11, 2026 21:02
b0b8c59 to
9cb10f8
Compare
Raiden-Makoto
force-pushed
the
RM/glm53-flash-kda-ptpc
branch
7 times, most recently
from
September 14, 2026 18:09
6fe5ca3 to
8b27e6d
Compare
Raiden-Makoto
marked this pull request as ready for review
September 15, 2026 17:27
Raiden-Makoto
requested review from
Alisehen,
AniZpZ,
BBuf,
DarkSharpness,
Edwardf0t1,
FlamingoPg,
HaiShaw,
OrangeRedeng,
b8zhong,
celve,
ch-wan,
hebiao064,
mmangkad,
yizhang2077 and
yuan-luo
as code owners
September 15, 2026 17:27
Raiden-Makoto
force-pushed
the
RM/glm53-flash-kda-ptpc
branch
from
September 30, 2026 20:44
6faf569 to
c2671d6
Compare
Raiden-Makoto
force-pushed
the
RM/glm53-flash-kda-ptpc
branch
from
September 30, 2026 20:46
c2671d6 to
0312489
Compare
Contributor
Author
|
/tag-and-rerun-ci |
Jacob0226
reviewed
Oct 1, 2026
Jacob0226
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the restructure. With the old GSM8K/serving tables removed, the packed path has no full-model evidence yet. Could you add GSM8K and an i8k TP4/TP8 serving A/B (selector unset vs set) on a checkpoint where do_fuse_qkvbfg is True, and state which checkpoint was used?
Jacob0226
approved these changes
Oct 5, 2026
Jacob0226
left a comment
Contributor
There was a problem hiding this comment.
LGTM.
Since you edited the TP8 path as well. Please submit TP8 perf and gsm8k as well.
Contributor
Author
|
I'll fix merge conflict and update the PR body |
# Conflicts: # python/sglang/srt/models/glm5_next.py
# Conflicts: # python/sglang/kernels/ops/attention/fla/fused_norm_gate.py
Raiden-Makoto
requested review from
Fridge003,
Ying1123,
fzyzcjy,
ispobock and
merrymercy
as code owners
October 7, 2026 20:20
Raiden-Makoto
force-pushed
the
RM/glm53-flash-kda-ptpc
branch
from
October 7, 2026 20:24
67a4c26 to
f9a6ac2
Compare
5 tasks done
This branch has not been deployed
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
GLM-5.3-Flash keeps its KDA qkv, low-rank f/g, beta, and output projections in BF16. The PTPC path repacks selected weights to per-channel FP8 and quantizes activations per token, but
o_projpreviously required a separate BF16 gated RMSNorm output followed by a standalone quantization kernel.This change adds an opt-in no-copy packed PTPC prefill path while preserving the upstream fused BF16 projection modules for decode. Prefill uses one FP8
[qkv | f_a | g_a]GEMM plus BF16 beta and passes qkv/beta/fg directly to their consumers without reconstructing the fused output; decode remains one fused GEMM.Modifications
SGLANG_OPT_GLM53_KDA_PTPC_MODULESselector and reject it unless AITER is active on gfx950.UnquantizedLinearMethodtensor-in/tensor-out for every other model and backend.fused_qkvbfg_a_projandfused_bfg_a_projconstruction instead of unfusing projections when PTPC is selected.[qkv | f_a | g_a]into one FP8 weight, quantizehidden_statesonce, and return qkv/beta/fg views directly without a full-width output concatenation.M=4096-16384, TP8M=8192-16384.ValueErrorinstead of a bare lookup failure.o_proj.Enable with:
Accuracy Tests
Focused validation passed 17 CPU contracts and 3 gfx950 projection tests. Coverage includes TP4/TP8 no-copy packed projection shapes, decode BF16 parity, prefill PTPC numerics, selector/backend failures, supported-layout errors, crossover boundaries, retained BF16 weights, finite outputs, and CUDA-graph capture.
Full GLM-5.3-Flash TP8 GSM8K on snapshot
03eb5366286afd40d2221b1d9c63a6dd1ba4832e: 1,319 examples, 1,200 evaluator threads, 4,096 maximum output tokens, thinking enabled, temperature 1.0, top-p 0.95, sampling seed unset.qkv_proj,f_a_proj,g_a_proj,o_projSpeed Tests and Profiling
Environment:
gfx950)rocm/sgl-dev:v0.5.19-rocm724-mi35x-20260910zai-org/GLM-5.3-Flash, snapshot03eb5366286afd40d2221b1d9c63a6dd1ba4832ee8a2d9d2abNo-copy packed first-stage latency
Real GLM-5.3-Flash checkpoint weights. Decode compares the same fused BF16 GEMM with the selector unset/set; prefill compares fused BF16 against one packed qkv/f/g PTPC GEMM plus BF16 beta, returning views without fused-output reconstruction.
Decode retains one fused BF16 projection launch. Shapes outside the enabled prefill window stay on fused BF16.
Fused o-path latency
Complete path is gated RMSNorm plus output projection. The candidate replaces the BF16 norm output and standalone quantization with the fused bridge:
Every enabled TP/M cell beat the complete BF16 path. TP4 keeps BF16 below 256 tokens because intermediate small-batch shapes were neutral or slower.
End-to-end serving
GLM-5.3-Flash snapshot
03eb5366286afd40d2221b1d9c63a6dd1ba4832e, TP4, random 8K input / 1K output. The first concurrency-4 run in each repetition is the warmup; the tables average the two measured runs per concurrency. Both arms use the same source and differ only by the PTPC selector.A. BF16 fused projections — selector unset:
B. No-copy packed PTPC —
qkv_proj,f_a_proj,g_a_proj,o_proj(delta versus BF16 fused projections):No-copy packed PTPC improves TTFT by 2.18-2.38%, ITL by 0.05-0.57%, E2E latency by 0.20-0.96%, and output throughput by 0.20-0.92% across the complete TP4 matrix.
TP8 end-to-end serving
GLM-5.3-Flash TP8, 131,072 context, random 8K input / 1K output. The first concurrency-4 run in each repetition is the warmup; the tables average the two measured runs per concurrency. Both arms use source
05fcea11c0and differ only by the PTPC selector.A. BF16 fused projections — selector unset:
B. No-copy packed PTPC —
qkv_proj,f_a_proj,g_a_proj,o_proj(delta versus BF16 fused projections):No-copy packed PTPC improves TP8 TTFT by 0.37-1.01%, ITL by 0.19-0.63%, E2E latency by 0.24-0.74%, and output throughput by 0.24-0.75% across the complete matrix.
Checklist
Scoped syntax, isort, Ruff, Ruff format, codespell, registered-test validation, and
git diff --checkpass.CI States
Latest PR Test (Base): ❌ Run #37683185870
Latest PR Test (Extra): ❌ Run #37683185566
Latest PR Test (AMD ROCm 10): ❌ Run #37683185864