Skip to content

[Triton/Gluon] [gfx1250] gemm_a16w16: register-store epilogue option and GPT-OSS large-M / TP2 configs - #7288

Closed
akao-amd wants to merge 11 commits into
ROCm:mainfrom
akao-amd:pr-gfx1250-gemm-a16w16-large-m-regstore
Closed

akao-amd wants to merge 11 commits into
ROCm:mainfrom
akao-amd:pr-gfx1250-gemm-a16w16-large-m-regstore

Conversation

@akao-amd

@akao-amd akao-amd commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Two changes for the gfx1250 Gluon gemm_a16w16 as GPT-OSS-120B prefill uses it (QKV N5120 K2880, O N2880 K4096, router N128 K2880; TP2: QKV N2560 K2880, O N2880 K2048):

  1. REGISTER_STORE on the compute_bound kernel. A config entry picks the epilogue: 0 = today's LDS-staged tensor_store_from_lds (default; an entry without the key is unchanged), 1 = buffer stores straight from the WMMA layout, 2 = convert_layout to 16-byte vectors along N, then buffer stores. A value outside {0, 1, 2} is rejected on the host (ValueError) and in the kernel (static_assert). AITER_GFX1250_A16W16_STORE overrides every non-persistent compute_bound launch; it is unset in serving.
  2. Configs for the prefill bands and for TP2. M_BOUNDS extends to 32768 on the three TP1 files, with compute_bound entries at REGISTER_STORE 2 for the bands that were falling through to any or to DEFAULT. Band-start entries use a smaller tile where 256×256 left most of a tile empty. Two new TP2 files (DEFAULT_FALLBACK) cover shapes that had no file.

Decode buckets (M ≤ 128 on TP1 QKV/O, and the LM head) are #7289, stacked on this branch.

Motivation

Prefill chunks of 16,384 tokens sit above the files' last bucket (8192). The loader then takes any. On the AITER pin SGLang ships for gfx1250 (26f4f1fb2) that entry is bandwidth_bound 128×128×64: in a gpt-oss-120b trace, QKV is 3,274 µs and O is 2,631 µs per layer per 16k chunk, 0.15 PFLOP/s against 0.64 at 7.5k tokens. Counting Prefill batch lines in a base1028 TP1 server log, M > 8192 is 94% of prefill batches at 70k/300 c4 and 11.9% of batches (20.2% of tokens) at 8k/1k c64 with mixed chunk. #6921 (merged 10-28) already moved any on main to compute_bound 256×128×64. This PR adds explicit buckets through 32768 that are faster than that any, and the TP2 files. TP2 had no shape file, so every M ran DEFAULT.json's bandwidth_bound tiles (about 5× slower at M ≥ 6000).

The new entries store from registers. On gfx1250 an LDS-staged tensor_store_from_lds can ship stale LDS (the same epilogue as #7202 / #7203). That race was not observed on this GEMM. The new entries still use the coalesced register store so they do not add another LDS → TDM store. At the shipped 256×256 tile, mode 2 is about 1.3% slower than mode 0 (time ratio 1.012–1.014, QKV and O, M 8192 and 16384, hot weights). Mode 1 is about 11–18% slower there (1.11–1.18×). An ablation on the existing small-M tiles, which this PR does not retune, measured mode 2 faster on some of those old entries: 24% faster for O at M 64 and 12% faster for QKV at M 16, and 0–5% slower for M 256–8192. This PR does not rely on that ablation.

Config keys

Lookup is the shape file GEMM-A16W16-N={N}-K={K}.json, then the first M_LEQ_* whose bound is ≥ M. M above every bound uses any. A missing file uses DEFAULT.json. DEFAULT_FALLBACK: true uses the file's own key when it has one and DEFAULT otherwise.

Every new or retuned entry below is compute_bound, 4 buffers, REGISTER_STORE 2, BLOCK_K 64 except the one partial-K tile noted.

File Keys this PR selects Tile (BLOCK_M×N×K), warps
N=5120,K=2880 (TP1 QKV) M_LEQ_4096, M_LEQ_8192, M_LEQ_16384, M_LEQ_32768 256×256×64, 8 (waves_per_eu 1). Covers M 2049–32768
N=2880,K=4096 (TP1 O) M_LEQ_3072 128×128×64, 4. Covers M 2049–3072
same M_LEQ_4096, M_LEQ_8192, M_LEQ_16384, M_LEQ_32768 256×256×64, 8. Covers M 3073–32768
N=128,K=2880 (router) M_LEQ_8192, M_LEQ_16384, M_LEQ_32768 128×128×64, 4 (waves_per_eu 0). Covers M 4097–32768
N=2560,K=2880 (TP2 QKV, new, DEFAULT_FALLBACK) M_LEQ_256 128×64×64, 4. M 129–256
same M_LEQ_512 128×128×128, 4. M 257–512. BLOCK_K 128 does not divide K 2880; the kernel peels the last K tile. Checked at M 257 and 512, with and without bias
same M_LEQ_1024, M_LEQ_1536 128×128×64, 4. M 513–1536
same M_LEQ_2048 through M_LEQ_32768 256×256×64, 8. M 1537–32768
N=2880,K=2048 (TP2 O, new, DEFAULT_FALLBACK) M_LEQ_256 / M_LEQ_512 / M_LEQ_1024 128×64×64 / 128×128×128 / 128×128×64, 4 warps
same M_LEQ_2048 256×256×64, 8. M 1025–2048
same M_LEQ_3072 128×128×64, 4. M 2049–3072
same M_LEQ_4096 through M_LEQ_32768 256×256×64, 8. M 3073–32768

Keys left byte-for-byte on the previous entry:

M_BOUNDS gained 1536 (TP2 QKV), 3072 (both O files), 16384 and 32768. A 256×256 tile placed on the first M past 2048 was slower than the old schedule (O M 2049 +16%, TP2 QKV M 1025 +9%, TP2 O M 2049 +5% and M 257 +3%). The smaller tiles in the table are the per-band picks that removed those regressions.

Performance (gfx1250, MI45x DPX partition, 96 CUs)

Kernel times are hot weights (one weight tensor, CUDA graph of 5 calls replayed 10×, median). Prefill at these M is compute-bound. End-to-end numbers are the controlled serving bracket below.

Kernel, M 16,384 (µs per call): the pin's any / main's any (#6921) / this PR

GEMM pin any main any (#6921) this PR
QKV N5120 K2880 3,243 722 617
O N2880 K4096 2,608 595 502
router N128 K2880 104 – 26

Dense file A-B-A over the changed bands (B / average of the two A arms; no changed point above 1.011): M 7,500 QKV 340 → 302 µs (0.887), O 288 → 246 (0.853); M 16,384 QKV 0.189, O 0.191, router 0.269 of the old file. TP2 at M 7,500: QKV 843 → 167 (0.202), O 719 → 132 (0.187). Unchanged buckets stay near 1.00 (router M ≤ 4096 up to 1.011, TP2 M 128 at 1.003 / 1.009). Router M 4097, the first changed router bucket, measured 1.009 and was kept.

End to end (gpt-oss-120b W4A8, SGLang, InferenceX fixed-seq run 1, adjacent A-B-A, box otherwise idle). A = recipe AITER 9d55e4f1b (the gfx1250 pin lineage), B = A plus these four commits. Output tok/s, B / average(A, A2):

Point TP1 TP2
1024/1024 c64 1.008 1.011
8192/1024 c64 1.067 1.183
70000/300 c4 1.302 1.265

Mean TTFT at 70k c4: TP1 3,884 → 2,936 ms, TP2 2,566 → 1,856 ms. GSM8K strict (1319, thinking, after load): TP1 0.9598 / 0.9598 / 0.9591 (A/B/A), TP2 0.9606 / 0.9560 / 0.9629.

Test

Hardware: one gfx1250 DPX/NPS2 partition, 96 CUs, image rocm/sgl-dev:v0.5.23-rocm101-mi45x-20261031, ROCm 10.1.0, Triton b509148826 (carries the s_wait_dscnt-before-barrier fix, llvm-project#220357). AITER_GFX1250_A16W16_STORE unset. bf16 out, row-major x/w, SGLang's TN layout. Bias on, plus a no-bias run for TP2 O (rank 1 passes no bias).

  • check_p1_correctness.py: 65 cases, both sides of every changed bound (2048/2049, 3072/3073, 4096/4097, 8192/8193, 16384/16385, 32768, plus 8193/9000/16500 and the TP2 bounds 128/129, 256/257, 512/513, 1024/1025, 1536/1537). Reference is fp32 x·wᵀ + b. Pass rule, stated before the run: y_new finite, max|y_new−ref| ≤ 2·max|y_old−ref| + 1e-6·max|ref|, and max|y_new−y_old| ≤ 2⁻⁶·max|ref|. 65/65 pass, y_new == y_old bitwise. The same entry with REGISTER_STORE 0 matches mode 2 bitwise (60/60 mode-2 cases). CUDA graph of 20 calls × 100 replays: 0 mismatches in 2,000 calls per case.
  • check_p1_correctness.py --no-bias --shapes=o_tp2: 17 cases. Bitwise equal to the old schedule, mode 0 matches mode 2, 0 mismatches in 2,000 replays each. O's N 2880 with BLOCK_N 256 leaves a 64-column tail; that tail is in every O case.
  • Barrier scan (scan_barrier_dscnt.py via b4_scan_named.py) on the compiled binaries: 0 flagged for the shipped tiles (36 in the final check cache, including the no-bias TP2 O tiles), for the microbench caches, and for the arm-B server caches (105 TP1, 96 TP2).
  • Serving bracket above. Arm B's TP2 server compiled REGISTER_STORE_2 256×256 and 128×128 tiles; DEFAULT.json has no mode-2 entry, so those launches came from the new files.

The four commits were validated on that recipe tree and applied onto main (0dd271600, 3-way, clean). main's any from #6921 is what M > 32768 still runs. Not run: AITER's op tests on gfx1250, shapes other than these five, the persistent kernel.

MI355X (gfx950), 2026-11-05, image rocm/sgl-dev:v0.5.23-rocm10-mi35x-20261102, ROCm 10.0.0. Whole op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py at this head (b91728f64c2a): 377 passed, 0 failed, 752 skipped. The 5 test_gemm_a16w16_gfx1250_gptoss_96cu_lookup cases pass and are not skipped. At the previous head 13d9dcc310b8 those 5 fail: configs/gfx950/gluon/gemm/gemm_a16w16/DEFAULT.json does not exist. main c1096fa40a90 on the same box: 372 passed, 0 failed (that test is not on main).

PR Self-Review

Reviewed revision

b91728f64c2acbef537acc68ca5d8876c16d6cfb

Behavior and intent

gfx1250 Gluon gemm_a16w16 compute_bound can store its output from registers, chosen per config entry by REGISTER_STORE. Existing entries omit the key and keep the LDS-staged TDM store, including any.

The GPT-OSS prefill shapes get buckets through M 32768, and TP2 gets shape files. Without them, M > 8192 on TP1 falls through to any, and every TP2 M falls through to DEFAULT.json. Those paths are several times slower at a 16k chunk than the entries in the table above. The new entries use mode 2 so those buckets do not add an LDS-staged TDM store. The same-tile measurement above does not show mode 2 faster than mode 0.

Validation and unverified scope

Validated on one gfx1250 DPX partition (96 CUs), image rocm/sgl-dev:v0.5.23-rocm101-mi45x-20261031, ROCm 10.1.0, Triton b509148826, AITER_GFX1250_A16W16_STORE unset.

  • Numerics: check_p1_correctness.py (65 cases, with bias) and the same script --no-bias --shapes=o_tp2 (17 cases). Old schedule read from the parent tree with git show. All cases bitwise equal to the old schedule under the tolerance above; 0 graph-replay mismatches in 2,000 calls per case; mode 2 bitwise-equal to mode 0 on the same tile.
  • Performance: run_bench.sh / file_aba.sh, hot weights. Dense A-B-A from M 2048 to 32768 (TP1) and M 128 to 32768 (TP2): new/old 0.17–1.011. Kernel M 16384: QKV 617 µs, O 502 µs, router 26 µs, against main's any at 722 / 595 µs for QKV / O.
  • Serving: one oaka plan, AITER reinstalled per arm, InferenceX fixed-seq run 1, GPUs otherwise idle. gpt-oss-120b W4A8 throughput B/avg(A): TP1 1.008 / 1.067 / 1.302 and TP2 1.011 / 1.183 / 1.265 at 1k c64 / 8k c64 / 70k c4. GSM8K strict 0.9553–0.9629 across arms.
  • Barrier scan of the shipped tiles and of the arm-B server caches: 0 flagged.

Not run on a checkout of AITER main itself (the same four commits apply cleanly onto 0dd271600). Not run: AITER op tests on gfx1250, other models' (N, K), the persistent kernel. M > 32768 still uses any's TDM store.

PR-specific question

The keys that consume the new selection are listed in the table under Config keys. Evidence that everything else keeps its previous selection:

  • The loader keys only on the exact (N, K) filename and then on M_LEQ_* / any. No other shape file is in the diff.
  • Inside the three edited TP1 files, M_LEQ_1…M_LEQ_2048 (QKV and O), M_LEQ_1…M_LEQ_4096 (router), and any are unchanged. Dense A-B-A at those bounds stays near 1.00, up to 1.011 on unchanged router buckets (M 3072–4096).
  • The two new files set DEFAULT_FALLBACK and their first key is M_LEQ_256, so M ≤ 128 stays on DEFAULT.json. A-B-A at TP2 M 128 is 1.003 (QKV) and 1.009 (O).
  • REGISTER_STORE is read only for a compute_bound entry that sets it, or when AITER_GFX1250_A16W16_STORE is set. That variable was unset for every measurement and in the serving bracket. Entries without the key still compile the mode-0 epilogue.

Changed op tests

op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py

  • test_gemm_a16w16_gfx1250_register_store and test_gemm_a16w16_gfx1250_store_env_override launch the Gluon kernel for store modes 0, 1 and 2, and reject an invalid mode. They skip unless Gluon is supported on the device.
  • test_gemm_a16w16_gfx1250_gptoss_96cu_lookup only reads JSON. It pins get_arch() to gfx1250 and passes cu_num=96, so an MI35X runner checks configs/gfx1250/96cu instead of a gfx950 Gluon default that is not in the tree. For the five gpt-oss (N, K) shapes at M 4096, 8192, 16384 and 32768 it requires a tuned compute_bound entry. The loader cache is cleared because its key does not include the arch. On an MI355X (gfx950) those 5 cases pass at this head and fail at 13d9dcc310b8.
  • test_gemm_a16w16_gfx1250_gptoss_tuned checks those shapes numerically and skips off a Gluon arch.

🤖 Generated with Claude Code

akao-amd and others added 4 commits November 1, 2026 23:08
…osen per config entry (REGISTER_STORE)

The compute_bound kernel ended with the gfx1250 B1 pattern: the tile is staged in LDS
(ds_store), a workgroup barrier, then tensor_store_from_lds, whose LDS read can miss
the waves' ds_stores on gfx1250 (no documented wait or fence closes it; B1a-B1c).
A config entry may now pick the epilogue with "REGISTER_STORE":
  0 the LDS-staged TDM store (default: every existing entry is unchanged),
  1 buffer stores straight from the WMMA layout (as the bandwidth_bound kernel),
  2 coalesced register store: convert_layout to a blocked layout of 16-byte
    vectors along N (an ordinary ds_store/barrier/ds_load round trip), then
    buffer stores rebased to the block in int64.
AITER_GFX1250_A16W16_STORE=<0|1|2> overrides every entry (A/B only).

Cost vs the TDM store at gpt-oss's existing entries (gfx1250 DPX partition, bf16,
bias): mode 2 +0..5 % at M 256-8192, -24 % at O M=64 (30.1 -> 22.9 us), -12 % at QKV
M=16; mode 1 +3..16 % at M >= 256.

Plan: perf1101 P1 (B1 prerequisite of the large-M a16w16 dispatch)

Co-Authored-By: Claude <[email protected]>
…), retuned 4096/8192, TP2 shape files

gpt-oss's QKV (N5120 K2880), O (N2880 K4096) and router (N128 K2880) files stopped at
M_LEQ_8192 and the loader searched only the standard bounds, so every prefill batch
above 8192 tokens (chunk 16384: 94 % of 70k/300 prefill batches, 12 % at 8k/1k c64
with mixed chunk) ran the 'any' entry, bandwidth_bound 128x128x64. The TP2 shapes
(QKV N2560 K2880, O N2880 K2048) had no file at all and ran DEFAULT.json at every M.

- QKV and O: M_BOUNDS up to 32768; M_LEQ_4096/8192/16384/32768 = compute_bound
  256x256x64, 4 buffers, 8 warps, waves_per_eu 1, coalesced register store
  (REGISTER_STORE 2: no new LDS-staged TDM store epilogue). Best of 126 candidates
  at M 16384 (BLOCK_K dividing K), and faster than the old 4096/8192 entries.
- Router: M_BOUNDS to 32768; M_LEQ_8192/16384/32768 = compute_bound 128x128x64,
  4 buffers, 4 warps, register store.
- TP2 QKV and O: new files with DEFAULT_FALLBACK (DEFAULT.json keeps M <= 128):
  M_LEQ_256..1024 = compute_bound 128x128x64, 2048..32768 = 256x256x64, register store.

Kernel time, old file -> new (us, bf16 + bias, one gfx1250 DPX partition, A-B-A):
  QKV  M 7500 340 -> 302, 8192 365 -> 307, 16384 3278 -> 618, 32768 6567 -> 1230
  O    M 7500 288 -> 246, 8192 293 -> 249, 16384 2643 -> 503, 32768 5252 -> 1020
  router M 8192 26.7 -> 18.9, 16384 101.5 -> 26.9
  TP2 QKV M 1024 51.5 -> 26.4, 7500 843 -> 167, 16384 1684 -> 308
  TP2 O   M 1024 43.9 -> 21.0, 7500 719 -> 132, 16384 1453 -> 267
Other buckets unchanged. fp32-reference max rel err 0.003 (same as before); CUDA-graph
replay bitwise equal over 6000 calls per shape at M 8192/9000/16384/16385.

Plan: perf1101 P1 (large-M a16w16 dispatch; router separately; TP2 files added)

Co-Authored-By: Claude <[email protected]>
…e, validate the store mode

Review follow-up (perf1101 P1, codex round 1, findings 3-4): REGISTER_STORE outside
{0, 1, 2} is rejected (ValueError on the host, static_assert in the kernel) instead of
falling to the TDM store; the two register-store modes share one store helper; the
store layout helper drops its unused BLOCK_M; the comment states the override's scope
(non-persistent gluon compute_bound launches; unset in serving).
Same kernels, same outputs: P1's correctness check passes unchanged (55 shape/M
cases, old vs new bitwise equal, 2,000 replayed calls each); mode-2 store cost at the
shipped 256x256 tile 1.012-1.014 of the TDM store.

Plan: perf1101 P1 (review round 1)

Co-Authored-By: Claude <[email protected]>
… 2049-3072, TP2 129-1536, 2049-3072)

Review follow-up (perf1101 P1, codex round 1, finding 2): a dense A-B-A over every
changed band showed four band starts slower than the old schedule (O M 2049 +16 %,
TP2 QKV M 1025 +9 %, TP2 O M 2049 +5 %, M 257 +3 %): 256x256 tiles just past a
bound leave most of a tile empty. Per-band sweep of eight register-store tiles:
  O (TP1): new bound 3072, M_LEQ_3072 = 128x128x64 (2049-3072: 0.91-0.95 of old).
  TP2 QKV: new bound 1536; M_LEQ_256 = 128x64x64, M_LEQ_512 = 128x128x128,
           M_LEQ_1024/1536 = 128x128x64, M_LEQ_2048 = 256x256x64.
  TP2 O:   new bound 3072; M_LEQ_256 = 128x64x64, M_LEQ_512 = 128x128x128,
           M_LEQ_1024 = 128x128x64, M_LEQ_2048 = 256x256x64, M_LEQ_3072 = 128x128x64.
All compute_bound, 4 buffers, 4 warps (256x256: 8 warps), coalesced register store.
Dense A-B-A (TP1 20 M from 2048 to 32768, TP2 28 M from 128 to 32768): new/old
0.17-1.01 everywhere, no point above 1.02. Old vs new outputs bitwise equal at every
band boundary (65 cases, same K order); 2,000 replayed calls each, 0 mismatches.

Plan: perf1101 P1 (review round 1)

Co-Authored-By: Claude <[email protected]>
@akao-amd
akao-amd requested a review from a team November 2, 2026 03:01
@github-actions

github-actions Bot commented Nov 2, 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 (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the gfx1201 ROCm runner
ci:multi-gpu 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: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
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 7288 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

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 stop the title rewrites; labels stay in sync either way.

@aiter-bot

aiter-bot commented Nov 2, 2026 •

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision b91728f64c2a · mode shadow

Author self-review accepted. Readiness report:

Author answers

  • PASS — current-SHA answers are present and structurally specific
Show the author's self-review answers

Behavior and intent

gfx1250 Gluon `gemm_a16w16` compute_bound can store its output from registers, chosen per config entry by `REGISTER_STORE`. Existing entries omit the key and keep the LDS-staged TDM store, including `any`.

The GPT-OSS prefill shapes get buckets through M 32768, and TP2 gets shape files. Without them, M > 8192 on TP1 falls through to `any`, and every TP2 M falls through to `DEFAULT.json`. Those paths are several times slower at a 16k chunk than the entries in the table above. The new entries use mode 2 so those buckets do not add an LDS-staged TDM store. The same-tile measurement above does not show mode 2 faster than mode 0.

Validation and unverified scope

Validated on one gfx1250 DPX partition (96 CUs), image `rocm/sgl-dev:v0.5.23-rocm101-mi45x-20261031`, ROCm 10.1.0, Triton `b509148826`, `AITER_GFX1250_A16W16_STORE` unset.

- Numerics: `check_p1_correctness.py` (65 cases, with bias) and the same script `--no-bias --shapes=o_tp2` (17 cases). Old schedule read from the parent tree with `git show`. All cases bitwise equal to the old schedule under the tolerance above; 0 graph-replay mismatches in 2,000 calls per case; mode 2 bitwise-equal to mode 0 on the same tile.
- Performance: `run_bench.sh` / `file_aba.sh`, hot weights. Dense A-B-A from M 2048 to 32768 (TP1) and M 128 to 32768 (TP2): new/old 0.17–1.011. Kernel M 16384: QKV 617 µs, O 502 µs, router 26 µs, against main's `any` at 722 / 595 µs for QKV / O.
- Serving: one oaka plan, AITER reinstalled per arm, InferenceX fixed-seq run 1, GPUs otherwise idle. gpt-oss-120b W4A8 throughput B/avg(A): TP1 1.008 / 1.067 / 1.302 and TP2 1.011 / 1.183 / 1.265 at 1k c64 / 8k c64 / 70k c4. GSM8K strict 0.9553–0.9629 across arms.
- Barrier scan of the shipped tiles and of the arm-B server caches: 0 flagged.

Not run on a checkout of AITER main itself (the same four commits apply cleanly onto `0dd271600`). Not run: AITER op tests on gfx1250, other models' `(N, K)`, the persistent kernel. M > 32768 still uses `any`'s TDM store.

PR-specific question

The keys that consume the new selection are listed in the table under Config keys. Evidence that everything else keeps its previous selection:

- The loader keys only on the exact `(N, K)` filename and then on `M_LEQ_*` / `any`. No other shape file is in the diff.
- Inside the three edited TP1 files, `M_LEQ_1`…`M_LEQ_2048` (QKV and O), `M_LEQ_1`…`M_LEQ_4096` (router), and `any` are unchanged. Dense A-B-A at those bounds stays near 1.00, up to 1.011 on unchanged router buckets (M 3072–4096).
- The two new files set `DEFAULT_FALLBACK` and their first key is `M_LEQ_256`, so M ≤ 128 stays on `DEFAULT.json`. A-B-A at TP2 M 128 is 1.003 (QKV) and 1.009 (O).
- `REGISTER_STORE` is read only for a compute_bound entry that sets it, or when `AITER_GFX1250_A16W16_STORE` is set. That variable was unset for every measurement and in the serving bracket. Entries without the key still compile the mode-0 epilogue.

Changed op tests

`op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py`

- `test_gemm_a16w16_gfx1250_register_store` and `test_gemm_a16w16_gfx1250_store_env_override` launch the Gluon kernel for store modes 0, 1 and 2, and reject an invalid mode. They skip unless Gluon is supported on the device.
- `test_gemm_a16w16_gfx1250_gptoss_96cu_lookup` only reads JSON. It pins `get_arch()` to gfx1250 and passes `cu_num=96`, so an MI35X runner checks `configs/gfx1250/96cu` instead of a gfx950 Gluon default that is not in the tree. For the five gpt-oss `(N, K)` shapes at M 4096, 8192, 16384 and 32768 it requires a tuned `compute_bound` entry. The loader cache is cleared because its key does not include the arch. On an MI355X (gfx950) those 5 cases pass at this head and fail at `13d9dcc310b8`.
- `test_gemm_a16w16_gfx1250_gptoss_tuned` checks those shapes numerically and skips off a Gluon arch.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply
  • ADVISORY — Copilot did not review the current head SHA

Code and op-test hygiene

  • PASS — no committed artifact or conflict marker detected

Required CI

  • PASS — Black: passed
  • PASS — Ruff: passed
  • PASS — Repository dependency: passed
  • FAIL — Aiter Test Gate: failed
  • Required CI failed; fix it before requesting human review.

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

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.

🟡 Changes recommended

The new tuning buckets are outside the tree selected on 96-CU devices, while missing REGISTER_STORE schema and search entries prevent mode tuning and cause installed buckets to revert to mode 0.

3 open issues
What changed in this PR

This PR adds selectable register-store epilogues to gfx1250 Gluon gemm_a16w16 and tunes GPT-OSS prefill configurations. It complements the separate decode retuning in #7289.

Changes:

  • Adds two register-store modes, host validation and an environment override while preserving mode 0 as the default.
  • Extends TP1 QKV, output-projection and router buckets through M=32768.
  • Adds TP2 QKV and output-projection configs with default fallback for uncovered buckets.
File Description
aiter/​ops/​triton/​gemm/​basic/​gemm_a16w16.py Selects and validates store modes for non-persistent compute-bound launches.
aiter/​ops/​triton/​configs/​gfx1250/​gluon/​gemm/​gemm_a16w16/​GEMM-A16W16-N=5120-K=2880.json Retunes TP1 QKV prefill and extends large-M coverage.
aiter/​ops/​triton/​configs/​gfx1250/​gluon/​gemm/​gemm_a16w16/​GEMM-A16W16-N=2880-K=4096.json Retunes TP1 output projection and adds intermediate and large-M buckets.
aiter/​ops/​triton/​configs/​gfx1250/​gluon/​gemm/​gemm_a16w16/​GEMM-A16W16-N=2880-K=2048.json Adds TP2 output-projection prefill configs.
aiter/​ops/​triton/​configs/​gfx1250/​gluon/​gemm/​gemm_a16w16/​GEMM-A16W16-N=2560-K=2880.json Adds TP2 QKV prefill configs.
aiter/​ops/​triton/​configs/​gfx1250/​gluon/​gemm/​gemm_a16w16/​GEMM-A16W16-N=128-K=2880.json Selects register stores for larger router batches.
aiter/​ops/​triton/​_gluon_kernels/​gfx1250/​gemm/​basic/​gemm_a16w16.py Implements masked register stores and optional coalesced output layout.

Review effort: Balanced

@zufayu
zufayu requested review from a team and k50112113 November 3, 2026 01:17
…96-CU tree (pure git mv)

They were tuned on a 96-CU DPX partition, and since ROCm#6573 a 96-CU device reads
configs/gfx1250/96cu/gluon/gemm/gemm_a16w16/ whole: in the plain tree no DPX
device ever loaded them (configs/AGENTS.md, CU trees).
…n the 96-CU tree

The retuned QKV (N 5120, K 2880), O (N 2880, K 4096) and router (N 128, K 2880)
tables were measured on a 96-CU DPX partition, which reads only the 96cu tree,
so on main they were never used there (Copilot, ROCm#7288). The 96cu files hold
these tables whole (buckets this PR did not retune keep ROCm#6921's values); the
plain-tree files go back to main's, so devices that read the plain tree see no
change from this PR.
The tuner's keys are the union of the family DEFAULT.json's keys, and
write_best_configs.py writes only those keys into a bucket. Neither gluon
DEFAULT.json (plain or 96cu) had REGISTER_STORE, so the tuner never searched it
and a retuned bucket silently lost it, going back to the LDS + TDM-store
epilogue (Copilot, ROCm#7288). Every DEFAULT bucket now says REGISTER_STORE 0 (what
it already meant; bandwidth_bound pops and ignores it) and SEARCH_SPACE offers
0, 1, 2.
…the public wrapper

Modes 0/1/2 on fp16 and bf16, bias on and off, at the gpt-oss bucket edges
(1025, 2049, 3073) and with partial M and N tiles (M 1, 97, 300; N 200); the
AITER_GFX1250_A16W16_STORE override for each mode; an invalid override (3) and
an invalid entry value (5) raise ValueError (Copilot, ROCm#7288).  73 passed on
gfx1250 (MI450 DPX partition, 96 CU).
…6-CU lookup

A 96-CU lookup of the QKV, O, router and TP2 shapes at M 4096-32768 must land on
tuned compute_bound entries (on the PR as filed it landed on the 96cu
DEFAULT's untuned bandwidth_bound rows), and every gpt-oss shape
must compute the right result at M 1, 64, 1000, 2049, 3073 and 8192 through the
tuned lookup.
@akao-amd

akao-amd commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Updated: the gpt-oss tables now live in the 96-CU tree they were tuned on (see the thread above: as filed they were never read on a DPX partition), the tuner keeps REGISTER_STORE, black is clean (CI's Black failure), and the store modes and tuned entries have tests. Rebases cleanly on main 7e9b010c6 (#6767's gfx1250-strict change to _GLUON_SUPPORTED_ARCHS merges without conflict). Could someone add ci:gfx1250-ffm-triton? Default PR CI does not run gfx1250.

@akao-amd

akao-amd commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

@ROCm/team_aiter @ROCm/triton_kernels_team Please take a look when you can. This is the base of #7289.

Two CI notes from the current head (13d9dcc):

I am following up on a gfx1250 gate for that lookup test. The shard-4 timeout is the cap, in a test this diff does not touch.

@akao-amd

akao-amd commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

@azaidy Tagging you as a Gluon owner for the gfx1250 gemm_a16w16 changes in this PR, alongside the team reviewers above.

The lookup test passed cu_num=96 and left the arch as the runner's, so MI35X asked for a gfx950 Gluon default that is not in the tree.
@akao-amd
akao-amd requested a review from azaidy November 5, 2026 10:26
Comment on lines +878 to +881
# Register store, coalesced: convert the tile to STORE_LAYOUT (16-byte vectors along N; the layout
# conversion's LDS round trip is ordinary ds_store/barrier/ds_load), then buffer stores. The TDM store of an
# LDS-staged tile (REGISTER_STORE == 0) is the gfx1250 B1 pattern: tensor_store_from_lds can read LDS before
# the waves' ds_stores are visible to it, and no documented wait or fence closes that window.

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.

Do you have any insight why this performs better compared to =0? This looks plain worse because the ds_stores should be the same but then we have (X * ds_loads + X * buffer_stores) vs just having one TDM store instruction?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We didn't claim mode 2 is faster. On the shipped 256×256 tile, mode 2 is about 1.3% slower than mode 0 (1.012–1.014× time, hot weights, QKV and O at M 8192 and 16384). Mode 1 is about 1.11–1.18×. The ablation line in the PR text was written badly: on the old small-M tiles, mode 2 measured faster for some shapes (the −24% / −12% figures). We're not relying on that. The end-to-end gain is the new buckets, not the store mode.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@AlexAUT Any follow-ups on this?

azaidy pushed a commit that referenced this pull request Nov 11, 2026
…with rotating weights; LM-head files (#7289)

* gfx1250 gluon gemm_a16w16 compute_bound: register-store epilogues, chosen per config entry (REGISTER_STORE)

The compute_bound kernel ended with the gfx1250 B1 pattern: the tile is staged in LDS
(ds_store), a workgroup barrier, then tensor_store_from_lds, whose LDS read can miss
the waves' ds_stores on gfx1250 (no documented wait or fence closes it; B1a-B1c).
A config entry may now pick the epilogue with "REGISTER_STORE":
  0 the LDS-staged TDM store (default: every existing entry is unchanged),
  1 buffer stores straight from the WMMA layout (as the bandwidth_bound kernel),
  2 coalesced register store: convert_layout to a blocked layout of 16-byte
    vectors along N (an ordinary ds_store/barrier/ds_load round trip), then
    buffer stores rebased to the block in int64.
AITER_GFX1250_A16W16_STORE=<0|1|2> overrides every entry (A/B only).

Cost vs the TDM store at gpt-oss's existing entries (gfx1250 DPX partition, bf16,
bias): mode 2 +0..5 % at M 256-8192, -24 % at O M=64 (30.1 -> 22.9 us), -12 % at QKV
M=16; mode 1 +3..16 % at M >= 256.

Plan: perf1101 P1 (B1 prerequisite of the large-M a16w16 dispatch)

* gfx1250 gluon gemm_a16w16: gpt-oss large-M buckets (M_BOUNDS to 32768), retuned 4096/8192, TP2 shape files

gpt-oss's QKV (N5120 K2880), O (N2880 K4096) and router (N128 K2880) files stopped at
M_LEQ_8192 and the loader searched only the standard bounds, so every prefill batch
above 8192 tokens (chunk 16384: 94 % of 70k/300 prefill batches, 12 % at 8k/1k c64
with mixed chunk) ran the 'any' entry, bandwidth_bound 128x128x64. The TP2 shapes
(QKV N2560 K2880, O N2880 K2048) had no file at all and ran DEFAULT.json at every M.

- QKV and O: M_BOUNDS up to 32768; M_LEQ_4096/8192/16384/32768 = compute_bound
  256x256x64, 4 buffers, 8 warps, waves_per_eu 1, coalesced register store
  (REGISTER_STORE 2: no new LDS-staged TDM store epilogue). Best of 126 candidates
  at M 16384 (BLOCK_K dividing K), and faster than the old 4096/8192 entries.
- Router: M_BOUNDS to 32768; M_LEQ_8192/16384/32768 = compute_bound 128x128x64,
  4 buffers, 4 warps, register store.
- TP2 QKV and O: new files with DEFAULT_FALLBACK (DEFAULT.json keeps M <= 128):
  M_LEQ_256..1024 = compute_bound 128x128x64, 2048..32768 = 256x256x64, register store.

Kernel time, old file -> new (us, bf16 + bias, one gfx1250 DPX partition, A-B-A):
  QKV  M 7500 340 -> 302, 8192 365 -> 307, 16384 3278 -> 618, 32768 6567 -> 1230
  O    M 7500 288 -> 246, 8192 293 -> 249, 16384 2643 -> 503, 32768 5252 -> 1020
  router M 8192 26.7 -> 18.9, 16384 101.5 -> 26.9
  TP2 QKV M 1024 51.5 -> 26.4, 7500 843 -> 167, 16384 1684 -> 308
  TP2 O   M 1024 43.9 -> 21.0, 7500 719 -> 132, 16384 1453 -> 267
Other buckets unchanged. fp32-reference max rel err 0.003 (same as before); CUDA-graph
replay bitwise equal over 6000 calls per shape at M 8192/9000/16384/16385.

Plan: perf1101 P1 (large-M a16w16 dispatch; router separately; TP2 files added)

* gfx1250 gluon gemm_a16w16 compute_bound: share the register-store code, validate the store mode

Review follow-up (perf1101 P1, codex round 1, findings 3-4): REGISTER_STORE outside
{0, 1, 2} is rejected (ValueError on the host, static_assert in the kernel) instead of
falling to the TDM store; the two register-store modes share one store helper; the
store layout helper drops its unused BLOCK_M; the comment states the override's scope
(non-persistent gluon compute_bound launches; unset in serving).
Same kernels, same outputs: P1's correctness check passes unchanged (55 shape/M
cases, old vs new bitwise equal, 2,000 replayed calls each); mode-2 store cost at the
shipped 256x256 tile 1.012-1.014 of the TDM store.

Plan: perf1101 P1 (review round 1)

* gfx1250 gluon gemm_a16w16: gpt-oss band starts without regressions (O 2049-3072, TP2 129-1536, 2049-3072)

Review follow-up (perf1101 P1, codex round 1, finding 2): a dense A-B-A over every
changed band showed four band starts slower than the old schedule (O M 2049 +16 %,
TP2 QKV M 1025 +9 %, TP2 O M 2049 +5 %, M 257 +3 %): 256x256 tiles just past a
bound leave most of a tile empty. Per-band sweep of eight register-store tiles:
  O (TP1): new bound 3072, M_LEQ_3072 = 128x128x64 (2049-3072: 0.91-0.95 of old).
  TP2 QKV: new bound 1536; M_LEQ_256 = 128x64x64, M_LEQ_512 = 128x128x128,
           M_LEQ_1024/1536 = 128x128x64, M_LEQ_2048 = 256x256x64.
  TP2 O:   new bound 3072; M_LEQ_256 = 128x64x64, M_LEQ_512 = 128x128x128,
           M_LEQ_1024 = 128x128x64, M_LEQ_2048 = 256x256x64, M_LEQ_3072 = 128x128x64.
All compute_bound, 4 buffers, 4 warps (256x256: 8 warps), coalesced register store.
Dense A-B-A (TP1 20 M from 2048 to 32768, TP2 28 M from 128 to 32768): new/old
0.17-1.01 everywhere, no point above 1.02. Old vs new outputs bitwise equal at every
band boundary (65 cases, same K order); 2,000 replayed calls each, 0 mismatches.

Plan: perf1101 P1 (review round 1)

* gfx1250 gluon gemm_a16w16: move the TP2 gpt-oss shape files into the 96-CU tree (pure git mv)

They were tuned on a 96-CU DPX partition, and since #6573 a 96-CU device reads
configs/gfx1250/96cu/gluon/gemm/gemm_a16w16/ whole: in the plain tree no DPX
device ever loaded them (configs/AGENTS.md, CU trees).

* gfx1250 gluon gemm_a16w16: the gpt-oss QKV, O and router entries go in the 96-CU tree

The retuned QKV (N 5120, K 2880), O (N 2880, K 4096) and router (N 128, K 2880)
tables were measured on a 96-CU DPX partition, which reads only the 96cu tree,
so on main they were never used there (Copilot, #7288). The 96cu files hold
these tables whole (buckets this PR did not retune keep #6921's values); the
plain-tree files go back to main's, so devices that read the plain tree see no
change from this PR.

* gfx1250 gluon gemm_a16w16: let the tuner search and keep REGISTER_STORE

The tuner's keys are the union of the family DEFAULT.json's keys, and
write_best_configs.py writes only those keys into a bucket. Neither gluon
DEFAULT.json (plain or 96cu) had REGISTER_STORE, so the tuner never searched it
and a retuned bucket silently lost it, going back to the LDS + TDM-store
epilogue (Copilot, #7288). Every DEFAULT bucket now says REGISTER_STORE 0 (what
it already meant; bandwidth_bound pops and ignores it) and SEARCH_SPACE offers
0, 1, 2.

* gfx1250 gluon gemm_a16w16: black

* gfx1250 gluon gemm_a16w16: test the REGISTER_STORE epilogues through the public wrapper

Modes 0/1/2 on fp16 and bf16, bias on and off, at the gpt-oss bucket edges
(1025, 2049, 3073) and with partial M and N tiles (M 1, 97, 300; N 200); the
AITER_GFX1250_A16W16_STORE override for each mode; an invalid override (3) and
an invalid entry value (5) raise ValueError (Copilot, #7288).  73 passed on
gfx1250 (MI450 DPX partition, 96 CU).

* gfx1250 gluon gemm_a16w16: test the tuned gpt-oss entries and their 96-CU lookup

A 96-CU lookup of the QKV, O, router and TP2 shapes at M 4096-32768 must land on
tuned compute_bound entries (on the PR as filed it landed on the 96cu
DEFAULT's untuned bandwidth_bound rows), and every gpt-oss shape
must compute the right result at M 1, 64, 1000, 2049, 3073 and 8192 through the
tuned lookup.

* gfx1250 gluon gemm_a16w16: read the 96-CU gpt-oss tables as gfx1250

The lookup test passed cu_num=96 and left the arch as the runner's, so MI35X asked for a gfx950 Gluon default that is not in the tree.

* gfx1250 gluon gemm_a16w16: gpt-oss decode buckets and LM-head tuning, stacked on the REGISTER_STORE PR

Rebuilt on top of pr-gfx1250-gemm-a16w16-large-m-regstore so the shared commits are not duplicated.
Only the gpt-oss decode buckets, the LM-head shape files and the 96-CU lookup test differ from that branch.

* gfx1250 gluon gemm_a16w16: drop the hardware-bug notes from the store comments
@akao-amd

Copy link
Copy Markdown
Contributor Author

@azaidy Closing this one: #7289 has merged and carries this PR's commits (the register-store epilogue and the GPT-OSS large-M / TP2 configs) into main. Thanks for the review. #7289

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants