Skip to content

The item handoff held one work item and the chain permits four, so 4096x4096x1024 never returned (#149) - #154

Merged
feitreim merged 4 commits into
mainfrom
fix-shallow-k-hang
Jul 30, 2026
Merged

feitreim merged 4 commits into
mainfrom
fix-shallow-k-hang

Conversation

@feitreim

Copy link
Copy Markdown
Owner

Base is gemm-sol (97b6406). Fixes #149.

4096x4096x1024 on [256, 256] now returns, and so does every rung below it on every entry: 22 timed rows, k from 2048 down to 256, all three entries, every one exact. The row that wedged a container is 0.0394 ms and 871.5 TFLOP/s.

The mechanism is not in the K loop, not in CLC, and has nothing to do with k_blocks' divisibility. The item handoff was a one-cell mailbox behind a phase-parity wait, and the kernel's own back-pressure lets the producer lead its slowest consumer by four publications.

The mechanism

Common::info was a single SharedCell<TileInfo> behind a single Semaphore, and next_info(sequence) waited parity sequence & 1. A mailbox behind a parity wait is sound only while the producer leads the consumer by less than the ring's depth, and one cell tolerates a lead of exactly one. Derive what the chain actually permits:

  1. The producer publishes index p only after item p-1's loads are all issued, and the last of those passed free.wait_recycled(p·k_blocks − 1) — the MMA warp's free commit for K block p·k_blocks − 1 − STAGES.
  2. At k_blocks == STAGES that block belongs to item p−2. So the producer's own throttle only says the MMA warp finished item p−2.
  3. Small's accumulator ring is two deep, so the MMA warp finishing p−2 means the epilogue released empty(p−4) — it has read index p−4 and is about to wait on p−3.
  4. Indices 0..=p are published against a consumer waiting on p−3: four outstanding, and one cell held one.

A handoff that shallow fails two ways, and both are in the same state space: the cell is overwritten before the consumer reads it, or — parity having period two — the wait lands on a phase the producer has already passed, and once the producer has published has_work = false and left, on one that never flips again. The second is a launch that does not return.

Nothing in that chain mentions k. What k sets is the margin: the epilogue's read of index s has to beat the producer's publication of s+1, which is a drain against a K loop, and shortening k shortens the K loop while the drain is fixed at #147's 2.82 µs a tile. That is the shape of a cliff at one value rather than a degradation, and it is why 0.774–0.803 of cuBLASLt at 1280 and above told nobody anything.

The three pieces of evidence

1. An exhaustive search over the interleavings, on the CPU, in cargo test. kittens::sync::handoff::depth_needed is the four steps above as a state machine over the three roles with no ordering between them, BFS'd to fixpoint. It answers:

trip count depth the chain needs
k_blocks == STAGES (k = 256) 4
k_blocks 8, 12, 16, 20 3
one item per cluster, any k 2

So four is the minimum and not a margin, and the last row is the one worth reading: 1024x1024x512 — every correctness gate this kernel has ever had — needs a depth of two. The one-deep handoff was unsound at every legal shape, including the gate's; it was winning a race, by a margin k sets. It also inverts the arithmetic the issue was chasing: the deepest lead is at the shallowest k, which is why "k_blocks % X == 0 breaks it" was dead on arrival and why 16 hanging while 24 and 32 ran was never a divisibility fact.

2. bench sol-watch: the same device body, one const apart, with C checked over all 16 777 216 outputs.

shape one deep four deep
4096x4096x1280 exact exact
4096x4096x1024 exact exact
4096x4096x512 11 885 748 of 16 777 216 outputs wrong exact
4096x4096x256 11 896 908 of 16 777 216 outputs wrong exact

The wrong outputs are zeros — C[0, 1536] = 0, want -1042 — so they were never written. Whole output tiles are missing: the producer republished into the one cell, the epilogue read a later item's coordinates, and the item it skipped stayed at the buffer's zeros. 71% of C, because a cluster runs three or four items and losing one loses a quarter of its work. The four-deep arm is exact at the same four shapes with everything else identical.

3. The ladder, fixed, walked all the way down. bench sol-k now descends to k = 256 on all three entries, and every row is checked exact at 1024x1024x512 and at its own shape before it is timed:

shape [256, 256] [256, 128] [512, 256]
4096x4096x2048 0.772 0.662 0.686
4096x4096x1280 0.728 0.661 0.608
4096x4096x1024 0.688 0.642 0.570
4096x4096x768 0.651 0.593 0.510
4096x4096x512 0.578 0.547 0.459
4096x4096x256 0.539 0.524 0.452

of cuBLASLt FP16 at the same shape. Shallow k is a slope and not a cliff, which the previous four rows could not show: the ratio falls monotonically from 0.772 to 0.539 as k drops eightfold, because the per-tile constant #148 priced at 3.4 µs is amortized over four K blocks instead of thirty-two. The entry ordering does not change across it — [256, 256] leads at every rung — so nothing here moves select_variant.

The candidates this eliminates

  • gemm_sol's [256, 256] entry does not return at 4096x4096x1024, and the shape is inside its contract #149's candidate 1 is the answer, and it named the right barrier for the wrong reason. It reads as a lag the drain sets, which is the margin; the defect is that a depth-one ring has no room for a lead the back-pressure permits, whatever the timing. The no drain ladder it suggested would have moved the boundary and still not said what to change.
  • Candidate 2 (the CLC loop) is out. STALL clc is a site in the instrument and no CTA ever reached it. CLC also reports something worth keeping: at 4096² only 888 of the 3072 warps the grid asks for ever ran — 148 CTAs × 6 — so a "512-cluster launch" is 74 clusters taking three or four items each, and the cancelled clusters never execute at all.
  • Candidate 3 (an unterminated K walk) is out by measurement now as well as by construction. STALL free and STALL load are both sites and neither fired.
  • Candidate 4 (the full/empty handshake) is out. Both are sites; neither fired. The issue was right that it is the one a reader reaches for first, and right that it is the least likely.
  • The phase-parity theory the brief had already refuted stays refuted — and the model says why it had to be: the reachable lead has no k_blocks % X in it at all.
  • turns == STAGES was a red herring, and k_blocks == STAGES is not. The coincidence the issue flagged without weight was turns = k_blocks/STAGES = 4. The quantity that appears in the derivation is k_blocks against STAGES — step 2 above — and it only bites at k_blocks == 4, which is k = 256. At k_blocks = 16 the chain needs three, and one cell was two short of that. So the STAGES = 2 discriminator was not run: the model answers the same question exhaustively, for free, and says the boundary tracks neither turns nor the trip count but the margin, which is continuous.

The fix

const ITEMS: usize = 4, and ready/info become a SemaphoreRing<ITEMS> and a new SharedCellRing<TileInfo, ITEMS>. About 55 lines of code across src/shared.rs and examples/src/gemm_sol.rs, of which the load-bearing part is one const and two field types; Common::handoff is the one place the index → (barrier, parity, cell) arithmetic lives, so the producer's arrive and the consumers' wait cannot disagree about the depth again.

It costs no shared memory. Four barriers and four TileInfo cells fit inside the padding the 128-byte-aligned staging buffer already left: SMALL_SHARED_BYTES is still 196 864, NARROW 131 328, LARGE 229 632, and no launch_contract moved. That is also the strongest single piece of evidence that the plan did not shift — the three const { assert! }s in the kernels are unchanged and still hold.

SharedCellRing is in the library rather than in the kernel because the rule is the library's: src/sync.rs's module docs already stated "every barrier's completions lead its waiter by at most one phase" as the soundness condition for parity arithmetic, and had no type that made the payload side of it checkable. It does now, and its doc says what a depth of one buys you.

The census did not move

regcount on 97b6406 and on this branch, diffed:

  • Every opcode column of every kernel is identical, all 79 of them. The three shipped entries: gemm_sol_m256 16/2/1/3/2/1/1/4/8/2/2/6/14, and gemm_sol_m256_n128 and gemm_sol_m512 likewise, unchanged in both crates.
  • Register counts moved a little and only downward, at zero spill and an unchanged 256-byte frame: gemm_sol_m256 104 → 96, gemm_sol_m256_n128 96 → 86, gemm_sol_m512 94 → 94. Occupancy cannot notice — these entries are one CTA per SM on the shared plan, and 96 registers × 192 threads is 18 432 of 65 536.
  • One side effect worth recording against the "crate composition moves register counts" finding: gemm_sol_m256_n128 was 96 in examples/ and 118 in experiments/ on the base, for the same source. It is 86 in both here.
  • The MMA warp's issue stream survives the fold: the barrier offsets are still literals (131104 and friends) and mov.b32 %rN, 1 is still the accumulate predicate at three of the four positions. Only register numbering shifted.

So this is census-neutral rather than byte-identical, and the deadline instrument itself is byte-neutral: it is a third dial at WATCH_OFF in every shipped kernel, and the two watch arms are the only new entry points in the PTX (77 → 79).

The instrument, which is the part that makes the next one cheap

WATCH is a third dial axis, orthogonal to ABLATE (which phase) and FOLD (the ring index), listed in WATCH_RUNGS and held to #147's dial_is_a_permutation guard. Above WATCH_OFF, every spin in the kernel becomes Semaphore::wait_before — a bounded parity wait on debug::clock64, new in src/sync.rs — and every warp writes a four-word mark at each loop head and on each expiry: site, sequence, ring index, parity. On any expiry the CTA's stop flag goes up and all six warps leave their loops, so the launch reaches cluster_sync and returns.

Eleven sites, one per barrier in the kernel plus one per loop head, so the report is a diagnosis and not a hint. Every wait is covered at all three entries, including the two empty waits that live inside the large entry's K loop.

The marks go past the end of C, in REPORT_ROWS rows the arm's launcher allocates for them, which is why the instrument needs no kernel parameter the shipped entries do not have and cannot drift from the body it watches. ClcCursor::next_before and a small Harvest enum bound the one loop whose termination is the hardware's.

The deadline is 1 << 30 SM ticks, about 0.6 s, four orders of magnitude past the ~26 µs an output tile takes at 4096³ — so no arm can time out on being slow.

The regression

Three things, and the first is the one that would have caught this.

  1. kittens::sync::handoff's tests, in tier 1. Three tests on depth_needed, at k_blocks == STAGES, at every deeper k, and at one item per cluster. ITEMS = 3 fails the first and ITEMS = 1 fails all three. No GPU, no container, 30 ms.
  2. gemm_sol::check grew SHALLOW_K_GATE: one shape per entry at k = 256 (k_blocks == STAGES) with more clusters than the device holds, so a cluster has to take a second item. That is the regime the gate could not reach — 1024x1024x512 is 16, 8 and 4 clusters against 74 resident, so every cluster got exactly one item, its producer published once and then the sentinel, and the handoff was never asked to hold two. 2048x2048x256, 2560x2048x256 and 5120x2048x256, all exact, about 20 M output comparisons between them, which is a fifth of what one bench row already checks. On modal_app.py::examples, not opt-in.
  3. bench sol-k walks to k = 256 on all three entries, plus an m sweep at fixed k = 1024 — 64 clusters to 512 at one trip count, which is the control the issue asked for, since at 4096² the grid is 256 tiles over 256 clusters at every k and the ladder alone cannot separate the two.

The other two entries

All three shared the defect and all three are fixed. [512, 256]'s chain is one step tighter — a one-deep accumulator interlock per half, so step 3 gives p−3 — so it needed three cells where the small entry needed four; one cell was short at both. [256, 128] is Small at another width and has the identical chain. Both are on the fixed ladder for all six rungs, both are on the new gate, and both were on the old one, which is how a one-deep handoff shipped: a lead of two was enough to break it and the gate only ever produced a lead of two by luck.

Four is one shared plan for all three rather than three barriers saved at the large entry, which is the trade the doc on ITEMS states.

Containers

Six: four CPU and two GPU. Three CPU builds (two of them my own compile errors, after the rebase onto 97b6406 put ABLATE under a permutation guard and the instrument had to move onto its own axis), two CPU regcounts for the before-and-after census, one GPU bench --case sol-watch and one GPU examples. The instrument and the fixed ladder run in one container by construction — sol-watch calls sol::sweep_k after itself, in that order, because the instrument is the half that cannot hang and a ladder that could would take everything printed after it. No container was lost to the watchdog and none had to be stopped from the CLI.

What this does not separate

  • Which branch 4096x4096x1024 took before the fix. The instrument observed the overwrite branch, at k = 512 and k = 256, and observed no stall at 1024 — because the marks are stores and they perturb the race they measure. Both branches come out of the same state space and the model says both are reachable; which one the shipped kernel took at 1024 is not established and would cost a container to find out, for nothing.
  • Why the boundary was between 1280 and 1024 and not somewhere else. The margin is a drain against a K loop and both are measured, but the constant that decides where they cross is the drain's latency rather than the 2.82 µs of serial cost The drain is exposed whole, and both of its expected levers measure zero #147 priced, and nothing here measures that.
  • Whether upstream's gemm_sol_final hangs at the same shape. Its TILE_READY is one barrier and its TILE_INFO one cell — the same structure, and Time gemm_sol_final unported: two thirds of the gap to cuBLASLt is upstream's own (#138) #145's copy is in the tree — so the derivation applies to it unchanged. It is not run here.
  • Where the shallow-k slope's per-tile constant goes. The ladder prices it (0.772 → 0.539 as k falls eightfold) and does not decompose it. The small entry's K loop is its feed's duty cycle, and the ring index was a port defect (#144) #148's arms would.

Two lines in somebody else's function

Declared rather than done quietly, per the coordination note. The MMA warp's operand wait and the epilogue's accumulator wait had to be routed through the instrument, which is one line in each:

  • Small::multiply_at and Small::multiply_stage: common.load.sem(SLOT).wait(parity) → common.wait_load::<WATCH>(SLOT, parity).
  • Small::epilogue: common.full.wait(sequence) → common.wait_full::<WATCH>(sequence).

Both are const-false at WATCH_OFF and expand to exactly what they replaced, which the census confirms — the MMA warp's issue stream and the drain's opcode counts are unchanged. wait_load reports and carries on rather than returning a failure, precisely so the K loop's shape is not the instrument's to change.

@feitreim
feitreim changed the base branch from gemm-sol to main July 30, 2026 02:00
@feitreim
feitreim force-pushed the fix-shallow-k-hang branch from 433055c to 0974da5 Compare July 30, 2026 02:01
@feitreim
feitreim merged commit aaadcc2 into main Jul 30, 2026
4 checks passed
feitreim added a commit that referenced this pull request Jul 30, 2026
…ine-sensitive

Measured against `aaadcc2` rather than argued about, because a compiler-backend
bump is exactly the change that moves registers with nothing watching: `regcount`
on `aaadcc2` and on the same tree with the pin moved. 46 of 272 rows moved, the
kernel set is identical on both sides, and `regcount --determinism` passes on the
new pin — 270 kernels, every counter, across two builds — which is what makes the
diff a function of the revision rather than of the build.

**This census was taken twice and the answer changed.** Against `336e3d7` it was
44 of 270 rows with `gemm_sol_m512_mma` among the newly-spilling four; #154 landed
in between and moves registers on its own, and against `aaadcc2` that kernel is
80 -> 79 with no spill. The newly-spilling set is not stable under the choice of
baseline, so a dependency diff has to be taken against the commit it will land on.

Not an LLVM bump: `rust-toolchain.toml` is byte-identical and both revisions
validate against `rust-llvm-22.1.2-1cb4e383`. Two files differ inside
`rustc-codegen-cuda/src` (`collector.rs`, `generated_intrinsics.rs`) beside
`cargo-oxide`'s `backend.rs`.

Four rows started spilling and **every one falls in register count while doing
so** — `gemm_sol_m256_n128` 86 -> 80 with 4/8, `gemm_ws_staged` 43 -> 40 with
16/20, `gemm_ws_staged_x8` and `_x8x4` 90 -> 80 with 8/12. That is `ptxas` taking
a lower target and paying in local memory, this file's oldest error arriving from
the toolchain instead of from a diff. No row stopped spilling. `m256_n128` is the
one that matters: unlike the `gemm_ws` arms it is a shipped variant
(`Variant::M256xN128`) and it spills in both crates.

The occupancy gate (#95) is green on both sides, and the opcode census moved in 3
of 80 kernels and only in `selp`.

**The decomposition survives, laddered on both pins.** `mma only` reads
99.5/99.6% of peak on the old pin and 99.7/99.6% on the new, every arm agrees
across the pin to 0.2 points or better inside its own two-pass spread, and
`[512, 256]` is the same at 99.3-99.7%. So `mma only` is still at peak, "there is
no tcgen05 issue-rate deficit" stands, and no published row needs amending. One
number does not reproduce and it is not the pin's: `mma only` is published at
100.6% and reads 99.5-99.6% on the *old* pin at `aaadcc2`, so #154 or the session
moved it, not the bump.

**The shipped spill does not resolve as a time.** `bench sol-small` twice round
robin: the N128/N256 ratio moves +-6.4% with inconsistent sign across four
shapes, and `M256xN256` — whose register count did not move — reads 0.5-4.8%
slower too, which fingers the container rather than the diff. The cost is
unestablished rather than zero; that table's own spread runs 4-87% at these
shapes, and settling it needs a same-container A/B a dependency bump cannot give.
feitreim added a commit that referenced this pull request Jul 30, 2026
…ll is outside the hot loop

Measured against `aaadcc2` rather than argued about, because a compiler-backend
bump is exactly the change that moves registers with nothing watching: `regcount`
on `aaadcc2` and on the same tree with the pin moved. 46 of 272 rows moved, the
kernel set is identical on both sides, and `regcount --determinism` passes on the
new pin — 270 kernels, every counter, across two builds.

**This census was taken twice and the answer changed.** Against `336e3d7` it was
44 of 270 rows with `gemm_sol_m512_mma` among the newly-spilling four; #154 landed
in between and moves registers on its own, and against `aaadcc2` that kernel is
80 -> 79 with no spill. The newly-spilling set is not stable under the choice of
baseline, so a dependency diff has to be taken against the commit it will land on.

Not an LLVM bump: `rust-toolchain.toml` is byte-identical and both revisions
validate against `rust-llvm-22.1.2-1cb4e383`. Two files differ inside
`rustc-codegen-cuda/src` (`collector.rs`, `generated_intrinsics.rs`) beside
`cargo-oxide`'s `backend.rs`.

Four rows started spilling and **every one falls in register count while doing
so** — that is `ptxas` taking a lower target and paying in local memory, this
file's oldest error arriving from the toolchain instead of from a diff. No row
stopped spilling. Those columns are **bytes**, which is worth 20x: `4,8` is one
32-bit register stored once and reloaded twice, not four stores and eight loads,
and the file now says so where it prints them.

`gemm_sol_m256_n128` is the only one that ships (`Variant::M256xN128`), so it is
the only one that had to be answered.

**The decomposition survives, laddered on both pins.** `mma only` reads
99.5/99.6% of peak on the old pin and 99.7/99.6% on the new, every arm agrees
across the pin to 0.2 points or better inside its own two-pass spread, and
`[512, 256]` is the same at 99.3-99.7%. So `mma only` is still at peak and no
published row needs amending. One number does not reproduce and it is not the
pin's: `mma only` is published at 100.6% and reads 99.5-99.6% on the *old* pin at
`aaadcc2`, so #154 or the session moved it.

**The shipped spill is outside the hot loop, and a CPU container settled it.**
`bench sol-small` could not: the N128/N256 ratio moves +-6.4% with inconsistent
sign and `M256xN256`, whose registers did not move, reads 0.5-4.8% slower too, so
that table's 4-87% spread is the container and not the diff. The disassembly can.
`nvdisasm -c` through `_print_sass_loops`' backward-branch loop finder says the
pin adds **exactly three** local-memory instructions to `m256_n128` and none to
the two unspilled controls: one `STL` and two `LDL` at `[R1+0x100]`, which is the
4 and 8 bytes arrived at independently. All three sit in 510-727 instruction
regions; the innermost 216-instruction loop, where this kernel's 64 pre-existing
frame accesses live on *both* pins, contains none of them. That bounds the cost at
<=0.6% of issue in one outer loop and zero in the inner one, against an instrument
that reproduces to 4-87%. Below the noise floor, with the noise floor stated.
feitreim added a commit that referenced this pull request Jul 30, 2026
…nd the one shipped spill is outside the hot loop (#152)

cuda-oxide `b099f64` → `20a5616` across all four manifests, all four lockfiles and
`CUDA_OXIDE_REF`. Every Rust change is a doc comment; `git diff main -- '*.rs'` has
zero non-comment changed lines.

**Two doc claims needed more than a hash.** `src/lib.rs`'s libdevice claim is not
re-establishable at the new pin — nothing in the tree makes a libdevice call
(`Abs` clears the sign bit, `fmax` is a comparison-select, `Sqrt`/`rsqrt` are
native), so no gate exercises it and repointing the hash would have been #106's
exact failure mode; the citation stays with the reason written down. And GAPS.md's
`cp.reduce` claim was wrong *before* the bump: 64 records are in `imported.json` at
**both** revisions as `int_nvvm_cp_async_bulk_tensor_reduce_*`, which is why a
`cp_reduce_*` grep finds nothing — reclassifying #42 as a generation-list change.

Read only from the checkout at `20a5616` with `git rev-parse HEAD` confirmed first,
per #106; six of the seven checkouts on the machine are not the pin. Repointed after
re-verification: the 13-line `clc.rs`, the `[u32; 32]` `pack16` result, the `.x8`
hazard, `generated/stmatrix.rs`, and all thirteen rows of GAPS.md's support table.
Kept at `b099f64` as provenance: the `gemm_sol_upstream` copy point and the
`stmatrix` observation, with `kernels.rs` hashing to `6746e517…` at both revisions
and in the vendored copy. The retracted register-count sentence still living in
`gemm.rs`'s `.pack::16b` doc is removed — #147 fixed it in the README and missed it
there, and repointing the hash beside it would have asserted retracted reasoning at
the new pin.

**The census had to be taken twice and the answer changed.** Against `336e3d7` it
was 44 of 270 rows with `gemm_sol_m512_mma` among the newly-spilling four; #154
landed in between and moves registers on its own, and against `aaadcc2` that kernel
is 80 → 79 with no spill at all. The newly-spilling set is not stable under the
choice of baseline, so a dependency diff has to be taken against the commit it will
land on. Final: 46 of 272 rows moved, identical kernel sets, `regcount
--determinism` passing on the new pin. Not an LLVM bump — `rust-toolchain.toml` is
byte-identical and both revisions validate against `rust-llvm-22.1.2-1cb4e383`.

Four rows started spilling and **every one falls in register count while doing
so** — `ptxas` taking a lower target and paying in local memory, which is this
repo's oldest error arriving from the toolchain rather than from a diff. The
columns are **bytes**: `4,8` is one 32-bit register stored once and reloaded twice.

**The one shipped spill is outside the hot loop, and a CPU container settled what a
GPU one could not.** `bench sol-small` cannot answer it — the N128/N256 ratio moves
±6.4% with inconsistent sign and `M256xN256`, whose registers did not move, reads
0.5-4.8% slower too, so that table's 4-87% spread is the container. The
disassembly can: `nvdisasm -c` through `_print_sass_loops` finds the pin adds
**exactly three** local-memory instructions to `m256_n128` and none to the two
unspilled controls — one `STL` and two `LDL` at `[R1+0x100]`, the 4 and 8 bytes
arrived at independently. All three sit in 510-727 instruction regions; the
innermost 216-instruction loop, where this kernel's 64 pre-existing frame accesses
live on *both* pins, contains none of them. Cost bounded at ≤0.6% of issue in one
outer loop and zero in the inner one. Below the noise floor, with the noise floor
stated.

**The decomposition survives, laddered on both pins.** Every arm agrees across the
pin to 0.2 points or better inside its own two-pass spread; `mma only` reads
99.5/99.6% old and 99.7/99.6% new, `[512, 256]` 99.3-99.7%. So `mma only` is still
at peak and no published row needs amending. One number does not reproduce and it
is not the pin's: `mma only` is published at 100.6% and reads 99.5-99.6% on the
*old* pin at `aaadcc2`, so #154 or the session moved it.

Also noted: `cuda-core` removed the public `ClusteredCooperativeValidationUnsupported`
variant, which the repo never names; and `.reqntid` is now emitted from a declared
exact block and driver-enforced per axis where `.maxntid` only bounded the product,
closed empirically by green `build`, `regcount` and 42/42 device cases.
feitreim added a commit that referenced this pull request Jul 30, 2026
…ter: the axis that is free is not the axis the hardware parallelizes (#153)

The drain is the largest term left in `gemm_sol` and #147 showed it is latency in
four warps: not bandwidth (<10% of shared write bandwidth), not bank conflicts
(`Swizzle128B` tiles all 32 exactly once at every pitch here), not store width,
not the convert, not the waits. Adding warps is the one remaining way to attack a
latency-bound chain, so it was built and measured. **It does not pay, and why it
does not closes the direction.**

Eight epilogue warps splitting the accumulator's **columns**, two round-robin
passes per shape, on `66e77a3`:

| shape | one wg (192 thr) | two wg (320 thr) | epilogue | of one wg |
| --- | ---: | ---: | ---: | ---: |
| 4096³ | 0.1031 / 0.1031 ms | 0.1050 / 0.1052 ms | 5.05 → 5.56 µs | 0.983 / 0.981 |
| 8192³ | 0.5810 / 0.5805 ms | 0.5799 / 0.5798 ms | 9.25 → 9.07 µs | 1.002 / 1.001 |

**The control is what makes this a finding rather than a wash.** Each arm
subtracts the `no drain` at *its own* thread count, because the split changes the
launch geometry — and the two controls agree to within 0.06% at both shapes. So
the two extra warps are free when idle, and the loss is the drain being slower
once split at the same total work. Not shipped; kept as a rung.

**The mechanism is the resource that fixed the row axis in the first place.**
Warps 0 and 4 own the *same* 32 tensor-memory lanes — warp 4 is warpgroup 1's warp
0 — so a column split does not spread LDTM traffic over more sub-partitions, it
puts two requesters on each of the same four. Same ports, twice the queueing. Rows
are tiled out at four by lane ownership and columns are shared with the warp that
already owns those lanes, so **there is no third axis**. That reconciles the two
statements a reader would otherwise take as contradictory: lane ownership is over
*rows*, and a column split satisfies it twice over rather than relaxing it.

By elimination the chain now ends at the **`stmatrix` scatter's transaction rate**.
This PR does not separate transaction rate from byte rate and says so; the arm that
could is one changing the access pattern at constant bytes *and* constant
instruction count.

Three things the split had to inherit, all reported rather than assumed:

- **The `[512, 256]` two-half `full`/`empty` handshake.** A *column* split leaves
  the set of warps touching each half unchanged, so only the arrival count moves,
  `RANKS·4·32` → `RANKS·8·32`; `initialize` takes it as an argument. It does not
  interact with #154's item-handoff depth: `empty` scales in arrivals with
  epilogue warps, `ready`/`info` scales in depth with `ITEMS`, and neither
  quantity appears in the other's expression. A wrong count would have hung.
- **Shared bytes: zero delta at all three entries, by construction** — `shared_plan`
  takes the entry width and doubling the warps halves each warp's width, so the
  product is unmoved. Now a compile-time assert rather than a table in prose:
  `epilogue_warps(ONE)·stage == epilogue_warps(TWO)·(stage/2)`.
- **The census here can only be negative evidence.** The split is opcode-identical
  to the shipped kernel, so it cannot say the split happened — only the exact
  output can, and it does: 1 048 576 BF16 outputs exact at both entries. That is
  also the only evidence that warp 4 owns warp 0's TMEM lanes; no document at this
  pin states it.

`DRAIN_WIDE`'s 128-column band cannot divide a 64-column per-warp staging tile, and
a literal in the dial is an illegal instantiation **even in the dead match arm**,
because Rust monomorphizes both sides of a `match` on a const before folding. The
band and its issue count became entry-supplied parameters, and the rule is now on
`dial_is_a_permutation` itself as the second half of the convention: values must be
a permutation of `0..len`, *and* every combination of dials must be legal, not just
the reachable ones.

Every claim here is a timing with a control and two passes. No conclusion is drawn
from an instruction count — which is the lesson `_print_sass_loops` established
when two levers filed off PTX counts turned out to be folded entirely by `ptxas`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gemm_sol's [256, 256] entry does not return at 4096x4096x1024, and the shape is inside its contract

1 participant