Distributed Training

Data, model, tensor and pipeline parallelism, gradient synchronisation with all-reduce, checkpointing for recovery, and the cost of a training run.

Distributed Training

Splitting a training run across many devices buys compute and pays in coordination. It is needed when the data, the model or the calendar does not fit on one machine — and for most models it is neither needed nor free.

Q · The training run takes too long, or does not fit — when does spreading it across machines actually help, and what does the coordination cost?
Data Parallelism

Every worker holds the full model and a different shard of the data; each computes gradients on its shard and the gradients are averaged. It is the simplest split, and it silently multiplies the batch size.

Q · The model fits on one device and the data does not — how do several copies of the same model train as one, and what changes about the optimisation?
Model, Tensor & Pipeline Parallelism

When the model itself does not fit on one device, you cut the model rather than the data — across layers, inside matrix multiplies, or across the optimizer state. Every cut moves activations or weights over the wire, and the wire becomes the bottleneck.

Q · The model's weights, gradients and optimizer state exceed one device's memory — which way do you cut it, and what does each cut cost in communication?
Gradient Synchronisation
▶ lab

Workers agree on a gradient by all-reduce — a ring exchange that is bandwidth-optimal — and the choice between waiting for everyone and not waiting decides staleness, straggler exposure, and whether two runs can ever produce the same bits.

Q · N workers each have a gradient and all of them need the average — how does that exchange work, what happens when one worker is slow or dead, and why is the result never bit-identical between runs?
Checkpointing

A training checkpoint saves model weights, optimizer state, the step counter, the data position and the RNG state so a run can resume exactly where it died. It is not the model artifact, and a resume that does not restore all of it silently trains a different run.

Q · A long run will die before it finishes — what must be saved, how often, and what does resuming have to reproduce for the second half to be the same run as the first?
Training Cost
▶ lab

A training run costs GPU-hours, CPU-hours, storage, network and — the multiplier that dominates — the number of times you run it. A hyperparameter search turns one run's cost into a bill, and most of the questions that reduce it are not about the hardware.

Q · What does a training run actually cost, what multiplies that cost, and which questions should be asked before buying more GPUs?