Unit 2 of 13 · about 4 hours · implement

Named device meshes, rank coordinates and group construction

A legal product is not enough: a wrong slice silently synchronizes unrelated shards. This unit extends DT-2 group construction to a named multidimensional layout.

You'll be able to

  • Implement rank-to-coordinate and coordinate-to-rank mappings with round-trip tests.
  • Construct groups by varying one coordinate while holding the others fixed.
  • Reject inconsistent mesh products and verify group membership with CPU collectives.

Covers

Logical device meshes and named mesh dimensionsRank coordinates and process-group construction
1

Read

In this order, only the parts listed

0 of 2 done

  1. Explicit coordinate slicesPicotron - 4D Composition

    ProcessGroupManager.__init__: grid, coordinate lookup, subgroup enumeration and group rank lists

  2. A CPU named mesh with independent checksTorchFeather - ParallelDims and Composition Plan

    main from process-group initialization to get_group, plus peer_rank

    Read mesh construction only here. Leave the schedule and numerical oracle for the correctness unit.

2

Focus on

  • Picotron orders axes as DP, PP, CP, TP. Its row-major rank is . Store axis order as part of the plan.
  • Different axis groups through one rank intersect at that rank. Groups on the same axis partition the world. Neither property means their physical links are independent.
  • All ranks must agree on group creation order and membership. Enumerate the full group list deterministically before any rank-specific execution.
Common mistakes · 2
  • Inferring node placement from adjacent rank numbers. Logical ordering and physical placement are separate inputs.
  • Creating groups only on participating ranks while other ranks follow a different order. Use a consistent global construction sequence.
3

Try it yourself

Closed-book, before checking anything

On four CPU processes with gloo, build a row-major DP-by-TP mesh of shape 2 by 2. Verify TP groups [0, 1] and [2, 3], DP groups [0, 2] and [1, 3], and rank-coordinate round trips. All-reduce the global rank as a scalar within each group and check its sum against the listed members. Then simulate a four-axis mesh with all degrees 2 and test every rank.
4

Quiz yourself

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

0 got · 0 missed

  1. 1.What is rank 2's coordinate in the row-major 2 by 2 DP-by-TP mesh?Answer

    DP coordinate 1 and TP coordinate 0. Its TP peer is rank 3 and its DP peer is rank 0.

  2. 2.Which coordinates change inside a pure PP group?Answer

    Only the PP coordinate. DP, CP and TP coordinates stay fixed.

  3. 3.What does a successful rank-sum check prove, and what does it not prove?Answer

    It checks the chosen group's collective membership for that fixture. It does not prove tensor ownership, update equivalence or placement performance.

You're done when

All simulated round trips and four-process group sums pass, and an invalid world-size product is rejected before group creation.

Only when you can do this without notes.

Leads to

Notes

Resources · 2 for this unit, 11 more in the 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.

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

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

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