Unit 1 of 10 · about 5 hours · derive, implement
Ordered stages, stage cost and balanced or automated partitioning
A pipeline is only as fast as its slowest stage, and every later schedule assumes the partition. Placing embedding, layers and output head once, with cost attached, fixes the map the rest of the section executes.
You'll be able to
- Partition an ordered layer stack over stages with embedding-first and output-last ownership and a stated remainder rule.
- Estimate per-stage cost from forward plus backward time and name the critical stage that sets the makespan.
- Explain why hand-placed splits are not automatic graph partitioning and what an automatic partitioner would still decide.
Covers
Read
In this order, only the parts listed
0 of 4 done
- Split layers across devicesUltra-Scale Playbook - Pipeline Parallelism
Pipeline Parallelism introduction through Splitting layers on various nodes - All forward, all backward: layer ranges per GPU, low-bandwidth activation transfers, and the note that activation memory stays flat because each stage holds of the layers for microbatches in flight
- PipelineParallel stage constructionPicotron - Pipeline Parallelism
PipelineParallel:distribute_layersevening out remainder layers over early ranks,embeddingon the first stage only,final_normandfinal_projon the last stage only,forwardthreadinghidden_statesthrough the assigned decoder layers - Stage maps with embedding and output weightsTorchFeather - Pipeline Minimal Example and Runtime
generate_llm_fqn_per_model_partwithinput_weightandoutput_weightchargingtok_embeddingsandnormplusoutputagainst the first and last stages, andpipeline_module_splitlooped versus V-shaped placement - Manual and tracer model splitsPyTorch Pipeline Parallelism Tutorial
Step 1 (page read 2026-10-14): manual split deleting layers 4 to 7 or 0 to 3 with
ModuleDictnames kept, and tracer split withSplitPoint.BEGINNINGatlayers.4plusbuild_stageStop after Step 1. Schedules and loss placement belong to later units.
Focus on
- Stages are ordered and contiguous: microbatch leaves stage for stage in both directions, so any partition is a cut plan over the layer list.
- First and last stages carry extra cost: the embedding lookup lives on stage 0 and the final norm plus output projection live on the last stage, and a balance that ignores them overloads both ends.
- Equal layer counts do not imply equal stage cost: position-dependent work such as the vocabulary projection, plus backward costing about twice forward, moves the critical stage.
- The tracer
split_specstill takes hand-placed split points; it automates cutting, not choosing where to cut.
Common mistakes · 3
- Counting the embedding, norm and output projection as free when balancing. Measure them as layers would be measured, or the end stages become the bottleneck.
- Assuming equal layer counts balance the pipe. Estimate forward plus backward seconds per stage and balance those, not layer counts.
- Calling a tracer
split_specan automatic partitioner. It places cuts you chose; a true partitioner would also choose cut positions from a cost model, and that stays later work.
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.Split 10 layers over 3 stages with Picotron's remainder rule. Which layers land on each stage?Answer
Counts : stage 0 holds layers 0 to 3, stage 1 holds 4 to 6, stage 2 holds 7 to 9. The remainder layer goes to the earliest rank.
2.Why does the Playbook say pipeline parallelism saves no activation memory per GPU?Answer
Each stage holds of the layers but microbatches are in flight before the first backward, so the layer fraction times the microbatch count leaves activation memory about flat.
3.Why does the tutorial split delete
ModuleDictentries instead of rebuilding a smaller list?AnswerDeleting keeps fully qualified names stable, so checkpoints save and load and FQN-addressed services keep resolving. Reindexing shifts every name.
4.A 12-layer model with
input_weight1 andoutput_weight1 is split over 4 stages. How many transformer layers does each stage hold?Answer14 effective layers split , minus the end weights: , which sums to 12.
Practice
- PyTorch pipelining tutorial: both splits, one output check
Run the Step 2 script with
manual_model_splitand again withtracer_model_splitundertorchrun --nnodes 1 --nproc_per_node 2; assert rank 1 prints identical lossesThe script falls back to
torch.device(cpu), so CPU is enough. Keep the 8-layer split and 4 microbatches; the output-equality gate is the point, not step time.
You're done when
Both split modes print identical rank-1 losses, and you can write any small layer-to-stage map with embedding and output ownership from memory.
Only when you can do this without notes.
Leads to
Notes
Resources · 4 for this unit, 8 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.
- 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.
- 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.
Also in this section
- 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.
- 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.
- 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.