Skip to content

The batch the B200 holds is 21, and the one worth taking is 16 - #105

Merged
feitreim merged 8 commits into
mainfrom
batch-size-sweep
Aug 6, 2026
Merged

feitreim merged 8 commits into
mainfrom
batch-size-sweep

Conversation

@feitreim

@feitreim feitreim commented Aug 6, 2026 •

Copy link
Copy Markdown
Owner

B = 12 was never measured against the card it runs on. Sweeping it says the
B200 holds 21, and that throughput stops paying at 16.

Measured

One B200 (178.4 GiB visible), wiki-val-00000.tok, 12 steps with the first
discarded, every number from bin/train.rs itself on current main.

B tokens/batch tokens/s MFU vs B=12 vs previous
12 24 576 79 200 35.17% — —
16 32 768 81 532 36.20% +2.94% +2.94%
18 36 864 81 684 36.27% +3.14% +0.19%
20 40 960 81 692 36.27% +3.15% +0.01%

The curve has one step in it and then flattens: 16 collects 2.94 of the 3.15
points on offer, and 20 costs 21 GiB for the remaining 0.2.

Allocation is entirely up front, so the figure after the workspace is also the
peak — the first step adds nothing to it. 12 sits at 129.4 GiB, and each unit
of B is 5.33 GiB on top of a fixed 65.4 GiB of weights, gradients and AdamW
moments. 21 fits with 1.1 GiB to spare and 22 does not. 16 leaves 27 GiB.

Shape

N, NP and C were three literals that had to be edited together and agree
with B; a wrong one was a runtime assert at best. They now follow from B,
which is the only number left to change. C = N * K / E is the capacity factor
of one that the literal 6_144 already encoded.

modal run modal_app.py::sweep_batch --batches 12,16,20 is the measurement. It
rewrites that one line per batch and builds the trainer again, which the
derivation above is what makes possible.

Why the sweep builds the trainer each time

The first version of this measured a separate binary carrying every batch size
at once, picking one at run time — one build for a whole sweep. It read 12 ->
20 as +5.5%. cuda-oxide collects kernels from the selected binary target, and
that binary's six monomorphizations do not compile to the trainer's device
code: it agreed with train.rs to 0.7% at B=12, the batch it was checked
against, and was 3.0% high at B=20. The +5.5% was its own codegen.

So the harness is gone and the sweep pays ~25s of rebuild per batch, which is
nothing beside the minutes each one spends initializing parameters.

Costs

  • Checkpoints record N and C in their header and refuse a mismatch, so
    nothing saved at B = 12 resumes here.
  • bin/profile.rs stays at 12. It is the A/B reference compare_profile
    builds historical refs against, and moving it would silently rebase every
    before/after claim.

@feitreim feitreim changed the title The batch the B200 actually holds is 18, and the one worth taking is 16 The batch the B200 holds is 21, and the one worth taking is 16 Aug 6, 2026
@feitreim
feitreim merged commit 174242b into main Aug 6, 2026
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