Repository navigation
The item stream has no boundary, and the drain lifts half-rows behind one wait (#80) - #84
Conversation
… clock probe (#80 forensics)
…g indexed globally, items handed over on two semaphore rings
Correction: the full-step A/B numbers in the description were the warm-up runs
Everything I wrote about the full step — the
GEMM rows on the same pair, −2.911 ms combined:
The three lm-head rows are still the ones that do not move, for the reason given in the description: at Note the step gains more than the GEMM rows do (−7.12 against −2.91). I have no measurement that attributes the extra −4.2 ms, and it is larger than I would claim from this diff — the honest reading is that a single measured pair still carries container noise in the untouched rows, and the GEMM-row sum is the defensible figure. The reverse-order container has reported its measured baseline (this branch) at 391.0024 ms and is still running its measured candidate; I will add it when it lands. The direction is not in question in either order or in either pair of runs, and the other gates in the description are unaffected — they were read correctly. Sorry for the noise. |
Both build orders, measured pairs — the full-step gate closedThe reverse-order container finished. Reading only
Both orders agree in direction and roughly in size, from two independent containers whose absolute levels differ by 7% — which is the cross-container spread the both-orders rule exists to see through. Per GEMM row, mean of the two measured pairs:
The ordering matches One thing I am not claiming. In both containers the step gains about twice what the GEMM rows do (−7.1 against −2.9, −9.9 against −5.0). That reproduces, so it is probably not pure noise, but this diff can only touch GEMM kernels and I have no measurement that attributes the remainder — the plausible story (a kernel that spends less time in barrier spin loops leaves more thermal headroom for its neighbours) is a guess, not a result. −3.93 ms on the GEMM rows is the figure I would defend; the −8.49 ms step figure is what the harness reported and should be read with that caveat. |
#80's residual was never the epilogue, the tile, the pipeline fill or the feed. It was a fixed per-item cost that cuBLASLt does not pay at all, and this PR deletes most of it. Thirteen of fourteen model rows improve and ten of twelve square-bench cells do; the ≥ 0.90 bar is still not met on six rows, and the residual is now accounted for down to two named terms.
The forensics that redirected the work
Two instruments, both preserved, reported in full at #80.
A depth sweep at fixed output geometry —
bin/budget.rs, kept in this PR. Hold the tile count, the wave quantization and thegroupedwalk still, sweepK, and fitper-item time = fixed + per_block · K/64for both sides. At the qkv geometry on main:Our per-K-block cost was already 8.5% below cuBLASLt's. The whole deficit was the intercept — which is why the ratio walked 0.69 → 0.84 → 1.01 → 1.11 as
Kdeepened, and why at K = 12288 main already beat cuBLASLt by 11%.A per-phase
clock64probe — branch80-phase-probe, deliberately not in the shipped module — then split that intercept. Per item at K = 3072, in SM ticks:pipeline::run's mbarrier re-arm and its openingcluster_synccluster_syncThree candidates died on those numbers. The fill is 0.25% of an item. The feed steady state is 2182 TFLOP/s aggregate against the B200's 2250 dense bf16, and ahead of cuBLASLt's own depth slope. And
PRE + POST + ACCis K-independent — 15 324 ticks at K = 3072 against 14 905 at K = 9216 — which closes the arithmetic exactly:48·1001 / (48·1001 + 15 100) = 0.761, and the measured 1660 TFLOP/s over the 2182 steady state is0.761.What changed
1. The item stream has no boundary.
pipeline::runre-arms all eight mbarriers on one thread and takes twocluster_syncs per item, and by construction nothing may cross it — the producer cannot issue item i+1's first TMA until item i's barriers have been invalidated and re-initialized behind two cluster barriers. So the barriers are armed once per launch, the operand ring is indexed by the global K block, and the item stream is two semaphore rings deep:fullsays an item's MMA chain is complete,emptysays its accumulator has been read. Each of the three roles walks the static strided schedule for itself (Walk), which is why — unlikegemm_sol, whose CLC queue hands tiles out — this needs no item mailbox at all. Nothing inside the loop is cluster-wide, and the producer crosses an item boundary withSTAGESblocks still in flight.ITEMS = 2is provable rather than a margin: the MMA of item i waitsempty(i), which a drain arrives at only afterfull(i − 1), so the issuer is never more than one item ahead of the epilogue and a slot's previous user is two items back.2. The drain lifts half-rows behind one wait. The probe's second finding was that
ACC ≈ DRAIN— 9 902 against 9 977 — so #83's release was deferring nothing. The reason is not store issue: moving store passes behind the release moved the number by 1%. What costs is the wait per.x8issue.TmemTile::tile_x8takes(M/16)·(N/64)of them serially, so the four[32, STAGE_N]bands this used to lift were eight exposed TMEM latencies an item.tile_x8_batchedputsISSUE_LIMITissues in flight behind one wait, and a[16, BLOCK_N]half-row is exactly that and exactly 128 registers — so the band leaves tensor memory in two waits, and the release lands with half the stores owed rather than a quarter. The bf16 drain takes the same treatment at its[32, STAGE_N]band (two issues, one wait) and the reduction drain at three half-bands; a fourth measured 177 registers, which is the 2 → 1 CTA cliff.Budgets ratcheted to measured, zero spill throughout: bf16 137 → 133, f32 store 118 → 168, accumulate 127 → 145. The f32 store count is the ceiling twelve warps an SM leave a thread, and it is the held half-row rather than a leak:
168 × 192 × 2 = 64 512still fits an SM's 65 536, and the f32 rows rose — a residency step down to 1 CTA/SM shows up as 0.46–0.53, which is how #83 caught the two-band hoist.Measured
Same-harness depth sweep at the qkv geometry, one container each (
bin/budget.rs):Per-item ticks at K = 3072 fell 63 445 → 57 926, and the item is now
ACC + MMAwith nothing else in it.model_shapes,
--features cublas, B200Two independent sessions of this branch (C1 / C2), against #83's two post-merge sessions:
Thirteen of fourteen rows improve on the session mean;
bwd down dWis flat and is the one row whose deficit is wave quantization rather than the item stream. Six rows still sit under 0.90, four of them by 1–3 points — the accounting for that is below, and #80 does not close on this.Square bench
The
maincolumn is #83's post-merge table, so these are cross-container comparisons and the small cells should be read loosely. The one cell that moves the wrong way is 16384³ f32 store, which is the same cell #83 recorded going the wrong way for the same structural reason: at a 1 GiBCthe deferred writeback overlaps the next item's operand streaming and pays an L2 term. The model has no such shape, and every square cell at 8192³ and below improves — f32 store by +8.9 points.Full-step A/B, same container, both build orders
--baseline-refruns the baseline first, so the second binary always pays the container's warm-up. Running it both ways cancels that, and the two orders agree on the size of it to within 0.02 ms:The implied second-position penalty is 4.97 ms from both orders independently, which is why order 1 alone reads as a regression: it is 1.78 = −3.19 + 4.97. The mean full-step delta (−3.19) and the mean GEMM-row delta (−2.99) agree to 0.2 ms, which is the check that matters — only GEMM rows can move, and they account for the whole step delta.
Per row, mean of the two orders:
The three lm-head rows are the ones that do not move: they are
N = 50432at 128 waves, where the per-item term this PR deletes was already amortized to nothing.What is left, and what it would take
ACCis now 8 310 ticks — 14% of a K = 3072 item — and it is the drain, entire: one batchedtcgen05.ldof the top half-row, one store pass, one batched load of the bottom half-row. Its floor is set by two facts that are both about the register file. The accumulator is 256 fp32 a lane, so no drain can hold a whole band and release before storing any of it; and at 192 threads and 2 CTAs/SM a thread gets 168 registers, of which 128 are already the half-row. The remaining rows below 0.90 are that term plus, on the two smallest tile counts, wave quantization:gate_up fwdruns 768 tiles at 86.5% last-wave efficiency against cuBLASLt's 94.4%, andbwd down dWruns 192 tiles at 64.9% against 86.4% — on that row the wave term alone is larger than the whole deficit.Two structural exits, both named rather than tried here:
M256_N128chains over column sub-ranges of the same accumulator would let the next item's first chain start after half the drain. It costs no tensor memory — which is what closed the double-buffer routes — but it re-labels which rank stages which 64 columns ofB, so the tensor map, the operand walk and the drain's column mapping all move together.[256, 128]losing on all fourteen rows, but it measured it while paying the item boundary twice as often, and both of the terms above are things a narrower tile improves. The dispatch machinery is preserved on80-narrow-tile; what it was compared against no longer exists.Gates
--kernel gemmparity: green, three runs. Budgets pinned at the measured 133 / 168 / 145, zero spill on all three.--kernel ops: green.--kernel model: green on rerun. The first run took the known stochastic miss of the MoE overfit assertion at 0.0597 against the 0.05 bound — the same value The drain runs beside the next item's MMA, not in front of it (#80 remedy 2) #83 recorded — with every numerical parity row green above it; the rerun landed 0.000046. That assertion is nondeterministic through the MoE scatter atomics, and this kernel's math is bit-identical to main's.model_shapes: table above, two sessions.