Unit 4 of 13 · about 4 hours · derive
Per-rank parameter, gradient, optimizer, checkpoint and buffer memory
Build on Memory, arithmetic intensity and reconciling estimates. Composition adds different divisors for different state, plus transient gathers that can invalidate an otherwise correct persistent-state estimate.
You'll be able to
- Derive persistent parameter, gradient, master-weight and optimizer bytes from their actual owners and dtypes.
- Account for gathered parameters, reduction buffers and checkpoint staging by lifetime and memory tier.
- Find the worst rank rather than accepting an average per-rank fit.
Covers
Read
In this order, only the parts listed
0 of 3 done
- State ownership under ZeRO and model parallelismTransformer Math 101 - Distributed Training
Distributed Training: Sharded Optimizers, 3D Parallelism and Sharded Optimizers + 3D Parallelism
Do not copy the 3D gradient-memory formula as universal: it omits the TP divisor for TP-sharded weight gradients. Derive each gradient from its local parameter shape. The 12-byte optimizer convention includes a master weight; it is not every PyTorch AdamW configuration.
- FSDP gathers a TP shard, not the whole modelDistributed Training Guide - Chapter 7 FSDP plus TP
Six-device ownership example and Applying FSDP after TP
- Checkpoint state and asynchronous lifetimeTorchFeather - ParallelDims and Composition Plan
CheckpointManager.__init__,dcp_save,saveandclose: state inventory, save future and waitingTrace retained state and completion only. Leave checkpoint durability and resume semantics for DT-9.
Focus on
- Use the DT-4 dtype ledger, but apply TP, PP and state-sharding divisors only to tensors they actually partition. CP usually leaves dense weights replicated unless its ranks also participate in state sharding.
- A gather materializes the stage's TP-local parameter unit. Prefetch may make multiple units live together. Do not divide this full compute window by the FSDP degree again.
- Separate durable checkpoint bytes from additional staging allocations. State-dict views can alias existing tensors; clones do not. Charge host staging to RAM and concurrent device buffers to device memory.
- Compute a timeline maximum of live allocations, not the sum of each category's separate maximum. Include tied state, padding, allocator reserve and the largest stage.
Common mistakes · 3
- Treating the source's bytes-per-parameter convention as an AdamW default. Record the tensors your implementation actually stores.
- Adding checkpoint file size to device memory even when staging lives on the host.
- Averaging uneven stages. The smallest device must fit its assigned peak, not the fleet's average.
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.Why is the synthetic persistent ledger 8,000,000 bytes?Answer
Each rank owns 500,000 parameters after TP, PP and FSDP. The stated state uses 16 bytes per parameter, giving 8,000,000 bytes, before transient storage.
2.What parameter shape is gathered under FSDP plus TP?Answer
The complete TP-local shard for the wrapped unit, not the unpartitioned model tensor and not just the persistent FSDP fragment.
3.Does an asynchronous save necessarily double device memory?Answer
No. Extra storage depends on staging location, copying and aliasing. A retained host copy increases host memory while training continues.
You're done when
Every persistent tensor has a dtype and owner, and your peak ledger distinguishes device gathers, host staging, shared storage and reserve.
Only when you can do this without notes.
Leads to
Notes
Resources · 3 for this unit, 10 more in the section
- 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. - 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.
- 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.
Also in this 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.
- 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.
- 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. - 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.