Repository navigation
[OPUS] opus gemm 256tile ring - #5397
Merged
Merged
Conversation
The split-K reduce launches as dim3(ceil(N, VEC*BLOCK), M, 1) and grid.y is
capped at 65535 on this part. Past that it does not fail, it writes garbage:
at M=65536 the output is NaN, and M >= 65537 stops launching at all with
"invalid configuration argument". The cliff is exactly 2^16 -- M=65535 is
clean, and the same shape on a .co kid, which has no reduce, is exact.
Three places, since the shape can arrive by three routes:
* candidate selection rejects the two _ws families above 65535, so tuning
never proposes one. It used to: tuning these shapes took the container
down with it, which is how this was found.
* the heuristic refuses M > 65535 outright, alongside the existing >4 GiB
guard. Every kid it can return is split-K, so there is nothing to fall
back to -- the message says to tune the shape instead, which lands on a
.co kid.
* the generated launcher checks before the reduce, for a tuned CSV or an
explicit kernelId that predates any of this.
Scoped to gfx1250. gfx942 and gfx950 launch the same reduce with batch * M
on grid.y and have the same ceiling; they are untouched here.
The four shapes that prompted this (M=65536, N=64/384/1024/2048, K=7168) now
tune in 56s where they used to hang the box, all four to 4wave_wl_co with
err_ratio 0.0, and verify against an fp32 reference at 1-2 absolute -- the
bf16 output quantisation itself, with no element outside tolerance.
Co-authored-by: Cursor <[email protected]>
The preceding commit makes opus refuse split-K where its reduce cannot
address the whole grid, so M=65536 now fails loudly instead of returning
wrong results -- but heuristic dispatch was the only thing serving those
shapes. Give them tuned rows instead.
dsv4 gains 9 shapes that had no bf16 tuned row at all:
65536x{64,384,1024,2048}x7168 plus M=1..128 of Nx32320x7168. Opus wins 5
of them, triton 4. dsv3 retunes all 114 gfx1250 rows now that the .co kid
families are available, moving 113 from triton to opus.
Co-authored-by: Cursor <[email protected]>
The bf16 partial was landed as the default for the two gfx1250 _ws families (cluster_tdm/clusterlaunch_tdm) because it cleared the tuner's 5e-2 gate at half the workspace. It clears the gate, but it is not exact: every split-K row tuned that way carried err_ratio 0.008-0.017, the bf16 accumulation of the partials showing through. fp32 partials take that to 0.0. Restore fp32 as the family default -- which is just the dataclass default, so this is a deletion: the loop that forced the two tags to bf16 and the candidate filter (_drop_fp32_ws_kids, OPUS_TUNE_FP32_WS) that existed only because fp32 kids were the exception both go. Everything else keys off splitk_workspace_dtype and follows: the workspace sizes at 4 bytes, the launcher's element_size check, the reduce's read width. gfx942/950 _sk families are a different tag and keep their per-name dtypes (5 fp32, 3 bf16) untouched; fp32 is also their original default, so no static_assert moves. Re-tuned the 66 split-K rows this touches, opus vs triton in one session: * dsv3 (35 rows): all stay opus, 1.008x geomean cost. The tuner buys back most of fp32's per-shape ~13% by re-picking split_k / tile, and one shape (4096x256x7168) moves to a .co kid and gets faster. * dsv4 (31 rows): 9 stay opus, 22 flip to triton -- fp32 slows opus just enough to lose the shapes triton has a real tuned config for, which is the same (N,K) split seen when these were first tuned. err_ratio for every gfx1250 split-K row in both files is now 0.0. All 39 surviving opus split-K rows verified through dispatch: correct workspace width, 1.7e-3..3.2e-3 vs fp32 reference, no launcher complaint. kimik3's 111 split-K rows are not re-tuned here and now run the fp32 kids they reference; verified 0/111 errors through dispatch. They are correct but tuned for the old bf16 split_k, so a re-tune is left as follow-up. Co-authored-by: Cursor <[email protected]>
…imit Co-authored-by: Cursor <[email protected]> # Conflicts: # aiter/configs/model_configs/dsv4_bf16_tuned_gemm.csv
Port the validated combots 256x256x64 P=4 GEMM optimization from the
standalone gcnasm harness into the 4wave_co (pre-compiled .co) integration
path, isolated behind a new tag so the shipped wl pipeline stays
byte-for-byte identical.
New isolated pipeline header
include/gfx1250/opus_gemm_pipeline_a16w16_4wave_wlr_gfx1250.cuh
- ring/pin variant of the wl pipeline with the combots defaults baked in:
OPUS_PIN_A=1 (pin A into B's 256-VGPR window, freeing the A LDS segment),
OPUS_C_STAGE_RING=1 (stage C over the dead A segment for a coalesced TDM
store instead of a single B slot), OPUS_A_SPREAD=1 (spread A fragment
reads across the B-prefetch gaps).
- kExpKHalf now derived as kBlockK/(2*kWmmaK) (macro override still honored),
keeping kHalvesPerSlot==2 for any B_K.
- own namespace/body: gemm_4wave_wlr_gfx1250 /
gemm_a16w16_4wave_wlr_body_gfx1250.
New tag a16w16_4wave_wlr_co wired through codegen + registry
- codegen/common.py: add tag to _A16W16_CO_TAGS.
- codegen/gen_instances_gfx1250.py: pipeline/traits/kernel-func/traits-name/
kargs-name maps, wave-layout co_traits_args condition, and emit
registration.
- gen_co/build_co.py: map tag -> new pipeline header.
- opus_gemm_common.py: add wlr to _CO_KID_BANDS (21000..27000) and handle the
tag in the name property (tag -> name-segment dict + wave-layout branch).
New instances in gen_co/co_kernels.json (256x256x64, P=4, c4x4)
- kid 21316: w4x1 layout
- kid 21317: w2x2 layout
(w1x4 omitted: large kExpN pushes kAPinEnd past the 1024-VGPR file under
PIN_A, so that geometry is infeasible.)
Pre-built code objects (bare amdhsa ELF, gen_co/gfx1250/)
- ...4wave_wlr_co_128x256x256x64_..._w2x2_c4x4_p4_v1024w1.co
- ...4wave_wlr_co_128x256x256x64_..._w4x1_c4x4_p4_v1024w1.co
Device code is byte-identical to the validated standalone combots build
(4304 opcodes, 1024 WMMA, diff=0).
Perf (gfx1250, graph-mode, via opus tuner JIT bench, splitK=0):
16384x2048x7168: 21317 -3.8%, 21316 +0.4% vs shipped 21179
16384x1024x7168: 21317 -4.3%, 21316 +0.4% vs shipped 21179
21317 (w2x2) reproduces the ~-4.6% standalone win; 21316 (w4x1) stays a
neutral candidate.
Co-authored-by: Cursor <[email protected]>
Contributor
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
PR title tags & labels: |
…e_ring Co-authored-by: Cursor <[email protected]>
… kid
Re-tuned M=16384 N={1024,2048} K=7168 on gfx1250 with the new 256x256x64 P=4
combots ring/pin kid (21317 w2x2) in the candidate set. It wins both:
N=1024: opus 21317, 114.76us (was opus 21179 108.9996us)
N=2048: opus 21317, 244.63us (was triton auto 238.4263us)
Same-machine tune, so the opus-vs-triton / opus-vs-21179 comparison is
apples-to-apples; the higher absolute us here just reflects this box running
slower than the machine the surrounding rows were tuned on. Only the two rows
change; the rest of dsv4 stays byte-identical to main.
Co-authored-by: Cursor <[email protected]>
demonsan
marked this pull request as ready for review
September 14, 2026 03:15
junhaha666
approved these changes
Sep 16, 2026
Fyzyukk
added a commit
to Fyzyukk/aiter
that referenced
this pull request
Sep 16, 2026
Resolve OPUS codegen and registry conflicts with ROCm#5397 while preserving exact-kid typed-workspace handling.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Performance (gfx1250)
Winner is kid 21317 (w2x2). Numbers below are all measured on the same
machine, so the comparisons are apples-to-apples; absolute µs are higher than
the surrounding dsv4 rows only because this box currently runs slower than the
machine those rows were originally tuned on.
opus 21317 vs previously-selected opus kid 21179 (same-harness single-kid bench)
Single-kid bench through the opus tuner graph path (same warmup/iters as
gemm_a16w16_tune.py), so both kids are timed identically in one run:(reproduces the ~−4.6% standalone combots win; kid 21316 w4x1 stays a neutral
candidate, ~+0.4%.)
Tuner pick — opus 21317 vs triton (same-machine re-tune)
The
gemm_a16w16_tune.pysweep (opus + triton candidates) selects opus 21317for both shapes, beating triton: