Repository navigation
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
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 |
1be6485 to
b9bd7da
Compare
…ackend Add OPUS MXFP4 x MXFP4 NT GEMM kernels for gfx950 aiter.gemm_a4w4(bpreshuffle=True) inputs (A row-major fp4x2, B shuffle_weight(16, 16), 1x32 UE8M0 e8m0_shuffle scales, bf16 C): - 2x2 4-wave pipeline, 18 pre-compiled .co (tiles 128/192/256 x 128/192/256; persistent, one tile per block, split-K, no-boundary), registered in gen_co/co_kernels.json under gfx950 and rebuilt byte-identically by build_co.py --arch gfx950; - 1x4 small-tile pipeline (M <= 512), JIT-built with stock ROCm, in-block K split for very small M. Family a4w4 / gfx950 with local kids 0-5, 10-15, 21-25, 30 (.co) and 410-416 (small), launched through opus_gemm / opus_bmm (family="a4w4", layout="bpreshuffle"); Python plans split-K and allocates Torch workspaces. aiter.gemm_a4w4 dispatches tuned rows whose kernelName is the OPUS instance name (kernelId = local kid), as the a8w8 / bf16 OPUS rows do. The a4w4 tuner gets an opus backend. a4w4_blockscale_tuned_gemm.csv: 692 of 1464 gfx950 rows switch to OPUS kernels where they beat the best asm / CK kernel in the same tuning run (MI355X); all other rows unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
b9bd7da to
c745d9c
Compare
…igned get_GEMM_config reuses a row tuned at a padded M for every M that pads up to it, so a row tuned with the no-bounds-check 256x256x256_nob kernel (needs M % 256 == 0 and N % 256 == 0) is also returned for e.g. M=1664 via the M=2048 row. _gemm_a4w4_opus launched it anyway and _a4w4_plan raised ValueError, failing op_tests/test_gemm_a4w4.py (M=1664, N=8192, K=28672). Switch to the same tile without _nob in that case (None -> CK/asm fallback if no twin is registered). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…w4_bpreshuffle/ Gives the bpreshuffle family its own directory (and build_info.json) under gen_co/gfx950/ instead of sharing the arch root. Files are moved unchanged; build_co.py's default gfx950 output, the runtime loader and co_image_path follow the new location. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The JSON list key now matches the image directory (A4W4_CO_KEY, relative to gen_co/), so co_image_path and build_co.py's default output derive from it. The manifest test checks the arch part of "<arch>/<family>" keys. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Move the gfx950 a4w4 bpreshuffle entries out of the shared co_kernels.json (back to its main content) into gen_co/co_kernels_gfx950_a4w4_bpreshuffle.json; images stay in gen_co/gfx950/a4w4_bpreshuffle/ (A4W4_CO_DIR). Drops the previous key rename and its manifest-test change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
opus_co_launch_mxfp4_gfx950.cuh becomes the family-agnostic opus_co_launch_gfx950.cuh: the launcher passes its image directory under gen_co/ (co_kernel(symbol, co_dir), cache keyed by co_dir/symbol) and calls opus_co_launch_gfx950. Read / ELF check / launch logic unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
New a8w8_mxfp8 opus_gemm family: MXFP8 x MXFP8 with 1x32 UE8M0 scales (row-major x_scale [M, K/32] / w_scale [N, K/32], not shuffled), B in shuffle_weight(16, 16), bf16 output, in all four operand layouts (NT = gemm_a8w8_mxfp8_bpreshuffle's inputs; NN: B stored [K, N]; TT: A stored [K, M]; TN: both). - 2x2-wave pipeline (pre-compiled .co, pin toolchain): tiles 256/192/128 x 256/192/128, one tile per block / persistent / split-K, M/N boundary handling; transposed operands go through LDS k-major and ds_read_tr8. Kids 0-16 (co_kernels_gfx950_a8w8_mxfp8_bpreshuffle.json), one image per layout in gen_co/gfx950/a8w8_mxfp8_bpreshuffle/. - Split-K: fp32 partials summed by splitk_reduce_kernel. - opus layer: _launch_a8w8_mxfp8_gemm picks the layout from the XQ / WQ strides (as the a16w16 4-wave family); A stored [K, M] needs M % 16 and B stored [K, N] needs N % 32. - gemm_a8w8_mxfp8_bpreshuffle runs libtype "opus" rows of the tuned CSV (NT), falling back to FlyDSL when the tile does not fit; the tuner adds the OPUS kids as candidates. No tuned-CSV changes. Shares the gfx950 pre-compiled .co infrastructure with the MXFP4 NT PR (ROCm#7979): its code is included here, its kid table, .co images and tuned CSV are not (they come with ROCm#7979). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…y lookup
- test_gemm_a4w4: tuned_shapes()/baseline use _A4W4_PRESHUFFLE_PREFIXES so the
OPUS rows run in CI; opus_a4w4_kid_sweep() launches every registered kid
(off-grid M, forced split_k=2 on split-K and small-tile kids); add padded-M
shapes that reach OPUS rows; assert only the tuned kernel (the default ASM
baseline is wrong on some large-M shapes, e.g. M=6528 N=7040 K=5632).
- gemm_a4w4_blockscale_tune: opus_candidates returns {} for a CU count with no
OPUS a4w4 table instead of aborting the default-backend tune.
- get_GEMM_config: document why OPUS rows also serve a padded M.
- a4w4 traits: the split-K counter block is zeroed by the launcher every launch.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…impler dispatch
The a4w4 family now has two layouts; this PR is layout="bpreshuffle" and every
name it adds carries it, so it can coexist with layout="plain" kids.
- Naming: tags a4w4_mxfp4_nt_bpreshuffle_co / a4w4_mxfp4_nt_bpreshuffle_small,
headers opus_gemm_{pipeline,traits}_a4w4_mxfp4_nt_bpreshuffle[_small]_gfx950.cuh,
kargs / traits / kernel functions / OPUS_MXFP4_BPRESHUFFLE_* and the
opus_gemm_common.py constants, .co symbols
opus_gemm_gfx950_a4w4_mxfp4_nt_bpreshuffle_co_*, tuned CSV kernelNames.
Kids are unchanged (0-30, 410-416).
- C++ entry opus_gemm_a4w4_bpreshuffle_launch (own e8m0_shuffle scale checks);
opus_check_a8_family_tensors takes the A/B dtype.
- .co pipeline: 64-bit tile base offsets (batch strides long long, row / column
offsets widened, host kargs too), buffer ranges bounded to one tile; a Y of
> 2^31 elements no longer overflows (reachable through the padded-M lookup,
e.g. M >= 262145, N = 6144, K = 16384 on the M = 8192 row). 18 .co rebuilt,
kernarg 136 B.
- aiter/ops/opus/gemm_op_a4w4.py follows the a8w8 structure:
_launch_a4w4_bpreshuffle_gemm / _bmm picked by dispatch, shape checks left to
the C++ entry, split-K pick folded into _a4w4_bpreshuffle_plan.
- gemm_a4w4: OPUS rows match the "opus_" prefix; _gemm_a4w4_opus maps the
name to its kid (nob -> bounded twin when M/N are not tile-aligned) and lets
the C++ entry check shapes; kernelId is no longer threaded through.
- test_gemm_a4w4: > 2^31-element Y through kids 0, 10, 30.
All 692 OPUS rows pass, every kid passes the sweep (incl. split_k=2), and the
large-offset case passes; .co kids are within 0.3% of the previous build.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ines Big pipeline: own namespace (opus_mxfp4_bpreshuffle), constexpr cache policies, ROW_PAIR / A_SPLIT_PAIR / B_SPLIT_PAIR, async_load_rows / async_load_blocks, opus layouts for the e8m0_shuffle scale panels (make_layout_gsf / ssf / rsf), one generic sched_quadrant (the hand-tuned 256x256 schedules are dropped), mma_quadrant as a function, the odd K tile step with a compile-time stage, and no split_k < 0 separate-reduce mode (aiter launches S > 0 only). Small pipeline: g_a / g_b / g_sfa / g_sfb up front with out-of-range K tiles by offset, wave-dim layouts, one LDS array with restrict read views, tiled MMA + mma_step / sched_step, KS partials in the ring, nt C stores with an OOB offset; B and the raw scale dwords stay in the register ring. kargs gain stride_b. All 18 .co rebuilt; every .co / small / split-K kid gives bitwise the same C as before (153 cases). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflicts with ROCm#6696 (gfx950 blockscale MXFP8 .co) and ROCm#6067 (ASM f4gemm _ps): - opus_co_launch_gfx950.cuh: main's loader with an optional co_dir for co_kernel() and an optional kernarg size for opus_co_launch_gfx950 (the defaults keep the a8w8 blockscale bpreshuffle images); the a4w4 bpreshuffle launcher passes "<name>.co", gfx950/a4w4_bpreshuffle and 136. - build_co.py: main's builder plus --family a4w4_bpreshuffle (build_one_a4w4_bpreshuffle, device-only clang++ on the pin toolchain); it rebuilds the 18 committed .co byte-identically. - opus_gemm_common.py / gen_instances*.py: both families registered. - a4w4_blockscale_tuned_gemm.csv: for each shape both sides retuned, the row with the lower us (121 OPUS, 267 main ASM). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…thout family Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflict with ROCm#7883 (ASM a4w4 GEMMs exact past 4 GiB) in op_tests/test_gemm_a4w4.py main(): both sets of gfx950 checks run (main's ASM last-tile / 4 GiB checks, then the OPUS large-offset check, kid sweep and fallback check). Co-Authored-By: Claude Fable 5.2 <[email protected]>
…tion', no test failure) Co-Authored-By: Claude Fable 5.2 <[email protected]>
- a4w4_blockscale_tuned_gemm.csv: remove fallbackKernelName / fallbackSplitK columns (back to the 12-column schema); the 549 OPUS kernelName selections stay. - gemm_op_a4w4.py: remove _a4w4_fallback_config / _log_a4w4_fallback; a declined preshuffle call now routes to the default ASM path instead of a CSV-recorded kernel. - validate_tuned_csv.py: restored to origin/main (OPUS rows produce a harmless warning). - test_gemm_a4w4.py: drop check_opus_fallback and the baseline fallback candidate. gen_instances.py keeps the opus_ exclusion; its fallback block is now inert (the CSV no longer has the column) so it is left untouched. Co-Authored-By: Claude <[email protected]>
12c8b3b to
20cc8f9
Compare
…line test The previous commit removed _a4w4_fallback_config / _log_a4w4_fallback, the triton_/flydsl_ padded-M fallback and the test's baseline candidate. Those are upstream code from ROCm#7317 (the narrow-N CSV still carries the fallback columns), not part of the OPUS change, so they are back exactly as on upstream/main. OPUS rows have no fallback columns and still fall through to the default ASM path. a4w4_blockscale_tuned_gemm.csv: two ASM rows (2048x16384x4096 and 32768x16384x53248) are back to upstream's rows; the diff against upstream is now the 549 OPUS rows only. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
Advisory review with the repo's Verdict:
Size / design: SPLIT — (1) pre-compiled 2x2 .co kids with build_co.py and the JSON/build_info; (2) JIT small-tile 1x4 pipeline and traits; (3) opus_gemm launcher, pybind and aiter/ops/opus/gemm_op_a4w4.py with dispatch.py; (4) gemm_a4w4 routing, the 549-row CSV retune and the tuner opus backend as the last stacked layer |
|
|
@aiter-bot review |
|
aiter-bot — queued behind 16 review(s); expect to start in about 4.6 h. The box reviews one PR at a time. |
@zufayu — please take a look. Re-comment |
|
@valar-cop review |
| ) | ||
| for split_k in splits: | ||
| y = torch.empty((M, N), dtype=dtype) | ||
| opus_gemm( |
There was a problem hiding this comment.
batch>1 opus_bmm and the _nob switch have no test, please add a batch=2 case with 3d scales and one padded-M call that lands on a _nob row
There was a problem hiding this comment.
- check_opus_bmm: every a4w4 kid through opus_bmm with 3D [B, rows, K/32] scales and different data per batch. It runs at B=2/3/4, on whole tiles (256×256) and on partial tiles (300×272, skipped for the nob kid). The small-tile kids also run split_k=2. 189/189 pass on gfx950.
- check_opus_nob_padded_m: M=2047 pads up to the tuned 2048 _nob row. It asserts that the bounded twin runs instead of the nob kid and checks the result against torch. Passes.
…ob switch check_opus_bmm_batch2: every a4w4 kid through opus_bmm at batch 2 with 3D [B, rows, K/32] scales (small-tile kids also at split_k=2). check_opus_nob_padded_m: M=2047 pads up to the tuned 2048 _nob row; assert gemm_a4w4 launches the bounded twin and matches the reference. Co-Authored-By: Claude <[email protected]>
…tiles Co-Authored-By: Claude <[email protected]>
|
@aiter-bot review |
@zufayu — please take a look. Re-comment |
…runcated watchdog read, size the agent timeouts for the 4-lane pool (#9201) * [CI] review-bot: read WORK out of a binary fetch log, retry a stalled watchdog read, size the agent timeouts for the 4-lane pool Three failure modes from the 2026-12-04 outage (6 failed runs, 01:24-03:02): - run_one.sh extracted WORK= from the tee'd fetch log with a bare grep, so a PR with binary artifacts (OPUS .co blobs put NULs in that log) made grep answer "binary file matches" instead of the match -- a fetch that SUCCEEDED was reported as "fetch produced no WORK dir" on every retry (#8283/#7979/#7983). grep -a reads the log as text. - watchdog.py caught only HTTPError, so a 30s socket timeout crashed the watchdog with a bare TimeoutError and failed a run whose review had already published a green card (#9178). A stalled GET is now retried (3 attempts, 5s backoff); a POST is never retried, because a retried comment can land twice, and a failed POST degrades to 0, which the caller already warns about. - AITER_AGENT_TIMEOUT=2400s was sized for one review at a time; the 4-lane pool serves four through the same GLM endpoint and workers measured 25-40+ min under that load, so 2400s timed out live while the backend answered normally (#8983/#8541). Defaults now 3300s/agent and 6900s/run (115 min, still under the job's timeout-minutes of 120; check_prompts.py asserts it). watchdog_test.py gains real-socket transport checks (the retry lives below the _get/_post seam its fakes replace) with a mutation guard; _fetchfail_test.sh gains the binary-log case. selftest: 156 green / 0 red. Co-Authored-By: Claude Code <[email protected]> * watchdog: retry a truncated response body, not just a stalled read A response that dies mid-body raises http.client.IncompleteRead -- an HTTPException, not an OSError -- so the OSError-only retry net added for the 2026-12-04 stall let it escape unretried and unnamed: the same bare-traceback crash one layer up, and _post's RuntimeError guard could not degrade it either. Name the family in the catch so a truncated GET is retried like a stalled one and a truncated POST degrades to 0. Co-Authored-By: Claude Code <[email protected]> --------- Co-authored-by: zufayu <[email protected]> Co-authored-by: Claude Code <[email protected]>
|
@aiter-bot review |
|
aiter-bot — queued behind 3 review(s); expect to start in about 39 min. The box reviews up to 4 PRs at a time. |
aiter-bot
left a comment
There was a problem hiding this comment.
ROCm/aiter PR #7979 — [HIP] [CK] [OPUS] Add opus mxfp4 bpreshuffle nt gemm
Review (advisory):
Validation (deterministic): NOT RUN — auto-validation disabled on this runner (REVIEW_AUTO_VALIDATE=0) and no gfx950 GPU present (8× MI300X gfx942, all busy); target op_tests/test_gemm_a4w4.py, correctness and perf triage both REQUIRED — environment gap, not a PR defect
Perf (advisory): NOT RUN — no gfx950 GPU on this box (8× gfx942, all at 97–98% use); the PR's own evidence is the retuned CSV's us columns vs upstream/main's (recomputed here: 71/59/42/40/337 over 549 rows, min +0.1%, no negative row) plus the author's four back-to-back padded-M timings on MI355X
Size: 5255 lines / 41 files — over the review bar
Design (advisory): SPLIT — (1) pre-compiled 2x2 .co kids + build_co a4w4 family + images; (2) JIT 1x4 small-tile pipeline; (3) host launch chain (launchers, checked C++ entry, pybind, registry, co loader); (4) aiter routing + tuner opus backend + the 549-row CSV retune as the last stacked layer
Human: recommend valar-cop review whether switching 549 default gfx950 gemm_a4w4 shapes to OPUS with no env gate, and the .co split-K reduction's relaxed-atomic synchronization, are the right contract for this op
aiter/aiter/ops/gemm_op_a4w4.py
Line 37 in 15b1a08
📝 [verified] The PR description still says "1x4 small-tile pipeline: JIT-built for M <= 512" while three tuned rows in aiter/configs/a4w4_blockscale_tuned_gemm.csv select small-tile kids at M=1024 ((1024,512,4096) and (1024,512,7168) on kid 410, (1024,800,5120) on kid 412), and the author's Nov 30 comment claims the range was corrected to M <= 1024 — the correction never landed in the body. Author must fix the description line.
📝 [verified] The author's own back-to-back padded-M timings (Nov 30 PR comment, MI355X) show two of the four padded-M shapes added to op_tests/test_gemm_a4w4.py slower at head — (65,32768,512) 6.17→6.21 µs and (129,32768,512) 8.64→9.16 µs (+6%) — so the padded-M dispatch buys the 549-row win at a small cost on those rows. Reviewer should ask whether those two rows should keep the previous kernel via the exact-M qualification the triton_/flydsl_ rows already have.
1 finding(s) posted inline, on the lines they are about:
csrc/opus_gemm/include/gfx950/opus_gemm_pipeline_a4w4_mxfp4_nt_bpreshuffle_gfx950.cuh:985-997— The .co split-K reduction in…
| // No agent-scope fences (on gfx950 they write back / invalidate the whole L2): the partials use system-coherent | ||
| // stores / loads that bypass the non-coherent L2, so vmcnt(0) before the relaxed device-scope counter is enough. | ||
| s_waitcnt_vmcnt(0_I); | ||
| sync_threads(); | ||
| if (thread_id_x() == 0) { | ||
| const int arrived = __scoped_atomic_fetch_add(&counters[tile_id], 1, __ATOMIC_RELAXED, __MEMORY_SCOPE_DEVICE); | ||
| const int last = arrived == split_k - 1; | ||
| if (last) __scoped_atomic_store_n(&counters[tile_id], 0, __ATOMIC_RELAXED, __MEMORY_SCOPE_DEVICE); | ||
| *sk_last_p = last; | ||
| } | ||
| s_waitcnt_lgkmcnt(0_I); | ||
| sync_threads(); | ||
| if (!*sk_last_p) return; |
There was a problem hiding this comment.
|
Shape-coverage check of this PR's kernel selection at head Routing coverage:
Gaps:
|
Summary
Add an OPUS backend for MXFP4 x MXFP4 NT GEMM with B preshuffle on gfx950. gemm_a4w4(bpreshuffle=True) interface to select tuned OPUS kernels.
Details
Speedup Distribution
Of the 1464 gfx950 / CU 256 shapes in
aiter/configs/a4w4_blockscale_tuned_gemm.csv, the tuned table selects OPUS for 549. Speedup isbase_us / head_us - 1, from theuscolumn of this PR's CSV and of upstream/main's CSV for the same shape.