Repository navigation
An accumulator releases from one lane a warp, and the 512 arrivals it replaces measured as nothing - #218
Merged
Conversation
… replaces measured as nothing `release_accumulator` had every lane of every epilogue warp arrive on `empty`, for a fact that is one per warp: a warp is done with the accumulator when its last `tcgen05.wait::ld` has retired, and that instruction retires the warp's loads and not the lane's. #197's split doubled the epilogue's warps and doubled the count with them -- 256 arrivals a slot to 512, against oxide-train's 8 -- on the barrier between an accumulator's drain and the next item's MMA. It was the most concrete follow-up that PR's review left, and it is worth nothing. The guard is a lane test and the count `empty` is armed with is the same statement read from the other end, so both move together: [256, 256] and [512, 256] RANKS * epilogue_warps(2) * 32 = 512 -> 16 [256, 128] RANKS * epilogue_warps(1) * 32 = 256 -> 8 Nothing else arrives on `empty` at either entry. The `[512, 256]` epilogue's two halves are two slots of the same ring signalled by the same call -- which is why `Large::epilogue` stops spelling the arrival itself and calls `release_accumulator(half)`, so one lane guard covers both entries and both slots. The epilogue and the MMA warp break their item loops on the same `has_work == 0`, so a launch's last item leaves no half-signalled slot behind. What makes the guard legal is the drain's closing `warp::sync_mask`: past it, no lane of the warp still has the accumulator in flight. `bench sol-ablate` table 7 is the A/B, both arms in one container, round-robin, two passes, against the `no drain` control at the same 320 threads: 4096^3 [256, 256] all lanes 0.0980, 0.0969 ms one lane 0.0979, 0.0980 ratio 1.001, 0.989 drain 3.46 -> 3.42, 3.16 -> 3.43 us 8192^3 [512, 256] all lanes 0.5385, 0.5387 ms one lane 0.5384, 0.5387 ratio 1.000, 1.000 drain 3.13 -> 3.11, 3.19 -> 3.19 us At [512, 256] the arms agree to four figures in both passes. At [256, 256] the passes disagree in sign by less than that shape's own spread on a fixed arm -- the all-lanes row alone moves 1.1% between them. It is a null: an arrival is one atomic increment on a shared word, a warp issues its 32 in one instruction, and the waiter is a parity spin that does not care how many ended it. It ships guarded anyway, because one a warp is what the code means. `bench sol-ablate` also could not run at all before this. #197 pinned the ablation probes to ONE_WARPGROUP and took the shipped kernels to 320 threads, but `Arm::Whole` launches the shipped kernel and kept asking for 192 -- which the launch contract rejects rather than runs, so table 1 died on `block (192, 1, 1) does not match required block (320, 1, 1)` and every table after it was lost. `whole` gets pinned probes of its own at the geometry every ladder here is held at, which is what #197 intended for the other thirty-three. regcount: the gate is green and every `gemm_sol` rung reads zero stack and zero spill. `gemm_sol_m512` moves 83 -> 95 registers and `gemm_sol_m256` does not move at all, and the two arms in one crate say the guard is what did it -- `gemm_sol_m512_wg2` 84 against `gemm_sol_m512_wg2_lane` 95. Residency is fixed by the shared plan either way; the step at 320 threads is 168 and 95 leaves 73.
This was referenced Aug 6, 2026
feitreim
added a commit
that referenced
this pull request
Aug 7, 2026
…is a gate (#225) (#229) * The jump tables were #219's after all, and the census that missed it is a gate (#225) Three readings of `regcount`'s jump-table census, each from a build that `_freshen` (#228) forced and whose four crates are seen to recompile in the container log, same image and same pinned nightly: 3ae07a8 #218, before the access ladder 0 of 309 bda3329 after #219, before #227 55 of 318 (9 shipped) 09beda9 main, after #227 0 of 319 #219 introduced every `brx` in this tree and #227 removed every one of them, which is the consumer's bisect exactly. #227 reported the opposite -- 51 already present at 3ae07a8, identical counts across its own fix -- from a comparison taken across the warm cache volume #228 later found serving stale builds. Both numbers are superseded. 3ae07a8 has no `AccessWidth` to match on at all, so zero is the only count that tree can produce. Half of #225's "necessary but not sufficient" survives and half does not. No GPU entry point mounts the cache volume (#226), so #227's B200 runs at then-main really were runs of the 55-table tree and those modules really did load. `shared_drain_quad` is the half that goes: it was added on the fix branch, after the fix had put both drains back on a three-case dispatch, so it has never carried a table and it is inside main's 0 of 319. Its doc said it demonstrated a JIT taking four of them; it demonstrated nothing of the kind, and now says so. So the census arms on the condition it set for itself. A kernel in the shipped set -- `examples/` plus `GATED_KERNELS` -- carrying a `brx` fails the run; probes are printed and do not, the way the local-memory depot's are. The table stays as the diagnostic. Watched in both directions: green at this branch (0 of 319) and red at bda3329's sources under the same armed `modal_app.py`, naming the nine shipped kernels. * The access ladder's note carries the in-tree numbers, not only the consumer's
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 out the review flag #197 left as "the most concrete follow-up here".
release_accumulatorhad every lane of every epilogue warp arrive onempty,for a fact that is one per warp: a warp is done with the accumulator when its
last
tcgen05.wait::ldhas retired, and that instruction retires the warp'sloads and not the lane's. #197's split doubled the epilogue's warps and doubled
the count with them — 256 arrivals a slot to 512, against oxide-train's 8 — on
the barrier between an accumulator's drain and the next item's MMA.
It is worth nothing, measured. It ships guarded anyway, because one arrival
a warp is what the code means and 512 was an accident of where the guard was
not.
The arrival-count arithmetic
The guard is a lane test; the count
emptyis armed with is the same statementread from the other end, so both move together or the kernel deadlocks.
[256, 256],[512, 256]—RANKS · epilogue_warps(2)[256, 128]—RANKS · epilogue_warps(1)Nothing else arrives on
emptyat either entry:[512, 256]epilogue's two halves are two slots of the same ringsignalled by the same call, which is why
Large::epiloguestops spelling thearrival itself and calls
release_accumulator(half)—SemaphoreRing<2>::semtakes the index mod 2, so
sem(sequence)at the one-accumulator entries andsem(half)at the two-accumulator one are the same call. One lane guard nowcovers both entries and both slots.
has_work == 0, read from the same shared cell by all 32 lanes, so a warpleaves as a warp and a launch's last item leaves no half-signalled slot.
[512, 256]early release insidemultiply_atis a wait, not anarrival.
What makes the guard legal is [
Common::drain]'s closingwarp::sync_mask:past it, no lane of the warp still has the accumulator in flight, and nothing
else in the drain reads tensor memory.
The A/B, which is same-container
bench sol-ablategrows a table 7 — both arms at the shipped geometry and theshipped drain, differing in one const, run round-robin against the
no draincontrol at their own 320 threads. Two whole passes, because what is being looked
for is a barrier's micro-cost.
[256, 256][512, 256]At
[512, 256]the two arms agree to four figures in both passes. At[256, 256]the two passes disagree in sign, and by less than that shape's ownpass-to-pass spread on a fixed arm — the all-lanes row alone moves 0.0980 to
0.0969, 1.1%, which is larger than the 1.1% the second pass reads as a
difference. So this is a measured null, not a small win.
The reading is that 512 arrivals cost nothing because nothing serializes them:
an
mbarrier.arriveis one atomic increment against a shared-memory word, the32 lanes of a warp issue theirs in one instruction, and the MMA warp's
empty.waitis a parity spin that the last arrival ends whichever lane it camefrom. The count was never the term.
(One footnote on that run: its
arrivalscolumn printed 256 and 8, theone-warpgroup counts, because the helper feeding it divided thread counts
instead of naming the warpgroups —
threadsis affine in the warpgroups, notlinear. Display only, and fixed in this PR. The kernels derive their own count
at compile time from their own
GROUPS, and a wrong one deadlocks rather thanmismeasures — both arms ran and both are on
check.)Cross-container, which says less
bench --case gemm-sol,mainand this branch, cuBLASLt FP16 taken in eachcontainer:
[256, 256][512, 256][512, 256]Read the same-container table and not this one. The denominator moved
0.08–0.83% between the two containers, in the same direction and by more than
either arm's own difference at every shape — where #197's pair held to 0.04% at
the two large shapes, this one did not. Every row here is inside that drift, and
all three rows of the shipped kernel are checked exact against the CPU reference
before they are timed.
bench sol-ablatecould not run at all before thisWorth flagging separately, because it is a live regression on
mainrather thansomething this change touched. #197 pinned the thirty-three ablation probes to
ONE_WARPGROUPso the ladder would keep comparing against what it always did,and took the shipped kernels to 320 threads. But
Arm::Wholelaunches theshipped kernel, and its thread count went to the pinned
ONE_WARPGROUPwiththe probes — so table 1's first row asked for 192 threads from a kernel whose
launch contract requires 320, which
validate_staticrejects rather than runs:Table 1 died there and every table after it was lost. Verified on
ac79127before touching anything.
wholegets pinned probes of its own —gemm_sol_m256_whole,gemm_sol_m512_whole, atONE_WARPGROUPand 192threads — which is what #197 intended for the other thirty-three, and keeps
tables 1/2/4/5 from silently comparing a 320-thread
wholeagainst 192-threadcompanions.
Arm::Wg2is the shipped kernel's own row and always was.Registers
scripts/modal-run regcount, gate green, zero stack and zero spill on everygemm_solrung including both new arms:gemm_sol_m512moves 83 → 95 andgemm_sol_m256does not move at all (82before and after,
mainmeasured with the same tooling). The two table-7 arms,compiled in one crate in one build, say the guard is what did it rather than the
Large::epiloguededupe:gemm_sol_m512_wg284 againstgemm_sol_m512_wg2_lane95, both at zero spill and zero stack. Residency isfixed by the shared plan either way — the step at 320 threads is 168 registers
and 95 leaves 73 of headroom — and the arm that carries the +11 is the one that
times identically to four figures at 8192³, twice.
Gates
scripts/modal-run build— clippy clean on all four manifests,sm_100acodegen for
device-tests,examplesandexperiments,ptxasclean.scripts/modal-run regcount— occupancy gate green, table above; no.localon any shipped entry or either new arm.
bench --case gemm-sol— all three entries checked exact against the CPUreference before timing, all green.
bench --case sol-ablate— every table, both passes; the two new arms are oncheck(Arm::EXACT_DRAINS) because they compute the sameC.scripts/fmt --checkclean.