Skip to content

[Config] [Tune] Add GLM-5.3-Flash a8w8 blockscale GEMM configs for gfx942 - #5343

Merged
valarLip merged 1 commit into
ROCm:mainfrom
jin-amd:glm5.3-flash-a8w8-blockscale-tuned-gemm
Sep 9, 2026
Merged

valarLip merged 1 commit into
ROCm:mainfrom
jin-amd:glm5.3-flash-a8w8-blockscale-tuned-gemm

Conversation

@jin-amd

@jin-amd jin-amd commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

What

Tuned a8w8_blockscale GEMM configs for the shapes GLM-5.3-Flash dispatches, on gfx942 / cu_num 304.

  • model_configs/a8w8_blockscale_tuned_gemm_glm5_3_flash.csv — 837 tuned rows, 94 M values from 16 to 16384
  • model_configs/a8w8_blockscale_untuned_gemm_glm5_3_flash.csv — the 842-shape tuner input

Why

None of the ten (N, K) pairs this model dispatches had a gfx942 entry in any existing a8w8_blockscale table, so all of them fell back to the default kernel. Three had gfx950-only rows; the other seven were absent from every table.

N K gfx942 rows before this PR
512, 1024, 2048, 3072, 6144, 12288 4096 0
4096 256, 1536, 3072, 6144 0

Where the shapes come from

Scraped from the not found tuned config lines of live vLLM serving runs at TP2, TP4 and TP8, which log 6569 distinct (M, N, K) between them. The three configurations dispatch mutually exclusive (N, K) sets -- each pair is the same unsharded weight divided by the TP degree -- and all ten are covered here:

Source logged shapes distinct (N,K) pairs
TP2 2001 3 (2048,4096), (4096,6144), (12288,4096)
TP4 1944 3 (1024,4096), (4096,3072), (6144,4096)
TP8 2624 4 (512,4096), (3072,4096), (4096,256), (4096,1536)

837 rows suffice for 6569 shapes because get_CKGEMM_config() retries the lookup at M, then gl0(M), then gl1(M), so tuning the gl0 ladder resolves every original M. Verified by replaying all 6569 logged shapes through that ladder against this CSV: 6569/6569 resolve, 0 fall through.

Gain over the default kernel

Time-weighted speedup across the tuned shapes is 2.61x (197.3 ms -> 75.6 ms summed over the 837 measurements). Median per-shape is 2.13x. The gain grows with M, so it matters most for prefill and large batched decode:

M range shapes median speedup share of total time saved
0–128 67 1.23x 0.2%
128–512 159 1.49x 2.0%
512–2048 268 2.12x 17.7%
2048–8192 293 2.69x 50.8%
8192+ 50 2.96x 29.3%

Both sides of that comparison come from the same harness — the production-operator benchmark, default kernels versus this CSV.

Validation

vLLM serving GLM-5.3-Flash at TP4 on 4x MI325X, with AITER_LOG_TUNED_CONFIG=1:

  • 11792 dispatched a8w8_blockscale shapes, 0 fell back to the default kernel
  • gsm8k 5-shot flexible-extract 0.9727 ± 0.0045, against 0.9750 ± 0.0043 on the default kernels — within one standard error, so the tuned kernels are not trading accuracy for speed

End-to-end serving throughput moved about +1% on a 131k-token-input, 1k-output workload at concurrency 2–8. That workload is prefill-dominated long-context, where these GEMMs are only ~1.4–2.0% of wall time; the kernel-level 2.61x is the number that generalizes, and workloads with a larger GEMM share will see more of it.

Merge safety

Keys are disjoint from the default table and all ten existing a8w8_blockscale_tuned_gemm* tables — 39,967 unique keys across the merged set with 0 duplicates — so get_config_file() merges this file without hitting the duplicate-shape RuntimeError in update_config_files().

Scope and caveats

  • gfx942 / cu_num 304 only; no gfx950 rows.
  • Five of the 842 shapes in the tuner input carry no tuned row on purpose. Tuning ran with --compare --update_improved, and for those five the compare gate measured the default kernel as equal or faster (−2.3% to +0.5%), so falling back is the better choice. They are (736, 512, 4096), (80, 4096, 256), (96, 4096, 256), (144, 4096, 3072) and (96, 4096, 6144).

…x942

Tune the a8w8 blockscale GEMM shapes GLM-5.3-Flash dispatches, on gfx942 /
cu_num 304. None of the ten (N, K) pairs had a gfx942 entry in any existing
a8w8_blockscale table, so all of them fell back to the default kernel; three
had gfx950-only rows and the other seven were absent entirely.

837 tuned rows over 94 M values from 16 to 16384:

    N=512,1024,2048,3072,6144,12288   K=4096
    N=4096                            K=256,1536,3072,6144

The shape inventory is scraped from the "not found tuned config" lines of
live vLLM serving runs at TP2, TP4 and TP8, which log 6569 distinct
(M, N, K) between them. The three configurations dispatch mutually
exclusive (N, K) sets, each pair being the same unsharded weight divided by
the TP degree -- 3 pairs from TP2, 3 from TP4, 4 from TP8 -- and all ten
are covered here. 837 rows suffice for 6569 shapes because
get_CKGEMM_config() retries the lookup at M, gl0(M) and gl1(M), so tuning
the gl0 ladder resolves every original M; verified by replaying all 6569
through the ladder against this CSV.

Time-weighted speedup over the default kernel across these shapes is 2.61x
(197.3 ms -> 75.6 ms summed over the 837 measurements); median per-shape is
2.13x. The gain grows with M -- 1.49x median for M in [128, 512), 2.69x for
[2048, 8192), 2.96x above 8192 -- so it matters most for prefill and large
batched decode.

Verified with vLLM serving GLM-5.3-Flash at TP4 on 4x MI325X: of 11792
dispatched a8w8_blockscale shapes, 0 fell back to the default kernel, and
gsm8k 5-shot flexible-extract scored 0.9727 +/- 0.0045 against
0.9750 +/- 0.0043 on the default kernels, within one standard error.

Five of the 842 shapes in the tuner input carry no tuned row on purpose: the
compare gate measured the default kernel as equal or faster there, so
letting them fall back is the better choice.

Keys are disjoint from every existing a8w8_blockscale_tuned_gemm table, so
get_config_file() merges this file with no duplicate-shape conflict.

Co-authored-by: Cursor <[email protected]>
@jin-amd
jin-amd requested review from a team and a lite review from Copilot September 8, 2026 14:04
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs; main branch always runs both MI35X and MI300X
multigpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 5343 --add-label <label>

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to opt this PR out.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is limited to adding well-formed tuned/untuned CSV config data that matches existing schema and is auto-discovered by the current config merge logic.

Pull request overview

Adds tuned a8w8_blockscale GEMM configuration coverage for GLM-5.3-Flash’s dispatched shapes on gfx942 (cu_num=304) by introducing a dedicated tuned table plus its corresponding tuner input list under model_configs/. This leverages the existing config merge behavior (AITER_CONFIG.get_config_file() merges all *a8w8_blockscale_tuned_gemm*.csv under model_configs/) so the new entries are automatically picked up at runtime without code changes.

Changes:

  • Add a new tuned config CSV for gfx942/cu_num=304 covering GLM-5.3-Flash’s relevant (M,N,K) space, leaving a small set of shapes intentionally untuned (so they continue to fall back).
  • Add the corresponding untuned (M,N,K) input CSV used to drive tuning / reproducibility of the tuned set.
File summaries
File Description
aiter/configs/model_configs/a8w8_blockscale_untuned_gemm_glm5_3_flash.csv Adds the tuner-input shape list (M,N,K) for GLM-5.3-Flash a8w8 blockscale GEMMs.
aiter/configs/model_configs/a8w8_blockscale_tuned_gemm_glm5_3_flash.csv Adds gfx942/cu_num=304 tuned kernel selections and perf metadata for GLM-5.3-Flash GEMM shapes.
Review details
  • Files reviewed: 1/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@zufayu
zufayu requested a review from yzhou103 September 9, 2026 01:24
@valarLip
valarLip merged commit 10f8874 into ROCm:main Sep 9, 2026
3 checks passed
jin-amd added a commit to jin-amd/aiter that referenced this pull request Sep 11, 2026
a8w8_blockscale_tuned_gemm_glm5_3_flash.csv landed in main via ROCm#5343
after this branch's cross-file dedup check, and it tunes the same
gfx942 / cu_num=304 / N=6144 / K=4096 shapes. 19 rows here duplicated it
on the runtime merge key (M, N, K, cu_num, gfx).

AITER_CONFIGS.get_config_file() merges every matching model CSV, and
update_config_files() rewrites the source files and raises on a
duplicate shape. Blockscale config resolution would therefore have
failed outright rather than adding the new rows.

Drop the overlapping rows here and leave the GLM-5.3-Flash table
untouched: 174 -> 155 rows. 17 of the 19 shapes had already selected the
identical kernel in both tuning runs, and the two that differ disagree
by under 2% across separate runs, so no measurable coverage is lost.
Merging all 12 *a8w8_blockscale_tuned_gemm*.csv files now yields 40,122
rows with 0 duplicate shapes.

Co-authored-by: Cursor <[email protected]>
yifehuan pushed a commit that referenced this pull request Sep 18, 2026
…X/MI325) (#5072)

* [CK] Tune a8w8 blockscale GEMM for GLM-5.2 TP4 on gfx942

GLM-5.2-FP8 served at TP4 on MI325X (gfx942, 304 CU) hits 174 a8w8
blockscale GEMM shapes that have no tuned entry, so every one of them
falls back to the default CK kernel. The shapes are N=6144 with
K in {3072, 4096, 6144}, i.e. the row-parallel projections whose K
doubles relative to TP8; the existing glm5_1 config only covers the
TP8 K values, so TP4 deployments are uncovered.

Tuned with csrc/ck_gemm_a8w8_blockscale/gemm_a8w8_blockscale_tune.py
--libtype both. All 174 shapes tuned successfully with errRatio 0.0,
and the CK legacy backend won every shape.

Isolated GEMM benchmark, tuned vs default kernels:
  decode sizes (M <= 256, 105 shapes)  median 1.62x
  prefill sizes (M > 256, 69 shapes)   median 3.22x
  all 174 shapes                       median 1.79x

End-to-end vLLM serving A/B on 4x MI325X, 131072 in / 1024 out,
identical images apart from this config: +7.9% total token throughput,
-5.8% median TPOT, -7.4% median TTFT at concurrency 2/4/6.

Co-authored-by: Cursor <[email protected]>

* Add gfx942 CK Tile blockscale instances

* Fix CK-Tile blockscale name registry for multi-arch builds

A multi-arch wheel build (GPU_ARCHS="gfx942;gfx950") keeps tuned CSV rows
for every target arch, because build_tune_dict filters with
get_build_targets(). The CK-Tile candidate registry, however, was built
from the single list selected by get_gfx(), which resolves a multi-arch
GPU_ARCHS to its last entry. Rows tuned for the other arch then had no
entry in kernels_by_name and the build aborted.

This only stayed latent because the sole pre-existing gfx942 CK-Tile
tuned row named a tile present in both lists. The gfx942 winner added
here (16x64x512) exists only in kernels_list_942.

Build candidate_kernels_by_name from every arch list. The arch-specific
candidate_kernels_cktile_dict used for tuning is unchanged, so kernel IDs
and sweep behavior stay the same.

Co-authored-by: Cursor <[email protected]>

* Restore sys.path after loading the instance module in tests

The CK-Tile instance module inserts aiter/jit/utils at sys.path[0] on
import, and patch.dict does not cover sys.path, so each load leaked a
copy that could shadow imports for later tests in the same process.

Co-authored-by: Cursor <[email protected]>

* Drop 19 GLM-5.2 rows colliding with the GLM-5.3-Flash configs

a8w8_blockscale_tuned_gemm_glm5_3_flash.csv landed in main via #5343
after this branch's cross-file dedup check, and it tunes the same
gfx942 / cu_num=304 / N=6144 / K=4096 shapes. 19 rows here duplicated it
on the runtime merge key (M, N, K, cu_num, gfx).

AITER_CONFIGS.get_config_file() merges every matching model CSV, and
update_config_files() rewrites the source files and raises on a
duplicate shape. Blockscale config resolution would therefore have
failed outright rather than adding the new rows.

Drop the overlapping rows here and leave the GLM-5.3-Flash table
untouched: 174 -> 155 rows. 17 of the 19 shapes had already selected the
identical kernel in both tuning runs, and the two that differ disagree
by under 2% across separate runs, so no measurable coverage is lost.
Merging all 12 *a8w8_blockscale_tuned_gemm*.csv files now yields 40,122
rows with 0 duplicate shapes.

Co-authored-by: Cursor <[email protected]>

---------

Co-authored-by: jin-amd <[email protected]@tus1-p15-g56.tus.tensorwave.lan>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: ThomasNing <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants