Distributed Training

One 80 GB GPU can train at most 5 billion parameters with Adam. Shard the training state across 64 GPUs with ZeRO-3, and the limit is 320 billion.

Learn four ways to split training over many GPUs, how the GPUs talk, and how to stop each GPU from holding a full copy.

Pick a strategy, then drag the GPU count. Watch one GPU's share of GPT-3's training state fall toward the 80 GB line. Then we build, piece by piece, the splits, the messages and the shards that make it work.

You need the training loop (forward pass, backward pass, gradient step) and a little Python. We build the rest from zero.

Based on Lecture 19 of MIT 6.5940: TinyML and Efficient Deep Learning Computing (Fall 2026), taught by Song Han and the MIT HAN Lab. Lecture 19 slides. Every idea is re-taught here in our own words and devices. It follows Diffusion Models II.

Fit GPT-3 into 80 GB

64

GPT-3 has 175 billion parameters. Bytes per parameter are the lecture's: 2 for weights, 2 for gradients, 12 for Adam, and the ZeRO formulas of Chapter 6. A bar above 400 GB is cut, keeps the mix of its parts, and carries its total. Activations are not counted.

Chapter 0

One GPU Is Too Slow

Count the GPU hours a big model needs, and measure how close many GPUs come to the ideal speedup

Your manager asks what you did last month. "I trained the model for one epoch." What is the plan for next month? "Train it for one more epoch." The lecture opens with this joke because it is real: big models take months on one GPU.

Better models cost more compute. The lecture's table counts GPU hours, the hours one GPU would need, measured on an NVIDIA A100.

ModelParametersGPU hours
ResNet-5026 million31
BERT-Base108 million84
GPT-3175 billion3,100,000

One GPU would need about 355 years for GPT-3. Distributed training splits one training job over many GPUs. The ideal is simple: a job of 10 GPU days on 1,024 GPUs finishes in 14 minutes. Your time costs more than the hardware.

Real runs fall short of the ideal. The lecture's example trains a video model, TSM, on the SUMMIT supercomputer (6 V100 GPUs per node). How close it comes is the scaling efficiency: the speedup you measure, divided by the speedup the extra GPUs promise.

Say it aloud

E equals T-zero over T-N, divided by N over N-zero.

E
E the scaling efficiency, from 0 to 1. One means every GPU pulls its full weight.
T0
T-zero the training time on the small setup, in minutes.
TN
T-N the training time on N GPUs.
N
N the number of GPUs in the big run.
N0
N-zero the number of GPUs in the small setup.
In plain words

Divide the old time T-zero by the new time T-N to get the speedup. Divide N by N-zero to get the speedup you paid for. E is the first over the second.

With numbers

TSM on 6 GPUs took 49 hours 50 minutes. On 1,536 GPUs it took 14 minutes, the slide's 211 times speedup. The GPUs grew 256 times, so E = 211 / 256 = 0.82.

Scale out the video model

The purple line is the ideal time. The dots are the measured runs. Drag the GPU count and read the gap.

768

Measured points are the lecture's TSM runs (slide 10): 6, 768 and 1,536 GPUs, with top-1 accuracy 74.1%, 74.1% and 74.0%. The ideal line divides the 6-GPU time by the growth in GPUs.

The failure is a run that adds GPUs and barely speeds up. Measure E at two sizes. If it drops, the GPUs spend time talking, not computing. Chapters 3 to 5 cut that talk.

  1. Four ways to split: data, pipeline, tensor and sequence.
  2. Data parallelism: the parameter server loop in five steps.
  3. Communication primitives: the verbs GPUs use to talk.
  4. All-reduce without a server: sequential, ring and parallel.
  5. Recursive halving: all-reduce in log N steps.
  6. ZeRO and FSDP: the four bars in the hero.
  7. Pipeline parallelism: split by layer, then fill the bubble.
  8. Tensor parallelism: split one matrix multiply.
  9. Sequence parallelism: split the tokens of a long text.
  10. The field guide: numbers, code and links.
A job takes 100 minutes on 8 GPUs and 20 minutes on 64 GPUs. What is its scaling efficiency?

Chapter 1

Four Ways to Split the Work

Cut the data, the layers, the matrices or the tokens, and see what each GPU then holds

You have three GPUs and one training job. The job has two parts: a model (layers of weights) and the data (a batch of examples). The data moves through the model as a tensor of shape [batch, tokens, hidden]. You can cut either part.

The lecture names four cuts. Each one is a parallelism: a rule for which piece of the work each GPU does.

Cut the job four ways

Left is the data tensor, right is a six-layer model. Each GPU's colour marks what it holds. Pick a cut.

A schematic of the lecture's four pictures (slides 13 to 31), drawn with three GPUs. Real models have far more layers.

CutEach GPU holdsWhat must travel
Datathe whole model, part of the batchgradients, once per step
Pipelinesome layers, the whole batch in turnactivations between neighbours
Tensora slice of every layerpartial results, inside each layer
Sequencethe whole model, part of the tokenskeys and values for attention

Data and sequence parallelism cut the data. Pipeline and tensor parallelism cut the model. Only the model cuts make the model smaller on each GPU.

A worked number. Take a batch of shape [16, 10, 512]: 16 examples of 10 tokens with 512 numbers each. Data parallelism on 4 GPUs gives each [4, 10, 512]. Now take one text of 100,000 tokens. The batch is 1, so data parallelism cannot cut it. Sequence parallelism on 4 GPUs gives each 25,000 tokens.

The failure: you pick data parallelism for a model that does not fit one GPU. Symptom: an out-of-memory error on every GPU at once. Measure: each GPU holds the full model, so memory per GPU does not change with N. Fix: a model cut, or ZeRO in Chapter 6.

You train on one document of 200,000 tokens with a model that fits one GPU. Which cut splits the work?

Chapter 2

Data Parallelism with a Parameter Server

Run the five-step loop by hand: replicate, split, compute, push and sum, update

Four workers each read a different slice of the data. They must still train one model, not four. Who keeps the one true copy?

The classic answer is a parameter server: one central machine that holds the model. The workers are the GPUs. Each holds a local copy of the model and a slice of the dataset. One training step has five parts:

  1. Replicate, or pull. The server sends the current weights to every worker.
  2. Split. The dataset is cut randomly but evenly, one slice per worker.
  3. Compute. Each worker runs forward and backward on its slice. It gets local gradients.
  4. Push and sum. Workers send gradients to the server. The server adds them.
  5. Update. The server takes one gradient step. Then the loop repeats.

Run one step of the loop

The server sits on top, four workers below. Press Step to move through the five parts, or Play to watch them run.

Illustrative: one weight, four made-up gradients and a learning rate of 0.1. The five steps are the lecture's (slide 41).

Call the weight w and the learning rate η. Worker j computes a gradient gj on its slice.

Say it aloud

w becomes w minus eta times one over N times the sum over j of g-j.

w
w the new weight, after the step.
w
w the weight that every worker pulled.
η
eta the learning rate.
1 / N
one over N turns the sum into an average over N workers.
Σj
the sum over j add one term per worker.
gj
g-j worker j's gradient on its slice.
In plain words

Add the N gradients g-j and divide by N. Multiply by eta. Subtract that from w.

With numbers

With made-up numbers: w = 1.00, eta = 0.1, gradients 0.4, 0.2, 0.6 and 0.2. The average is 0.35, so w = 1.00 − 0.035 = 0.965.

One GPU does three things per step: sample, compute, update. The distributed loop adds two synchronization steps, pull and push, where workers wait for the network.

pythonfor i in range(T):                          # on worker j
    w = server.pull()                       # sync 1: replicate
    x, y = shard_j.sample()                 # this worker's slice
    g = grad(loss, x, y, w)                 # local gradient
    server.push_and_sum(g)                 # sync 2: server averages, then steps

The failure is a slow worker. Symptom: three GPUs sit idle at every push. Measure: time each worker's compute step. Fix: split evenly, as step 2 says, so every slice takes the same time.

Which two steps does distributed training add to the single-GPU loop?

Chapter 3

Communication Primitives

Learn the seven verbs GPUs use to move tensors, and name the two the parameter server uses

Four GPUs each hold one number: 1, 2, 3 and 4. You want the total on every GPU. What messages do you send? Libraries such as MPI, Gloo and NCCL give you a fixed set of verbs, called communication primitives.

PrimitiveShapeWhat happens
Send, Recvone to oneone process passes a tensor to another
Scatterone to manyone GPU sends a different piece to each
Gathermany to oneone GPU collects every piece
Reducemany to onelike gather, but adds or averages on the way
Broadcastone to manyone GPU sends the same copy to all
All-Reducemany to manya reduce whose result lands on every GPU
All-Gathermany to manya gather whose result lands on every GPU

See who sends and who receives

Four GPUs start with 1, 2, 3 and 4. Pick a verb and watch the lines carry the numbers from Before to After.

The values 1, 2, 3, 4 and the reduce to 10 are the lecture's example (slide 46). Send goes from GPU 0 to GPU 3, as on slide 44. A real tensor has millions of numbers; the pattern is the same.

The worked number from the lecture: gather turns [1] [2] [3] [4] into [1, 2, 3, 4]. Reduce turns them into [1 + 2 + 3 + 4] = [10]. Reduce sends the same messages as gather, but each message adds as it lands, so the result stays one number long.

Now name the parameter server's two steps. Replicate and pull is a broadcast: the server sends the same weights to all workers. Push and sum is a reduce: every worker's gradient flows to the server, which averages them.

The failure: you reduce where you need an all-reduce. Symptom: only GPU 0 holds the summed gradient, so the other GPUs step with their own gradient and the copies drift apart. Measure: compare a checksum of the weights across GPUs after a few steps. Fix: an all-reduce, so every GPU gets the same sum.

In the parameter server loop, which primitives do "replicate and pull" and "push and sum" use?

Chapter 4

All-Reduce Without a Server

Find the server's bottleneck, then compare three ways to all-reduce on time, peak load and total traffic

Add workers to a parameter server and each worker's job stays the same: send one gradient, get one copy of the weights. The server's job grows. Call the size of one gradient D and the number of workers N.

Say it aloud

B-server equals N times D.

Bserver
B-server the bytes the server receives in one push and sum.
N
N the number of workers.
D
D the size of one worker's gradient, in bytes.
In plain words

Each of the N workers sends one gradient of size D, so the server takes in N times D. The pull sends the same amount back out.

With numbers

With made-up numbers: D = 100 MB and N = 64 workers. The server takes in 6.4 GB per step, while each worker sends only 100 MB.

The lecture calls this O(N) at the server and O(1) at each worker. The big-O label says how a cost grows with N, ignoring constant factors. Can the workers add their gradients with no server at all? That is an all-reduce, and there are three ways to run one.

Compare four ways to sum gradients

The top shows one step's messages. The bars show the lecture's three costs on a log scale. Pick a scheme, then drag N.

8

Bar lengths are the lecture's big-O table (slide 57) with every constant set to 1, so they compare growth, not seconds. The message picture shows at most 8 nodes.

Ring keeps the peak load flat because each piece is a 1/N chunk of the gradient. Our own count: 2(N − 1) steps, so each GPU sends 2(N − 1)/N × D in total. For N = 8 and D = 4 GB that is 7 GB, under 2D at any N.

The failure: ring's time is O(N). Symptom: at 1,024 GPUs a ring needs 2,046 steps, and each step pays a fixed start-up cost. Measure: time the all-reduce of a tiny tensor as N grows. Fix: combine ring's low load with parallel's few steps. That is the next chapter.

Which all-reduce keeps each GPU's peak load constant as N grows?

Chapter 5

Recursive Halving: All-Reduce in log N Steps

Pair the GPUs at offset 1, then 2, then 4, and watch every GPU collect every colour

Eight GPUs each hold one colour of data. You want every GPU to hold the mix of all eight. Ring passes the colours one hop at a time. Can each step double what a GPU holds?

Recursive halving all-reduce, from the MPICH work of Thakur, Rabenseifner and Gropp, does exactly that. In step 1 each GPU swaps with the neighbour at offset 1 (GPU 1 with 2, 3 with 4). Both now hold two colours. In step 2 they swap at offset 2, and hold four. In step 3, at offset 4: all eight.

Double the colours each step

Each square is a GPU, and its stripes are the colours it holds. Press Step to run one exchange. Pick 4, 8 or 16 GPUs.

The offsets 1, 2 and 4 and the 8-node picture are the lecture's (slides 58 to 66). The 4 and 16 GPU cases follow the same rule.

Each step doubles the colours, so N colours take as many steps as you must double 1 to reach N.

Say it aloud

Steps equals log base two of N.

steps
steps the exchanges until every GPU holds the full sum.
log2
log base two how many times you double 1 to reach a number.
N
N the number of GPUs, a power of two here.
In plain words

Count how many times you double 1 to reach N. That count is the number of steps.

With numbers

N = 8 gives 3 steps. N = 1,024 gives 10 steps, where our ring count from Chapter 4 gives 2,046.

Why is this not free? In each step a GPU sends everything it has summed so far, a full-size tensor. Our own count: about D × log2 N bytes per GPU, against ring's under 2D. Halving wins when there are many GPUs and the message is small. Ring wins when the message is large.

The failure: N is not a power of two. Symptom: with 6 GPUs, GPU 3's partner at offset 4 would be GPU 7, which does not exist. Measure: check N for a power of two before the run. A simple fix: let two GPUs first hand their data to partners, run the exchange on 4, then send them the result. That adds two steps.

How many exchange steps does recursive halving need for 64 GPUs?

Chapter 6

ZeRO-1, 2, 3 and FSDP

Count 16 bytes per parameter, then shard Adam, then the gradients, then the weights

GPT-3 has 175 billion parameters. At 2 bytes each in FP16, the weights alone are 350 GB. The best GPU in the lecture, an A100, has 80 GB. Training also needs the gradients and the optimizer states.

The lecture counts the training state per parameter, with Adam in mixed precision. Weights take 2 bytes and gradients 2 bytes. The optimizer states take 12: an FP32 copy of the weights, the momentum and the variance. That is 16 bytes. Plain data parallelism keeps all 16 on every GPU: N identical copies.

ZeRO, from DeepSpeed, removes the copies. Each stage shards one more part: it cuts that part into N pieces and gives each GPU one piece.

StageShardsBytes per parameterLargest model, N = 64
Baselinenothing2 + 2 + 12 = 165 billion
ZeRO-1Adam2 + 2 + 12/N = 4.219 billion
ZeRO-2Adam, gradients2 + 2/N + 12/N = 2.236 billion
ZeRO-3Adam, gradients, weights16/N = 0.25320 billion

The last column comes from one division. Call one GPU's memory C and the bytes per parameter b.

Say it aloud

Psi-max equals C over b.

ψmax
psi-max the most parameters one GPU's share can hold.
C
C one GPU's memory: 80 GB here.
b
b bytes each GPU keeps per parameter, from the table.
In plain words

Find b for your stage and N. Divide the memory C by b. The answer is psi-max.

With numbers

ZeRO-3 on 64 GPUs: b = 16 / 64 = 0.25 bytes, so psi-max = 80 GB / 0.25 = 320 billion. GPT-3 at 175 billion fits.

Raise the model-size ceiling

Each curve is one stage's largest model as N grows, on log scales. Pick a stage and drag N.

64

The formulas and the N = 64 values (5, 19, 36 and 320 billion) are the lecture's (slides 69 to 73). We compute other N live. Activations are not counted.

In PyTorch, ZeRO-3 is FSDP, FullyShardedDataParallel. With weights sharded, a GPU must fetch a layer's other shards before it runs that layer. ZeRO-3 trades that traffic for memory.

The failure: ZeRO-1 and ZeRO-2 hit a floor. Symptom: you double the GPUs and the largest model barely grows. Measure: b tends to 4 for ZeRO-1 and 2 for ZeRO-2, so psi-max stops at 20 and 40 billion. Fix: ZeRO-3, whose b keeps falling as 16/N.

With ZeRO-2 on 64 GPUs, why can you never pass about 40 billion parameters, however many GPUs you add?

Chapter 7

Pipeline Parallelism and the Bubble

Cut the model by layer, see three GPUs wait, then cut the batch into micro-batches to fill the gaps

GPT-3's 350 GB of weights do not fit one GPU. Cut the layers into 8 groups and put one group on each of 8 GPUs: 350 / 8 = 43.75 GB each, under 80 GB. This is pipeline parallelism. Each group is a stage.

Now run one batch. Stage 1 runs its forward pass, then hands the activations to stage 2, and so on. The backward pass comes back in reverse. At any moment only one stage works. The idle slots form the bubble. With 4 stages, each GPU is busy one quarter of the time: 25%.

GPipe (Huang et al.) fixes most of it. Cut the batch into micro-batches: [16, 10, 512] becomes four of [4, 10, 512]. Stage 1 starts micro-batch 2 while stage 2 runs micro-batch 1. The weights do not change inside a batch, so this is safe. Call the stages S and the micro-batches m.

Say it aloud

U equals m over m plus S minus one.

U
U the busy fraction: the share of time each GPU computes.
m
m the number of micro-batches: the useful slots per pass.
m
m the same count again, inside the total.
S
S the number of stages. S minus 1 slots are lost filling and draining.
In plain words

Each stage does m useful slots on the way forward. The pass takes m plus S minus 1 slots, because the last stage starts S minus 1 slots late. U is useful over total.

With numbers

The lecture's case, S = 4. With m = 1, U = 1 / 4 = 25%. With m = 4, U = 4 / 7 = 57%, the slide's 2.5 times improvement. With m = 16, U = 16 / 19 = 84%.

Shrink the bubble

Each row is a stage, each cell a time slot. Purple is forward, yellow is backward, grey is idle. Drag both sliders.

4
4

The GPipe schedule as the lecture draws it (slide 80), with every forward and backward slot the same length. That is a simplification; a real backward pass takes longer. The 25% and 57% are the slide's.

The failure is a thin pipeline. Symptom: GPUs show low use though every GPU holds work. Measure: count m and S, and compute U. Fix: raise m. U still never reaches 1, because S − 1 slots always fill and drain.

A pipeline has 4 stages and 8 micro-batches. What is its busy fraction?

Chapter 8

Tensor Parallelism

Split one layer's matrix by columns, the next by rows, and join the answer with one all-reduce

The pipeline still idles. Can every GPU work on the same layer at the same time? Yes, if you cut inside the layer. Tensor parallelism splits a weight matrix into N chunks, one per GPU. Megatron-LM (Shoeybi et al.) does this for the two linear layers of a transformer's feed-forward block.

The lecture's example has shapes [1, 2] @ [2, 6] @ [6, 2]. The input X is 1 by 2. The first weight A is 2 by 6. The second weight B is 6 by 2.

  1. Column split of A. Broadcast X to every GPU. GPU i holds a block of A's columns, Ai, and computes Yi = act(X Ai) with no messages.
  2. Row split of B. GPU i holds the matching rows, Bi, and computes Zi = Yi Bi. Each Zi is full size but partial.
  3. All-reduce. Add the Zi. Every GPU now holds Z.
Say it aloud

Z equals the sum over i of act of X times A-i, times B-i.

Z
Z the block's output, 1 by 2.
Σi
the sum over i the all-reduce over the GPUs.
act
act the activation, GeLU in Megatron-LM. It acts on each number alone.
X
X the input, the same on every GPU.
Ai
A-i GPU i's columns of the first weight.
Bi
B-i GPU i's matching rows of the second weight.
In plain words

Each GPU multiplies X by its columns A-i, applies act, and multiplies by its rows B-i. The all-reduce adds the partial answers into Z.

With numbers

With the made-up numbers in the device and act = ReLU, two GPUs give Z1 = [5, 6] and Z2 = [2, 4]. Their sum is [7, 10], the same as one GPU.

Split the matrices and add the answers

Each colour band is one GPU's slice: columns of A, rows of B. Pick how many GPUs share the block.

Shapes are the lecture's example (slide 84). We made up the numbers inside. ReLU stands in for GeLU so the sums stay whole.

Attention splits the same way. The Q, K and V projections split by columns, which is by heads. Each GPU runs softmax(Q KT) V on its own heads with no messages. The output projection splits by rows, then one all-reduce.

The failure: split A by rows. Then each GPU holds a partial sum before the activation. ReLU(−3 + 5) = 2, but ReLU(−3) + ReLU(5) = 5. Measure: compare with the one-GPU output. Fix: columns first, so the activation sees whole numbers.

Why does Megatron-LM split the first weight by columns and the second by rows?

Chapter 9

Sequence Parallelism

Split a long text's tokens over GPUs, then fix attention with an all-to-all or a ring of keys and values

A training text can pass 100,000 tokens. Call the tokens T and the GPUs N. Sequence parallelism gives each GPU a block of tokens.

Say it aloud

T-local equals T over N.

Tlocal
T-local the tokens one GPU holds.
T
T the tokens in the whole text.
N
N the GPUs that share the text.
In plain words

Cut the T tokens into N equal blocks. Each GPU keeps T-local of them.

With numbers

T = 100,000 tokens and N = 8 GPUs give 12,500 tokens per GPU.

The fully connected layers act on each token alone, so they run like data parallelism. Attention is the hard part: every query needs the keys and values of every token, and those sit on other GPUs. The lecture gives two answers.

Get every query its keys

The grid is queries against keys; a filled cell has its scores. Pick a method and press Step.

Three GPUs and three heads, as in the lecture's pictures (slides 93 to 96). The ring order follows slides 94 to 96: GPU 1 holds KV1, then KV2, then KV3.

A worked number for the ring. With T = 100,000 and N = 8, each step scores a block of 12,500 queries against 12,500 keys: about 156 million scores. Eight steps cover the whole grid. The next block travels while the GPU computes, so the transfer hides behind the math when the link is fast enough.

Ulysses has a rule from the lecture: the GPU count equals the sequence partitions equals the head partitions. The failure follows. Symptom: a model with 32 heads on 64 GPUs cannot run Ulysses alone. Measure: check that the heads divide evenly over N. Fix: use Ring Attention, which has no head limit.

In Ring Attention on 3 GPUs, what moves between GPUs?

Chapter 10

The Field Guide

Keep the numbers, the terms, the checklist and the core code in one place

Data and sequence parallelism split the data. Pipeline parallelism splits the model by layer. Tensor parallelism splits it by tensor. The primitives move the pieces, and ZeRO removes the copies. Part II of this lecture is not out yet; this page covers Part I only.

Numbers to keep

WhatValueWhere
GPT-3 on one A1003.1 million GPU hours, about 355 yearsChapter 0, slide 6
TSM on SUMMIT49 h 50 min on 6 GPUs, 14 min on 1,536 (211 times), 74.1% to 74.0%Chapter 0, slide 10
Parameter server loadworker O(1), server O(N)Chapter 4, slide 52
All-reduce costs (time, peak, total)sequential N, N, N; ring N, 1, N; parallel 1, N, N squaredChapter 4, slide 57
Recursive halvinglog2 N stepsChapter 5, slide 66
Training state16 bytes per parameter: 2 + 2 + 12Chapter 6, slide 69
Largest model on 80 GB, N = 645, 19, 36, 320 billion (baseline, ZeRO-1, 2, 3)Chapter 6, slide 73
Pipeline busy fraction, 4 stages25% naive, 57% with 4 micro-batchesChapter 7, slide 80
GPT-3 weights over 8 stages350 / 8 = 43.75 GB per GPUChapter 7, slide 75
Ulysses ruleGPUs = sequence partitions = head partitionsChapter 9, slide 93

Terms in one line each

TermMeaning
Parameter serverOne machine that holds the model and sums the workers' gradients.
All-reduceSum a tensor across GPUs and leave the sum on every GPU.
All-to-allEvery GPU sends a different piece to every other GPU.
ShardCut a tensor into N pieces and give each GPU one.
FSDPPyTorch's FullyShardedDataParallel, an implementation of ZeRO-3.
BubbleThe idle slots while a pipeline fills and drains.
Micro-batchA slice of the batch that moves through the pipeline on its own.

A checklist for a distributed run

The core as code

pythonimport math

def bytes_per_param(stage, n):            # Adam, mixed precision
    w, g, o = 2, 2, 12                        # weights, gradients, optimizer states
    if stage >= 1: o /= n                       # ZeRO-1 shards Adam
    if stage >= 2: g /= n                       # ZeRO-2 shards gradients
    if stage >= 3: w /= n                       # ZeRO-3 shards weights (FSDP)
    return w + g + o

def largest_model(stage, n, gpu_gb=80):   # billions of parameters
    return gpu_gb / bytes_per_param(stage, n)

def busy(m, s): return m / (m + s - 1)           # GPipe busy fraction
def ring_bytes(d, n): return 2 * (n - 1) / n * d  # sent per GPU
def halving_steps(n): return int(math.log2(n))

print([round(largest_model(z, 64)) for z in range(4)])   # [5, 19, 36, 320]
print(busy(1, 4), round(busy(4, 4), 2))                   # 0.25 0.57
print(ring_bytes(4, 8), halving_steps(1024))              # 7.0 10

Where it sits in the field

Real runs stack these cuts. The library has a fuller tour in CS 336, data and tensor parallelism and CS 336, pipeline and FSDP. Long-context attention is in Long-Context LLMs.

Keep going

The takeaway. Cut the data to go faster. Cut the model, or shard its state, to fit. Every cut adds messages, so pick the primitive whose cost grows slowest with N.

Credit

This lesson follows Lecture 19 of MIT 6.5940: TinyML and Efficient Deep Learning Computing (Fall 2026), taught by Song Han and the MIT HAN Lab. Read the lecture on the course site, which links the slides. The lecture cites TSM (Lin et al., 2019), the parameter server (Li et al., 2014) and MPICH collectives (Thakur et al., 2005). It also cites GPipe (Huang et al., 2018), Megatron-LM (Shoeybi et al., 2019) and ZeRO (Rajbhandari et al., 2019). For long sequences it cites DeepSpeed Ulysses (Jacobs et al., 2023) and Ring Attention (Liu et al., 2023). All explanations, devices and worked examples here are our own, except where we say a number is the slide's.

A model's training state does not fit one GPU, and you want every GPU to keep running every layer. Which method fits that wish?

Now press Teach. Explain from memory the 16 bytes per parameter, what each ZeRO stage shards, and why ring and halving trade steps for bytes. Then go back to the GPT-3 bars at the top and find the fewest GPUs that fit.

MIT 6.5940 Lecture 19: Distributed Training (Part I)
The course site · Lecture 19 slides · Back to Diffusion Models II · Back to Gleams