Unit 5 of 13 · about 3 hours · derive
Per-rank activation and temporary memory under a composed plan
Training-step operation, activation and communication arithmetic gave a whole-model estimate. A composed plan needs the peak lifetime on each stage, not that estimate divided by world size.
You'll be able to
- Derive saved activation bytes from local layouts and the number of live pipeline microbatches.
- Separate saved tensors from attention, routing and collective workspaces.
- Revise a plan's activation estimate when recomputation, SP or CP changes.
Covers
Read
In this order, only the parts listed
0 of 2 done
- Which activations really shrink with TP?Transformer Math 101 - Distributed Training
Training: Activations and Batch Size, including the three recomputation formulas and their assumptions
Use this as an FP16, no-SP reference model. Do not apply its materialized-attention term to a fused attention implementation without checking what is saved.
- Schedule changes activation lifetimeThe Ultra-Scale Playbook - 5D Parallelism and Finding the Best Configuration
One forward, one backward and Llama 3.1 schemes: stored activations and the comparison with all-forward-all-backward
Use your DT-6 schedules rather than rebuilding them. Track saved tensors at stage boundaries and within stages.
Focus on
- Count each saved tensor from its local shape and dtype. Residuals may be replicated while MLP intermediates are TP-sharded; SP changes only the regions where its layout is active.
- At a stage, multiply per-microbatch saved bytes by the schedule's live microbatch count, then add temporary storage at that event. GPipe and 1F1B need not have the same peak.
- CP shards queries and sequence-local tensors, but remote KV blocks or all-gathered KV storage add temporary memory. EP needs routing indices, packed tokens and padding for the actual capacity policy.
Common mistakes · 3
- Dividing all activation memory by TP. Replicated residuals and normalization inputs can remain unchanged without SP.
- Calling activation checkpointing a durable training checkpoint. Here it trades saved tensors for recomputation, not recovery storage.
- Charging a quadratic attention matrix when the chosen fused kernel does not save it, or forgetting its linear-size statistics and workspace.
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.Eight synthetic boundary tensors are live. What storage do they occupy?Answer
8,388,608 bytes, or 8 MiB. This counts only the stated boundary tensors.
2.Does increasing accumulation always increase activation memory?Answer
No. Sequential microbatches can release activations before the next starts. A pipeline schedule can keep several microbatches live, so use its lifetime trace.
3.Why does full recomputation not make activation memory zero?Answer
It retains recomputation boundaries and still needs current-layer intermediates, outputs and workspaces.
You're done when
The simulated live-set maximum agrees with your byte ledger for both schedules, and changing recomputation or layout changes only the tensors it actually affects.
Only when you can do this without notes.
Leads to
Notes
Resources · 2 for this unit, 11 more in the section
- The Ultra-Scale Playbook - 5D Parallelism and Finding the Best ConfigurationHugging Face · primary
Study 5D Parallelism in a Nutshell, then Finding the Best Training Configuration (fitting a step in memory, reaching the global batch, optimizing throughput) at https://nanotron-ultrascale-playbook.static.hf.space/index.html#finding_the_best_training_configuration. Rebuild a small planner that enumerates legal DP, TP, CP, PP and EP degrees and ranks them by predicted memory and step time; its heatmaps are its own H100 cluster's results.
- Transformer Math 101 - Distributed TrainingEleutherAI · support
Use the sharded-optimizer, 3D-parallelism and activation equations as a cross-check of your planner's memory terms.
Also in this section
- Picotron - 4D CompositionHugging Face · required
Trace create_config.py, process_group_manager.py and train.py across DP, TP, PP and CP. Run the CPU 3D example or a smaller equivalent, assert group membership and compare observed event order with the planner.
- First-Principles Video - Device Mesh Composition SegmentUmar Jamil · support
Watch 08:37:34 on device meshes and combining pipeline with data parallelism. Reconstruct its rank-coordinate table and compare it with Picotron process groups and your planner output.
- Distributed Training Guide - Chapter 7 FSDP plus TPLambda Labs · support
Read the 2D FSDP plus TP path in
07-2d-paralleland explain why FSDP is applied after TP and what limits the TP degree. Running it needs several GPUs. - How to Scale Your Model - Chapters 4 to 6Google DeepMind · required
Use Part 4 (transformer math), Part 5 (training parallelism) and Part 6 (LLaMA 3 case study) to independently estimate parameters, FLOPs, memory, communication, time and cost for one configuration, then the GPU rooflines in Part 12. Keep TPU constants labeled and compare its recommendation with the Playbook.
- Efficient Large-Scale Language Model Training on GPU Clusters Using Megatron-LMNarayanan et al. (SC 2021) · required
Read the composition of tensor, pipeline and data parallelism, the interleaved schedule and the performance analysis of parallel configurations. Check its guidance against your planner on one model and cluster.
- CS336 Assignment 2 (Spring 2026) - Section 8 Analyzing Parallelism StrategiesStanford University · required
Solve
data_parallel_calcs,fsdp_calcs,tp_calcsandfsdp_tp_calcs(Sections 8.2 to 8.5) with your planner, and reconcile any disagreement before trusting either. - TorchFeather - ParallelDims and Composition PlanTorchFeather · support
Inspect distributed/parallel_dims.py and model/parallelize.py. Build the exact mesh product and divisibility table for one FSDP, TP, CP, PP and EP configuration, then identify ordering assumptions in its composition.
- TensorTonic - Choose a Topology-Aware Parallel PlanTensorTonic · support
Solve Choose a Topology-Aware Parallel Plan, then compare its memory and communication model with yours.
- NanotronHugging Face · depth
Inspect configuration, parallel context and trainer paths used by the Ultra-Scale benchmarks only after the planner works. Its "3D" means DP, TP and PP: there is no context or expert parallelism.
- Bumblebee - Parallel State and CompositionBumblebee · depth
Only as a possible capstone target: read
primitive/parallel/and the composition tests in a clean checkout to compare TP, EP, ETP, CP and PP contracts. Its multi-GPU paths are untested upstream. - HetPipe - Heterogeneous Partitioning and PlacementPark et al. · support
Read arXiv:2005.14038v1 Section 4, Pipelined Model Parallelism Within a VW, for its Model Partitioning paragraph, Section 7, Partitioning Algorithm, and Section 8.1, Methodology, for resource allocation to virtual workers. Reuse device-specific compute, memory and placement constraints in a synchronous simulator; do not adopt its stale-weight update semantics or source speedups.