Why split training across workers?
Introduction
Project introduction
Why split training across workers?
Large models are trained on hundreds or thousands of GPUs at once, for two reasons. One GPU is too slow, because the work of a training run would take years on it. One GPU is also too small, because a 7.5 billion parameter model trained with Adam needs about 120 GB just for its weights, gradients and optimizer state, before counting any activations.
Every machine that shares the work is called a worker. Splitting the work is the easy part. The hard part is that the workers must stay in agreement, and every number they send each other costs network time on every step.
Two ways to split, and what each one sends
Data parallelism gives every worker a full copy of the model and a different slice of the batch. After the backward pass the workers average their gradients with an all-reduce, so every copy takes the same step. Done right, it is exactly the same training as one worker on the whole batch. ZeRO keeps that idea but stops every worker from storing the same optimizer state.
Model parallelism splits the model itself. Pipeline parallelism gives each worker some layers and streams small micro-batches through them. Tensor parallelism splits a single layer so each worker holds part of every weight matrix. Each choice moves different data, either gradients, activations or layer outputs, and some leave workers idle. DiLoCo goes the other way and lets workers train alone for many steps before they talk.
What each worker holds
4 workersWorker 1
all 4 layers
Worker 2
all 4 layers
Worker 3
all 4 layers
Worker 4
all 4 layers
Each worker holds the whole model, a quarter of every batch
They send gradients, every step (all-reduce)
What you will build
01
Communication
The bytes of a ring all-reduce against a parameter server, and the ring itself, step by step.
02
Memory
How much of the model states each worker holds at every ZeRO stage.
03
Splitting the model
A pipeline schedule with its bubble, a tensor-parallel MLP, and the DiLoCo outer step.
Start with the bytes on the wire
Count what a ring and a parameter server send to combine one step of gradients.