Unit 5 of 10 · about 4 hours · derive
The pipeline bubble and activation lifetime under GPipe and 1F1B
The bubble decides whether more stages buy speed, and activation lifetime decides whether the schedule fits in memory. Both come from one slot count.
You'll be able to
- Derive bubble fraction, utilization and makespan for fill-drain schedules from the slot model.
- Contrast GPipe and 1F1B activation lifetimes and state each schedule's peak stashed count.
- Predict how utilization moves with stage and microbatch counts before measuring.
Covers
Read
In this order, only the parts listed
0 of 3 done
- Naive bubble, AFAB estimate and the 1F1B memory noteUltra-Scale Playbook - Pipeline Parallelism
Pipeline Parallelism naive bubble with FIG.XLVII, the AFAB estimate pages with FIG.XLVIII, and the 1F1B note that stashed activations drop from to microbatches while the bubble stays the same size
- 1F1B activation boundMemory-Efficient Pipeline-Parallel DNN Training
Sections 2 and 3 (arXiv:2006.09503v3): 1F1B steady state with at most microbatches in flight and no weight stashing in the Flush variant, contrasted with GPipe holding all
- Bubble figures and transfer on the critical pathHow to Scale Your Model - Pipeline Parallelism in Chapter 5
Pipeline Parallelism section: the 2-stage 2-microbatch bubble figure with data-parallel AllReduces marked, and the transfer-cost figure shifting stages on the critical path
Focus on
- One wave lasts slots: utilization is and the idle fraction is , for either wave direction.
- The book's is bubble over ideal compute, an upper bound that exceeds 1 when ; use the slot fraction when you need a fraction of total time.
- GPipe stashes microbatches per stage at the wave boundary; 1F1B keeps at most warmup plus one live per stage, so at most on the first stage and 1 on the last.
- Backward costing twice forward scales bubble and total together, so the fraction is unchanged under equal stage costs; unequal stages need the critical-stage derivation instead.
Common mistakes · 3
- Quoting as the idle fraction. It is bubble over ideal compute; the idle fraction of total slots is .
- Assuming 1F1B wastes less compute than AFAB at fixed . Same bubble; the memory bound is what lets grow.
- Treating the TensorTonic two-wave model as 1F1B. Its backward wave starts only after the forward wave completes, which is the AFAB shape, not interleaved steady state.
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.A run has 4 stages and 8 microbatches. What are the utilization and the idle fraction?Answer
Utilization , idle fraction .
2.What is each schedule's peak stashed activation count per stage?Answer
GPipe holds all microbatches at the wave boundary. 1F1B holds at most warmup plus one live per stage, peaking at on the first stage.
3.Backward costs twice forward on every stage. Does the bubble fraction change?Answer
No. Both bubble and total scale by the same forward-plus-backward factor, so the fraction stays under equal stage costs.
4.Two stages, two microbatches, forward plus backward waves. What are total slots, bubble slots and utilization?Answer
Total 12, bubble 4, utilization : each wave has 2 useful cells per slot-row pattern giving 8 useful of 12.
Practice
- TensorTonic: Measure Pipeline Bubble Utilization
Implement
pipeline_bubble_utilization(num_stages, num_microbatches, include_backward)returningschedule,bubble_slots,total_slotsandutilization; pass all public casesDerive answers from the slot model before running: the checker compares exact schedule cells, idle counts and the float ratio.
You're done when
The TensorTonic cases pass and you can derive utilization, idle fraction and both peak counts for any small and without notes.
Only when you can do this without notes.
Leads to
Notes
Resources · 3 for this unit, 9 more in the 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.
- 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.
- 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.
Also in this section
- 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. - 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. - 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.
- 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. - 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.
- 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.