Repository navigation
Description
mma_ab's N is always the subtile width, and the two places that say otherwise write past the accumulator
The bug
mma_ab walks one 64-wide output band per B subtile, offsetting the
accumulator by 64 columns each time (src/mma.rs:203-215):
while band < SharedTile::<E, K, N, S>::SUBTILES {
...
E::mma(tmem + (band as u32) * 64, ..., instruction, ...);So the instruction descriptor's N must be the subtile width, 64 — never
the tile's logical N. Its own doc says so twice ("One 64-wide output band per
B subtile"; "tmem owns 64 * B::SUBTILES fp32 columns"), and the shipped
O = P·V in feitreim/oxide-train passes M128_N64 for exactly these operand
shapes, B200-validated against two oracles.
Two places in this repo pass M128_N128 instead:
src/mma.rs:183—mma_ab's own doctest.examples/src/flash_forward.rs:174—output_shape, used at line 224
forO = P·V.
With p: SharedTile<Bf16, 128, 64> and v: SharedTile<Bf16, 64, 128>,
v has 2 subtiles, so N = 128 issues:
| band | accumulator columns written | should be |
|---|---|---|
| 0 | 0..128 | 0..64 |
| 1 | 64..192 | 64..128 |
Band 1 overwrites half of band 0's result and runs 64 columns past the
TmemTile<128, 128>. In flash_forward the allocation is 256 columns and the
output tile starts at 64, so it stays inside the allocation and faults
nothing — it just computes a wrong O.
src/tmem.rs:40 is not an instance: that is mm_abt, which issues one
instruction at tmem and no band loop, so its N is B's row count and 128
is right there. The distinction is exactly the trap.
Why it survived
examples/src/flash_forward.rs says so itself at line 19: "Status:
compiles, and is in the default build. There is no launcher and no CPU
reference, so nothing here is measured against a known-good O." That is
ferro #85's blocker, and this is the first thing it has cost — feitreim/oxide-train#68
was told to start from that file's shape, and this is the one line of it that
cannot be copied.
Fix, in two sizes
Now: change both to M128_N64. Two lines, provably right.
Properly: this is #128 part 2 restated with a casualty. MmaShape is an
argument the operands already determine — for mma_ab under a 2-byte element
and Swizzle128B the legal N is the constant 64, and there is no other
answer a caller could give. #128 proposes deriving the shape from a TmemTile
accumulator; mma_ab does not even need that much, since B::SUBTILE_COLS is
already in scope at the issue site. A const { assert!(...) } that the passed
shape's N equals SUBTILE_COLS would have failed this at codegen (tier 2)
rather than in an unvalidated example.
Acceptance
Both call sites read M128_N64, and either the shape stops being an argument
to mma_ab or a codegen assert rejects the ones that are wrong.
Activity
An MN-major B is one instruction wide, and mma_ab stops banding it (#175