04 / THE ARC

What multiplies, and what doesn't

Before splitting anything across cards, be exact about which piles of memory grow when you turn which dial. Two dials, two different answers, and mixing them up makes the rest of this session unreadable.

Batch size does not copy the model

A batch of 8 means 8 samples flow through the same weights. The weights are read, not consumed. Sample three does not need a private copy of the matrix, any more than eight people reading one signpost need eight signposts.

8 samples in the batch the weights one copy 8 sets of activations raise the batch to 64 and this side grows eightfold this does not move
One set of weights in the middle, regardless of how many samples pass through it. What multiplies is on the right.

What does scale with batch size is activations — the intermediate values each sample produces on its way through the network, kept because the backward pass needs them. A batch of 8 holds 8 sets. A batch of 64 holds 64. That is real memory, and it is why raising the batch size is what usually makes a card run out. But it is a separate pile from the sixteen bytes per weight.

Two piles, two scaling laws
PileScales withBatch 8 → 64
params, gradients, optimizer states parameter count unchanged
activations batch size × sequence length

Which pile this session is about

Data parallel and ZeRO both work on the first row. Activation memory is a real problem with its own solutions — gradient checkpointing, sequence parallelism — and it is not what we are doing here. Every number from this point counts the sixteen bytes per weight.

GPU count does copy the model

The other dial behaves completely differently. Put the model on 8 cards so they can each work on part of the batch, and each card needs the weights locally to do its forward pass. Eight cards, eight replicas.

one global batch of 8, split one sample per card gpu 0gpu 1 gpu 2gpu 3 gpu 4gpu 5 gpu 6gpu 7 480 GB480 GB 480 GB480 GB 480 GB480 GB 480 GB480 GB every card carries the full training state, identical to its neighbour's 8 × 480 GB = 3,840 GB to train a model that needs 480
Eight copies, not sixty-four. The batch was split across the cards, not duplicated on each one.
8samples per batch
1copy of the model
 
8GPUs
8copies of the model

Eight is the number that matters, and it is the number the next few pages attack. Eight identical sets of optimizer states sitting on eight cards, when between them they only ever needed one set spread out. Nothing about the arithmetic requires that duplication. It is an artefact of how data parallel was built, and removing it is what ZeRO does.

BACKTerminology