Skip to content

[OPUS] opus gemm 256tile ring - #5397

Merged
junhaha666 merged 8 commits into
mainfrom
blyu/opus_gemm_256tile_ring
Sep 16, 2026
Merged

junhaha666 merged 8 commits into
mainfrom
blyu/opus_gemm_256tile_ring

Conversation

@demonsan

@demonsan demonsan commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

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:

shape (M×N×K) opus 21179 (prev) opus 21317 (new) Δ
16384×1024×7168 117.30 µs (2050.4 TFLOPs) 110.66 µs (2173.4 TFLOPs) −5.7%
16384×2048×7168 240.61 µs (1999.2 TFLOPs) 230.09 µs (2090.7 TFLOPs) −4.4%

(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.py sweep (opus + triton candidates) selects opus 21317
for both shapes
, beating triton:

shape (M×N×K) triton opus 21317 Δ
16384×1024×7168 129.11 µs (1862.9 TFLOPs) 114.76 µs (2095.8 TFLOPs) −11.1%
16384×2048×7168 256.68 µs (1874.1 TFLOPs) 244.63 µs (1966.4 TFLOPs) −4.7%

binglue.lyu and others added 5 commits August 31, 2026 13:16
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]>
@github-actions

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 5397 --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.

demonsan and others added 3 commits September 10, 2026 07:48
… 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
demonsan marked this pull request as ready for review September 14, 2026 03:15
@demonsan
demonsan requested a review from a team September 14, 2026 03:15
@github-actions github-actions Bot changed the title [OPUS]opus gemm 256tile ring [OPUS] opus gemm 256tile ring Sep 14, 2026
@github-actions github-actions Bot added the OPUS label Sep 14, 2026
@junhaha666
junhaha666 merged commit 9a9140a into main Sep 16, 2026
118 of 120 checks passed
@junhaha666
junhaha666 deleted the blyu/opus_gemm_256tile_ring branch September 16, 2026 02:19
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.
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.

2 participants