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 |
87d9ffd to
ad4ab51
Compare
Extends the gfx950 OPUS MXFP8 blockscale GEMM (FP8 A / B, E8M0 scales 1x128 for A and 128x128 for B, BF16 C) from NT to the three other operand layouts, without a transpose copy. Stacked on PR ROCm#7387. - One pipeline / traits pair for the three directions: opus_gemm_pipeline_mxfp8_4wave_gfx950.cuh / opus_gemm_traits_mxfp8_4wave_gfx950.cuh. Each operand picks its LDS path from its storage: A_T (A stored [K, M]) and B_T (B stored [K, N]) read with ds_read_tr8; NN = (0, 1), TT = (1, 0), TN = (1, 1). 2x2 waves, LDS-DMA copies, A / B and part of C pinned to AGPRs; TR8 reads use the ds_read_tr8 builtin so their results land in AGPRs. - Traits <BM, BN, PadM, GroupM>: 256x256 or 256x128 tiles, optional PadM, GroupM 0 (2x2 raster) / 4 / 8 / 16 as NT's gm. - CO kids 56-85, appended to co_kernels_gfx950_a8w8_blockscale_bpreshuffle.json; images and build records in gen_co/gfx950/a8w8_blockscale_bpreshuffle/ (pin toolchain, 0 spills): 56-67 NN / TT / TN x {256x256, 256x256 PadM, 256x128, 256x128 PadM} 68-85 NN / TT / TN x {256x256, 256x128} x GroupM {4, 8, 16} - Same kargs and launcher family as NT (a8w8_blockscale_bpreshuffle); the direction comes from the kernel name (_mxfp8_(nn|tt|tn)_) and the generated launcher checks that direction's operand / scale strides. - Called through the public exact-kid entry opus_gemm(..., family= "a8w8_blockscale_bpreshuffle", layout="bpreshuffle", kid=56..85); a tensor layout of another direction is rejected by the launcher's stride check. The shape heuristic / tuner never pick the direction kids. Like the other gfx950 MXFP8 kids they are compiled on request (tuned rows, the compiled-kids sidecar or opus_gemm_tune._ensure_kids_compiled), not by default. - build_co: the pin check of the direction kids accepts AGPR ranges filled by plain or TR8 LDS reads. - test_opus_co_integration.py: NN / TT / TN kids (256x256 across the scale panel, 256x128 PadM, GroupM 16) against a torch reference, and another direction's launcher rejecting the strides. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ad4ab51 to
8673a97
Compare
… TT / TN - aiter.ops.opus.gemm_a8w8_blockscale_bpreshuffle_opus(XQ, WQ, x_scale, w_scale, dtype, *, kernelId=None, out=None): reads NN / TT / TN from the operand strides, rejects NT, and picks a kid by shape when kernelId is not given (256x128 for N % 256 or outputs up to 2048 x 2048, GroupM 16 from M = 16384, PadM only when M % 256). - default_compiled_keys adds kids 56-85 on gfx950, so the API runs on a fresh JIT build; no tuned row or heuristic requests these kids. - test_opus_co_integration: every kid 56-85 against the reference, plus API tests (shape-picked kid per layout, explicit kernelId + out, NT and unsupported-shape rejection). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…T / TN Merge _BPRESHUFFLE_ARGUMENTS and _mxfp8_direction_arguments into one _bpreshuffle_arguments(direction) template; only the XQ/WQ layout check, the scale layout check and stride_a / stride_b / stride_sfb differ per direction. Read the direction from the CO manifest "pipeline" field instead of matching the kernel name. Generated NT sources (8784 instances) are byte-identical; the 30 NN/TT/TN sources differ by one line break only. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Replace the kernel-name regex MXFP8_DIRECTION_PATTERN with mxfp8_direction(entry), which maps the manifest "pipeline" field (mxfp8_nn / mxfp8_tt / mxfp8_tn) to "NN" / "TT" / "TN". Used by the candidate filter, default_compiled_keys, the gfx950 host codegen, the build_co pin check and the gemm_a8w8_blockscale_bpreshuffle_opus kid selection. Same 30 direction kids as before; generated sources are byte-identical and the 30 rebuilt .co disassemble identically. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Training callers (dgrad / wgrad) pass activations and gradients as B, so B
must not need shuffle_weight, as in DeepGEMM's fp8_gemm_{nt,nn,tn,tt}.
- B reuses A's copy / LDS / read layout builders (N as M): K-contiguous
storage reads with ds_read_b128, [K, N] storage with ds_read_b64_tr_b8 and
the same XOR swizzle as A_T. The shuffled-B builders are removed.
- Add plain NT, (A_T, B_T) = (0, 0): kids 86-95 (pipeline mxfp8_nt), the
same 10 tile variants as each other layout. The 256x256 A-first schedule
splits A reloads by a_chunks (NT's plain A has 2 chunks per fragment).
- Non-NN-schedule B copies use per-pass layouts, which keeps B's buffer
resource in SGPRs (no waterfall loops in TN GroupM / TT PadM).
- Rename the API to gemm_a8w8_blockscale_opus; it accepts NT as well.
- Rebuild all 40 COs (kids 56-95) and sync build_info.json.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
[M, K] / [N, K] operand slots hold 8 rows of 128 bytes, so the plain ds_read_b128 operand reads hit the same banks: SQ_LDS_BANK_CONFLICT per 8192^3 call was 18.7M for NN (A) and TT (B) and 35.5M for NT (both), against 2.0M for TN. Pad these slots by 64 bytes and store chunk c of row r at c ^ (r % 4) (copy lane permutation + a constant per-lane read shift); every layout is now at 2.0M. The pad / swizzle pair was picked with an LDS microbenchmark of the reader's addresses. 256x256 NT / NN / TT get 1.5-7% faster; 256x128, GroupM and TN are unchanged. Rebuild the 40 COs (kids 56-95). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…MXFP8 The NT / NN / TT / TN kernels take plain B, so they no longer live with the preshuffled-B COs: - kids 56-95 move to gen_co/co_kernels_gfx950_a8w8_blockscale.json and gen_co/gfx950/a8w8_blockscale/ (with their own build_info.json); the bpreshuffle manifest and directory are back to their ROCm#7387 contents. - each manifest entry carries its image_dir; the CO loader takes the image path relative to gen_co/gfx950/, and build_co writes to the kids' own directory by default. - headers renamed to opus_gemm_{pipeline,traits}_a8w8_blockscale_mxfp8_4wave_gfx950.cuh. The 40 COs are moved, not rebuilt; rebuilding them from the renamed sources gives identical disassembly. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… bpreshuffle Stacked on ROCm#7387 / ROCm#8283. Two gfx950 families of one pre-compiled 2x2 pipeline (opus_gemm_pipeline_a8w8_mxfp8_gfx950.cuh, traits B_SHUF picks the B layout), each with the same 17 tiles / variants (nob 256x256; np 256x256 / 256x128 / 128x256 / 128x128 / 192x256 / 256x192; persistent and split-K on those tiles but 256x256, which runs out of registers there): - a8w8_mxfp8: kids 100-116, plain operands, one image per layout <name>_<nt|nn|tt|tn>.co (68 .co); the launcher picks NT / NN / TT / TN from the XQ / WQ strides. B is copied and read as the mirror of A: B [N, K] with A [M, K]'s LDS swizzle, B stored [K, N] k-major + ds_read_tr8 as A stored [K, M]. A stored [K, M] needs M % 16, B stored [K, N] N % 16. - a8w8_mxfp8_bpreshuffle: kids 0-16 (kid + 100 is the same tile / variant in a8w8_mxfp8), NT with B = shuffle_weight(w, (16, 16)) (the input of gemm_a8w8_mxfp8_bpreshuffle), one image <name>.co (17 .co). Row-major 1x32 e8m0 scales, bf16 C, per-tile 64-bit C base (outputs past 4 GiB), split-K partials summed by splitk_reduce_kernel. gemm_a8w8_mxfp8_bpreshuffle routes libtype "opus" tuned rows to the bpreshuffle kids; the mxfp8 tuner times them; DSV4 gfx950 1x32 M >= 1024 rows retuned (OPUS on 18 of 18). C++ entries opus_gemm_a8w8_mxfp8_launch / opus_gemm_a8w8_mxfp8_bpreshuffle_launch (one shared check, per-family kid tables). gfx950 pre-compiled kernel infrastructure (on ROCm#8283's loader / build_co): - opus_co_launch_gfx950.cuh: opus_co_launch_gfx950<int KARGS_BYTES = 96> for the 112-byte MXFP8 kargs; the launchers load "<family>/<name>.co" through ROCm#8283's co_kernel(symbol, image relative to gen_co/gfx950/). - build_co.py --arch gfx950 --family a8w8_mxfp8 | a8w8_mxfp8_bpreshuffle builds a family on its own (as ROCm#7983's a4w4): device-only clang++ on the pin toolchain, -cuid pinned, into gen_co/gfx950/<family>/ with its build_info.json. The blockscale build is unchanged (the default family). - gen_instances.py: host launchers marked splitk_reduce_arch emit the reduce TU. - tuner: opus_mxfp8_candidates / run_gemm_opus_mxfp8 beside the blockscale OPUS search (only blockscale kids go to ensure_opus_kids_compiled). MXFP8 names are prefixed (a8w8_mxfp8_co_kernels_declared, ...), so nothing collides with gfx950_co_kernels_declared / opus_candidates / run_gemm_opus. The 85 .co are byte-reproducible with the build above. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The NT / NN / TT / TN kernels take plain B, so they no longer register under a8w8_blockscale_bpreshuffle or need layout="bpreshuffle": - new family a8w8_blockscale_mxfp8 (kernel tag a8w8_blockscale_mxfp8, layout "plain", BF16 Y), gfx950 only, own kid space 0-39: NT 0-9, NN 10-19, TT 20-29, TN 30-39 (manifest renumbered; COs unchanged). - C++ entry opus_gemm_a8w8_blockscale_mxfp8_launch with its own gfx950 kid table (GENERATE_A8W8_BLOCKSCALE_MXFP8_KID_DISPATCH_GFX950). - opus_gemm(..., family="a8w8_blockscale_mxfp8", layout="plain", kid=...) and gemm_a8w8_blockscale_opus route through it. - The family is compiled as a mandatory family, so candidate_kids_for_shape and default_compiled_keys are back to ROCm#7387. - build_co --family selects the gfx950 CO manifest. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… bpreshuffle Stacked on ROCm#7387 / ROCm#8283. Two gfx950 families of one pre-compiled 2x2 pipeline (opus_gemm_pipeline_a8w8_mxfp8_gfx950.cuh, traits B_SHUF picks the B layout), each with the same 17 tiles / variants (nob 256x256; np 256x256 / 256x128 / 128x256 / 128x128 / 192x256 / 256x192; persistent and split-K on those tiles but 256x256, which runs out of registers there): - a8w8_mxfp8: kids 100-116, plain operands, one image per layout <name>_<nt|nn|tt|tn>.co (68 .co); the launcher picks NT / NN / TT / TN from the XQ / WQ strides. B is copied and read as the mirror of A: B [N, K] with A [M, K]'s LDS swizzle, B stored [K, N] k-major + ds_read_tr8 as A stored [K, M]. A stored [K, M] needs M % 16, B stored [K, N] N % 16. - a8w8_mxfp8_bpreshuffle: kids 0-16 (kid + 100 is the same tile / variant in a8w8_mxfp8), NT with B = shuffle_weight(w, (16, 16)) (the input of gemm_a8w8_mxfp8_bpreshuffle), one image <name>.co (17 .co). Row-major 1x32 e8m0 scales, bf16 C, per-tile 64-bit C base (outputs past 4 GiB), split-K partials summed by splitk_reduce_kernel. gemm_a8w8_mxfp8_bpreshuffle routes libtype "opus" tuned rows to the bpreshuffle kids; the mxfp8 tuner times them; DSV4 gfx950 1x32 M >= 1024 rows retuned (OPUS on 18 of 18). C++ entries opus_gemm_a8w8_mxfp8_launch / opus_gemm_a8w8_mxfp8_bpreshuffle_launch (one shared check, per-family kid tables). gfx950 pre-compiled kernel infrastructure (on ROCm#8283's loader / build_co): - opus_co_launch_gfx950.cuh: opus_co_launch_gfx950<int KARGS_BYTES = 96> for the 112-byte MXFP8 kargs; the launchers load "<family>/<name>.co" through ROCm#8283's co_kernel(symbol, image relative to gen_co/gfx950/). - build_co.py --arch gfx950 --family a8w8_mxfp8 | a8w8_mxfp8_bpreshuffle builds a family on its own (as ROCm#7983's a4w4): device-only clang++ on the pin toolchain, -cuid pinned, into gen_co/gfx950/<family>/ with its build_info.json. The blockscale build is unchanged (the default family). - gen_instances.py: host launchers marked splitk_reduce_arch emit the reduce TU. - tuner: opus_mxfp8_candidates / run_gemm_opus_mxfp8 beside the blockscale OPUS search (only blockscale kids go to ensure_opus_kids_compiled). MXFP8 names are prefixed (a8w8_mxfp8_co_kernels_declared, ...), so nothing collides with gfx950_co_kernels_declared / opus_candidates / run_gemm_opus. The 85 .co are byte-reproducible with the build above. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tests - _select_mxfp8_direction_kid is cached per shape (it filtered the registry on every call). - Tests: the PadM / GroupM kids at K = 1024 in all four layouts, contiguous column-major x_scale. - build_info.json: the images were built as kids 56-95 and renumbered to 0-39 without a rebuild. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…main, ROCm#8266) The CI image is on triton 3.9, which rejects scalar[None, :] in _dynamic_mxfp4_quant_kernel_asm_layout; op_tests/test_gemm_a4w4.py fails to compile it on this branch. Same line as upstream main, so a later merge of main is a no-op here. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…t-K BF16 ULP flake, ROCm#8374)
Co-Authored-By: Claude Fable 5.2 <[email protected]>
… kid pick Kernel (NT / NN / TT / TN, all 40 COs rebuilt, zero spills): - A and B are addressed from a 64-bit base per tile, or per K tile for an operand stored [K, M] / [K, N], with a range of just that view, so A, B and the output may each be 4 GiB or larger. The limit is now one view below 2**31 bytes instead of the whole operand. - K need not be a multiple of 128. A [K, M] / [K, N] view of the last K tile ends with the last K row, so the rows past K read zero. A K-contiguous operand's last tile is copied as before and then rewritten from the last 16 bytes of each row, shifted and zero-filled, which never reads past the row. The iteration that copies the last K tile runs after the steady loop. - The rows of a K-contiguous operand may be more than K apart. Launcher and shape checks: wide_input / pad_k in the CO manifest; ceil(K / 128) scale groups; K >= 16 with a K-contiguous operand. gemm_a8w8_blockscale_opus: - Any M, N, K: M is zero-padded to a multiple of 16 (XQ and x_scale), N to a multiple of 128 (WQ), K below 16 to 16, and [M, N] is cut from the padded output. - The kid pick is refitted to a sweep of every kid over 264 shapes per direction on a 256-CU gfx950: 256x128 tiles while they do not outnumber the CUs, GroupM 4 / 8 for a tall, narrow grid. Against the fastest kid it is 0.5% slower on average (was 3.2%, worst case 48%); 1.6% on 120 shapes outside the grid (was 5.2%). Not addressed: a K % 128 != 0 operand packed [M, K] / [N, K] has rows that do not start on a 128-byte boundary, which the kernel reads up to 2x slower on a small GEMM (TN, and rows a multiple of 128 apart, are unaffected). Co-Authored-By: Claude Fable 5.2 <[email protected]>
demonsan
left a comment
There was a problem hiding this comment.
Reviewed at head 633109985c5f. Nice work on the 4-layout pipeline and per-tile 64-bit addressing. Before merging, we need genuine all-shape support (and a few edge-case/hygiene fixes):
1. Support arbitrary (M, N, K) shapes natively (not via full-tensor Python padding copies)
Right now, the kernels themselves still require M % 16 == 0 (pm1 kids only; non-pm1 kids require M % 256 == 0), N % 128 == 0, and K >= 16 for K-contiguous layouts (NT/NN/TT). gemm_a8w8_blockscale_opus works around this by allocating zero-padded copies of XQ, x_scale, WQ, and Y in Python (plus a full Y[:M, :N].contiguous() copy on output), while exact-kid opus_gemm(..., family="a8w8_blockscale_mxfp8") rejects unaligned shapes outright.
For training dgrad/wgrad on large tensors, full-matrix padding copies double peak HBM and add HBM round-trips. Please support arbitrary (M, N, K) in the kernel (arbitrary M / N tail handling without full-tensor copies, e.g., column-bounded epilogue / N-tail OOB and M % 16 != 0 handling), and also handle empty tensors (M == 0 / N == 0 / K == 0) cleanly if callers pass them.
2. Shape & layout edge-case bugs in gemm_a8w8_blockscale_opus
Even with the current wrapper, several shape/layout edge cases are broken or inconsistent:
- Silent K-mismatch when
K < 16(aiter/ops/opus/gemm_op_a8w8.py:659-678):WQ.shape[1] == XQ.shape[1]is never validated before padding. For non-TN calls where bothKdimensions are< 16and differ (e.g.XQ=[16, 8],WQ=[128, 12]), both operands get zero-padded torun_k = 16, bypassing C++'sWQ.size(-1) == kcheck and silently returning wrong output. - Wide-row stride vs.
Kextent mismatch (csrc/opus_gemm/opus_gemm_common.py:3963-3966vs.csrc/opus_gemm/codegen/gen_instances_gfx950.py:3332): Python checksB_M * k <= INT32_MAX(using logicalk), whereas the C++ launcher checksB_M * XQ.stride(-2) <= INT32_MAX. A wide-row view withstride(0) > 8,388,607and smallerkpasses kid selection and then fails in C++. Also on non-gfx950 devices, an empty registry currently surfaces the misleading"below 2**31 bytes"ValueError. M=1, K=1/N=1, K=1stride ambiguity (aiter/ops/opus/gemm_op_a8w8.py:486-505):stride == (1, 1)always resolves tok_contiguous("N"/"T"), which causes explicitTT/TNkernelIdcalls to fail after padding into the wrong storage layout.- Explicit non-
pm1kernelIdwithM % 256 != 0(aiter/ops/opus/gemm_op_a8w8.py:559-568, 671):_mxfp8_run_shapealways padsMto a multiple of 16 regardless of the requestedkernelId'sm_align(256 for non-pm1kids). - Layout asymmetries:
- Strided views (
stride > M/N) are accepted for K-contiguous operands ([M, K]/[N, K]), but rejected forA_T/B_T([K, M]/[K, N], which require exact(1, M)/(1, N)). - Non-contiguous
outfails in C++ (Y.is_contiguous()) when(M, N)is already aligned, yet succeeds viaout.copy_(Y[:M, :N])when padded.
- Strided views (
3. Binary verification, reproducibility, docs & PR hygiene
.cohash check: please add a test inop_tests/test_opus_co_integration.pyverifying all 40 shipped.cofiles matchco_sha256inbuild_info.json(like the gfx1250 test) and document the exact rebuild command.- Benchmark reproducibility: please include the benchmark/sweep script (or a
--scenario benchpath) backing the latency table and the 264-shape kid-selection fit (m_tiles >= 4,n_tiles <= 8), so reviewers can reproduce numbers and re-fit for 128-CU parts. - Docs & Self-Review: please update
csrc/opus_gemm/gen_co/README.mdfor--familyandgfx950/a8w8_blockscale/, and fill in thePR Self-Reviewsection (currentlyWAITING ON AUTHOR). - PR size: at ~6.5k lines / 59 files, consider splitting into stacked PRs (1. codegen/launcher plumbing, 2. kernel headers +
.co+build_info.json, 3. Python API + tests) to make review easier.
…pies Kernel (NT / NN / TT / TN; 32 COs, zero spills, AGPR pins kept): - Every kid takes any M, N and K >= 1 and reads A, B and x_scale in place. M tiles overlap instead of being partial (the last one starts at M - 256, a single tile of 128 <= M < 256 rows puts its second half at M - 128), so the main loop is unchanged. A partial N tile is handled by the buffer bounds check on the B view and a column mask in the epilogue. - Each view ends with its operand, so every load is inside the operand or rejected. A rejected 16-byte load that holds valid bytes (the chunk with K of a K-contiguous operand, the last 16-column group in the last K row of a [K, M] / [K, N] one, the last 16 rows of x_scale) is reloaded exactly with 8 / 4 / 2 / 1-byte loads before the K tile is read. K below 16 no longer needs padding. - What only the fix-ups, the scale panel refill and the epilogue need is parked in LDS, not kept in SGPRs across the main loop. - The PadM kids are gone (every kid does what they did): 8 kids per layout, NT 0-7, NN 8-15, TT 16-23, TN 24-31. Launcher and registry: any_shape in the CO manifest replaces wide_input / pad_k; grid and scale groups round up; a [K, M] / [K, N] operand and the output may be views of a wider buffer; the view limits go by the pitch, in Python as in the launcher. gemm_a8w8_blockscale_opus: no padding and no output copy; XQ / WQ K mismatch is an error; an empty product returns an empty or zero output; a single row or column is taken by the kids of every layout; a strided-column out is rejected whatever M is; the pick may take 256x256 tiles on a ragged N; the registry is no longer read on every call. CO build: -fuse-cuid=none makes the images reproducible bit for bit; build_info.json is build_co.py's own output and a test checks the tracked images against its hashes. gen_co/README.md documents the family and the rebuild command; op_tests/op_benchmarks/hip/bench_opus_a8w8_blockscale_mxfp8.py reruns the latency table and the kid-pick sweep. Co-authored-by: Fyzyukk-AMD <[email protected]>
Nested ifs merged, a placeholder-free f-string made a plain string, imports sorted, a lambda made a def and a self-assignment dropped. No behaviour change. Co-authored-by: Fyzyukk-AMD <[email protected]>
… the launcher The tune entry looks the kid up in the registry on every call, which costs several hundred microseconds and hid the kernels behind it: every preshuffled-B kid timed about 420 us. Launch with the instance instead, and skip a kid the JIT module has no launcher for. Co-authored-by: Fyzyukk-AMD <[email protected]>
op_tests/test_opus_a8w8_blockscale_mxfp8.py follows the op_test layout: per (layout, M, N, K), gemm_a8w8_blockscale_opus against an fp32 torch reference with its time, TFLOPS and TB/s, aligned shapes next to ragged ones, and for NT the preshuffled-B kernel when the build has a launcher for one of its CO kids. It replaces op_tests/op_benchmarks/hip/bench_opus_a8w8_blockscale_mxfp8.py. Co-authored-by: Fyzyukk-AMD <[email protected]>
|
1. Support arbitrary (M, N, K) shapes natively (not via full-tensor Python padding copies) The kernels now take any M, N, K >= 1 natively. The Python wrapper no longer pads or copies, and the exact-kid path takes the same shapes. Empty tensors return an empty or zero output. Every kid takes any M, so the PadM kids are removed (8 kids per layout). 2. Shape & layout edge-case bugs in gemm_a8w8_blockscale_opus All fixed, each with a test:
Each has a test in 3. Binary verification, reproducibility, docs & PR hygiene
|
|
@aiter-bot review |
|
aiter-bot — queued behind 9 review(s); expect to start in about 2.6 h. The box reviews one PR at a time. |
@zufayu — please take a look. Re-comment |
|
@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 #8283 — [HIP] [OPUS] Add opus gfx950 blockscale_mxfp8 nn/tt/tn layout gemm
Review (advisory):
Validation (deterministic): NOT RUN — triage required the target op_tests/test_opus_a8w8_blockscale_mxfp8.py (the one test target this PR adds) but auto-validation is disabled (REVIEW_AUTO_VALIDATE=0) and this box has no idle GPU to run it by hand (all 8 GPUs ~90% busy, torch.cuda unavailable); CI at head 8e9674f ran the new tests green (Aiter Test and OPUS Test on MI35X), which is not a head-matched report.
Perf (advisory): NOT RUN — perf triage required the target (it ships the perftest harness) but no idle GPU and no validator on this box; the PR's latency table is head-only (measured against the preshuffled NT kernel and against the PR's own previous revision, not against main).
Size: 6120 lines / 53 files — over the review bar
Design (advisory): SPLIT — (1) the family plumbing: registry, codegen, launcher, dispatch and contract (opus_gemm_common.py, gen_instances_gfx950.py, gen_instances.py, opus_co_launch_gfx950.cuh, opus_gemm_arch_gfx950.cuh, opus_gemm.h, opus_gemm.cu, rocm_ops.hpp, opus_gemm_pybind.cu, dispatch.py, launch_plan.py); (2) the kernel and its binaries: the two new gfx950 pipeline/traits headers, the CO manifest, the 32 .co images, build_info.json, build_co.py, gen_co/README.md; (3) the Python API and its tests: gemm_op_a8w8.py, aiter/ops/opus/init.py, op_tests/test_opus_a8w8_blockscale_mxfp8.py, op_tests/test_opus_co_integration.py — the author's case for one PR (kernel, .co images and Python API change together) is real, but at this size a review degrades from reading to sampling; ghstack keeps the together-ness while making each part readable.
Human: recommend demonsan review whether the one-pipeline-four-layouts design of PR #8283 (shared A/B copy and LDS layouts with B passing N as M, overlapping M tiles and 32-bit-range buffer views replacing Python-side zero-padding) is the right contract for the a8w8_blockscale_mxfp8 training callers, and where the stacked seams should fall.
python3 op_tests/test_opus_a8w8_blockscale_mxfp8.py on a locked MI35X before merge.
📝 [verified] The new op ships dormant: nothing outside the two test files calls gemm_a8w8_blockscale_opus, and no consumer PR is mentioned for the DeepGEMM-style fp8_gemm_{nt,nn,tn,tt} training caller the interface mirrors. Reviewer should ask who lands the first consumer and where that work is tracked.
📝 [verified] The kid-pick rule in gemm_op_a8w8.py was fitted to a 264-shape sweep on a 256-CU gfx950 only, but the family registry maps the same 32 kids to 128-CU gfx950 parts too, where the pick's fit is stated nowhere and the kid-pick test skips unless cu_num == 256 — a 128-CU part could be getting silently suboptimal kid choices (latency only, not correctness, and unmeasured here). Author must state or measure the 128-CU fit, or scope the pick's claim to 256-CU parts.
Summary
Adds a gfx950 OPUS MXFP8 1x128 blockscale GEMM for the NT, NN, TT and TN operand layouts with plain (not shuffled) A and B, as DeepGEMM's
fp8_gemm_{nt,nn,tn,tt}. Training callers (dgrad / wgrad, where B is an activation or a gradient produced every step) run directly from the stored tensors, with no transpose copy and noshuffle_weightpass. The preshuffled-B NT kernels from #6696 / #7387 are unchanged. The kernels take any M, N and K >= 1 and read A, B and the scales in place, with no padded copy of any tensor; A, B and the output may each be 4 GiB or larger.Details
One pipeline for four layouts:
opus_gemm_pipeline_a8w8_blockscale_mxfp8_4wave_gfx950.cuh/opus_gemm_traits_a8w8_blockscale_mxfp8_4wave_gfx950.cuh. A and B share the same copy / LDS / read layouts (B passes N as M); each operand picks its path by its storage: K-contiguous ([M, K]/[N, K]) reads withds_read_b128,A_T(A stored[K, M]) /B_T(B stored[K, N]) withds_read_b64_tr_b8. NT = (0, 0), NN = (0, 1), TT = (1, 0), TN = (1, 1). Both LDS layouts are XOR-swizzled, so the operand reads are free of bank conflicts. 2x2 waves, LDS-DMA copies, A / B and part of C pinned to AGPRs.Formats: FP8 A / B as stored, E8M0 scales (1x128 for A, 128x128 for B), BF16 C. The scales have
ceil(K / 128)K groups andceil(N / 128)N groups; the last group covers the elements left.Any M, N, K in the kernel: every kid takes every shape.
[K, M]/[K, N]one, the last 16 rows of x_scale) is reloaded exactly with 8 / 4 / 2 / 1-byte loads before that K tile is read.[M, K]/[N, K]operand any pitch >= K apart, K rows of a[K, M]/[K, N]one any pitch >= M / N apart, output rows any pitch >= N apart.Kids: 8 per layout (NT 0-7, NN 8-15, TT 16-23, TN 24-31): 256x256, 256x128, and GroupM 4 / 8 / 16 of each. All 32 COs have zero VGPR / SGPR spills, no scratch, and the AGPR pins checked by the builder.
Interface: new
aiter.ops.opus.gemm_a8w8_blockscale_opus(XQ, WQ, x_scale, w_scale, *, kernelId=None, out=None). The layout is read from the operand strides (pass.t()views, never copies); withoutkernelIda kid is picked by shape. The kids also run through the exact-kidopus_gemm(..., family="a8w8_blockscale_mxfp8", layout="plain", kid=...), which takes the same shapes. An empty product (M, N or K of 0) returns an empty or zero output without a launch. A single row or column is stored both ways at once and is taken by the kids of every layout.Kid pick: 256x128 tiles while they do not outnumber the CUs, else 256x256; GroupM for a tall, narrow grid. On a sweep of every kid over 264 shapes per layout (256 CUs, three timings per kid) the pick is 1.0 - 1.2% slower than the fastest kid on average.
CO build:
-fuse-cuid=nonein the manifest makes the images reproducible bit for bit, from any checkout path.build_info.jsonisbuild_co.py's own output;gen_co/README.mdhas the rebuild command.Performance
MI355X (gfx950, 256 CUs), BF16 output, microseconds from
op_tests/test_opus_a8w8_blockscale_mxfp8.py(kid picked by shape). NT shuffle = a preshuffled-B NT CO (a8w8_blockscale_bpreshuffle) onshuffle_weight(B).Ragged shapes, us for NT / NN / TT / TN. "Before" is the previous revision of this PR, which zero-padded copies of the operands in Python.
Test Plan
op_tests/test_opus_co_integration.py -k gfx950: 619 passed. Everya8w8_blockscale_mxfp8kid against an fp32 reference on aligned and ragged shapes through the exact-kid path, wrong-layout rejection,gemm_a8w8_blockscale_opusover runs of M, N and K around the tile, half-tile, 16-row and K-tile edges, pitched operand and output views, single rows and columns, empty products, K mismatch and strided-output rejection, A / B / C past 4 GiB, views past 2 GiB rejected, the kid pick, and the tracked.coimages against the hashes inbuild_info.json. Operands are followed by FP8 NaN bytes and the output by canaries.op_tests/test_opus_a8w8_blockscale_mxfp8.py: 36 rows (4 layouts x 9 shapes), err = 0 on all.op_tests/test_opus_a8w8_interface.py: 8 passed.Test Plan
op_tests/test_opus_co_integration.py-k gfx950: 295 passed (every a8w8_blockscale_mxfp8 kid against an fp32 reference, wrong-layout rejection, gemm_a8w8_blockscale_opus with any M / N / K, wide-row views, A / B / C past 4 GiB, views past 2 GiB rejected, the kid pick).op_tests/test_opus_a8w8_interface.py: 8 passed.