Unit 9 of 13 · about 4 hours · derive
TP versus CP for long context, and DP, ZeRO and PP under batch limits
More dimensions are not automatically better. A plan must respect batch and memory constraints while retaining enough useful work per rank to amortize its communication.
You'll be able to
- Compare TP and CP for a long-context workload using local shapes, memory and attention communication.
- Compare DP, ZeRO and PP at a fixed global batch without changing the intended update.
- Defend at least three feasible alternatives and state when recomputation, offload or fewer dimensions is preferable.
Covers
Read
In this order, only the parts listed
0 of 2 done
- Weights, activations and long-context tradeoffsThe Ultra-Scale Playbook - 5D Parallelism and Finding the Best Configuration
5D Parallelism in a Nutshell: PP versus ZeRO-3 comparison, TP/SP interplay and the CP discussion
- Fixed batch limits the data dimensionHow to Scale Your Model - Chapters 4 to 6
How to shard LLaMA 3-70B for training: pure FSDP, sequence-sharded and mixed FSDP/TP questions
Answer before revealing the solutions. The final suggested 2048-way FSDP with 4-way TP uses 8192 chips, not the stated full 8960-chip pod. Treat it as a smaller allocation, then enumerate legal factors for the full pod. The memory table earlier in the chapter omits gradients and transient buffers.
Focus on
- CP reduces local sequence ownership and adds attention exchange, while usually retaining dense weights. TP reduces selected weights and computation widths, but can make local GEMMs small and introduce dependent collectives throughout the block.
- At fixed update batch, increasing DP reduces examples per replica and the microbatches available to each pipeline. Neither TP nor CP creates extra training examples. Derive the batch again after each factorization.
- ZeRO-3 trades persistent state for gathers; PP trades depth ownership for bubbles and boundary transfers. Retention across microbatches can avoid repeated gathers but raises peak memory.
- Compare recomputation and host offload as alternatives when their compute or transfer cost buys feasibility. Keep the loss, token budget and optimizer update fixed; throughput does not establish convergence or recovery suitability.
Common mistakes · 3
- Increasing global batch merely to make the preferred mesh look efficient. That changes the optimization workload.
- Assuming CP fixes a weight-memory problem. It mainly partitions sequence-local activations unless combined with state sharding.
- Rounding each degree independently and forgetting to recheck the world-size product.
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 can TP help a weight-heavy model more than CP at the same degree?Answer
TP partitions substantial parameter tensors. Pure CP retains those weights and mainly reduces local activation ownership.
2.Why can a small fixed global batch make deep PP unattractive?Answer
Few microbatches per pipeline leave a large fill/drain overhead. More accumulation is not free if it changes the prescribed global batch.
3.Is 2048-way FSDP with 4-way TP a legal allocation of every chip in an 8960-chip pod?Answer
No. It uses 8192 chips. Either name the unused capacity or choose factors whose product is 8960 and recheck model and batch constraints.
Practice
- How To Scale Your Model: sharding LLaMA 3-70B for training
The pure FSDP, sequence-sharded and mixed FSDP plus TP questions in How to shard LLaMA 3-70B for training, answered on paper before opening each solution
The givens are TPU v5p numbers; keep them labeled as such. Check the suggested allocation's product against the full pod, then add gradients and transient buffers to its memory answer. The section mini-project carries the three-scenario comparison into trainlab.
You're done when
Your three scenario tables retain at least three feasible alternatives each and explain distinct winners without changing the batch or hiding unused ranks.
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.
- 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.
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. - 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. - 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.
- 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.