Repository navigation
The batch that stopped paying at 16 pays to 32, because the fusions moved the wall - #117
Merged
Merged
Conversation
…oved the wall `B = 16` was chosen when a unit of batch cost 5.33 GiB and the curve went flat right after it. The fusions cut that to 3.39 GiB, which moves the B200's ceiling from 21 to 33 and, with it, where the curve flattens: 32 is worth 2.7% over 16, and the flat stretch is now 32 -> 33, not 16 -> 20. Measured on one B200, 12 steps with the first discarded, every number from train.rs itself: B tokens/s MFU peak VRAM vs B=16 16 90 286.2 40.09% 119.80 GiB -- 20 90 488.7 40.18% 133.36 GiB +0.22% 24 91 527.3 40.64% 146.94 GiB +1.37% 28 92 055.7 40.88% 160.50 GiB +1.96% 32 92 717.6 41.17% 174.05 GiB +2.69% 33 92 680.0 41.15% 177.40 GiB +2.65% 34 out of memory 32 keeps 4.30 GiB spare; 33 keeps 0.95 and buys nothing.
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.
B = 16was chosen in #105, when a unit of batch cost 5.33 GiB and the curvewent flat immediately after it. The fusions of #108-#114 cut that to 3.39 GiB,
which moves two things at once: the B200's ceiling from 21 to 33, and where the
curve flattens. It is now 32 -> 33, not 16 -> 20.
Measured
One B200 (178.35 GiB visible),
wiki-val-00000.tok, 12 steps with the firstdiscarded, every number from
bin/train.rsitself, all in one container.modal run modal_app.py::sweep_batch --batches 16,20,24,28,32 --steps 12.The memory model never breaks: every point is within 0.08 GiB of
65.5 + 3.39·B, and the fit through the endpoints is 3.388 GiB per unit ofBon 65.59 GiB of weights, gradients and AdamW moments.
The ceiling is 33, and it is measured
33 fits with 0.95 GiB to spare; 34 dies in allocation with
DriverError(2, "out of memory"). So the ceiling the slope predicts is theceiling the card has. 33 is also not faster than 32 — −0.04%, well inside the
run-to-run spread — so the last GiB buys nothing, and 32 is the largest batch
that still leaves a margin (4.30 GiB).
Same container, both refs
modal run modal_app.py::train_ab --ref batch-size-recheck, two rounds each,alternating, on one B200:
+1.94% on a card that ran ~1.4% slower overall than the sweep's, which is why
the pair is quoted alongside the sweep row rather than instead of it. Both
agree on sign and both clear the bar; take +1.9% as the conservative number.
(This is the first
train_abrun against a branch rather thanmain— it needsthe ref-resolution fix in #116.)
The win is not tile quantization
Worth saying, because in this codebase that is usually the first guess.
The tcgen05 GEMM grid is persistent and capped:
2 * min(tiles, 74)= 148 CTAs(
gpu/gemm/src/host.rs:80-94), one per SM. Every dominant GEMM thereforelaunches the same 148 CTAs at every batch size, and its last-wave efficiency
sits between 97% and 100% across 16..32 with no trend in
B. Nothing tilesbetter at 32 than at 16, and nothing tiles badly at any of them:
N = 2048·Band
C = 512·Bclear every divisibility gate for every integerB.What does change is the launches whose grid is small and proportional to
N.router_softmax_topkandrouter_backwardtakeLaunchConfig::for_num_elems(N)(gpu/model/src/lib.rs:4795,:5065), whichis 256 threads per block and so
N/256 = 8·Bblocks: 128 at B=16, less thanone wave on 148 SMs, and 256 at B=32. Beside them sit the fixed-width
serialization points —
moe_bin_assignat 8 CTAs,moe_aux_termsat 8 × 12layers, the loss tail at 1 — whose cost is simply amortized over twice the
tokens. A gain that accumulates gradually over 20/24/28/32 rather than arriving
as a step is what that predicts, and is what the table shows.
Costs
NandCin their header and refuse a mismatch, sonothing saved at
B = 16resumes here.bin/profile.rsstays at 12. It is the A/B referencecompare_profilebuilds historical refs against, and moving it would silently rebase every
before/after claim.
batch now has to come out of
Brather than out of slack.