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

Layer partitioning into ordered pipeline stagesStage cost estimation and balanced partitioningAutomated graph partitioning
1

Read

In this order, only the parts listed

0 of 4 done

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

  2. PipelineParallel stage constructionPicotron - Pipeline Parallelism

    PipelineParallel: distribute_layers evening out remainder layers over early ranks, embedding on the first stage only, final_norm and final_proj on the last stage only, forward threading hidden_states through the assigned decoder layers

  3. Stage maps with embedding and output weightsTorchFeather - Pipeline Minimal Example and Runtime

    generate_llm_fqn_per_model_part with input_weight and output_weight charging tok_embeddings and norm plus output against the first and last stages, and pipeline_module_split looped versus V-shaped placement

  4. 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 ModuleDict names kept, and tracer split with SplitPoint.BEGINNING at layers.4 plus build_stage

    Stop after Step 1. Schedules and loss placement belong to later units.

2

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_spec still 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_spec an automatic partitioner. It places cuts you chose; a true partitioner would also choose cut positions from a cost model, and that stays later work.
3

Try it yourself

Closed-book, before checking anything

From a blank file, partition a 10-layer stack over 3 stages with the remainder-to-early-ranks rule, mark embedding and output ownership, and write each stage's layer list with its per-stage layer count.
4

Quiz yourself

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

0 got · 0 missed

  1. 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. 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. 3.Why does the tutorial split delete ModuleDict entries instead of rebuilding a smaller list?Answer

    Deleting keeps fully qualified names stable, so checkpoints save and load and FQN-addressed services keep resolving. Reindexing shifts every name.

  4. 4.A 12-layer model with input_weight 1 and output_weight 1 is split over 4 stages. How many transformer layers does each stage hold?Answer

    14 effective layers split , minus the end weights: , which sums to 12.

5

Practice

  • PyTorch pipelining tutorial: both splits, one output check

    Run the Step 2 script with manual_model_split and again with tracer_model_split under torchrun --nnodes 1 --nproc_per_node 2; assert rank 1 prints identical losses

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

Also in this section