Repository navigation
The store stage cost a reordering to try, and it hides nothing (#15) - #107
Merged
Merged
Conversation
`lcsf` was queued behind an occupancy step that no longer exists and a staging buffer it never needed. Both premises are wrong, and removing them makes the experiment cheap enough that the answer is a measurement rather than an estimate. The occupancy step: since #87, `CTAS_PER_SM` is 2 because 256 accumulator columns are half of tensor memory, not because 98392 B is half the shared budget. `min(512/columns, shared/plan)` is `min(2, 2)`, so shared memory up to 18344 B a CTA is invisible rather than pre-paid. And 16384 B is an eighth of a CTA's per-item output, not "a band" — the largest staging that fits is a [128, 32] strip, eight single-buffered TMA round trips an item. The staging buffer: none is needed. `pipeline::run` re-arms mbarriers and touches no tensor memory, so an undrained accumulator survives the item boundary intact. Deferring the drain one item is a reordering of phases inside `Job::work`, and `src/pipeline.rs` is unmodified — `lcf`'s scaffold already admits an `lcsf` job. No fp32 `TensorMapElement`, no fp32 swizzle, no `stmatrix`, no proxy fence, no occupancy step. It does need a synchronisation the boundary does not supply: the `cta_group::2` MMA is issued by the leader and writes both ranks' halves, so the pre-MMA rendezvous has to be `cluster_sync` inside the item. Measured over two B200 sessions, five sizes, static schedule, GROUP = 8, every exact row checked element-by-element before it was timed: -5.4% to +1.2%, never reliably positive. 8192³ is -0.2%/-0.0% and 16384³ is -1.0%/+1.2%, and on the second the control moved 2.0% while the treatment held to 0.2%. The pre-registered prediction was +4% to +11% and it is refuted; the 1024³ falsifier behaved as predicted and loses most, so the cost model is right and the benefit is absent. f ~ 0, against the 0.65 #98 set as the bar. `Epilogue::HotStore` closes the one question the cheap form leaves open, which is the only thing #15's TMEM -> shared -> TMA route buys over it: holding the epilogue's instructions fixed while deleting its HBM traffic is worth 0-1.2%. The epilogue is issue-bound, not bandwidth-bound. It computes a wrong `C` on purpose, is excluded from the correctness gate, and says so in its own launch label. 168 registers, 0 spill store, 0 spill load, 528 B stack frame on `gemm_cg2_lcsf` — byte-identical to `gemm_cg2` and to all four sweep rungs, which is the pre-registered prediction and the evidence that nothing is held across the boundary. Residency is 2 CTAs an SM, counted by #87's census at this exact envelope; no byte of the plan moved, so no new rung was run. `gemm` still ships `lcf`. The losing attempt stays runnable, on the correctness gate at both shapes and all three traversal widths, because the constraint that decided it is a property of this tile: the overlap window is one pipeline fill and #87 moved `STAGES` once already.
`cargo fmt --all` at the root does not reach `examples/` — it is a separate crate rather than a workspace member, which is why tier 1 formats all three by hand and why this only showed up there.
This was referenced Jul 29, 2026
Closed
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 #15 for the GEMM, with a measured rejection rather than a build.
The two premises this was queued behind, both wrong
The occupancy step does not exist. The brief re-derived 233472/2 − 98392 = 18344 B a CTA free, which is right. What it misses is that since #87
CTAS_PER_SMis 2 because 256 accumulator columns are half of tensor memory —min(512/columns, shared_per_sm/plan)ismin(2, 2). So shared staging up to 18344 B is invisible, not pre-paid, and above it the plan falls to one CTA an SM (#98's 25–44% cliff).16384 B is not "a band". A
[32, 128]fp32 band is one warp's share of one drain step; a CTA's per-item output is 128×256 fp32 = 131072 B. The largest staging that fits is a[128, 32]strip — eight single-buffered fill→fence→TMA-store→wait-read round trips an item, since double buffering wants 32768 B.None of which matters, because the store stage needs no buffer
pipeline::runre-arms mbarriers and touches no tensor memory, so an undrained accumulator survives the item boundary intact. Deferring the drain one item is a reordering of phases insideJob::work.src/pipeline.rsis unmodified —lcf's scaffold already admits anlcsfjob. No fp32TensorMapElement, no fp32 swizzle, nostmatrix, no proxy fence, no occupancy step. #94 scoped 250–400 lines; the thing that had to be built to find out was not on the path to finding out.It does need a synchronisation the boundary does not supply, which is a finding on its own: the
cta_group::2MMA is issued by the leader and writes both ranks' halves, so abar.syncwould let the leader overwrite tensor memory the peer is still draining. The pre-MMA rendezvous iscluster_sync, moved inside the item.Measured — prediction stated first, and refuted
Predicted +4% to +11% at 8192³/16384³, nothing at 1024³. Two B200 sessions, min ms over 30 launches, static,
GROUP = 8, every exact row checked element-by-element before timing:−5.4% to +1.2%, never reliably positive.
f ≈ 0, against the 0.65 #98 set as the bar. On the 16384³ sign flip the control moved 2.0% while the treatment held to 0.2% — the documented cross-run spread, not a result. The 1024³ pre-registered falsifier loses most, exactly as predicted, so the cost model is right and the benefit is absent.The one question the cheap form leaves open, closed
The deferred drain hides
{LDTM + stores}behind one pipeline fill; #15's TMEM→shared→TMA route gets the same window for its LDTM and additionally decouples the global write.Epilogue::HotStoreholds the epilogue's instructions fixed and deletes its HBM traffic (38 MB rewritten in L2 vs 268 MB / 1 GB streamed):Deleting a gigabyte of streaming writes is worth nothing. The epilogue is issue-bound, not bandwidth-bound, so the expensive route's only remaining advantage over the cheap one is ≤1.2%. It computes a wrong
Con purpose, is excluded from the correctness gate, and says so in its own launch label — the one deliberate exception to rule 1, stated rather than hidden.Why, structurally: the accumulator is single-buffered in TMEM, so the drain must finish before the item's first MMA and the window cannot exceed
STAGESof loads (a second accumulator is 512 columns = one CTA an SM). Meanwhile #98 measured a lone CTA flat at ~585–640 TFLOP/s against 900–1299 for three — the neighbouring CTA's K loop is already covering these issue slots.lcsfproposes to spend a resource inter-CTA overlap has already spent.Costs, checked not asserted
gemm_cg2_lcsfat 168 / 0 spill store / 0 spill load / 528 B frame, byte-identical togemm_cg2and all four sweep rungs. The pre-registered prediction, and direct evidence nothing is held across the boundary. Gate reads 168 against 255.lcfcontrol at 0.828 / 0.881 (s1) and 0.824 / 0.855 (s2), reproducing Sweep the GEMM's pair tile and pipeline depth: [256,256] at three stages should dominate on paper #87's published 0.826 / 0.886.lcsfat 0.826 / 0.872 and 0.824 / 0.866. Nothing here moves the shipped kernel.lcsfon the::examplesgate at both shapes and all three traversal widths, including4096x4096x256where every cluster carries a pending accumulator across boundaries and one past the loop — the way this fails silently.What ships
gemmstill shipslcf.Lcsf,HotStore, theEpilogueaxis andbench --case epiloguestay, andLcsfstays on the correctness gate — the constraint that decided this is a property of this tile, and #87 movedSTAGESandBLOCK_Nonce already. A tile with a longer fill, or a kernel whose epilogue is genuinely latency-exposed, should re-run this rather than inherit its answer.What this does not claim:
lcsfis a bad trade for a GEMM whose accumulator is single-buffered in TMEM and whose epilogue is issue-bound. #15's original motivation — a training kernel with a producer-consumer epilogue — is a different kernel and nothing here prices it. What is established is the method: a store stage costs one reordering to try, so measure before anyone scopes a tensor map.examples/README.md§7 has both tables and the forward pointers from the three earlier sections that promised this.lcsc,interpreterandcommon/templates.cuhare untouched, so #15 stays open for those unless you want it split.