Repository navigation
The wait is worth two thirds as much where something is covering it, and the epilogue was never gemm_ws's problem (#118) - #119
Merged
Conversation
…and the epilogue was never gemm_ws's problem (#118) `.x8` LDTM and `stmatrix.x4` on `gemm_ws`, plus the two `no drain` controls the ladder is subtracted from, and the result is a lever that pays and a hypothesis that dies. The levers. Against #116's `staged`, `.x8` is +15.7% / +6.2% / +3.0% at 4096/8192/16384 cubed and `.x4` is +1.2% / +0.0% / +0.1% — the same clean null it was on `gemm_cg2`. They do not compose here: `staged8` and `staged84` are within 1.1% and trade places between sessions, and the register column said so in advance, `.x4` recovering 2 registers (94 -> 92) where on `gemm_cg2` it recovered 14 (94 -> 80) and that recovery *was* the composition gain. Best rung is +19.4% / +9.5% / +5.2% over the shipped register epilogue, 0.615 -> 0.726, 0.782 -> 0.856, 0.810 -> 0.852 of cuBLASLt. Zero spill in every rung; 94 is the largest count in the file against a reachable 255. #117's mechanism predicted the shortfall and got it. `.x8` removes a latency the drain never overlaps; this kernel already overlaps it, so `.x8` is worth 67%, 72% and 83% of what it was worth on `gemm_cg2`. By `whole - no drain` the same epilogue is exposed at 8.62 us a tile here against #114's 20.43, and its LDTM half at 3.20 against #117's 8.07 — 40-47%, which is what warp specialization and the accumulator ping-pong buy, stated as a number for the first time. "Twice the LDTM (16 against 8)" is true of the PTX and false of the work. Every census column doubles, not just LDTM, because `gemm_ws` emits its epilogue at two call sites (`Ws::work` and `Ws::finish`) where the fused job has one. The bands are `RegTile<32, 64>` in both files. The floor is the finding. `gemm_ws_no_drain` — the shipped kernel with the epilogue deleted, the probe that put `gemm_cg2` at 1850 TF/s against the library's 1808 — reaches 0.829 / 0.923 / 0.888 of cuBLASLt, and at 8192 and 16384 cubed it is *slower than `gemm`'s complete `staged84` launch*. Best against best is -9.7% / -9.4% / -6.9%; deleting the epilogue outright recovers 12.7 / 7.2 / 3.9 of those points. So no, `gemm_ws` does not beat `gemm`, and it could not have: #112's 7.3% closes to 6.9% after both kernels spent everything #116 and #117 found. The deficit is the multiply and the operand stream at one CTA an SM. #112 blamed the peer CTA and #114 refuted it; `gemm_ws.rs` blamed the missing peer CTA and this refutes that, by deleting the epilogue and losing anyway. The stale paragraph is corrected in place rather than removed. Residency counted, not queried (#77): two new census rungs at this kernel's own 131 176 B and 147 584 B read 1 resident, 1 holding at both, closing the gap the `cg2 512` rung left at a 32 B plan (1 holding, 2 resident, 100.9 us parked in a blocking alloc; 0.9 us here). No default moved. `staged8` is the rung to ship on `gemm_ws` — `.x4` is a null here alone and in composition — and that is a change worth making on its own.
feitreim
added a commit
that referenced
this pull request
Jul 29, 2026
…ce (#119) (#120) `gemm`'s default epilogue becomes `staged84` and `gemm_ws`'s becomes `staged8`. #116, #117 and #118 each ended by saying the rung was worth shipping and that shipping it belonged in its own change; this is that change and it is the whole of it. No rung added, none deleted, nothing retuned — every entry point still launches and is still on the correctness gate. The two differ on purpose. `.x8` costs +52 and +50 registers identically; what differs is what `.x4` hands back — 14 on `gemm_cg2` (94 -> 80) and 2 on `gemm_ws` (94 -> 92) — and that recovery IS the composition gain. There the pair is +5.1% at 16384^3 against `.x8` alone's +3.6%; here `staged8` and `staged84` land inside 1.1% and trade places between sessions, so the tie goes to the rung with less surface. Confirmed in one container with cuBLASLt re-measured in it (#109's lesson): `gemm` 0.1432 -> 0.1044, 0.7584 -> 0.6684 and 5.5157 -> 5.0132 ms, which is +37.2% / +13.5% / +10.0% and 0.583 -> 0.801, 0.827 -> 0.939 and 0.871 -> 0.958 of the library. `gemm_ws` +19.6% / +8.7% / +6.3% and 0.599 -> 0.717, 0.790 -> 0.858, 0.812 -> 0.863. Both reproduce their published ratios; the 16384^3 rows moved because the denominator did. The constants that describe the shipped launch moved with it: `main.rs` reports 114 816 B and 147 584 B, and `CTAS_PER_SM` does not move on either kernel because the tensor-memory term of `min(512 / columns, shared per SM / plan)` binds at both envelopes. `regcount`'s occupancy gate gained `gemm_cg2_staged_x8x4` and reads 166 / 42 / 80 against a ceiling of 255. Deliberately unmoved: the ablation cube, `bench --case epilogue` and `bench --case staged` stay built at `lcf`, and `ws_bench` table 1 now NAMES `lcf` on both sides rather than taking `gemm`'s default, so its one variable is still where the overlap comes from.
This was referenced Jul 29, 2026
This was referenced Aug 6, 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.
.x8LDTM andstmatrix.x4ongemm_ws(#117's two widths on the kernel that had never had them), plus the twono draincontrols the ladder is subtracted from. One lever pays, one is a null, and a hypothesis this repo has carried since #112 dies.Every timed row was checked element-by-element against the CPU reference before it was timed;
check_ccompares bf16 words with==and no tolerance. The twono drainrungs write noCon purpose and say so in their own label. One container, min of 30 timed launches, static schedule,GROUP = 8.The levers
ws s4msstagedstaged8staged4staged848vs4vs84vsBest rung is +19.4% / +9.5% / +5.2% over the shipped register epilogue, taking the kernel from 0.615 to 0.726, 0.782 to 0.856 and 0.810 to 0.852 of cuBLASLt.
They do not compose here, and the register column said so in advance.
.x8costs the same +50 registers either side (44 → 94);.x4recovers 2 here against 14 ongemm_cg2, and that recovery wasgemm_cg2's composition gain.staged8andstaged84are within 1.1% and trade places between sessions. Zero spill everywhere; 94 is the largest count in the file against a reachable 255 at six warps.The mechanism predicted the shortfall and got it
#117 established that the win is the wait and not the issue.
gemm_wsalready covers that wait — the drain is deferred one item, on four warps of its own, producer never stopping — so.x8had to be worth less here, and it is: 67%, 72% and 83% of its value ongemm_cg2.By #114's
whole − no drain, in µs a tile:ws s4stagedstaged8staged84The same epilogue is exposed at 8.62 µs here against #114's 20.43, and its LDTM half at 3.20 against #117's 8.07 — 40–47%. That is what warp specialization and the accumulator ping-pong buy, as a number for the first time.
"Twice the LDTM (16 against 8)" is true of the PTX and false of the work. Every census column doubles —
stmatrix8 against 4,cvt16 against 8 — becausegemm_wsemits its epilogue at two call sites (Ws::workandWs::finish) where the fused job has one. The bands areRegTile<32, 64>in both files, so dynamic LDTM per tile is identical, and it measures 2.5× cheaper, not twice as dear.The floor, and the answer to "does
gemm_wsbeatgemm"gemm_ws_no_drainis the shipped kernel with the epilogue deleted — #114's probe, which putgemm_cg2at 1850 TF/s against the library's 1808.wsno drain msgemm'sstaged84No. At 8192³ and 16384³ this kernel loses to
gemm's complete launch while running no epilogue at all. Best against best is −9.7% / −9.4% / −6.9%, and deleting the epilogue recovers only 12.7 / 7.2 / 3.9 of those points. #112's 7.3% at 16384³ closes to 6.9% after both kernels have spent everything #116 and #117 found.#112 blamed the peer CTA hiding
gemm_cg2's epilogue and #114 refuted it;gemm_ws.rsthen blamed the missing peer CTA, and this refutes that too — by deleting the epilogue and losing anyway. The stale paragraph is corrected in place rather than removed. What is left is the multiply and the operand stream at one CTA an SM; the two epilogue-free kernels are ~10% apart at 8192³ (1.02 of cuBLASLt against 0.923).StoreRing(#111) no longer has "about 7% to find" here — it has at most 3.0%.Against the library, same container
cuBLASLt 1616.5 / 1784.9 / 1876.0 TFLOP/s. The
gemm 84column reproduces #117's 0.796 / 0.944 / 0.922 from another session, which is the drift control.gemmgemm 84ws s4ws stagedws staged84wsfloorResidency, counted
cuOccupancyMaxActiveBlocksPerMultiprocessorreturns 1 for anything containing atcgen05.alloc(#77). Two new%smid/%globaltimercensus rungs at this kernel's own 131 176 B and 147 584 B count 1 resident, 1 holding at both, against a budget of 1. That also closes the gap thecg2 512rung left at a 32 B plan — 1 holding but 2 resident, the second CTA parked 100.9 µs inside a blocking allocator, against 0.9 µs here.Shape of the change
Tile::drain_staged<WIDE, X4>, andWs's epilogue selector becomes oneconst DRAIN: u8(drain::REGISTER/STAGED/STAGED_X8/STAGED_X4/STAGED_X8_X4/REMOVED) rather than a fourth positional bool.no draincontrols, one per envelope.gemm::bench_withso this file can measuregemm's best rung as a control in its own session rather than quoting it.ws_benchgrows from four tables to six; the sweep is ~90 s of B200.No default moved.
staged8is the rung to ship ongemm_ws—.x4is a null here alone and in composition — and that is a change worth making on its own, on #116's and #117's precedent.