Repository navigation
An MN-major B is one instruction wide, and mma_ab stops banding it (#194) - #195
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #194.
The change
mma_abwalks its MN-majorBthroughSharedTile::mn_walk, one instruction per K chunk covering the whole[M, N], instead of oneN = 64instruction per stackedBsubtile intotmem + 64 * subtile.That is
mma_atb'sBhandling exactly — the two walks differ only in theirA— and it makesshapethe operands' logical product at every entry point in the module.mma_ab's doc loses the two paragraphs explaining why itsNwas the band's,mm_abloses the clause that referred to them, and the mistake #175 documents stops being representable:M128_N128for a[K, 128]Bis now the right answer rather than the one that overlaps the bands.New bound: one leading offset reaches one stacked subtile, so
Bis at most two of them wide. Aconstassert, not a wrongD.TmemTile::fragmentissues both of its loads before waiting on either.tcgen05.wait::ldretires prior loads, plural — the basis oftile_x8_batched— so waiting after each meant the.x1path never had more than one load in flight and paid full TMEM latency per four values. Batching costs nothing in liveness, since both arrivals are the call's return value either way, and it halves the waits of every.x1band includingTmemTile::tile.Why
Two reasons, and the second is the one that motivated it.
One shape rule fewer.
GAPS.md§3.3 already recorded that the MN-major operand has two right descriptor spellings and that the new walks use the leading-offset one;docs/library/mma.mdalready recorded that this is what letsmma_atbcover a 128-wide MN in one instruction.mma_abwas the last caller of the banding spelling.1.50× the tensor-core rate on that product. oxide-train#94's cadence probe — one warp, one CTA, chained walks into a resident accumulator, 256 rounds a variant, on a B200:
M128_N64_K16-equivalentmma_abtM128_N64K=128mma_abtM128_N128K=128mma_abtM128_N256K=128mma_abtwoN=64bands,[128,64] × [64,128]N=128bandissue/instrequalsretire/instrin every row: the issuing thread is back-pressured against a full MMA pipe, so these are the tensor core's retirement rates and not front-end tolls. A quarter-width MMA costs the tensor core what a half-width one costs, andN = 256buys nothing overN = 128.Why it is the same sum
Same operands, same products, same K order — the wide form issues chunk 0..K/16 into one accumulator where the banded form issued chunk 0..K/16 into band 0 and then into band 1. Any given output element accumulates over K in the identical order; elements are independent. Bit-identical, and stated as such rather than measured to a tolerance.
The descriptors say it too, and there is a host test for it now:
the_wide_ab_walk_keeps_the_banded_walks_chunk_addressesrequiresmn_walk's chunk address at every K chunk to equaloperand_descriptor(k_rows_offset(chunk))— the banded walk's own address arithmetic. The second 64 columns move out of a second instruction's base address and into the first's leading offset, which the existingan_mn_major_walk_reaches_the_second_subtile_by_leading_offsetalready pins.k_rows_offsetis now#[cfg(test)]: it is no longer how any walk reaches a chunk, only the independent statement of the geometry the tests holdmn_walkto.Callers updated
device-tests'walk_ab→MmaShape::M128_N128. This is the gate: themma A·Bᵀ…mma transpose controlcases run all four operand orders over one pair of logical matrices staged four ways and require the same product from each, so a wide walk that reads its second subtile wrong fails there rather than in a tolerance.examples/'flash_forwardoutput_shape→M128_N128, and the comment that explained the band rule now explains that there isn't one.mma_ab's doctest.Downstream, oxide-train has four
mma_abcall sites — the forward'sO = P·V, backward-q'sdQ += dS·K, backward-kv'sdV += Pᵀ·dYanddK += dSᵀ·Q— all[K, 128]against a 128-column accumulator, and all move toM128_N128in the pin bump.Gates
scripts/fmt --checkclean across all four manifests.cargo test— 112 lib + 82 doctests, green, including the new descriptor-equivalence test.cargo clippy --all-targets --all-featuresclean.cargo checkondevice-tests/,examples/andexperiments/.gpu-cirun: themmatranspose-control family formma_ab's product andldtm x8 mapfor the.x1path thefragmentbatching touches.