Repository navigation
The drain runs beside the next item's MMA, not in front of it (#80 remedy 2) - #83
Merged
Merged
Conversation
This was referenced Aug 4, 2026
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.
#80 remedy 2: the drain no longer runs in front of the next item's MMA — it runs beside it.
What changed
One structural change to
pipeline::run's job, in the formkittens::pipeline::Job's doc already sanctions: the epilogue is deferred one item. The band warps open itemiby draining itemi−1's accumulator, hand the accumulator's columns back through a new cluster barrier (acc_free, living in the staging tiles' alignment padding — the shared plan does not move) the moment their lasttcgen05.ldretires, and close the item waiting out itsdone— so every barrier still completes inside the item that armed it. What runs beside the MMA is the previous drain's store tail plus the whole next TMA fill; what remains serial is the load half of the drain, which a single-buffered accumulator cannot give away.Supporting changes:
model_shapesrow lost 5–20% — divergent spin loops share a warp's issue, and the MMA chain stalled behind the producer's polling. The extraction-point kernel and ferro'sgemm_wsboth kept these roles on their own warps; now this kernel does too.What was tried and lost (all preserved)
gemm_ws): ferro-kittens#188/#189 measured it at the shallow-K money shapes for the first time — its epilogue-free floor loses to the shipped 2-CTA kernel with its exposed epilogue at every K=3072 shape (0.822/0.880/0.884 vs 0.828/0.896/0.909). Route closed in both regimes.80-stagger-probe): +2.8% best at 4 µs, monotonically worse beyond — in-phase is an attractor; a one-time nudge relapses within an item.9b4d12f): Reduce's drain with the add turned off measured a wash to −3% on its own rows — seven of eight engine round-trips sit before the release, so the engine's latency lands on the critical path where the register stores' issue did not. ferro The GEMM entry points declare their block, so the driver stops deriving it (#122) #123's finding survives deferral.Measured (model_shapes, same-container cuBLASLt, B200)
Two independent sessions of the identical final kernel (run A / run B) against the post-#82 baseline rows, because the big bf16 rows swing several points between containers and one session would over-claim:
* run B's lm_head dx is a session outlier (ours 4.45 → 5.02 ms on a byte-identical binary while cuBLASLt moved 2%); run A matches the baseline.
Square bench, branch vs main @ bad698a, same-day separate containers:
The accumulate columns are the deferral working exactly as designed — the fold's long tail is what overlaps best. The 16384³ store cells are a real ~2–3% ms regression (5.06→5.20 bf16, 5.34→5.44 f32, reproduced in two branch containers): a measured tradeoff, not noise. Working hypothesis: at the 1 GiB operand footprint the deferred C writeback overlaps the next item's operand streaming and pays an L2 term (#114 saw the same term at K=32768). The model's own deep-K rows (K=8192/9216) improved (0.92–0.93 → 0.955–0.967), so the training step is on the right side of this trade everywhere.
Residual attribution
tcgen05.ld, and the register file caps how many loads can run ahead of the stores (the overlap fraction is held-registers / 256). That is the remaining epilogue term on qkv fwd / o_proj fwd / down fwd / lm_head fwd, and the honest ceiling of remedy 2 at this tile.Gates
--kernel gemmparity: green (three runs), budgets pinned at the measured 137 / 118 / 127, zero spill.--kernel ops: green.--kernel model: green (one stochastic miss of the MoE overfit assertion at 0.0597 vs the 0.05 bound with every numerical parity row green, then 0.000099 on rerun — the assertion is nondeterministic through the MoE scatter atomics, not a numerics change; this kernel's math is bit-identical to main's).--baseline-ref bad698aA/B, same container, both build orders: 402.2150 → 399.5803 ms and 404.4007 → 401.6943 ms (−2.6/−2.7 ms, consistent).(Opened by the session orchestrator from the completing agent's drafted body + on-disk gate logs; the agent's session ended after the A/B completed.)