Exercises — Data parallelism and ZeRO optimization
The master memory formula everything below leans on:
Figure — stacked memory bars (Ex 2.1–2.3 made visible). The chart below stacks the three memory components (orange = params , magenta = grads , violet = optimizer states ) for each stage at B, . Watch what shrinks left-to-right: in ZeRO-1 only the tall violet block collapses; in ZeRO-2 the magenta block also shrinks; in ZeRO-3 all three blocks are cut to . The number above each bar is the per-GPU total you compute in the Level-2 exercises.

Level 1 — Recognition
Exercise 1.1
A model has parameters. In standard data parallelism with mixed precision + Adam, how many bytes per GPU does the optimizer state alone occupy, and what three sub-pieces make it up?
Recall Solution
What we're asked: just recall the breakdown of the term. Optimizer state bytes, made of:
- Momentum (fp32):
- Variance (fp32):
- Master weights (fp32 copy):
Why fp32? The Adam update touches tiny numbers; fp16 would underflow them to zero. The parent note earned this — the master copy keeps precision the fp16 params lose.
Exercise 1.2
Match each collective to its role: (a) AllReduce, (b) ReduceScatter, (c) AllGather — against (i) "every GPU ends with the full averaged gradient", (ii) "every GPU ends with only its own slice of the averaged gradient", (iii) "reassemble the full parameter set from partitions."
Recall Solution
- (a) AllReduce → (i) full averaged gradient everywhere. Used by standard DP.
- (b) ReduceScatter → (ii) each GPU keeps only its slice. Used by ZeRO-2/3 to partition gradients.
- (c) AllGather → (iii) rebuild full params. Used by ZeRO-1/3.
See AllReduce and Collective Communication for the wiring of each.
Level 2 — Application
Exercise 2.1
A model has parameters. Compute the standard-DP memory per GPU in GB (use bytes).
Recall Solution
What: plug into . Why it matters: a 7B model already busts an 80 GB A100 under plain data parallelism — that is the whole reason ZeRO exists.
Exercise 2.2
Same , now with ZeRO-3 across GPUs. Memory per GPU in GB?
Recall Solution
What: . From 112 GB → 14 GB. That is the full reduction, because ZeRO-3 partitions every component.
Exercise 2.3
For , , compute ZeRO-1 and ZeRO-2 memory per GPU (GB).
Recall Solution
ZeRO-1: GB. (Here GB and GB before splitting; .)
ZeRO-2: GB. ( GB; GB before splitting; .)
Ladder of savings: 112 → 38.5 → 26.25 → 14 GB as we go standard → Z1 → Z2 → Z3. This is exactly the shrinking-bars figure at the top of the page.
Level 3 — Analysis
Exercise 3.1
Derive the ZeRO-1 memory-reduction factor from the two memory formulas, then evaluate its limit as . Interpret that limit.
Recall Solution
What: ratio of standard to ZeRO-1 memory. Why divide? "How many times smaller" is exactly old÷new. Cancel (it's in every term): Limit: as , . Interpretation: ZeRO-1 can never beat no matter how many GPUs you add, because the params+grads () stay replicated forever. Only the optimizer state ever leaves. That ceiling is why ZeRO-2 and ZeRO-3 exist.
Exercise 3.2
Verify that ZeRO-3 moves 3× the communication of standard DP. Then say in one sentence why three-times, structurally.
Recall Solution
Standard DP: one AllReduce of gradients. One payload () crosses the ring's fraction: ZeRO-3: AllGather params in the forward pass () + AllGather params again in the backward pass () + ReduceScatter grads once (): Ratio: . ✓ Why 3×: we now move parameters twice (forward, backward) plus gradients once, versus a single gradient movement in plain DP.
Figure — the 3× gap. The plot below draws (orange) and (violet) as functions of , in units of bytes. Both curves rise and flatten toward horizontal ceilings — for standard DP, for ZeRO-3 — because . The permanent vertical gap between the ceilings is the 3× communication penalty you just derived.

Exercise 3.3
For , , confirm the parent's numbers: memory/GPU and communication volume/step (in TB, bytes).
Recall Solution
Memory: bytes GB. ✓ Communication: . Counting both send+receive on the link this rounds to the parent's TB of moved bytes.
Level 4 — Synthesis
Exercise 4.1
You have and eight 80 GB A100s (). Activations need GB per GPU. Which ZeRO stage is the cheapest-communication one that still fits? Show each stage's model-state memory and add activations.
Recall Solution
Budget: GB for model state.
- Standard: GB. ✗
- ZeRO-1: GB. ✗
- ZeRO-2: GB. ✗
- ZeRO-3: GB. ✗ (80 > 60!)
Nothing fits on data parallelism alone. Correct synthesis answer: even ZeRO-3 needs 80 GB of state + 20 GB activations = 100 GB > 80 GB. You must combine with another technique — e.g. Activation Checkpointing to shrink the 20 GB, or offload optimizer state (Memory-Efficient Optimizers), or add Pipeline Parallelism to raise the effective . The lesson: ZeRO stages don't live alone.
Exercise 4.2
Same setup but you add Activation Checkpointing cutting activations from GB to GB, and you may raise . What is the smallest (power of 2) so ZeRO-3 fits in 80 GB?
Recall Solution
Need . Smallest power of 2: . Check: GB ≤ 80 GB. ✓ Synthesis point: checkpointing frees space, but the model state still forced us to double the GPU count. Two levers pulled together.
Level 5 — Mastery
Exercise 5.1
Prove the general reduction factor for any ZeRO memory formula of the form (with ) is , and find its ceiling. Then read off the ceilings for Z1, Z2, Z3.
Recall Solution
Derivation: Limit: take properly (never divide by blindly). Divide top and bottom by : the term , leaving The case is genuinely different and must be handled separately. If the denominator is , so the ratio is , which grows without bound as — there is no finite ceiling. So:
- ZeRO-1 (): ceiling .
- ZeRO-2 (): ceiling .
- ZeRO-3 (): no ceiling — reduction , pure scaling. This is the mathematical reason ZeRO-3 is the endgame: nothing stays replicated (), so nothing caps the win.
Figure — reduction ceilings. The plot below shows the reduction factor vs for each stage. ZeRO-1 (orange) and ZeRO-2 (magenta) flatten toward the dotted horizontal lines at and — their finite ceilings. ZeRO-3 (violet) rises as a straight line with no ceiling, because . The picture is the result made visual: a bigger replicated part means a lower flat ceiling.

Exercise 5.2
Define compute–communication overlap efficiency as where . For the parent's 175B / 64-GPU case: TB, bandwidth GB/s, s. Compute efficiency, then find the needed to reach 80% efficiency.
Recall Solution
Comm time: s (parent rounds to ~7). Efficiency: . ✓ (matches parent's ~59%.)
For 80%: need s. Then GB/s. Mastery reading: to lift efficiency from 59% → 80% you need ~2.75× the bandwidth. Efficiency is bandwidth-bound, which is exactly why hardware (NVLink 4, InfiniBand NDR) drives ZeRO-3's viability.
Exercise 5.3
A student claims: "ZeRO-3 with gives the same throughput as standard DP with , just less memory." Steel-man then refute using the numbers of Ex 5.2 versus standard DP's communication .
Recall Solution
Standard DP comm bytes: bytes TB (per direction), so counting the round trip ≈ TB — one third of ZeRO-3's ~2.06 TB, matching the 3× factor. Standard DP comm time: s ⇒ eff . Refutation: ZeRO-3 (59%) has lower throughput per step than standard DP (81%) at the same — the extra parameter gathers cost time. The student conflated memory wins with speed. ZeRO-3's win is that it lets you train at all when the model wouldn't otherwise fit; standard DP simply can't run a 175B model on 80 GB cards. Throughput is traded for feasibility.
Recall Self-test recap
Ceiling of ZeRO-1 memory reduction as N→∞ ::: (params+grads stay replicated) Ceiling of ZeRO-2 ::: Ceiling of ZeRO-3 ::: unbounded, pure Why ZeRO-3 costs 3× communication vs standard DP ::: AllGather params twice + ReduceScatter grads once vs one AllReduce What ZeRO never partitions ::: activations (need Activation Checkpointing / Gradient Accumulation)