Repository navigation
[Config] Add gfx950 BF16 GEMM tunings for Gemma-4-26B-A4B - #7457
Conversation
Gemma-4-26B-A4B on MI355X (TP1) had no gfx950 rows for its dense attention, MLP and router GEMMs, so every M used the torch default. Add 49 FlyDSL rows for the seven text-layer shapes. Each row is faster than the default at every M it serves through exact or padded lookup.
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
READY FOR HUMAN REVIEWPR Self-ReviewRevision Author self-review accepted. Readiness report: Author answers
Show the author's self-review answersBehavior and intentValidation and unverified scopePR-specific questionChanged op testsPR state
Copilot findings
Code and op-test hygiene
Required CI
Shadow mode reports what would block but keeps the status successful. Set |
PR Pundit review(Testing PR Pundit Code Review agent. Not all comments may be relevant. This is a one-time automated pass: please address what is useful, no need to request a re-review. Please reply to each point, whether it applies or not: we harvest these replies, and both kinds are enormously helpful for tuning the agent. Reach out to @peymanr for suggestions.)
1. 🟠 Should fix: Decode GEMM N=8192,K=2816 at M=1..16 runs untuned torch path: this PR omits low-M rows
Who is affected: gfx950 users of the Gemma-4-26B-A4B config running a bf16 GEMM with N=8192, K=2816 at M<=16 (or M>128). Checked against the code by an independent pass. Shared from a pilot of PR Pundit, an agentic code reviewer that builds and tests the change and reads the project's past reviews. Reviewed at |
Thanks, this one is intentional. These M were tuned (the full tuning grid covered M = 1–16384 for all seven shapes), but no candidate met the keep rule (≥ 3% faster at its own M and ≥ 0.98× at every M it serves), measured with tgemm.mm in a CUDA graph. At M ≤ 16 this shape is bandwidth-bound and the default already streams the 46 MB weight at about 4.7 TB/s; the best FlyDSL rows were 0.99× / 1.01× / 1.01× / 1.00× at M = 1 / 4 / 8 / 16, and M = 2 was 1.015× in the rotated-weight sweep. For larger M the tuner's best was torch itself at M = 1024 / 8192 / 16384, and its FlyDSL picks at M = 2048 / 4096 measured 0.989× / 0.982×. So those M keep the default, with correct results and no slowdown. |
Summary
This PR adds 49 gfx950 (MI355X,
cu_num=256) FlyDSL rows for the seven dense BF16 GEMMs of Gemma-4-26B-A4B (google/gemma-4-26B-A4B-it), plus the untuned list they were tuned from. Each row is faster than the current default at every M it serves through exact or padded lookup (worst point 1.017×), and SGLang's output throughput on Gemma-4-26B-A4B at TP1 goes up 2.8–4.0% at concurrency 8 to 64, with median TPOT down 2.8–4.8%. GSM8K is unchanged.Motivation
On gfx950, Gemma-4-26B-A4B runs seven dense BF16 GEMMs per text layer through
tgemm.mm: the attention projections of the sliding and global layers, the dense MLP, and the MoE router. None of them has a gfx950 row inbf16_tuned_gemm.csvormodel_configs/, so every M falls back to the torch default (F.linear). At decode sizes the FlyDSL kernels in this table are up to 1.9× faster (for exampledown_projM=1, 8.96 → 4.82 µs).Changes
aiter/configs/model_configs/gemma4_26b_a4b_bf16_tuned_gemm.csv: 49 gfx950 rows (cu_num256), all FlyDSL.aiter/configs/model_configs/gemma4_26b_a4b_bf16_untuned_gemm.csv: every tuned key, so the table can be re-tuned.aiter/configs/bf16_tuned_gemm.csvormodel_configs/. The default config merge picks the new file up by its name.qkv_proj(16 × 256 + 2 × 8 × 256)qkv_proj(16 × 512 + 2 × 2 × 512)o_projo_projgate_up_proj(2 × 2112)down_projThe shapes and M values come from a running SGLang server with
AITER_LOG_TUNED_CONFIG=1. Decode M are the CUDA graph batch sizes, and prefill chunks reach the power-of-two rows through padded-M lookup. The five vision-tower shapes (K = 1152 or 4304) run only on image inputs and are not included.How the configs were made
On aiter
fd88e5b7fwith FlyDSL 0.4.1, one MI355X GPU, once per (N, K):The untuned list is the seven shapes at M = 1, 2, 4, 8, 16, 32, 64, 128, 1024, 2048, 4096, 8192 and 16384 (91 keys). The search covers asm, FlyDSL, OPUS, Triton, skinny and torch, with no hipBLASLt. All 49 kept rows are FlyDSL.
err_ratiois at most 0.0219; the 35 rows above 0.005 are all split-K.The tuner only times each key's own M, but a row also serves every M that pads onto it. So every candidate row was re-timed over the whole range it serves, through the public
tgemm.mmin a CUDA graph (50 calls per graph, weights rotated over 8 copies, median of 7 replays). The sweep covers every M from 1 to 160 plus 85 points from 513 to 16384 for all seven shapes, 1715 points per arm, with the default and candidate tables in separate processes, alternating. A row is kept only if it is at least 3% faster at its own M and no measured M that resolves to it is slower than 0.98×. After each drop the sweep is re-run with the reduced table until no row changes. Rows removed this way include:On main
f60ee45ddthis took three passes (53 → 50 rows, 2 runs per arm). The final check is on this PR's base8f1d6bd1, which includes the FlyDSL hgemm kernarg preload from #6427, with 3 runs per arm. It dropped (10240, 2816) M=16384, which is only 1.02× at its own M; the earlier 2-run check had kept it because one run was slow in both arms. A second pass with the 49 rows changed nothing.Performance (if applicable)
tgemm.mm(N, K) = (2816, 2112), M=1, CUDA graphtgemm.mm(N, K) = (2816, 8192), M=32, CUDA graphDetails below are on MI355X, gfx950, ROCm 10.0.
Kernel latency
tgemm.mmin a CUDA graph, main8f1d6bd1/ this PR in µs, median of 3 runs ("default" means no row serves that M):The lowest worst point over the served range is 1.017× ((2816, 2112) M=128, over M=65–128); every other row is at least 1.035× at its worst point.
First-call cost
FlyDSL does not compile per M: a new M on a row that has already run costs 0.12–0.24 ms in a fresh process, the same as a repeated call (one of 30 such calls took 1.6 ms). Each FlyDSL kernel pays a one-time cost on its first use in a process: 14–15 ms when it is loaded from a FlyDSL cache on local disk (18–37 ms from a cache on NFS), and 0.27–0.42 s when it is compiled into an empty cache. The first FlyDSL call in a process also loads the whole cache index (
load_allin FlyDSL 0.4.1's cache manager): 0.78–0.79 s with a 5030-entry cache on local disk, and 13.5–15.4 s with the same cache on NFS, mostly file locks and opens. That cost depends on the cache size and the file system, not on this table, which adds 49 entries. The wheel build pre-compiles the FlyDSL kernels of the tuned tables (run_aotinsetup.py), and in SGLang most of these rows are first used during warm-up and CUDA graph capture. Outside CUDA graphs the FlyDSL path has more host-side launch work thanF.linear: onf60ee45dda plain Python loop oftgemm.mmtook about 35 µs per call against about 16.5 µs for the default. Decode runs in CUDA graphs, and TTFT below is unchanged.End to end
End to end in SGLang
1ad0149814(lmsysorg/sglang-rocm:v0.5.23-rocm10-mi35x-20261101), TP1,SGLANG_USE_AITER=1, with aiter replaced by this PR or its base (8f1d6bd1) and FlyDSL 0.4.1 as pinned by aiter. The PR server loads the table the way an installed build does, merged frommodel_configs/with noAITER_CONFIG_GEMM_BF16. Server flags are--kv-cache-dtype fp8_e4m3 --moe-runner-backend triton --context-length 11264 --mem-fraction-static 0.85 --swa-full-tokens-ratio 0.15 --disable-radix-cache. Load issglang.benchmark.servingwith random-ids, 8192 in / 1024 out, a different seed per run. A fresh server per block, in the order main, PR, main, PR; each block discards a 32-prompt warm-up and measures 2 runs per concurrency (48 / 96 / 128 prompts at concurrency 8 / 32 / 64). Medians over 4 runs per arm:At concurrency 8 and 32 the throughput ranges of the two arms do not overlap. At concurrency 8 the first
mainrun (887.9 tok/s) is lower than the other three (940.9–961.6); against those three the gain is +3.1%. At concurrency 64 they overlap because the second block pair ran about 4% faster than the first in both arms; within each pair the PR is faster, +2.7% (2446.0 / 2466.1 → 2516.8 / 2527.7) and +2.4% (2576.2 / 2546.1 → 2623.7 / 2624.0). TPOT moves with throughput and TTFT does not: per-request TTFT has a standard deviation of about 400 ms at concurrency 8 and 1400–2900 ms at 32–64, because a request either starts prefill at once or waits behind others, so the table reports mean and p90 instead of the median. WithAITER_LOG_TUNED_CONFIG=1the PR server logs 486–505 hits on these rows per block and no errors.Accuracy
GSM8K over all 1319 questions on the same servers:
sglang.test.few_shot_gsm8k(completion prompt)The chat run uses the first 5 train problems as shots, temperature 0 and max 512 tokens; strict match is the number after
####. The completion-prompt script scores low on this instruction-tuned model in both arms, so it is only an A/B check.Testing
This PR adds config rows only, so no test is added. The rows are keyed to gfx950 with
cu_num256 and are not selected on MI250X or MI300X. On MI355X (gfx950), rebased on main 8f1d6bd, with the two files inmodel_configs/:op_tests/tuning_tests/test_config_shape_collision.py(31 passed) andtest_csv_validation.py(19 passed).bf16_tuned_gemm.csvplus 28model_configs/*bf16_tuned_gemm*.csvfiles) resolves all 49 keys to their own FlyDSL rows throughget_GEMM_A16W16_tuned_config.python3 csrc/gemm_a16w16/gemm_a16w16_tune.py --run_config aiter/configs/model_configs/gemma4_26b_a4b_bf16_tuned_gemm.csv: every row runs, no errors.Documentation
This PR adds tuned config files that the existing config merge picks up; no API, option or documented behavior changes.
Dependencies
Breaking Changes
None.
PR Self-Review
Reviewed revision
e3f8a3f
Behavior and intent
get_GEMM_A16W16_tuned_confignow returns a FlyDSL row for the seven dense BF16 GEMM shapes of Gemma-4-26B-A4B on gfx950 with 256 CUs, at the 49 listed M and at every M that pads onto them. Before, these shapes had no row on any architecture, sotgemm.mmalways ran the torch default (F.linear), which is slower at every M these rows serve.Validation and unverified scope
Validated on MI355X (gfx950, 256 CU, ROCm 10.0), FlyDSL 0.4.1, on this PR's head and its base 8f1d6bd: the tuning tests, lookup and
--run_configchecks in Testing; a CUDA-graph sweep oftgemm.mmover 1715 M points per arm, 3 runs per arm, with every row at least 1.017× faster than the default at every M it serves; and SGLang1ad0149814end to end at TP1 (+2.8–4.0% output throughput at concurrency 8–64, TTFT within noise) with GSM8K unchanged. The eager-loop host overhead was measured on f60ee45. Main has moved since by #7390, which is gfx1250 MLA only and does not touch the BF16 GEMM path.Unverified: TP > 1 (the shapes change with the head split), the vision-tower shapes, MI350X (also gfx950 with 256 CUs, so it selects these rows; not measured), other GPUs and CU counts (they have no rows and keep the default), and frameworks other than SGLang.
PR-specific question
The workload keys are
(gfx950, cu_num 256, M, N, K, bias False, bf16, bf16, scaleAB False, bpreshuffle False)for (N, K) = (8192, 2816), (10240, 2816), (2816, 4096), (2816, 8192), (4224, 2816), (2816, 2112) and (128, 2816), at the M listed in Changes. Lookup matches(N, K)exactly and pads only M, so no other shape can resolve to these rows. No table on main, for any architecture, has a row for these seven (N, K) (checked acrossbf16_tuned_gemm.csvand 28model_configs/files), so no M of these shapes changes from another tuned row to one of these: every M that changes moves from the torch default to a row here. The sweep in Performance covers those M on both sides, and the merged tables have no duplicate keys.Changed op tests
None.
Powered by Hyperloom, with human review, writing and testing.