Unit 9 of 10 · about 4 hours · explain, implement
Recompute inside stages and pipeline groups combined with DP or TP
Stages compose: recompute trades memory inside a stage, and data parallelism replicates stages across groups. Both change what the backward communicates, so both need oracle checks.
You'll be able to
- Apply activation checkpointing inside a stage and state the alive-versus-recomputed contract.
- Build pipeline-by-data group membership and place gradient averaging on the replicate group.
- Explain the ZeRO-1 versus ZeRO-3 pairing choice under microbatching.
Covers
Read
In this order, only the parts listed
0 of 5 done
- Re-materialization designGPipe: Efficient Training of Giant Neural Networks using Pipeline Parallelism
Section 3 (arXiv:1811.06965v5): re-materialization recomputing forward activations in the backward pass to trade compute for memory; pair with the activation-lifetime numbers from the bubble unit
- Selective and full checkpoint policiesTorchFeather - Pipeline Minimal Example and Runtime
apply_acwith the selective custom policy and_apply_full_acper transformer block as the policy menu for checkpointing inside stages - Pipeline stages composed with other parallelismTorchFeather - Pipeline Minimal Example and Runtime
pipeline_llm: stages per rank from the schedule class, per-partparallelize_fnapplying tensor or data parallelism inside each pipeline group, andbuild_pipeline_schedulewarning when microbatches undercount stages - Composability contractPyTorch Pipeline Parallelism Tutorial
What is
torch.distributed.pipelining(page read 2026-10-14): composability with DDP, FSDP and tensor parallelism with the TorchTitan 3D reference, and thePipelineStagegroup argument carrying the pipeline subgroup - Pipeline plus sharding pairing costsHow to Scale Your Model - Pipeline Parallelism in Chapter 5
Pipeline Parallelism item (2), Pipelining makes data parallelism and FSDP hard: per-microbatch weight all-gathers and delayed gradient reduction as the composition costs, with ZeRO-1 style replication as the workable pairing
Focus on
- Checkpoint regions must sit inside one stage: only the region inputs stay alive and the rest recomputes, following the activation-checkpointing unit's contract.
- Pipeline groups move activations while replicate groups average gradients: same-stage ranks across data coordinates form the averaging group, and pipeline peers never average each other's parameters.
- Microbatching shrinks the compute that amortizes a ZeRO-3 all-gather to one microbatch share, which is why replication-style ZeRO-1 pairs better with pipelines.
- Picotron holds data-parallel sync until the last microbatch's backward through
require_backward_grad_sync; syncing every microbatch would pay a full all-reduce per microbatch.
Common mistakes · 3
- Checkpointing across a stage boundary. The recompute region must sit inside one stage, or the backward needs activations from another rank.
- Composing pipeline with ZeRO-3 naively. Per-microbatch all-gathers amortize over a microbatch share of the batch, so prefer replication inside pipeline groups.
- Forgetting RNG determinism under recompute. State the seed-preservation policy from the activation-checkpointing unit, or dropout diverges between the two passes.
Try it yourself
Closed-book, before checking anything
Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.What stays alive when one pipeline stage is checkpointed with
torch.utils.checkpoint?AnswerOnly the region inputs. Region outputs and intermediates recompute in the backward pass, and the recompute region must not cross a stage boundary.
2.Eight processes run pipeline degree 2 by data degree 4. Which ranks average gradients together?Answer
Same-stage ranks across data coordinates, in the replicate group. Pipeline peers hold different parameters and never average each other.
3.Why does ZeRO-3 pair badly with pipelines while ZeRO-1 pairs well?Answer
ZeRO-3 all-gathers weights per microbatch while compute per microbatch shrinks to a batch share. ZeRO-1 replicates parameters and shards only optimizer state, so no per-microbatch gather sits on the critical path.
4.Why does Picotron set
require_backward_grad_syncfalse during 1F1B steady state?AnswerData-parallel sync waits for the last microbatch's backward. Syncing every microbatch would pay a full gradient all-reduce per microbatch instead of once per step.
You're done when
You can draw the group grid, place the averaging call, and state the alive set of a checkpointed stage without notes.
Only when you can do this without notes.
Leads to
Notes
Resources · 4 for this unit, 8 more in the section
- TorchFeather - Pipeline Minimal Example and RuntimeTorchFeather · required
Run
minimal_examples/pp_gpipe.pywith 8 Gloo processes on CPU (two stages by four replicas); it checks outputs and averaged gradients against a reference. Read its taggedisendandirecvcalls, thendistributed/pipeline_parallel.py, and compare the event order with Picotron. - PyTorch Pipeline Parallelism TutorialPyTorch · required
Complete the tutorial and compare
ScheduleGPipeandSchedule1F1B, then read https://docs.pytorch.org/docs/2.14/distributed.pipelining.html for the interleaved, looped, zero-bubble and DualPipeV schedules the tutorial omits. Preserve the model split, microbatch and loss contracts before adapting it. - How to Scale Your Model - Pipeline Parallelism in Chapter 5Google DeepMind · support
Work the pipeline bubble and communication examples in Chapter 5. Use them to test your cost model under different stage counts, microbatch counts and imbalanced layers.
- GPipe: Efficient Training of Giant Neural Networks using Pipeline ParallelismHuang et al. (NeurIPS 2019) · support
Read the partitioning, microbatching and re-materialization design and the bubble overhead statement. Use it as the fill-drain specification your simulator reproduces.
Also in this section
- Ultra-Scale Playbook - Pipeline ParallelismHugging Face · primary
Read Pipeline Parallelism through All forward, all backward, One forward, one backward, Interleaving stages and Zero bubble and DualPipe. Derive bubble fraction and peak activation count for your simulator before running any schedule.
- Picotron - Pipeline ParallelismHugging Face · required
Read pipeline_parallel/pipeline_parallel.py and pp_communications.py beside the pipeline branch in train.py. Build a schedule event simulator first, then reproduce GPipe and 1F1B with shape, tag and ordering assertions.
- Picotron Tutorial - Steps 7 and 8Hugging Face · support
Read
step7_pipeline_parallel_afabandstep8_pipeline_parallel_1f1bwith their diffs; the video series stops before pipeline parallelism. - First-Principles Video - Pipeline Parallelism SegmentUmar Jamil · support
Watch 06:06:17 for pipeline parallelism and 06:26:52 for GPipe, 1F1B and zero-bubble schedules. Stop after GPipe and 1F1B to draw and test those event traces; zero-bubble implementation remains depth work.
- Memory-Efficient Pipeline-Parallel DNN TrainingNarayanan et al. (ICML 2021) · support
Read the PipeDream-Flush (1F1B) schedule and its activation-memory bound. Compare its stashed-activation count with GPipe in your simulator.
- Zero Bubble Pipeline ParallelismQi et al. (ICLR 2024) · support
Read the split of backward into input and weight gradients and the handcrafted schedules. Optional vocabulary for zero-bubble and DualPipe schedules.
- TensorTonic - Pipeline Bubble UtilizationTensorTonic · support
Solve the pipeline bubble utilization problem, then extend its model to 1F1B and interleaved stages in your simulator.
- Distributed Training Subsystem - Pipeline SchedulerRoadmap-Final · support
Complete the scheduler, event trace, activation-lifetime accounting and failure injection required in Milestone B. Keep the simulator runnable without GPUs.