Repository navigation
[Triton/Gluon] [gfx1250] gemm_a16w16: GPT-OSS decode buckets retuned with rotating weights; LM-head files - #7289
Conversation
…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]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
WAITING ON AUTHORPR Self-ReviewRevision Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision. Questions to answer in the PR description
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
There was a problem hiding this comment.
🟡 Changes recommended
The seven updated tuning tables are bypassed on the target’s 96-CU configuration path, and the new store modes lack direct regression tests for overrides and LM-head shapes.
2 open issues
What changed in this PR
Retunes gfx1250 Gluon gemm_a16w16 for GPT-OSS decode using rotating weights to model cold-weight serving. The diff also includes the register-store support and prefill configurations from parent PR #7288.
Changes:
- Retunes TP1 QKV and O-projection buckets for M ≤ 128.
- Adds TP1 and TP2 LM-head decode tables with default fallback for larger M.
- Includes configurable register-store epilogues and the parent PR’s large-M and TP2 projection tables.
| File | Description |
|---|---|
aiter/ops/triton/gemm/basic/gemm_a16w16.py |
Reads and validates store modes, then passes store layouts to the kernel. |
aiter/ops/triton/configs/gfx1250/gluon/gemm/gemm_a16w16/GEMM-A16W16-N=5120-K=2880.json |
Retunes TP1 QKV decode and includes parent prefill buckets. |
aiter/ops/triton/configs/gfx1250/gluon/gemm/gemm_a16w16/GEMM-A16W16-N=2880-K=4096.json |
Retunes TP1 O decode and includes parent prefill buckets. |
aiter/ops/triton/configs/gfx1250/gluon/gemm/gemm_a16w16/GEMM-A16W16-N=2880-K=2048.json |
Adds parent TP2 O prefill settings with default fallback. |
aiter/ops/triton/configs/gfx1250/gluon/gemm/gemm_a16w16/GEMM-A16W16-N=2560-K=2880.json |
Adds parent TP2 QKV prefill settings with default fallback. |
aiter/ops/triton/configs/gfx1250/gluon/gemm/gemm_a16w16/GEMM-A16W16-N=201088-K=2880.json |
Adds TP1 LM-head decode settings. |
aiter/ops/triton/configs/gfx1250/gluon/gemm/gemm_a16w16/GEMM-A16W16-N=128-K=2880.json |
Includes parent router prefill buckets through M = 32768. |
aiter/ops/triton/configs/gfx1250/gluon/gemm/gemm_a16w16/GEMM-A16W16-N=100544-K=2880.json |
Adds TP2 LM-head decode settings. |
aiter/ops/triton/_gluon_kernels/gfx1250/gemm/basic/gemm_a16w16.py |
Adds register-store layouts and epilogues while retaining the default TDM store. |
Review effort: Balanced
…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.
|
@ROCm/team_aiter @ROCm/triton_kernels_team Please take a look. This is stacked on #7288. The register-store and prefill commits are the parent; the decode buckets and LM-head files are the top. Same CI picture on head |
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.
… 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.
ddb8f47 to
e2264bb
Compare
… comments Co-authored-by: Cursor <[email protected]>

��## Summary
Retunes the decode graph buckets (M d" 128) of the TP1 QKV (
N=5120,K=2880) and O (N=2880,K=4096) files, and adds LM-head files forN=201088,K=2880(TP1) andN=100544,K=2880(TP2). The LM-head files setDEFAULT_FALLBACKand defineM_LEQ_1throughM_LEQ_128only, so M > 128 stays onDEFAULT.json.compute_bound picks set
REGISTER_STORE2 (the coalesced register store from #7288). bandwidth_bound picks store from registers on that kernel's existing path and do not set the key.Stacked on #7288 (
pr-gfx1250-gemm-a16w16-large-m-regstore). This commit does not change the large-M buckets, the TP2 QKV/O files, or the router file. Until #7288 merges, the diff against main also contains that PR. Please review the decode-bucket retune and the two LM-head files here. The register-store epilogue, the large-M buckets, and the TP2 QKV/O files are #7288.Motivation
Decode reads the weight matrix from HBM on every step. A microbenchmark that reuses one weight tensor keeps it hot in cache and picks a different tile than serving does. With rotating weights (40 copies for QKV, 48 for O, each set > 1 GB, one hot activation) the current entries reproduce a gpt-oss-120b trace: O at M 64 is 30.2 �s (trace 30.6; slower than M 128 at 15.4 �s), QKV at M 4 is 17.6 �s (trace 18.6). The LM head had no shape file, so it ran
DEFAULT.json(363 �s at M 64, N 201088).The new entries were chosen under that cold-weight setup: 220 sampled candidates of both kernels at each bucket's top M, then the top 10 re-timed at 2� 4 M inside the bucket. The pick is the best mean ratio to the old entry across the bucket.
Config keys
Lookup is
GEMM-A16W16-N={N}-K={K}.json, then the firstM_LEQ_*with bound e" M. This commit writes only the keys below.M_LEQ_256and above on the QKV and O files, theiranyentries, and every other shape file are unchanged from #7288.N=5120,K=2880M_LEQ_1,M_LEQ_4,M_LEQ_8REGISTER_STORE2M_LEQ_16M_LEQ_32REGISTER_STORE2M_LEQ_64REGISTER_STORE2M_LEQ_128N=2880,K=4096M_LEQ_1,M_LEQ_4,M_LEQ_8M_LEQ_32REGISTER_STORE2M_LEQ_64M_LEQ_128REGISTER_STORE2N=201088,K=2880(new)M_LEQ_1throughM_LEQ_16M_LEQ_32M_LEQ_64REGISTER_STORE2M_LEQ_128REGISTER_STORE2N=100544,K=2880(new)M_LEQ_1,M_LEQ_4M_LEQ_8,M_LEQ_16M_LEQ_32M_LEQ_64,M_LEQ_128REGISTER_STORE2O
M_LEQ_16is unchanged. It measured 1.003� 1.005 of the old entry, inside the noise of an unchanged key.Left on the previous selection after the same sweep:
DEFAULT.jsonalready serves, within 4% of the best sampled candidate.DEFAULT_FALLBACKkeepsDEFAULT.json. M 129 was part of the numeric check.Performance (gfx1250 MI45x DPX partition, 96 CUs, rotating weights)
A-B-A, file configs. A is this branch's parent (#7288). Each point is a CUDA graph of 40� 48 calls (2� 3 copies for the LM heads: 2.3 GB and 1.7 GB, still cold), median of 20. Times in �s, then B / average(A).
The LM head at M 128 moves between the two A arms (569 vs 486 �s): a cold ~1.2 GB stream. The weakest new buckets are still ahead of the old entry (LM head TP1 M 72 at 0.88, TP2 M 96 at 0.90). No measured M in 1� 128 got slower, apart from O M 12/16 on the unchanged
M_LEQ_16key (1.003 / 1.005).End to end, on top of #7288 (gpt-oss-120b W4A8, SGLang TP1, fixed-seq run 1, controlled A-B-A, box idle). The bracket holds P6a on both sides and swaps this commit in the middle arm. Output tok/s, this commit / the arms without it:
70k mean TTFT stays inside the two neighboring arms (2,857 / 2,861 / 2,781 ms). GSM8K strict 0.9553� 0.9636 across the five arms; the arm with this commit is 0.9598.
Test
Hardware: same partition and image as #7288 (
rocm/sgl-dev:v0.5.23-rocm101-mi45x-20261031, ROCm 10.1.0, Tritonb509148826).AITER_GFX1250_A16W16_STOREunset. QKV and O with bias. Both LM heads without bias, matching SGLang'stgemm.mm(hidden, weight).check_p3_correctness.py: 72 cases. M is every bucket edge and an interior point (1, 2, 4, 5, 8, 9, 12, 16, 17, 24, 32, 33, 48, 64, 65, 96, 128, 129). M 129 is the first key this commit does not own. Same tolerance as [Triton/Gluon] [gfx1250] gemm_a16w16: register-store epilogue option and GPT-OSS large-M / TP2 configs #7288 (finite, within 2� the old entry's fp32 error, and within 2{ v of the old output). 72/72 pass, old and new bitwise equal. CUDA graph of 20 calls (4 for the LM heads) � 50 replays: 0 mismatches. N 100544 with BLOCK_N 128 leaves a 64-column tail; that tail is in every TP2 LM-head case that uses BLOCK_N 128. K 2880's partial tile is in the BLOCK_K 128 and 256 cases.replay_*.jsonl): 2,000� 10,000 calls per shape and M, 0 mismatches. That checks repeatability only; the numeric gate is the check above.run_bench.sh --rotate(48 O, 40 QKV, 2 / 3 for the two LM heads),run_refine.shfor the top 10 per bucket,file_aba.shfor the table above.Not tried: the persistent Gluon kernel, and the OPUS rows. Validated on the recipe AITER tree, then this one commit applied cleanly on top of #7288's branch.
MI355X (gfx950), 2026-11-05, image
rocm/sgl-dev:v0.5.23-rocm10-mi35x-20261102, ROCm 10.0.0. Wholeop_tests/triton_tests/gemm/basic/test_gemm_a16w16.pyat this head (ddb8f4778ae1): 377 passed, 0 failed, 764 skipped. The 5test_gemm_a16w16_gfx1250_gptoss_96cu_lookupcases pass and are not skipped. The same 5 failed at #7288's pre-fix head13d9dcc310b8(that commit is not in this branch) with a missingconfigs/gfx950/gluon/gemm/gemm_a16w16/DEFAULT.json. mainc1096fa40a90on the same box: 372 passed, 0 failed.PR Self-Review
Reviewed revision
ddb8f4778ae162418817746fbd98157e04bdbec5Behavior and intent
GPT-OSS decode (M d" 128) was selecting tiles that are fast when the weight matrix stays in cache and slow when it is streamed. With rotating weights the old O M 64 entry is ~30 �s and the old QKV M 4 entry is ~18 �s, matching a serving trace, and both are slower than neighboring larger M. This commit replaces those buckets, and adds the two LM-head files that were missing, with tiles picked under cold weights.
compute_bound picks use
REGISTER_STORE2 from #7288. bandwidth_bound picks use that kernel's register store. OM_LEQ_16and every key for M > 128 stay on the parent selection.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, Tritonb509148826,AITER_GFX1250_A16W16_STOREunset. Parent tree is #7288.check_p3_correctness.py, 72 cases, old entries read from the parent withgit show(LM heads fall back toDEFAULT.jsonthere). 72/72 bitwise equal to the old schedule under the stated tolerance. 0 graph-replay mismatches.file_aba.shwith rotating weights. O M 40� 64 goes from 29.7� 30.5 �s to 7.6� 8.3 �s. QKV M 4 goes from 17.7 �s to 6.5 �s. LM head N201088 M 64 goes from 363 �s to 227 �s. TP2 LM head M 64 goes from 185 �s to 116 �s.Not run: AITER op tests on gfx1250, shapes other than these four, the persistent Gluon kernel, OPUS. The large-M and TP2 QKV/O results belong to [Triton/Gluon] [gfx1250] gemm_a16w16: register-store epilogue option and GPT-OSS large-M / TP2 configs #7288; this commit does not remeasure them. LM-head A-arm times at M 128 drift (569 vs 486 �s) because the working set does not fit in cache.
PR-specific question
The keys this commit selects are the seven
M_LEQ_1&M_LEQ_128entries onN=5120,K=2880and onN=2880,K=4096except OM_LEQ_16, plusM_LEQ_1&M_LEQ_128on the two new LM-head files. Tiles are in the table under Config keys.Everything else keeps the parent's selection:
M_LEQ_256and above andanyare not in this commit. The numeric check includes M 129, which resolves to that next key, and it matches the parent bitwise.M_LEQ_16is not in the diff. A-B-A at M 12 and M 16 is 1.003 and 1.005.N=128,K=2880), TP2 QKV (N=2560,K=2880) and TP2 O (N=2880,K=2048) are not in this commit. The decode sweep measured them and left them: the best router candidate was 0.85� 1.00� the current entry, and TP2 decode was within 4% of DEFAULT.M_LEQ_128and setDEFAULT_FALLBACK, so M > 128 stays onDEFAULT.json. No other(N, K)file is added or edited.REGISTER_STOREapplies only where the key is set. The override env var was unset. bandwidth_bound entries in this commit do not set it.Changed op tests
op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py� same tests as #7288, plus the two LM-head shapes ontest_gemm_a16w16_gfx1250_gptoss_tuned.test_gemm_a16w16_gfx1250_gptoss_96cu_lookupstill covers the five prefill shapes only (the LM heads are tuned for decode M). It pinsget_arch()to gfx1250 so the MI35X runner readsconfigs/gfx1250/96cuinstead of a gfx950 Gluon default. On an MI355X (gfx950) those 5 cases pass at this head. The kernel tests skip unless Gluon is supported on the device.