Repository navigation
The two pair tiles cross over between 1536 and 2048 cubed, and the host picks from the shape (#105) - #209
Merged
Conversation
…st picks from the shape (#105) #104 promoted the pair tile to `[256, 256] @ STAGES = 3` and stated its two costs rather than burying them: `n % 256 == 0` where 128 used to do, and 18% at 1024 cubed. Both rungs stayed launchable, so the material for a fix was already in the file. What did not exist was anything choosing between them, or any measurement to choose by — the sweep had both tiles at 8192 cubed and 16384 cubed and the crossover is somewhere below 2048 cubed, which nothing had timed. `bench --case crossover` is that measurement. Four rungs across eight shapes: the pre-#104 kernel as the denominator, `[256, 128] @ s4` to price the occupancy step at a fixed tile, `[256, 256]` fused to price the tile at a fixed epilogue, and `[256, 256]` on `staged84` because that is what actually launches. Its own case rather than a fifth table on `tile`, which costs most of an hour where this costs a minute — a measurement the next tile change has to re-take should be cheap to re-take. It was run three times, and the reason is in the answer: those rows are 12-23 microsecond launches and #98's 2.9% of drift between containers is 10-12% down there. What reproduces is the sign. 512 and 1024 cubed lose on every run, 2048 cubed and above win on every run, and 1536 cubed straddles zero — so the crossover is bracketed at 36 < T <= 64 output tiles of the wide rung. Which mechanism it is, since the issue asks rather than assumes: **the tile's parallelism, and the occupancy step is not reachable at all down there.** The same-tile arm reads -2.0%, +11.1% and +0.0% at 1024 cubed across the three runs — not a small effect measured imprecisely, no effect — and the `reached` column says why before the clock does: at 32 clusters on 148 SMs no SM is asked to hold a second CTA, so a rung admitted for 3 and a rung admitted for 2 run the identical schedule. #101's 14-16% is a price on a resource the small end is not spending. The loss tracks the SM column instead: at 1024 cubed the wide tile puts 32 SMs to work where the narrow one puts 64, and loses 8.4-11.9%. `gemm::plan_for` is the chooser, host-side beside the grid arithmetic. It thresholds on the wide rung's tile count and not on `n`, because tile count against SM count is the quantity the mechanism is about — a threshold on `n` would send 16384x512 to the narrow rung and that shape has a full grid. It picks an epilogue with the tile because it has to: `staged84` is built on the wide rung only. `bench_with` does not consult it, so every A/B's control arm still reads the rung it names. No rung is deleted. The acceptance holds by construction below the threshold — the fallback is `gemm_256x128_s3`, the pre-#104 entry point itself and not a reconstruction of it — and by measurement above it. `n = 1152` is a kernel rather than an error, `4096x4224x4096` runs at 1271.7 TFLOP/s, and `GEMM_SIZES`' `256x128x256` row is back. `check` grows the one shape class that was on no gate at all: every check size in this file divides both tiles, so the chooser's fallback route had never been computed by anything. It takes its plan from `plan_for`, so it tests the rule and not only the rung it happens to pick.
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.
Closes #105.
#104 promoted the pair tile to
[256, 256] @ STAGES = 3and stated its twocosts rather than burying them. Both rungs stayed launchable, so the material
for a fix was already in the file; what did not exist was anything choosing
between them, or any measurement to choose by.
The instrument
bench --case crossover— four rungs across eight shapes, the sizes--case tiledoes not visit. Its own case rather than a fifth table there, becausetileis 8192³ and 16384³ dozens of times over and costs most of an hour: ameasurement the next tile change has to re-take should cost a minute. This
one runs in 47-72 s.
Two of the four arms are instruments rather than candidates:
[256,128] k64 s3[256,128] k64 s4[256,256] k64 s3[256,256] k64 s3 staged84The timing table
Run 3, in full, losing rows kept. B200, driver 580.95.05, one container,
--features cublas, every row checked element by element against the CPUreference before it was timed.
n % 256 != 0n % 256 != 0SMsismin(2·tiles, 148)— SMs the launch puts a CTA on at all.reachedis
ceil(CTAs / 148), the CTAs an SM must hold for the grid to be placed,against the
CTA/SMthe rung is admitted for.The percentages do not reproduce; the routing does
Three runs in three containers. Those rows are 12-23 µs launches and #98's 2.9%
of drift is 10-12% down there:
(Run 1 predates the
paidcolumn's correction and lost its 512³ rows to atruncated capture; every other cell is one container each.)
512³ and 1024³ lose on every run, 2048³ and above win on every run, 1536³
straddles zero. The crossover is between 36 and 64 output tiles of the wide
rung, and that is the whole of what these runs establish. Anyone quoting
"−8.4% at 1024³" is quoting one container.
Which mechanism: parallelism, and the step is not even reachable
The
[256,128] s3againsts4arm — same tile, same tile count, same waves,same intensity, 3 CTAs an SM against 2:
Below 2048³ the occupancy step does not have a sign — −2.0%, +11.1%, +0.0%
at 1024³ is no effect, not a small one, and the
reachedcolumn says why beforethe clock does: at 32 clusters on 148 SMs no SM is asked to hold a second CTA,
so a rung admitted for 3 and one admitted for 2 run the identical schedule.
#101's 14-16% is a price on a resource the small end is not spending.
So the small-size loss is quantization, and all of it: at 1024³ the wide
tile puts 32 SMs to work where the narrow one puts 64 and loses 8.4-11.9%; at
512³ it is 8 against 16 and 13.5-15.3%. The loss tracks the
SMscolumn, andthe arm built to price
CTA/SMreturns noise.Where the step is reachable it is −3.6 to −6.4% at 4096³ and above, and at
3072³ it is +8.1%: losing a CTA an SM shortens the grid from 222 clusters to
148, and 288 tiles divide into that at 97.3% wave efficiency against 64.9%. An
occupancy step whose sign is set by wave quantization is not a 14-16% constant,
and #101's figure should not be carried to sizes it was not taken at.
The rule as shipped
CROSSOVER_TILESis 64 — the upper end of the measured bracket, becauseeverything between 36 and 64 is unmeasured and a rule that has to guess should
guess toward the rung that was already shipping. Tiles, not
n: themechanism is tile count against SM count, and a threshold on
nwould send16384x512 — 32 wide tile-rows and a full grid — to the narrow rung.
It picks an epilogue with the tile because it has to:
staged84is built on thewide rung only, so the narrow route gives up #119's epilogue, and that cost is
inside the numbers above rather than beside them.
bench_withdoes notconsult it — a control whose rung moved with the shape would not be one — so
gemm_ws' control arm and every A/B ingemm.rsstill read the rung they name.gridandwave_efficiencydo consult it, becausebenchlaunches it.The chooser's own row, run 3, against the better of the two arms it was choosing
between (the two controls are excluded — scoring a rule against a rung it may
not pick measures nothing):
Run 1's threshold left 0.5% at 1536³ and run 2's left none; the column is zero
or inside the drift at every row of every run.
Acceptance
No rung is deleted. "No shape that worked before #104 is slower after this"
holds by construction below the threshold: the fallback is
gemm_256x128_s3,which is not a reconstruction of the pre-#104 kernel but the entry point itself,
kept launchable by #104 as its control. Below 64 wide tiles, and at every
nthe wide tile cannot divide, the launch is byte for byte the one that shipped.
Above the threshold it is faster, on three runs.
And the constraint the issue opens on is gone from the call site:
n = 1152isa kernel rather than an error,
4096x4224x4096runs at 1271.7 TFLOP/s and 0.769of cuBLASLt, and
GEMM_SIZES'256x128x256row — the one-cluster-one-itemfloor #87 had to delete — is back.
gemm::checkgrows the one shape class that was on no gate at all: every checksize in the file divides both tiles, so the fallback route had never been
computed by anything. It takes its plan from
plan_for, so it tests the ruleand not only the rung it happens to pick.
The denominator
cuBLASLt in the same container, run 3. Not a flattering table and the one worth
keeping: below 2048³ this kernel is 0.59-0.68 of a vendor GEMM whichever tile it
picks. The chooser stops #104 widening that gap; it recovers none of it.
Gates
GitHub Actions is in an outage; run by hand on this branch's head, rebased onto
origin/mainat 2703360 (#206).scripts/fmt --checkcargo test(library)scripts/modal-run buildcargo doc --features host,sm_100acodegen of all three kernel crates, plus the--features cublasbuildscripts/modal-run regcountgemm_cg2_staged_x8x4at 80 registers andgemm_256x128_s3at 168/0/0, both unchanged, since no kernel source movedscripts/modal-run examples512x384x256 exact on [256,128] k64 s3 (n % 256 != 0, so the chooser has no other rung)scripts/modal-run bench --case crossoverdevice_testswas not run: nosrc/ordevice-tests/file is touched and thediff is host-side dispatch and documentation.
What the next tile change has to re-measure
CROSSOVER_TILESis a property of this pair of rungs on this device. Moveeither tile, move
SHIPPED_EPILOGUE, or changeMAX_CLUSTERSand the bracketmoves. The instrument is
bench --case crossover, it costs a minute, and thething to read off it is which choosable arm wins at each size — not the
percentage, which below 2048³ does not survive a change of container.