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

Activation checkpointing within stagesPipeline groups combined with data or tensor groups
1

Read

In this order, only the parts listed

0 of 5 done

  1. 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

  2. Selective and full checkpoint policiesTorchFeather - Pipeline Minimal Example and Runtime

    apply_ac with the selective custom policy and _apply_full_ac per transformer block as the policy menu for checkpointing inside stages

  3. Pipeline stages composed with other parallelismTorchFeather - Pipeline Minimal Example and Runtime

    pipeline_llm: stages per rank from the schedule class, per-part parallelize_fn applying tensor or data parallelism inside each pipeline group, and build_pipeline_schedule warning when microbatches undercount stages

  4. 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 the PipelineStage group argument carrying the pipeline subgroup

  5. 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

2

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.
3

Try it yourself

Closed-book, before checking anything

Closed-book, state what stays alive and what recomputes when one stage is checkpointed, and draw pipeline-by-data group membership for 8 processes with pipeline degree 2 and data degree 4, marking which group averages gradients.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.What stays alive when one pipeline stage is checkpointed with torch.utils.checkpoint?Answer

    Only the region inputs. Region outputs and intermediates recompute in the backward pass, and the recompute region must not cross a stage boundary.

  2. 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. 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. 4.Why does Picotron set require_backward_grad_sync false during 1F1B steady state?Answer

    Data-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.py with 8 Gloo processes on CPU (two stages by four replicas); it checks outputs and averaged gradients against a reference. Read its tagged isend and irecv calls, then distributed/pipeline_parallel.py, and compare the event order with Picotron.

  • PyTorch Pipeline Parallelism TutorialPyTorch · required

    Complete the tutorial and compare ScheduleGPipe and Schedule1F1B, 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_afab and step8_pipeline_parallel_1f1b with 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.