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

Per-rank parameter, gradient and optimizer memoryCheckpoint and communication buffer memory
1

Read

In this order, only the parts listed

0 of 3 done

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

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

  3. Checkpoint state and asynchronous lifetimeTorchFeather - ParallelDims and Composition Plan

    CheckpointManager.__init__, dcp_save, save and close: state inventory, save future and waiting

    Trace retained state and completion only. Leave checkpoint durability and resume semantics for DT-9.

2

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

Try it yourself

Closed-book, before checking anything

For a synthetic model with 12 million evenly partitioned parameters, TP 2, PP 3 and FSDP 4, assume BF16 parameters and gradients, an FP32 master copy and two FP32 moments. Derive persistent tensor storage of 8,000,000 bytes per rank. Then draw a live-window ledger for one gathered TP-local layer, its prefetched successor, a gradient buffer and an asynchronous host checkpoint copy. Mark unknown workspace and allocator reserve separately; do not call the persistent total a peak.
4

Quiz yourself

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

0 got · 0 missed

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

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_calcs and fsdp_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.