Repository navigation
The accumulator is released at the load that last read it, and the entry that cannot ping-pong says why (#221) - #223
Merged
Merged
Conversation
…try that cannot ping-pong says why The deferred release #221 asks for is already at the `[256, N]` entries — `empty.wait(sequence - ACCUMULATORS)` is `empty(i - 2)`, the release item `i - 2` made — and cannot exist at `[512, 256]`, whose two slots are one item's two M-halves and whose allocation is already an SM's whole 512 TMEM columns. What is left there is the release's *timing*: a warp is done with the accumulator at its last band's `tcgen05.wait::ld`, not at the end of the drain, so the arrival moves there and the last band's `stmatrix` and `st.global` passes leave the next item's critical path.
…utes `bench sol-ablate` table 6 crosses the warpgroup split with the release's timing, and #221's prediction that the split's win would shrink is wrong: the split is 1.019/1.019 late and 1.020/1.021 early. The early release is 14% off the drain at two warpgroups, not all of it, and a deferred release is what the prediction needed.
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 #221.
Step zero: the two surveys were each half right, and the reconciliation is that the entries differ
#221 asked for the current release semantics before anything else. They are not
one thing — they are two, and the difference is structural rather than a choice
anyone made.
The
[256, N]entries are already deferred, and have been.Small::multiply(examples/src/gemm_sol.rs:646-648) waitsand
SemaphoreRing::<2>::wait(i - 2)(src/sync.rs:434) issem((i-2) % 2).wait(((i-2) / 2) & 1)— sloti % 2at the phase itemi - 2'srelease_accumulator(i - 2)ended. That isempty(i - SLOTS)exactly, oxide-train#86's timing, written out longhand; it is literally
wait_recycled(sequence).The 512-column allocation ping-pongs and the wait skips a generation.
The
[512, 256]entry is not deferred, and cannot be. Its waits areempty.sem(0).wait((sequence - 1) & 1)(:836-838) andempty.sem(1)at thesame generation inside
multiply_at(:791-793) — both the previous item'sdrain. But its two slots are not a ping-pong across items at all: they are the
item's own two 256-row halves of a 512-row macro-tile, both live for the
whole K walk. A deferred release needs a third
[128, 256]slot, andalloc_cluster::<512>is already the whole of an SM's tensor memory(
src/tmem.rs:15— "an SM has 512"). There is no third slot to have.docs/kernels/gemm_sol.md:165had already said this in passing ("a one-deepaccumulator interlock per half"); nobody had connected it to #197.
Which is the reconciliation #221 asked for
oxide-train's
gemm_sol_finalis a one-accumulator geometry — this tree's[256, 256]. So oxide-train PR #119's null for the warpgroup split was measuredagainst an already-deferred release, and #197's +2.1% was measured at
[512, 256], where the drain sits between an item and its successor entire. Thesame #197 table read +0.8%/+0.9% at
[256, 256]. The split's win tracks thedeferral nearly 2.5 to 1.
The arithmetic agrees to a tenth of a percent. At 8192³ the
[512, 256]entryruns 7 items a cluster in 0.5396 ms, so an item is 77 µs; #197's split cut the
drain 4.72 → 3.05 µs, and 1.67 / 77 = 2.2% against the 2.1% measured. The drain
there is exposed essentially 1:1.
What ships instead: the release moves to the load that last read the accumulator
What
[512, 256]cannot defer across items it can stop paying for inside one. Awarp is done with the accumulator the instant its last band's
tcgen05.wait::ldretires — nothing below that load reads tensor memory — butthe arrival sat at the end of
Common::drain, past that band'sstmatrixpassand past the
ld.shared/st.globalpass under it. So it moved to the lastband's load, behind one
warp::sync_mask(the same sync #218's lane guard alreadyneeds).
drainnow takes the slot it is draining;release_accumulatorhas nocall site outside it.
The interaction table — the square, one binary, same residency
bench sol-ablatetable 6 is now the cross of the warpgroup split and therelease timing rather than one of them. All four corners hold
ALL_LANESscope sothe only things moving are the two levers; each subtracts the
no drainat itsown thread count. Two passes:
8192³
[512, 256]— the entry the target shapes useone, late#221's prediction that the split's win would shrink is wrong. Two warpgroups
over one is 1.019/1.019 late and 1.020/1.021 early — the levers are additive
to within a tenth of a percent in both passes, and the best corner is both, which
is the corner that ships. The reason is in the same table: the early release takes
14-15% off the drain at two warpgroups and 7-8% at one, not the whole of it.
Three quarters of an item's drain is still standing between the accumulator and
the next MMA, and only a deferred release removes that — which is the thing this
entry cannot have.
4096³
[256, 256]— the entry that is already deferredBoth levers are nulls inside that shape's own spread — a fixed arm moves 0.0949 to
0.0961 between passes, which is larger than either effect. Which is #221 being
right about the entry it was right about.
Ratios vs cuBLASLt, three shapes
bench --case gemm-sol, ours against a cuBLASLt FP16 taken in the same process,stream and clock. Read the ratio column: the denominator held to 0.12% across the
two containers.
[256, 256][512, 256][512, 256]The 8192³ row is the one table 6 corroborates in a single container: +0.6% at two
warpgroups, both passes, against +0.58% here.
Registers, and the honest cost
Zero spill and zero stack throughout, and every gated kernel is inside its step —
but this is not free:
Against 82 / 80 / 83 before. The barrier between the last load and its landing
gives
ptxasa reason to keep more of the band alive across it. Residency here isfixed at one CTA an SM by the shared plan (229 632 B of 233 472) and no register
count can raise it, so
wants 1is still met — butgemm_sol_m512'sallowsfalls 2 → 1 and its headroom 85 → 56 registers. That is the number to watch before
the next thing is added to this epilogue, and it is called out in the docs.
Correctness
bench --case gemm-solchecks every shape against the CPU reference before itis timed, at all three entries and all three shapes.
examples: all three entries exact over every rung, worst |rel| 3.89e-3 (bf16).Arm::EXACT_DRAINS, socheckcompares theirCagainst the reference at both entries.Shape of the diff
examples/src/gemm_sol.rs—draintakesslotand releases at the lastband's load; the two epilogues drop their trailing release.
experiments/src/gemm_sol.rs— the release dial becomes two bits(
ALL_LANES/ONE_LANE/ALL_LANES_EARLY/ONE_LANE_EARLY), same arity atevery instantiation, so the shipped path and every arm move together.
experiments/src/sol_ablate.rs—Arm::PairedEarlyandArm::Wg2Early, fourkernels, and table 6 as a 2×2.
docs/kernels/gemm_sol.md— two new sections under the epilogue.