Repository navigation
[Config] [gfx950] Add GLM-5.3-Flash TP4 fused KDA in-proj bf16 GEMM tunings - #5982
Conversation
…=6416, K=4096) When a GLM-5.3-Flash checkpoint leaves the KDA projections unquantized, SGLang fuses q/k/v, beta, f_a and g_a into one bf16 GEMM (fused_qkvbfg_a_proj). At TP4 that is N=6416, K=4096, run once in each of the 34 KDA layers per decode step. glm53_flash_bf16_tuned_gemm.csv only has the TP8 shape (N=3336), so at TP4 tuned_gemm has no entry and hipBLASLt's default pick takes 17.6 us per call at decode batch 4, against 11.6 us for the tuned kernel. The rows cover the decode graph batch sizes M=1-8, 12, 16, 20, 24, 32, 40, 48, 56 and 64 on 256-CU gfx950. err_ratio is 0 everywhere except the split-K FlyDSL picks at M=32/40/56 (at most 1.2%).
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Hardware-specific performance and numerical behavior require final human validation on the stated gfx950 environment.
Review effort: Balanced
Findings: None
What changed in this PR
Adds gfx950 TP4 BF16 GEMM tuning data for GLM-5.3-Flash’s fused KDA projection.
Changes:
- Adds 17 untuned shapes for N=6416, K=4096, M=1–64.
- Adds matching hipBLASLt, FlyDSL, and Triton selections.
| File | Description |
|---|---|
aiter/configs/model_configs/glm53_flash_bf16_untuned_gemm.csv |
Adds TP4 tuning inputs. |
aiter/configs/model_configs/glm53_flash_bf16_tuned_gemm.csv |
Adds gfx950 tuned configurations. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The first 17 rows stop at M=64, so a decode batch above 64 (concurrency 72 and up) still falls through to hipBLASLt's default pick for N=6416, K=4096. Add 38 rows for the SGLang decode graph batch sizes M=72-256 step 8 and 272-512 step 16, from gemm_a16w16_tune.py --with-hipblaslt on 256-CU gfx950, checked against the default pick through tgemm.mm in a HIP graph over 34 rotating weights: - M=96, 112 and 160: the tuner's pick is 2-4% slower than the default hipBLASLt solution, and falling through to the next row is slower still, so these rows pin the default solution (solidx 18601, 18580, 18640). - M=120 and 200 have no row: their tuned picks were 2% slower, while falling through to the M=128 and M=208 rows matches or beats the default. None of the rows is split-K and err_ratio is 0 on every row.
66015e3 to
c0a562f
Compare
A hipblaslt row stores a solution index that only exists in the hipBLASLt build it was tuned on, so it can error in another docker. Maintainers asked for these rows to be removed in ROCm/aiter#5982. Tune gemm_a16w16_tune.py without --with-hipblaslt, and use a torch row (F.linear, no index) where only hipBLASLt beat the default or where a shape needs to stay pinned to stock.
A hipblaslt row stores a solution index that only exists in the hipBLASLt build it was tuned on, so it can error in another docker. Re-run gemm_a16w16_tune.py without --with-hipblaslt over all 57 SGLang decode graph batch sizes (M=1-8, 12-64, 72-256 step 8, 272-512 step 16) for N=6416, K=4096. Checked through tgemm.mm in a HIP graph over 34 rotating weights, 8 runs per arm. The tuner's pick was slower than the default at M=96, 112, 352, 368, 384, 464, 480 and 496 (up to +17%), so those rows are torch rows from --libtype torch: F.linear, the same path as with no row, which keeps the M from padding onto a neighbour's row. Rows: 42 FlyDSL, 2 Triton, 13 torch, 0 hipblaslt.

Motivation
GLM-5.3-Flash's KDA attention computes q/k/v, beta and the f/g gate inputs with one fused bf16 GEMM, run in each of its 34 KDA layers per decode step. At TP4 that GEMM is N=6416, K=4096 (3 × 2048 + 16 + 2 × 128). At decode batch 1–16 it takes 17.5–18.5 us; a tuned kernel takes 11.2–11.9 us.
glm53_flash_bf16_tuned_gemm.csvonly has the TP8 shape (N=3336), so N=6416 falls through to thetorchdefault (F.linear). This PR adds 57 rows, one per SGLang decode graph batch size up to M=512. No row ishipblaslt; no other shape changes.Test Plan
MI355X (gfx950, 256 CUs), ROCm 10.0.0,
rocm/sgl-dev:v0.5.20-rocm10-mi35x-20260928.Step 1 —
gemm_a16w16_tune.pyproduces the rows. Default backends, no--with-hipblaslt:python3 csrc/gemm_a16w16/gemm_a16w16_tune.py --input_file glm53_flash_kda_tp4_untuned.csv \ --tuned_file glm53_flash_kda_tp4_tuned.csv --mp 4Rows that lost to stock in Step 2 were re-tuned with
--libtype torch.Step 2 — a
tgemm.mmharness A/Bs the rows through the call SGLang makes.AITER_CONFIG_GEMM_BF16lists the image's stock tuned CSVs, with and without the new rows. Each point is a HIP graph of 34 calls over 34 rotating weights, so weights miss L2; median of 8 runs. Correctness: relative L2 against fp32F.linear. End to end: SGLangbench_servingwith sgl-project/sglang#41870, which emits this GEMM; only the CSV differs, two runs per arm on swapped GPUs.Step 2 harness
Test Result
Kernel, us/call, M ≤ 64 (Step 2):
Split-K rows raise rel L2 to at most 3.2e-3, still bf16 rounding.
M = 72–512, same harness. At M=96, 112, 352, 368, 384, 464, 480 and 496 FlyDSL lost to stock (up to +17%), so those rows are
torch:F.linear, the same path as no row, which also stops the M padding onto a neighbour's row.44 of 57 M are faster; the 13
torchrows match stock within 0.6%.End to end, GLM-5.3-Flash-Quark-MXFP4, TP4, input 8192 / output 1024, mean of two runs per arm:
GSM8K: 96.82% / 96.97% stock, 97.04% / 96.97% tuned.