Skip to content

The drain is exposed whole, and both of its expected levers measure zero - #147

Merged
feitreim merged 9 commits into
gemm-sol-integratedfrom
epilogue-drain-overlap
Jul 30, 2026
Merged

feitreim merged 9 commits into
gemm-sol-integratedfrom
epilogue-drain-overlap

Conversation

@feitreim

@feitreim feitreim commented Jul 29, 2026 •

Copy link
Copy Markdown
Owner

E > D: there is no overlap to fail

#144 measured the epilogue at 19.7% of the launch at 4096³ and 11.9% at 8192³ —
the largest single term at both shapes — and listed, first among the things it
could not separate, "the epilogue's own cost from its failure to overlap."

It is separated here, and the frame was wrong. The instrument is a doubling
ladder
, not a fifth ablation: each rung repeats one more pass of the drain per
band, with the extra global stores aimed at the cluster's own first output tile so
they stay in L2. An extra pass has nothing left to hide behind, so it is paid
serially by construction — that is what makes twice all − per issue the
drain's own occupancy cost D, against which E = paired − no drain is what the
launch actually pays. Serial by construction rather than by argument is the
whole design.

One container, µs per tile per critical-path cluster:

4096³ [256,256] 8192³ [512,256]
ld.shared + st.global 0.97 (36%) 3.59 (42%)
stmatrix, and a doubled one's write-after-write 1.59 (59%) 5.86 (69%)
cvt −0.18 (0%) −1.13 (0%)
LDTM and its wait 0.14 (5%) −0.95 (0%)
D, the whole chain serially 2.70 8.50
E, what the launch pays 5.35 (198% of D) 9.40 (111% of D)

E > D at both shapes. Not "incompletely overlapped" — negatively overlapped:
the first drain costs the launch more than a whole extra serial one does, which
is only possible if the drain is not failing to hide behind the MMA phase but
actively slowing it. At 4096³, where the accumulator is double-buffered across
output tiles and the structure permits overlap, it is nearly twice as bad.
Buffering is demonstrably not sufficient, so no amount of restructuring toward
"more overlap" is the fix.

Both expected levers measure zero

The LDTM half is free. Doubling tcgen05.ld and its waits — census ldtm
2 → 4, ldtm.wait 2 → 4 — costs nothing. That is the opposite of #117, and both
are true: #117 took eight issues and eight waits a band down to one and one and
was worth +23.6/+8.6/+3.6%; from there, the remaining waits are already covered
by the other three epilogue warps. #117's lever is closed.

The convert is free too, and this is where .pack::16b finally dies properly.
experiments/README.md dismissed .pack::16b because
tcgen05_ld_16x256b_x8_pack16 returns [u32; 32], the same 32 registers as
_x8_raw
. That is true at the pin (abi-v1.toml, verified) and it answered a
different question
: equal register counts are consistent with equal bits
moved, which is exactly why no convert was performed — it says nothing about
whether the cvt instructions survive. Register count alone is the reasoning this
repo has been burned by at #47, #63, #67, #76 and #81. Asked separately:

  1. Does .pack::16b remove the cvt? Yes. gemm_sol_m512_pack16 censuses
    cvt.rn.bf16x2 at 0 against the shipped drain's 8, with stmatrix,
    ld.shared.v4, st.global.v4 and st.global.b32 all unmoved. The convert is
    genuinely folded into the load, and the ABI table could never have said so.
  2. Is it usable? No — and not for a values reason. The arm faults: one
    launch raised Xid 13, Out Of Range Address on every SM and returned
    DriverError(700). Read as 16-bit-typed, the addressing the qualifier implies
    does not land inside a [128, N] fp32 allocation at all. So the coordinator's
    inference — same registers off twice the columns — is right, and twice the
    columns is off the end of the accumulator.
  3. Would removing the cvt have helped? No. The nocvt rung is the shipped
    drain with the same LDTM count, the same wait count, the same eight stmatrix
    a band and cvt at zero — in bounds, no .pack::16b involved — and it is
    0.0 to 1.4% slower, two round-robin passes at both shapes.

So the lever is closed on an instruction census and a timed oracle, and the 69%
that twice shared − twice global prices is the stmatrix pass and the
write-after-write a doubled one owes its own staging tile, not the cvt beside it.

What ships, and what it is worth

bench sol-ablate, two round-robin passes per shape, cuBLASLt 1605.0 and
2143.9 TFLOP/s in this container.

drain 4096³ min ms epilogue 8192³ min ms epilogue vs cuBLASLt at 8192³
per issue (#144's) 0.1090 / 0.1081 5.56 / 5.39 µs 0.5876 / 0.5870 9.94 / 9.89 µs 0.875 / 0.875
paired (ships) 0.1084 / 0.1084 5.40 / 5.45 µs 0.5833 / 0.5829 9.33 / 9.31 µs 0.881 / 0.881
wide 0.1086 / 0.1099 5.46 / 5.82 µs 0.5870 / 0.5871 9.86 / 9.91 µs 0.875 / 0.875
nocvt (oracle, wrong C) 0.1088 / 0.1083 5.51 / 5.43 µs 0.5916 / 0.5920 10.52 / 10.61 µs 0.869 / 0.868
  • paired — a band's two LDTM issues in flight before one wait. +0.7% of
    the launch at 8192³
    in both passes; neutral at 4096³ (+0.6% / −0.3%, sign
    flips, so: nothing). Epilogue 11.8% → 11.2%; cuBLASLt 0.875 → 0.881.
    Zero shared-bytes delta. Census identical to the drain it replaces in every
    column but ldtm.wait, 2 → 1. Exact over 1 048 576 BF16 outputs. It ships.
  • wide — 128-column bands, four issues behind one wait. Loses at both
    shapes
    on this base. Kept as a rung. Zero shared-bytes delta, and the only rung
    that is not free: 176/168 registers and a 512-byte frame against 256. This PR
    does not separate its loss from that frame.
  • nocvt and pack16 are oracles, not candidates, and say so in their
    own docs and table captions.

Assignment 1: the dial collision is now a build failure

MMA_ONLY = 4 and TWICE_GLOBAL = 4 would have silently remapped one arm onto
another — every downstream number wrong while looking fine. Fixed, and fixed
structurally rather than once:

pub const ABLATE_ARMS: [(&str, u8); 8] = [("whole", WHOLE), …, ("twice all", TWICE_ALL)];
pub const DRAIN_RUNGS: [(&str, u8); 5] = [("per issue", DRAIN_PER_ISSUE), …, ("nocvt", DRAIN_NOCVT)];

const fn dial_is_a_permutation<const N: usize>(dial: [(&str, u8); N]) -> bool { … }
const _: () = {
    assert!(dial_is_a_permutation(ABLATE_ARMS));
    assert!(dial_is_a_permutation(DRAIN_RUNGS));
};

Each dial is asserted to be a permutation of 0..len, so reusing a value fails
to build, and adding an arm without widening the array fails to build too. The
lists are also what arm_name reads, so they are load-bearing rather than
decorative — an unlisted value has no name to print. The root cause is named in
the doc comment: a bare numeric const dial is what two experiment sets can extend
independently, and const generics take no enums, so the guard is the answer rather
than a type.

TWICE_GLOBAL/SHARED/ALL renumbered to 5/6/7; DRAIN_* gets its own axis 0-4.

#144's neutrality guarantee, re-verified after the merge

regcount on the merged tree: "4 kernel(s) in both crates: identical opcode
counts"
, and all three shipped entries census identically in examples/ and
experiments/:

kernel               mma  ldtm  ldtm.wait  tma  stmatrix  ld.sh.v4  st.g.v4  st.g.b32  cvt  bar.sync  bar.warp  mbar.arrive
gemm_sol_m256         16     2          1    3         2         1        1         4    8         2         2            6
gemm_sol_m256_n128    16     2          1    2         2         1        1         4    8         2         2            6
gemm_sol_m512         32     2          1    4         2         1        1         4    8         2         2            6

ldtm.wait 2 → 1 is the only column this PR moves in a shipped kernel. Every
other one is #146's value unchanged.

The census also caught a void arm mid-merge, which is the point of having it

Pointing the twice_* arms at SHIPPED_DRAIN after the flip made all three
census identical to paired — the ladder lives in the per-issue drain's loop,
so routing them through the batched one silently deleted the doubling. Caught by
the census, not by a number that looked plausible. The arms now name
DRAIN_PER_ISSUE explicitly, the ladder's base row is per issue, and the table
prints per issue − no drain beside paired − no drain so the wait term is
visible in situ (0.25 µs at 4096³, 0.50 at 8192³).

The wide rung's first spelling was void the same way and for a different reason:
written as a loop over an [_; ISSUES] array it censused as one ldtm with a
1024-byte frame — LLVM declined to unroll at four issues, the array needed a
runtime index and went to local memory. tile_x8_batched names its issues at
literal indices for that reason, and the reason is in its doc.

The full arm census

kernel                       mma  ldtm  ldtm.wait  tma  stmatrix  ld.sh.v4  st.g.v4  st.g.b32  cvt  regs  frame
gemm_sol_m512                 32     2          1    4         2         1        1         4    8    96    256
gemm_sol_m512_paired          32     2          1    4         2         1        1         4    8   112    256
gemm_sol_m512_per_issue       32     2          2    4         2         1        1         4    8   112    256
gemm_sol_m512_wide            32     4          1    4         2         1        1         4    8   168    512
gemm_sol_m512_nocvt           32     2          1    4         1         1        1         4    0    91    256
gemm_sol_m512_pack16          32     1          1    4         1         1        1         4    0    68    128
gemm_sol_m512_twice_global    32     2          2    4         2         2        2         8    8    94    256
gemm_sol_m512_twice_shared    32     2          2    4         4         2        2         8   16   133    256
gemm_sol_m512_twice_all       32     4          4    4         4         2        2         8   16    94    256
gemm_sol_m512_nodrain         32     0          0    4         0         0        0         0    0    71      0

Every ladder rung doubles exactly the columns it names. nocvt and pack16 show
cvt 0 with the store columns intact. mbar.arrive is uniform across every
draining arm, so no arm dropped a barrier. Zero spills everywhere.

nocvt's stmatrix reads 1 static against paired's 2 because its block loop
rolls where store_tile_x4's nested loops give two — the dynamic count is the
same eight a band. That is the one place the oracle is not byte-identical
codegen, and it is stated rather than glossed.

Correctness

  • examples green: all three shipped entries exact over 1 048 576 BF16
    outputs
    each, == and no tolerance.
  • gemm_sol_drains, a gate in the experiments crate's check: paired,
    per issue and wide at both entries, all six exact. nocvt and pack16
    are excluded and cannot be included — stated on Arm::EXACT_DRAINS.
  • device-tests' ldtm x8 batched map: sttm round trip with one line
    changed, four .x8 loads outstanding at once resolved after a single
    tcgen05.wait::ld. That is a claim about what one wait retires which no document
    at this pin makes, and a batched LDTM returning its registers in another order is
    exactly how this breaks without faulting.

Runs

build ×4, regcount ×5, examples ×3, bench --case sol-ablate ×2 — plus
cargo test, cargo clippy --all-targets and scripts/fmt. Two of those build
runs and two regcount runs were failures I caused and fixed; one bench run
died on the pack16 fault, which is reported above as a finding rather than
hidden.

What this does not separate

  • stmatrix from the write-after-write a doubled stmatrix pass owes its own
    staging tile.
    5.86 µs is an upper bound on that pass. The lower bound is 4.91
    by subtraction from the three clean terms, and the conclusion is the same.
  • wide's loss from wide's stack frame.
  • Our drain from upstream's — but the bound is now tight. Time gemm_sol_final unported: two thirds of the gap to cuBLASLt is upstream's own (#138) #145 puts the port
    4.3% behind upstream at 8192³ and 7.8% at 4096³, so at most that much of the
    epilogue's 11.2% and 20.1% can be port overhead. gemm_sol's [256, 256] entry does not return at 4096x4096x1024, and the shape is inside its contract #149's stage fold is a
    separate port defect in the MMA consumer worth +2.2-4.3% at 4096³, and it
    consumes part of that same budget — so the epilogue is very likely almost
    entirely a cost the reference pays too
    . (Its mechanism as published is the
    inter-stage critical path — the scalar work between one load.wait
    returning and the next being entered. The earlier "shorter spin loop" account
    was retracted by its own author after the PTX showed that loop got one
    instruction longer and the kernel got faster anyway. The corrected mechanism
    is the same shape as this PR's finding: a cost that exists only in the presence
    of the phase beside it, which is why whole gains 4% and mma only, which has
    no waits, is null across four passes.) The arm that would settle it is upstream's own device body
    at NO_DRAIN, now that Time gemm_sol_final unported: two thirds of the gap to cuBLASLt is upstream's own (#138) #145's harness is in this crate.

What to try next

Both routes left are concurrency, because that is what the ladder left: cvt zero,
LDTM zero, store width maximal, and stmatrix not bandwidth-bound and not
bank-conflicted (Swizzle128B maps one m8n8 matrix's eight rows onto eight
chunks whose banks tile all 32 exactly once, at both staging pitches).

  • A second epilogue warpgroup. Four warps cannot fill the shared-memory
    pipeline and TMEM lane ownership forbids a fifth within a warpgroup — but warp
    4 is warpgroup 1's warp 0 and owns the same 32 lanes as warp 0, so eight
    epilogue warps can split the accumulator's columns where they cannot split
    its rows. Free in the resource that binds: eight warps staging [32, 128] is
    65 536 B against four staging [32, 256], and eight staging [32, 64] is
    32 768 B against four staging [32, 128] — both plans byte-identical, so the
    launch contract's shared figure and the no drain control both survive. 320
    threads rather than 192, inside the register file at 112. The one lever left with
    double-digit headroom — and why this does not contradict "there cannot be a
    fifth warp"
    is spelled out below.
  • The rolled shared→global loop. The census says
    global.rs::drain_in_accesses is rolled — one static ld.shared.v4 and one
    st.global.v4 for 16 iterations a lane — so every iteration exposes a shared-load
    latency in front of its store. Batching four chunks before the first store is
    ~30 lines in global.rs and acts on the 42% third; every kernel using
    store_shared_rows would get it.

The re-merge

Merged onto gemm-sol-integrated at 20bd898 (the head; the coordinator's
message named 4d47cda, which 20bd898 is a documentation-only commit on top
of). Re-validated after merging, not before:

  • build green.
  • regcount green: 4 kernel(s) in both crates: identical opcode counts, and
    all three shipped entries census identically in examples/ and experiments/ —
    mma 16/16/32, ldtm 2, ldtm.wait 1, tma 3/2/4, stmatrix 2, ld.sh.v4 1, st.g.v4 1, st.g.b32 4, cvt 8, bar.sync 2, bar.warp 2, mbar.arrive 6. ldtm.wait 2 → 1 is
    still the only column this PR moves in a shipped kernel.
  • Every ablation arm still censuses as its name claims: twice global doubles the
    store columns only, twice shared adds stmatrix 2 → 4 and cvt 8 → 16,
    twice all adds ldtm/ldtm.wait 2 → 4, nocvt and pack16 show cvt 0 with
    the stores intact. The mid-merge void does not recur.
  • examples green: all three shipped entries and all three exact drain rungs
    exact over 1 048 576 BF16 outputs each.

Two collisions, both caught at build time rather than in a number:

  1. Arm::LADDER — the cadence agent's depth-table arm set and my doubling
    ladder had taken the same name. Mine is now Arm::DOUBLING, and both docs say
    which is which: LADDER sweeps K with the kernel held, DOUBLING holds the
    shape and repeats a phase.
  2. about() non-exhaustive — nine new arms across the two branches.

The ABLATE enumeration did not collide, which is the guard working as
intended: FOLD came in as its own bool axis rather than as ABLATE values, so
dial_is_a_permutation(ABLATE_ARMS) had nothing to catch. The body now carries
three orthogonal dials — ABLATE (which phase), FOLD (the MMA warp's ring
index), DRAIN (the epilogue's issue structure) — and the two numeric ones are
each guarded as a permutation of 0..len.

Why a second epilogue warpgroup does not contradict "there cannot be a fifth warp"

These read as opposite claims and are not, because they are about different axes of
the same constraint.

TMEM lane ownership is over rows. A warp's tcgen05.ld reaches the 32 TMEM
lanes of its own sub-partition, and which sub-partition is fixed by the warp's
index within its warpgroup. A [128, N] accumulator is 128 lanes, so the four
warps of one warpgroup tile it exactly: EPILOGUE_WARPS = BLOCK_M / 32 is that
arithmetic, and a fifth warp of the same warpgroup has no rows left to own.
That is the sense in which there cannot be a fifth, and it is why widening the
epilogue by adding warps to warpgroup 0 is not a lever.

A second warpgroup does not add a fifth warp to the first. Warp 4 is warpgroup
1's warp 0, and it owns the same 32 lanes warp 0 owns — rows 0-31, again. So
eight epilogue warps cannot split the accumulator's rows any finer than four
can; what they can split is its columns. Warp w drains rows 32 · (w % 4) and
the column half w / 4, and every warp is still reading only the lanes its
sub-partition index entitles it to. Lane ownership is untouched; it is satisfied
twice over
rather than relaxed.

So the two statements are: rows are tiled out at four warps (hardware, and it
closes the row axis for good), and columns are not (which is the axis the lever
uses). The reason this is worth trying is that the ladder showed the drain is
latency-bound — cvt zero, LDTM waits zero, store width maximal, stmatrix at
under 10% of shared write bandwidth and not bank-conflicted — and eight warps is
twice the outstanding work against the same shared-memory pipeline.

And it is free in the resource that binds: eight warps staging [32, 128] is
65 536 B against four staging [32, 256], and eight staging [32, 64] is 32 768 B
against four staging [32, 128] — both shared plans byte-identical, so the
launch contract's shared figure and the no drain control both survive. What it
costs is 320 threads rather than 192, which at 112 registers is inside the register
file.

The one thing it does not inherit is the full/empty arrival count:
empty.init_all(RANKS * EPILOGUE_WARPS * 32) is derived from EPILOGUE_WARPS, so
it follows, but the [512, 256] entry's two-half handshake would want re-reading
before anyone trusts a number off it.

feitreim added 6 commits July 29, 2026 19:28
…g ladder, and one wait a band where there were two

The epilogue is the largest single term in `gemm_sol` at both shapes with a
gap. #144 measured it at 19.7% and 11.9% of the launch and left two things
fused: the drain's own cost and its failure to overlap. This separates them,
prices the chain a third at a time, and ships the one lever the split says is
worth anything.

Three new `ABLATE` arms make a doubling ladder, each repeating one more pass of
the drain per band with the extra global stores aimed at the cluster's own
first output tile so they stay in L2. An extra pass has nothing left to hide
behind, so it is paid serially by construction: `twice all - whole` is the
drain's own occupancy cost D, and `whole - no drain` is what the launch pays.

E > D at both shapes. None of the drain is hidden, and at M256 -- where the
accumulator IS double-buffered across tiles -- E is 191% of D, so the drain
also slows the phase it runs beside. The LDTM half is free: doubling
`tcgen05.ld` and its waits costs zero. What is left is the register->shared
half, at 60-70% of D.

Two drains built on that. `paired` puts a band's two LDTM issues in flight
before one wait and ships (+0.9% at 8192^3, nothing at 4096^3, two round-robin
passes each, every census column but the wait identical). `wide` puts four
behind one wait and loses.

New: `TmemTile::tile_x8_batched`, an `ldtm.wait` census column, a
`ldtm x8 batched map` device case, six ablation arms, two tables, and a
correctness gate for the arms that compute a right C.
@feitreim feitreim changed the title The drain is exposed whole and the LDTM half of it is free: a doubling ladder, and one wait a band where there were two The drain is exposed whole, and both of its expected levers measure zero Jul 30, 2026
@feitreim
feitreim changed the base branch from gemm-sol-diag to gemm-sol-integrated July 30, 2026 00:33
@feitreim
feitreim merged commit 97b6406 into gemm-sol-integrated Jul 30, 2026
4 checks passed
feitreim added a commit that referenced this pull request Jul 30, 2026
…to cuBLASLt is the reference's own (#138)

NVLabs' canonical Blackwell `gemm_sol_final`, rebuilt through ferro-kittens' typed
tiles and pipeline primitives rather than transcribed as device code: CLC work
stealing, two-CTA clusters with `cta_group::2` MMA, four TMA/shared stages, two
TMEM accumulator halves, an unrolled K loop, L2-aware output ordering, and three
asynchronous warp streams. FP16 in, FP32 compute, BF16 out; every entry checked
exact over 1 048 576 outputs.

Five PRs of measurement landed with it, and between them they moved the target.

**The reference is not parity.** Upstream `gemm_sol_final`, unported and timed on
one device, one clock, beside cuBLASLt and beside this port, reaches only
0.877/0.911/0.966 of cuBLASLt at 4096/8192/16384 cubed (#145). Two thirds of the
shortfall is upstream's own; a third is port overhead, consistently across all
three sizes. Matching the reference was never a route to parity.

**Wave quantization cancels.** cuBLASLt pays the identical sawtooth on the
identical tile count — 3.46/3.89/4.32/4.76 waves against ours over 74 clusters —
so it divides out of the ratio and 4096 cubed's deficit is a rate, not a tiling
problem (#146). Every tiling lever that buys quantization back was built and lost;
a third `[256, 128]` entry ships for shapes at or below half a wave, worth
1.27-1.29x at 1024/1536 cubed.

**Where the time goes, laddered in K rather than read off a launch** (#144, #148).
An arm's launch conflates a rate with a per-tile constant: un-laddered, the MMA-only
arm read 88.7% of peak and looked like an issue ceiling; laddered it is 100.6%. The
feed is a duty-cycle problem, not bandwidth and not instruction count — the narrow
tile needs its feed running 95.5% of tensor-core busy time and pays 24.5% for the
contention, where the wide tile needs 55.7% and pays nothing. The barrier round
trip is zero.

**One port defect found and fixed.** The MMA warp indexed both rings and both stage
barriers off a runtime `global_k`, where `k_blocks % STAGES == 0` makes each
unrolled position's stage a constant. Handing it as a const folds barrier addresses
to literals, hoists both descriptors out of the K loop, and computes the parity once
a turn instead of four times: +2.2 to +4.3% at 4096 cubed, null at 8192 as
predicted. The gain is in the inter-stage critical path, not the spin loop — an
earlier account of the mechanism was retracted when the PTX contradicted it.

**The drain is exposed whole, and both of its expected levers measure zero** (#147).
A doubling ladder, where an extra pass is serial by construction, separates the
drain's own cost from what the launch pays: the launch pays 191% of a serial drain
at 4096 cubed and 118% at 8192, so there is no overlap to fail. Doubling LDTM and
its waits costs nothing; `.pack::16b` does remove the `cvt` but faults out of bounds,
and a legal `nocvt` oracle is slower, so the convert was never the cost. The
62-70% is the `stmatrix` pass and its write-after-write.

**A PTX count is a hypothesis; SASS or a timed arm is the evidence.** Two levers
filed off PTX instruction counts turned out to be folded entirely by `ptxas` —
three poll bodies differing by an instruction in PTX are byte-identical at three
instructions in SASS. `modal_app.py::_print_sass_loops` disassembles a real cubin
and finds loops by backward branch rather than by mnemonic. What this does and does
not disturb about the repo's existing PTX conclusions is recorded in
`experiments/README.md`.

Against cuBLASLt 0.778 and against upstream 0.917 at 4096 cubed, from 0.758 and
0.891. Nsight Compute is confirmed unavailable on this harness and the reason has a
floor under it, so ablation is the instrument.

Open: **#149**, the `[256, 256]` entry does not return at 4096x4096x1024, a shape
inside its own contract.
feitreim added a commit that referenced this pull request Jul 30, 2026
cuda-oxide goes from b099f64 to 20a5616 across all four manifests, all four
locks and `CUDA_OXIDE_REF` in `modal_app.py` — nine build files that move
together, since the codegen backend and the device/host/core crates have to come
from one revision. The lockfile diffs are the rev string and nothing else: zero
non-rev changed lines across the four, and `cargo metadata --locked` passes on
each.

#142's 41-case validation predates the #144–#148 stack, so it no longer covers
the tree and is not leaned on. What is leaned on is re-verification: every claim
this commit repoints was read out of a checkout whose `git rev-parse HEAD` was
confirmed to be `20a56163f258e09f2c51e4c27ae4e4ff17582443` first, which is
#106's rule. Six of the seven checkouts in that cargo directory are not the pin,
`/Users/finn/projects/cuda-oxide` (at `29396b7`) among them.

**Two claims did not just need a new hash.**

`src/lib.rs` said libdevice math is legal beside tcgen05 in one pure-PTX
artifact "at cuda-oxide b099f64". Moving that hash would have asserted it at a
revision nothing checks, because **nothing in this tree makes a libdevice
call** — `Abs` clears the sign bit rather than calling `fabsf`, `fmax`/`fmin`
are comparison-selects, `Sqrt`/`rsqrt` lower to native `sqrt.rn.f32`, and
`exp2`/`log2` are FMA polynomials or the `ex2` SFU. So no gate re-establishes
it, a green `build` says nothing either way, and the citation stays at
`b099f64` with the reason written down.

`GAPS.md` said `cp.reduce.async.bulk.tensor` was absent from cuda-oxide "in
every form — not in the generated crate and not in `intrinsics/imported.json`
either", and argued from that that reduction stores were a lowering to
contribute. The records are there, and were there at `b099f64` too: 64 of them
at both revisions, spelled `int_nvvm_cp_async_bulk_tensor_reduce_*` — which is
why a grep for `cp_reduce_*` finds nothing and how the claim lasted. They are
simply not admitted to the generated crate, where the count is zero. That makes
#42 the same shape as prefetch one row below it, a generation-list change rather
than a lowering, and a smaller ask than the file claimed.

**Provenance kept where it is the historical fact.** The `gemm_sol_upstream`
copy was taken at `b099f64` and the port measured there; `gemm_sol_final/` is
byte-identical at `20a5616` and upstream's `kernels.rs` and the vendored copy
all hash to `6746e517…`, so those citations keep `b099f64` and say why. The
`stmatrix` defect is annotated rather than rewritten: #145 proved it survives
the bump, so `ldst.rs`'s `ptx_asm!` workaround stays and `upstream_ptx`'s
docstring now records that the bump drops neither workaround.

**One retracted argument removed rather than repointed.** `gemm.rs`'s
`.pack::16b` doc still carried "the register count does not fall, so nothing is
packed" — the sixth instance of the register-count error (#47, #63, #67, #76,
#81) that #147 refuted and corrected in `experiments/README.md`. Repointing the
hash beside it would have asserted the retracted reasoning at the new pin, so
the doc now carries #147's two answers instead: `cvt.rn.bf16x2` censuses at 0
and the arm faults with `Xid 13`.
feitreim added a commit that referenced this pull request Jul 30, 2026
cuda-oxide goes from b099f64 to 20a5616 across all four manifests, all four
locks and `CUDA_OXIDE_REF` in `modal_app.py` — nine build files that move
together, since the codegen backend and the device/host/core crates have to come
from one revision. The lockfile diffs are the rev string and nothing else: zero
non-rev changed lines across the four, and `cargo metadata --locked` passes on
each.

#142's 41-case validation predates the #144–#148 stack, so it no longer covers
the tree and is not leaned on. What is leaned on is re-verification: every claim
this commit repoints was read out of a checkout whose `git rev-parse HEAD` was
confirmed to be `20a56163f258e09f2c51e4c27ae4e4ff17582443` first, which is
#106's rule. Six of the seven checkouts in that cargo directory are not the pin,
`/Users/finn/projects/cuda-oxide` (at `29396b7`) among them.

**Two claims did not just need a new hash.**

`src/lib.rs` said libdevice math is legal beside tcgen05 in one pure-PTX
artifact "at cuda-oxide b099f64". Moving that hash would have asserted it at a
revision nothing checks, because **nothing in this tree makes a libdevice
call** — `Abs` clears the sign bit rather than calling `fabsf`, `fmax`/`fmin`
are comparison-selects, `Sqrt`/`rsqrt` lower to native `sqrt.rn.f32`, and
`exp2`/`log2` are FMA polynomials or the `ex2` SFU. So no gate re-establishes
it, a green `build` says nothing either way, and the citation stays at
`b099f64` with the reason written down.

`GAPS.md` said `cp.reduce.async.bulk.tensor` was absent from cuda-oxide "in
every form — not in the generated crate and not in `intrinsics/imported.json`
either", and argued from that that reduction stores were a lowering to
contribute. The records are there, and were there at `b099f64` too: 64 of them
at both revisions, spelled `int_nvvm_cp_async_bulk_tensor_reduce_*` — which is
why a grep for `cp_reduce_*` finds nothing and how the claim lasted. They are
simply not admitted to the generated crate, where the count is zero. That makes
#42 the same shape as prefetch one row below it, a generation-list change rather
than a lowering, and a smaller ask than the file claimed.

**Provenance kept where it is the historical fact.** The `gemm_sol_upstream`
copy was taken at `b099f64` and the port measured there; `gemm_sol_final/` is
byte-identical at `20a5616` and upstream's `kernels.rs` and the vendored copy
all hash to `6746e517…`, so those citations keep `b099f64` and say why. The
`stmatrix` defect is annotated rather than rewritten: #145 proved it survives
the bump, so `ldst.rs`'s `ptx_asm!` workaround stays and `upstream_ptx`'s
docstring now records that the bump drops neither workaround.

**One retracted argument removed rather than repointed.** `gemm.rs`'s
`.pack::16b` doc still carried "the register count does not fall, so nothing is
packed" — the sixth instance of the register-count error (#47, #63, #67, #76,
#81) that #147 refuted and corrected in `experiments/README.md`. Repointing the
hash beside it would have asserted the retracted reasoning at the new pin, so
the doc now carries #147's two answers instead: `cvt.rn.bf16x2` censuses at 0
and the arm faults with `Xid 13`.
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.

1 participant