Repository navigation
[ASM] [Bugfix] Make the bf16 and a4w4 ASM GEMMs exact past 4 GiB - #7883
Conversation
The bf16gemm kernels address A, B and out through buffer instructions with 32-bit byte offsets. With any of them at 4 GiB or more, the output is wrong (1.6% to 100% of elements) and nothing raises. Below 4 GiB the kernels are exact. gemm_a16w16_asm now raises when A, B or out is 4 GiB or larger.
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
…n 256x256 The 256x256 kernels write fp32 output through one buffer descriptor per 256-row tile, so a whole-output limit refused shapes they compute correctly (measured exact up to 8 GiB). The check now runs after kernel selection.
The f4gemm 256x256 kernel returns wrong output without an error once A, B or out is 4 GiB or more; the other 33 preshuffled kernels are exact there. The heuristic now skips it at those sizes, and a 256x256 kernel requested by name (for example a tuned M = 8192 row reused at a larger M) is replaced by the heuristic's choice with a warning.
|
I think the real problem is that kernel is using 32bit arithmetic to compute tiles base offset. Then you can move the base ( which is 64 bit ) to the right place. Agents should be able to even patch binaries to do that. |
Every buffer descriptor in these kernels covered a whole operand: its size
(32-bit num_records) was rows x row stride from s_mul_i32, and each lane's
32-bit offset included tile_row0 x row stride. Both wrap once A, B or out
reaches 4 GiB, and the kernels then read zeros or drop stores.
Each tile now adds tile_row0 x row stride to the 48-bit descriptor base with
a 64-bit multiply-add, sizes the descriptor to min(rows - tile_row0, tile)
rows, and drops the tile term from the lane offsets. This is the addressing
the f4gemm 224x256 kernel already uses. The K loop, the partial-tile
clipping and the split-K atomics (which use the same base) are unchanged.
Patched: all 24 gfx950 bf16gemm kernels (A, B and out), and
f4gemm_bf16_per1x32Fp4_{BpreShuffle,noBpreShuffle}_256x256 (A and B, plus
the bf16 out tile size of BpreShuffle). The other 33 f4gemm kernels were
already exact past 4 GiB. Code generated from the shipped code objects by a
pattern-checked disassemble/patch/reassemble step; .text outside the patched
instructions, the kernel descriptors and the metadata are unchanged.
gemm_a16w16_asm: the gfx950 kernels now address each tile from its own 64-bit base, so the A/B/out size check only runs on gfx942, whose kernels are unchanged. gemm_a4w4_asm: the 256x256 kernels are exact past 4 GiB, so the heuristic and named requests no longer avoid them (the launcher is back to main). Tests: - test_gemm_a16w16.py: test_asm_rejects_4gib_operands becomes test_asm_4gib_operands (-t asm_4g, in the default run). On gfx950, A, B and out (bf16 and fp32) just past 4 GiB must be exact in every element for the heuristic and one kernel per family; on gfx942 they must raise. - test_gemm_a4w4.py: check_asm_4gib becomes check_asm_4gib_operands, run on gfx950. Out, A and B just past 4 GiB must be exact in every element for the heuristic, BpreShuffle_256x256 with and without split-K, and (A, B) noBpreShuffle_256x256.
The 22 gfx942 bf16gemm split-K kernels have the same 4 GiB wrap as the gfx950 ones: each buffer descriptor's 32-bit size and each lane's 32-bit offset include tile_row0 x row stride, so A, B or out at or past 4 GiB give wrong results without faulting. Each code object is its gfx950 sibling with only the ELF e_flags target byte changed, so they get the same 64-bit per-tile base: tile_row0 x row stride added to the 48-bit descriptor base, the descriptor sized to min(rows - tile_row0, tile) rows, and the tile term dropped from the lane offsets, for A, B and out (stores and split-K atomics). Each patched code object is again the patched gfx950 sibling with only e_flags changed. The kernel descriptors and metadata are unchanged.
…x942 gemm_a16w16_asm: the gfx942 kernels now address each tile from its own 64-bit base too, so the launcher no longer rejects A, B or out of 4 GiB or more on gfx942 (the file is back to main). test_gemm_a16w16.py: test_asm_4gib_operands expects exact results on gfx942 as well, for the heuristic and one kernel per gfx942 family (64x64_pf3_splitk, 64x64_bshuffle_splitk, 64x64_splitk_clean, 64x64_bshuffle_splitk_clean); the 256x256 kernels exist only on gfx950.
The gfx942 kernels compute 32-bit offsets for every row of the last tile, including the rows past M, and those stores wrap onto the first rows. With M = 16383 (out 256 KiB below 4 GiB) the 160x64 kernel returned rows 0-95 wrong, so the check now rounds M and N up to whole tiles.
…the check removed
#7883 makes the gfx950 ASM GEMMs exact past 4 GiB. On gfx942 no shipped ASM row can be reused at a shape with a 4 GiB operand: the rows stop at M=7296 with N, K <= 6144, and getPaddedM only rounds M up by at most 128 or maps it to 8192.
The K loop moves each A/B descriptor base forward by one K step and lowers num_records by the same step, so the window end stays put. With a per-tile size of min(rows - tile_row0, tile) x row stride, a last tile of one or two rows is smaller than the prefetch distance at small K, so num_records wrapped below zero and the prefetches past the end of K read past the end of A or B (a GPU memory fault when the operand ends an allocation, e.g. 64x64_pf3_splitk M=65 K=64). Each such s_sub_u32 is now followed by s_cselect_b32 nr, 0, nr, which keeps num_records at 0 on borrow, so those loads are clipped as they were with the whole-operand size. SCC is only read by the new instruction, and no SGPR is added. The split-K kernels lower num_records only before the K loop (5 or 6 sites); the 256x256 bf16gemm and f4gemm kernels do it 11 to 13 times, 4 per K-loop body of 200 to 440 instructions. This also removes the original kernels' fault when all of A is one or two rows at small K. The gfx942 code objects are again their gfx950 siblings with only the ELF e_flags target byte changed; kernel descriptors and metadata are unchanged.
test_gemm_a16w16.py: test_asm_last_tile_at_allocation_end (-t asm_4g, in the default run, gfx942 and gfx950) places A at the end of a 64 MiB allocation with M = tile + 1 or 2 and K = 64 or 128, and checks every element for the heuristic, 64x64_pf3_splitk, 64x64_bshuffle_splitk, 64x64_splitk_clean at split 2 and, on gfx950, 256x256 and 256x256_bpreshuffle. A read past the end of A is a GPU memory fault, which aborts the test process. test_gemm_a4w4.py: check_asm_last_tile_at_allocation_end does the same on gfx950 for BpreShuffle_256x256 (split 0 and 1) and noBpreShuffle_256x256 with M = 257 or 258, K = 256 or 512.
There the heuristic picks 32x64_bshuffle_splitk_clean at split 1 without a semaphore, which faults at address 0 on main as well.
|
@JohnNikolay84 Thanks for the suggestion. I followed it: the kernels now compute each tile's offset in 64 bits and move the 64-bit descriptor base there, and the binaries are patched. The description has the details. In short:
The per-kernel assembly diffs, the patch script and a script that rebuilds all 48 code objects from |
Keep A and out past 4 GiB and a 1-row last tile at the end of an allocation for each separately built kind (plain-B and preshuffled-B split-K, *_clean, 256x256, f4gemm BpreShuffle_256x256 at log2_k_split 0). Drop the heuristic cases (the K = 64 pick depends on unordered_map order), B and FP32-output cases, 2-row tails, noBpreShuffle_256x256 and a4w4 split-K, and the free-memory skip. Run the a4w4 checks only with the default shapes, after the summary.
READY FOR HUMAN REVIEWPR Self-ReviewRevision Author self-review accepted. Readiness report: Author answers
Show the author's self-review answersBehavior and intentValidation and unverified scopePR-specific questionChanged op testsPR state
Copilot findings
Code and op-test hygiene
Required CI
Shadow mode reports what would block but keeps the status successful. Set |
JohnNikolay84
left a comment
There was a problem hiding this comment.
there are still unresolved comments
The asm 4 GiB and allocation-end checks now read the kernel names from the CSV tables that the launchers read (hsa/<gfx>/bf16gemm and hsa/<gfx>/f4gemm). The tests no longer name kernels in string literals. - test_gemm_a16w16.py: the checks run every kernel in the bf16gemm table. The splitK column selects the split-K setup and the output dtype. - test_gemm_a4w4.py: the checks run every f4gemm kernel with bpreshuffle=1 and ps=0. N is 512, so 128x512 gets a whole N tile. - The allocation-end M is tileM + 1 from the table, so each kernel gets a 1-row last tile.
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]>
Summary
Two ASM GEMM ops return wrong output, without an error, once A, B or the output reaches 4 GiB: their kernels address each operand through one buffer descriptor whose 32-bit size and 32-bit lane offsets wrap at 4 GiB. This PR patches the code objects so every tile addresses memory from its own 64-bit base:
gemm_a16w16_asm(bf16gemm kernels): all 24 gfx950 kernels and all 22 gfx942 kernels (the gfx950 set without the two 256x256 kernels).gemm_a4w4_asm(f4gemm kernels), gfx950: the two 256x256 kernels. The other 33 f4gemm kernels already use a 64-bit base per tile: I measured all 33 exact with the output past 4 GiB, 15 of them with A and 21 with B past 4 GiB, and checked the rest in their disassembly.mainhas since added a persistentBpreShuffle_256x256_pskernel ([ASM] [HIP] [CK] Add persistent gfx950 f4gemm 256x256 kernel (_ps) #6067), which this PR does not change: it is exact with the output past 4 GiB, and its launcher check keeps A and B below 4 GiB, so larger A or B falls back to the patchedBpreShuffle_256x256.Below 4 GiB nothing changes: outputs at normal shapes are bit-identical to the original kernels' (except split-K with atomic accumulation, whose summation order varies from run to run anyway), and kernel times show no consistent change. The launchers are not changed.
The kernels have no sources in the repository, so the patched code objects were produced by disassembling, patching and reassembling the shipped ones. This gist has the per-kernel assembly diffs, the patch script, a script that regenerates all 48 code objects from
mainbyte for byte, and the validation harness; start with0_README.md.Motivation
Kernel names. bf16gemm kernels are named
bf16gemm_{bf16,fp32bf16}_tn_<tileM>x<tileN>[_variant], f4gemm kernelsf4gemm_bf16_per1x32Fp4_{BpreShuffle,noBpreShuffle}_<tileM>x<tileN>. In the variants,bshuffleandbpreshuffletake a preshuffled B;pf3takes a plain B.*_splitkkernels without_cleanrun without splitting K. Only*_splitk_cleankernels split K: each K slice adds its partial sum atomically into the output, and the slices coordinate through a 16 × 64 semaphore workspace, which limits the grid to 1024 workgroups. (ColumnsbPreshuffle,pfandsplitKofhsa/<arch>/bf16gemm/bf16gemm_fp32bf16.csv.)The bug. These kernels access memory only through buffer descriptors. In the affected kernels each A and B descriptor covered the whole operand: its size (
num_records, 32 bits) was rows × row stride, computed withs_mul_i32, which keeps only the low 32 bits, and each lane's 32-bit offset included the tile's first row × row stride. Both wrap at 4 GiB. Loads past the wrapped size return zeros, and stores past it are dropped, so the kernel never faults. The output descriptor of some kernels already had a per-tile base, but its size, (M − tile's first row) × row stride, wraps for the first tiles in the same way.Measured on MI355X (gfx950) with unpatched
main, kernel selected by passing its name, every output element compared with an fp32 reference. "At 4 GiB" means the operand is the smallest tile-aligned size of at least 2³² bytes. Fraction of the output that is wrong:256x256,256x256_bpreshuffle64x64_pf3_splitk,160x64_bshuffle_splitk32x64_splitk_clean,128x64_bshuffle_splitk_clean(split-K 4)BpreShuffle_256x256³noBpreShuffle_256x256¹ The 256x256 bf16gemm kernels write FP32 output on a separate store path that already used a per-tile base and size.
² With at most 1024 workgroups, the output of a
*_cleankernel stays far below 4 GiB.³ With
log2_k_split0 (the a4w4 launcher's split-K setting, log₂ of the number of K slices), at M × N × K = 1048576 × 256 × 8192 for A and 256 × 1048576 × 8192 for B; withlog2_k_split1, 75%.⁴ At M × N × K = 20000 × 107520 × 512 (4.005 GiB of output): the first tile's output size wraps to the 5.8 MB past 4 GiB (27 rows), so that tile's stores from row 27 on are dropped.
⁵ When M is a multiple of 256; see "Existing bugs not fixed here".
On gfx942 (MI300X) the original kernels gave the same fractions (A and B 77%, output 100%,
*_clean68%).One step below each limit (one row or column less), every kernel is exact, with one exception. When the last M tile is partial, some original kernels already fail just below 4 GiB of output: they compute offsets for the tile's rows past M, and those wrap onto the first rows. For example, at M = 16383,
160x64_bshuffle_splitkreturns rows 0–95 wrong, and the kernels with 48- and 96-row tiles return rows 0–31 wrong, on both architectures. The patch fixes this case too.How these shapes are reached today.
tgemm.mm(aiter/tuned_gemm.py) andgemm_a4w4(aiter/ops/gemm_op_a4w4.py) look up (M, N, K) in a tuned-config CSV (aiter/configs/bf16_tuned_gemm.csv,aiter/configs/a4w4_blockscale_tuned_gemm.csvand the per-model files inaiter/configs/model_configs/). If no row matches M, they retry with M padded (get_padded_minaiter/ops/gemm_op_common.py); the coarsest padding maps every M above 8192 to 8192. When an ASM launcher gets no kernel name, it picks a kernel by its own heuristic.tgemm.mmwith a preshuffled weight and no tuned row uses ASM at any size; no other backend handles that layout.llama70Brow for N = 57344, K = 8192 (256x256, tuned at M = 8192) also serves M = 40960, where rows from 3510 on come back wrong.BpreShuffle_256x256row tuned at M = 8192: one ina4w4_blockscale_tuned_gemm.csvand 14 in the per-model files. The other rows at M = 8192 nameBpreShuffle_256x256_ps. For example,gemm_a4w4at N = 59136, K = 8192, M = 36352 (a 4.004 GiB output) uses the M = 8192 row; with the original code object, 0.6% of the output is wrong.256x256at such sizes when_pscannot take the call, for example with A or B of 4 GiB or more; otherwise_psreplaces it.Changes
Code objects (48):
hsa/gfx950/bf16gemm/*.co(24),hsa/gfx942/bf16gemm/*.co(22) andhsa/gfx950/f4gemm/f4gemm_bf16_per1x32Fp4_{BpreShuffle,noBpreShuffle}_256x256.co(2).What each tile now does, for A, B and (where it did not already have a per-tile base) the output:
s_mul_i32/s_mul_hi_u32,s_add_u32/s_addc_u32);min(rows - first_row, tile) × row stride, so the hardware still clips the partial last tile;s_sub_u32 nr, nr, step), so the end of the descriptor stays put. The prefetches continue past the end of K. With a whole-operand size that never went below zero, but a size covering only a last tile of 1–2 rows would wrap and let those prefetches read past the end of A. Each suchs_sub_u32is now followed bys_cselect_b32 nr, 0, nr, which sets the size to 0 on borrow. That clips exactly what the original clipped: everything at or past the end of the operand.The f4gemm 224x256 kernel already addresses memory this way. The split-K atomics use the same per-tile base. Kernel descriptors and metadata are unchanged, and no new SGPRs are used.
Cost: the split-K kernels gain 26–27 scalar instructions, all before the K loop. The 256x256 kernels gain 25–28, of which 4 are in the K loop body (a body of 205–443 instructions).
How the code objects were produced:
co_tool.pyin the gist disassembles a code object into reassemblable assembly and reassembles it;patch64.pyapplies the rewrites. Every rewrite matches an exact instruction sequence, with an asserted match count per kernel. It also checks that every scratch register it writes is dead afterwards, and asserts every write and scalar read of each saturated size register. The shipped gfx942 bf16gemm code objects are byte-identical to their gfx950 siblings except the target byte in the ELF header, so the same rewrites apply unchanged.Excerpt:
f4gemm_bf16_per1x32Fp4_BpreShuffle_256x256, A descriptor, lane offset and one prefetchLaunchers (
csrc/py_itfs_cu/asm_gemm_a16w16.cu,csrc/py_itfs_cu/asm_gemm_a4w4.cu): no change.Tests:
The tests take their kernels from the launcher tables: every bf16gemm kernel, and every f4gemm kernel with
bpreshuffle=1andps=0. The out-of-tree validation below covers every kernel and operand.op_tests/test_gemm_a16w16.py -t asm_4g, added to the file's default-tlist so the CI run includes it, on gfx950 and gfx942:test_asm_4gib_operands: A and bf16 output just past 4 GiB must be exact in every element for every non-split-K kernel inbf16gemm_fp32bf16.csv, and A (FP32 output, split 2) for every*_splitk_cleankernel.test_asm_last_tile_at_allocation_end: A at the end of a 64 MiB allocation, so a read past it faults, and a last M tile of 1 row (M = tileM + 1), at K = 64 and 128 for every non-split-K kernel, and K = 128 at split 2 for every*_splitk_cleankernel. Every element must be exact.op_tests/test_gemm_a4w4.py, run on gfx950 after the summary table, with the default shapes only (not with-mnkor--csv):check_asm_4gib_operands: output and A just past 4 GiB must be exact for every f4gemm kernel withbpreshuffle=1andps=0(34 on gfx950), atlog2_k_split0. A uses N = 512.check_asm_last_tile_at_allocation_end: the same allocation-end check for those kernels, M = tile_M + 1, N = 512, K = 256 and 512.Remaining limits. Each descriptor now covers at most one tile, so the limits are per tile: one tile's rows of A, B and the output must each span less than 4 GiB.
Performance (if applicable)
Each code object was timed with
aiter.test_common.run_perftestin 6 separate processes on one GPU, alternating original and patched. For each shape, the table gives the change in the minimum and in the median of the 6 per-process times.BpreShuffle_256x256, 3 bf16256x256, 8 bf16 split-K), 3 FP32-output or split-K variants of those, and 6 shapes for kernels no tuned row selectsThere is no consistent direction. The +5.5% median on gfx942 (
64x64_splitk_clean, M × N × K = 7168 × 64 × 4096) comes from processes that run in one of two modes: both the original and the patched kernel take about 19.4 µs or 21.4 µs per process, and the patched kernel drew the slow mode in 3 of 6 processes, the original in 1. Its minimum changes by +0.6%. On gfx950 the 1024 × 16384 × 6656 split-K shapes show the same two-mode behaviour.Testing
Documentation
Dependencies
Breaking Changes
None. On gfx950 and gfx942, shapes with A, B or output of 4 GiB or more now compute correctly instead of returning wrong values.
Merge notes.
-tlist inop_tests/test_gemm_a16w16.py, so whichever merges second needs a one-line merge.PR Self-Review
Reviewed revision
07742a9
Behavior and intent
The 24 gfx950 and 22 gfx942 bf16gemm code objects and the two gfx950 f4gemm 256x256 code objects now give each tile its own 64-bit descriptor base, so
gemm_a16w16_asm(gfx950, gfx942) andgemm_a4w4_asm(gfx950) compute A, B and output of 4 GiB or more correctly, where they used to return wrong output without an error. Below 4 GiB the outputs are unchanged.Validation and unverified scope
The measurements below ran at 49635be. This revision merges
main, which addsBpreShuffle_256x256_ps(#6067), a launcher check for it, retuned a4w4 rows and a split-K test intest_gemm_a4w4.py; the changes of this PR are the same. At this revision, on MI355X:_psis exact with the output at 4.005 and 4.06 GiB (M × N × K = 20192 and 20480 × 106496 × 512) and through its tuned row at 20192 × 106496 × 16384, and the launcher rejects it with A at 4 GiB.gemm_a4w4at 36352 × 59136 × 8192 (tuned rowBpreShuffle_256x256) is exact with the patched code object, and 12909406 of 2149711872 elements are wrong with the original.CI. At edce462 (49635be plus a
mainmerge), the CI rantest_gemm_a16w16.pyon MI355X (17asm_4gcases exact) and MI300X (11 exact), andtest_gemm_a4w4.pyon MI355X (4 exact) and MI300X; all passed. At this revision the tests run 72asm_4gcases on MI355X, 64 on MI300X and 136 a4w4 cases on MI355X.Method. Original (
main) and patched code objects were run with the same launcher build, one process per case, kernel selected by name, every output element compared with an fp32 reference (computed from the bf16 inputs, or from the dequantized FP4 inputs for a4w4). The harness in the gist, used for the gfx942 runs, also checks that a guard region after the output stays untouched. Allocation-end cases place A or B at the end of an allocation and confirm that the memory after it is unmapped, so a read past it faults.Reproducing. In the gist:
reproduce.sh MAIN_CHECKOUT PR_CHECKOUTregenerates the 48 code objects frommain's and compares them with this branch (all 48 identical);make_cases.pyandrun.pyrun the bf16gemm correctness, allocation-end and performance cases on either architecture (instructions in0_README.md). The op tests:python3 op_tests/test_gemm_a16w16.py(default-tlist, includesasm_4g) andpython3 op_tests/test_gemm_a4w4.py.Disassembly round trip. Disassembling and reassembling without patches gives back byte-identical code, kernel descriptors and metadata for all 81 shipped code objects of these directories: 59 on gfx950 (24 bf16gemm, 35 f4gemm) and 22 on gfx942.
MI355X (gfx950):
*_cleankernels: A and B at split-K 4.BpreShuffle_256x256: exact withlog2_k_split0 and 1 for A at 4 GiB and at 6 GiB with a partial last M tile, B at 4 and 6 GiB, and output at 4.005, 4.05, 8.0 and 8.01 GiB.noBpreShuffle_256x256: exact for A at 4 and 6 GiB, B at 4 and 6 GiB, and output at 4.05 and 8.0 GiB.*_splitk_cleankernel without a semaphore, 1 isnoBpreShuffle_256x256reading past the end of B (both under "Existing bugs not fixed here").s_cselect_b32saturation removed, the patched kernels fault in 170, which is what the allocation-end op tests guard against.python3 op_tests/test_gemm_a16w16.pypasses;-t asm_4gruns 72 cases on MI355X, all exact (36 past 4 GiB, 36 allocation-end). The a4w4 checks run 136 cases, all exact (68 and 68). With the original code objects the allocation-end cases pass and the 4 GiB checks fail on their first case; with the saturation removed, both files fault on their first allocation-end case.test_gemm_a16w16.pycan also log twocheckAllclose failedlines at 64 × 256 × 5120, also onmain: there, bf16-output split-K (split 16) adds each partial sum into the bf16 output, so rounding accumulates; FP32 output is exact.MI300X (gfx942), with the gfx942 code objects of this revision:
python3 op_tests/test_gemm_a16w16.py -t asm_4gexited 0 with all 30 cases exact. This revision runs 64 cases on gfx942 (32 past 4 GiB, 32 allocation-end), every kernel in the gfx942 table.Unverified:
*_256x256_4x4_pskernels: neither measured nor changed; they behave as onmain.BpreShuffle_256x256_ps: not changed, and measured only with the output past 4 GiB (above); not measured with an operand at the end of an allocation.Existing bugs not fixed here (also on
main, independent of 4 GiB):Without a kernel name, the bf16 launcher can run a
*_splitk_cleankernel with a null semaphore pointer, which faults at address 0. This happens in two cases:std::unordered_map) decides which one wins, so the op tests do not run the heuristic.splitK=1,gemm_a16w16_asmpasses an empty semaphore tensor. The heuristic ignores the requested split and can still pick such a kernel at split 2 or more (for example M = 64 or 257, N = 256, K = 128, on gfx950 and gfx942).Every shipped ASM tuned row names its kernel, so tuned shapes in
tgemm.mmreach neither case.noBpreShuffle_256x256reads past the end of B when B ends an allocation (its B descriptor size is not lowered in the K loop, so there is nothing to saturate). It also writes whole 256-row tiles when M % 256 ≠ 0, past the output thatgemm_a4w4allocates with M rounded up to a multiple of 32. Either can fault, or the write can overwrite the allocation that follows.Both f4gemm 256x256 kernels give wrong values in some rows when N % 256 ≠ 0 and
log2_k_split= 0. Their stores are bounded per tile, not per row, so the partial N tile's columns from N on land in the next row.PR-specific question
Which architecture, dtype and shape boundaries select the changed kernel path, and what invariant prevents unsupported inputs from reaching it?
The patched code objects are the ones
gemm_a16w16_asmloads on gfx950 and gfx942 (bf16 input, bf16 or FP32 output) andgemm_a4w4_asmloads on gfx950 (bf16 output), whether the kernel was picked by heuristic, tuned row or name. There is no size gate: each descriptor covers at most one tile, so the only limits left are per tile (see "Remaining limits" under Changes).Changed op tests
op_tests/test_gemm_a16w16.py(-t asm_4g, gfx950 and gfx942): no existing test runs the ASM kernels near 4 GiB or with an operand at the end of an allocation. Onmainthe 4 GiB check fails on its first case (A past 4 GiB, almost all of the output wrong). The allocation-end check guards the saturation: without it the patched kernels fault there.op_tests/test_gemm_a4w4.py(gfx950): the default shapes include 32768 × 106496 × 16384 (a 6.5 GiB output), but its tuned row is a 224x256 kernel, which was already correct, so no existing shape ran 256x256 at 4 GiB. Onmainthe 4 GiB check fails on its first case: rows 27–255 of the first tile come back wrong. The checks select kernels from the f4gemm table bybpreshuffle=1, ps=0, so the heuristic and_psdo not affect them.