Skip to content

mma_ab bands its MN-major B 64 wide, which is one shape rule too many and 1.50x off the tensor core's rate #194

Closed

Description

@feitreim

mma_ab is the one walk in src/mma.rs whose shape is not the operands' logical product. It bands its MN-major B 64 columns at a time — one instruction per stacked subtile, into tmem + 64 * subtile — so N has to name the band, and passing the product silently overlaps the bands. That is #175, which was closed by correcting the two callers that passed the product.

The other MN-major walks do not band. mma_atb and mma_atbt go through SharedTile::mn_walk, which reaches MN columns 64..128 through the descriptor's leading offset rather than a step along the row, and cover a 128-wide MN in one instruction. GAPS.md §3.3 already records that both spellings are right; docs/library/mma.md already records that the leading offset is what makes the one-instruction form possible.

Two reasons to move mma_ab onto the same spelling.

It is a shape rule that does not need to exist. With B through mn_walk, shape is [M, N] at every entry point in the module, mma_ab's doc loses its two-paragraph footnote, and the mistake #175 documents becomes unrepresentable rather than merely written down.

It is 1.50× the tensor-core rate. Measured on a B200 (oxide-train#94's cadence probe — one warp, one CTA, chained walks into a resident accumulator, 256 rounds a variant), per M128_N64_K16-equivalent of work:

walk instrs issue/instr retire/instr ticks/unit
mma_ab M128_N64×2 bands, [128, 64] × [64, 128] 2048 48.0 48.2 48.2
the same product in one M128_N128 band 1024 63.9 64.1 32.1

issue/instr equals retire/instr in both rows, so the issuing thread is back-pressured against the MMA pipe and the number is the tensor core's own rate, not a front-end toll. A quarter-width MMA costs the tensor core what a half-width one costs: the same probe puts M128_N64 at 55.7 ticks/unit against M128_N128's 32.0 and M128_N256's 32.0.

Every mma_ab caller in either repo is a [K, 128] B against a 128-column accumulator: this crate's flash_forward example, device-tests' walk_ab, and oxide-train's forward O = P·V, backward-q dQ += dS·K, and backward-kv dV += Pᵀ·dY / dK += dSᵀ·Q.

The bound the new form has and the old one did not: one leading offset reaches exactly one stacked subtile, so B is at most two of them wide (N * E::BYTES <= 2 * ATOM_BYTES). No caller is wider, and it should be a const assert rather than a wrong D.

Same products in the same K order, so it is the same sum bit for bit — device-tests' walk_ab case, which requires the same reference product from all four operand orders, is the gate.

Separately and in the same area: TmemTile::fragment issues tcgen05.ld then tcgen05.wait::ld, twice, so the .x1 path never has more than one load in flight and pays the full TMEM latency per four values. tcgen05.wait::ld retires prior loads, plural — which is the whole basis of tile_x8_batched — so the pair can be issued before either is waited on, at no liveness cost, since both arrivals are the call's return value either way. That halves the waits of every .x1 band including TmemTile::tile.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions