Log inStart free
LESSON 11.10 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Data parallelism and DDP

Watch four GPUs train one model on a split batch, then sync their gradients.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 11.10 · DDP BAY4 GPUS · 2 SAMPLES EACH · SAME WEIGHTS
01
Stage 1 of 6 · Split the batch
Each GPU holds the same 4 layers. Data parallelism gives each GPU 2 of the 8 samples.
Explain it simply

You see four GPUs, and each one holds the same model: the same 4 layers of weights. The batch of 8 samples is split, so each GPU gets two of them. On the right, one GPU alone takes all 8, the normal way to train. Each GPU now does only a quarter of the work.

4 GPU columns hold the same weight grid. Each has 2 of the 8 samples. A dashed column on the right holds all 8.

samplesweightsgradients, backwardAllReduceone GPU, whole batch
batch12345678GPU 0weightsfull modelGPU 1weightsfull modelGPU 2weightsfull modelGPU 3weightsfull model1 GPUweightsall 8 samplesL1L2L3L41122334455667788the batch, split over the GPUs|Bₖ| = 8 / 4 = 2 samples per GPUbatch12345678GPU 0weightsfull modelGPU 1weightsfull modelGPU 2weightsfull modelGPU 3weightsfull model1 GPUweightsall 8 samplesL1L2L3L41122334455667788the batch, split over the GPUs|Bₖ| = 8 / 4 = 2 samples per GPU
Toy: 4 tanh layers (2×2 weights, 2 biases), 8 samples, η 0.5; timing: same layers at 20 MB, 10 GB/s
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
∣Bk∣=∣B∣ / N|\sy{bk}{data}{B_k}| = |\sy{b}{data}{B}| \,/\, \sy{n}{param}{N}
∣Bk∣=8/4=2|B_k| = 8 / 4 = 2

Each GPU gets an equal share of the batch.

Common mix-ups

MYTHData parallelism splits the model across the GPUs.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01With 2 GPUs instead of 4, does the mean gradient change?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.