Repository navigation
Eight epilogue warps split the columns and the drain does not get faster: the axis that is free is not the axis the hardware parallelizes - #153
Conversation
a7c26f7 to
6babbfa
Compare
…ster: the axis that is free is not the axis the hardware parallelizes The drain is ~12 points of the launch at 8192^3 and ~20 at 4096^3, E > D says it interferes rather than failing to overlap, and LDTM waits, the convert and store width all measure zero. That left adding parallelism, and lane ownership forbids a fifth warp per warpgroup -- but warp 4 is warpgroup 1's warp 0 and owns the same rows, so eight warps can split the accumulator's COLUMNS. Built, exact, and it does not pay: -1.4/-1.8% at 4096^3 and +0.3/+0.4% at 8192^3 over two round-robin passes, against a `no drain` control at its own 320 threads that matches the 192-thread one to a tenth of a percent. So the two extra warps are free when idle and the drain is slower once split -- -9% of the drain at 4096^3, +3% at 8192^3, for twice the warps at the same work. 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, so a column split puts two requesters on each of four sub-partitions instead of spreading over more. There is no third axis. Kept as a rung, exact at both entries over 1 048 576 BF16 outputs, which is what says the null is about the hardware and not the code.
6babbfa to
66e77a3
Compare
|
The block is cleared. Re-run on The exactness bar passes on this tree. The tables, re-measured on
The control still holds, which is what makes this a finding rather than a wash. The conclusion reproduces across the pin bump, the rebase and the container: −1.7/−1.9% at 4096³ and +0.1/+0.2% at 8192³, against −1.4/−1.8% and +0.3/+0.4% pre-rebase. Same sign, same verdict, and it is not shipped. Also green on this head: |
The lever, and the null
The drain is the largest remaining term in
gemm_sol, and #147 left it with threeof its four internal levers measured at zero: LDTM waits (doubling them costs
nothing), the convert (the
nocvtoracle is 0.0-1.4% slower), and store width(
stmatrix.m8n8.x4is the widest b16 form there is).E > Dsays it interfereswith the phase beside it rather than failing to overlap. A latency-bound chain that
cannot be widened or shortened leaves adding parallelism — and lane ownership
forbids a fifth epilogue warp per warpgroup, but warp 4 is warpgroup 1's warp 0 and
owns the same rows, so eight warps can split the accumulator's columns.
Built, exact, and it does not pay. More usefully: the reason it does not pay
closes the direction rather than just declining it.
Pre-rebase base
a7c26f7, cuBLASLt 1683.6 and 2157.9 TFLOP/s in thatcontainer:
[256,256][512,256]−1.4% and −1.8% of the launch at 4096³; +0.3% and +0.4% at 8192³, both passes
agreeing in sign at both shapes.
Two round-robin passes at each shape. Not shippable, kept as a rung.
The control that makes it a finding rather than a wash
Each arm subtracts the
no drainat its own thread count, because the splitchanges the launch geometry and a shared control would carry two warps of
scheduling into the subtraction. Those two controls come out identical:
no drain, 192 threadsno drain, 320 threadsTo a tenth of a percent, at both shapes, on
a7c26f7.So the two extra warps are free when they do nothing, at both shapes. The loss
is not "320 threads is slower" — it is the drain being slower once it is split, at
the same total work.
Why, and why there is no third axis
The mechanism is the same resource that fixed the row axis in the first place.
tcgen05.ldreaches the 32 tensor-memory lanes of the issuing warp's ownsub-partition, and which sub-partition that is comes from the warp's index within
its warpgroup. Warps 0 and 4 therefore own the same 32 lanes. A column split
does not spread the LDTM traffic over more sub-partitions — it puts two
requesters on each of the same four. Same ports, twice the queueing.
EPILOGUE_ROWS = BLOCK_M / 32is hardware arithmetic, and a fifth warp of a warpgroup has no rowsleft to own.
those lanes, which is what this PR measures.
There is no third axis. So the drain is bound by something shared across warps
rather than by per-warp latency, and per-warp parallelism cannot reach it.
What that leaves, by elimination
Not bytes: 262 144 B into shared per cluster per tile in ~6 µs is 3.5 TB/s
device-wide against an SM's ~230 GB/s of shared write bandwidth — under 10% of it.
Not bank conflicts:
Swizzle128Bmaps onestmatrix.m8n8matrix's eight rows ontoeight distinct 16-byte chunks whose banks tile all 32 exactly once, at every staging
pitch here, because every row pitch is a whole multiple of 128 B and the row term
drops out of the bank index. Not width, not the convert, not the waits.
What is left is the
stmatrixscatter's transaction rate, which nothing hereseparates from its byte rate. That is the honest end of the chain, and the arm that
would separate them changes the access pattern at constant bytes and constant
instruction count.
The two things carried in
1. The
[512, 256]entry's two-half handshake inherits the split, and that is afinding rather than an assumption. I flagged it as the one thing the split might
not get for free. Re-read: for each sequence the epilogue waits
full.sem(half),drains, and arrives on
empty.sem(half), for each of two halves. A column splitleaves the set of warps touching each half unchanged — all of them, once — so the
only thing that moves is the arrival count, from
RANKS · 4 · 32toRANKS · 8 · 32.initializenow takes that count as an argument rather thanderiving it from a module constant. A wrong count would have hung rather than
mis-answered; it is exact at both entries instead.
2. Shared bytes: zero delta, at all three entries — and now an assert, not
prose.
shared_plantakes the entry's staging width, and doubling the warpshalves each warp's width, so the product is unmoved by construction:
[256, 256][32, 256][32, 128][256, 128][32, 128][32, 64][512, 256][32, 128][32, 64]…and the same for the other two entries.
dynamic_sharedis 196 864 / 131 328 /229 632 either way, which is what lets one
no draincontrol at each thread countserve its arm and keeps residency at the one CTA/SM that binds.
Correctness is the gate, because the census cannot be
Exact over 1 048 576 BF16 outputs at both wide entries,
==and no tolerance,through
gemm_sol_drainsin the experiments crate'scheck— plus all threeshipped entries unchanged and exact.
That is load-bearing here in a way it usually is not: the split's opcode census is
identical to the shipped kernel's in every column, because each warp runs half as
many staged passes through the same rolled loop. So the census can only be negative
evidence — it proves the shipped kernels did not move, and it cannot say the split
happened. A split that sent both column groups to the same columns would have left
half of
Cuntouched and censused exactly the same. The exact outputs are also theonly evidence anywhere that warp 4 really does own warp 0's tensor-memory lanes:
no document at this pin states it, and nothing in tree had asked before.
regcounton6babbfa:4 kernel(s) in both crates: identical opcode counts, and all three shipped entries identical inexamples/andexperiments/with
ldtm.waitat 1 — the only column this branch moves in a shipped kernel.Every arm still reads as its name claims on this base — the ladder doubles exactly
the columns it names,
nocvtandpack16showcvt0 with the stores intact, andthe split is opcode-identical to the shipped kernel, which is the point of the
section above. Zero spills everywhere; the split's controls carry no frame.
The exactness bar has not been re-run on
6babbfa. It passed ona7c26f7—paired,per issue,wideandtwo warpgroupsexact over 1 048 576 BF16outputs at both wide entries, plus all three shipped entries — and
examplesonthis base died on the spend limit before launching. Since that gate is the only
evidence both that the split happened and that warp 4 owns warp 0's TMEM lanes,
this PR should not land until it has run on
6babbfa.PTX counts as hypotheses
Taken as instructed. Nothing here concludes from an instruction count: the census's
role is entirely negative, and every claim about the split is a timing with a
control and two passes. The one place a count appears is the shared-bytes table,
which is arithmetic on a plan rather than a count of emitted instructions.
The rebase
git rebase --onto origin/main origin/gemm-sol, as instructed. It did not applycleanly — 43 conflicts — so it was resolved rather than replayed:
gemm_sol.rs, ten hunks, all one shape: both sides appended const parametersto the same generic lists. Kept both, with The item handoff held one work item and the chain permits four, so 4096x4096x1024 never returned (#149) #154's axes first, so a call site reads
ABLATE, FOLD, DRAIN, WATCH(which phase, which spelling) beforeGROUPS, WARP_STAGE, WIDE_BAND, WIDE_ISSUES(how the epilogue is laid out).sol_ablate.rs, 33 hunks: tookmain's and re-applied the split's fourkernels, arms, table,
threads()and module doc.sol_watch.rs: The item handoff held one work item and the chain permits four, so 4096x4096x1024 never returned (#149) #154's module calls the bodies too and needed the new axes.Found by the build rather than by a conflict.
The two parameterisations do not interact
#154 changed the arrival count's neighbour, not the count. The resolved code shows
it in adjacent lines:
emptyis the accumulator handshake and scales in arrivals with epilogue warps;ready/infoare the item handoff and scale in depth withITEMS. Neitherquantity appears in the other's expression, so neither can silently override the
other, and
ready's waiters are unbounded so eight warps waiting on one barrierneeds no change.
One convention, generalised out of this PR
DRAIN_WIDE's band is 128 columns and a band must divide the per-warp stagingwidth, which is 64 at two warpgroups. A literal
128in the drain dial is then anillegal instantiation even in the dead match arm — Rust monomorphizes both sides
of a
matchon a const before anything folds it away. So the band and its issuecount became parameters supplied by the entry, which is the only place that knows
both numbers.
That is the same class as #147's dial collision, so it is now written on
dial_is_a_permutationitself as the second half of the rule:0..len— checked at compile time, because acollision otherwise silently remaps one arm onto another.
shape a dial implies has to come from whoever knows all the dials, rather than
being written as a literal where one dial can see it and the others cannot.
Runs
On
6babbfa(post-rebase):buildpass,regcountpass,cargo test,cargo clippy --all-targets,scripts/fmtpass.examplesandbench --case sol-ablatedid not run — the Modal workspace hit its spend limit(
benchexit 2,examplesexit 1workspace is disabled), which isinfrastructure and not the diff.
On
a7c26f7(pre-rebase):build,regcount,examplesandbench --case sol-ablateall pass, and that is where every timing above and theexactness bar come from.
What this does not separate
stmatrixscatter's transaction rate from its byte rate. The end of thechain, and it wants a counter this container does not have.
split between the two shapes is consistent with contention a longer K loop
absorbs, but this PR does not establish that.
reproduced twice; the difference is reported, not explained.