liveBook · Manning

N-dimensional parallelism

As explained in Deep Learning with PyTorch, Second Edition

A distributed-training approach combining multiple parallelism strategies along different dimensions.

N-dimensional parallelism combines several ways of distributing training work instead of relying on one strategy alone. Data parallelism replicates models and splits data; model parallelism divides model computation and parameters; pipeline parallelism assigns sequential stages; tensor parallelism partitions layers or tensors. section 16.12 section 16.6

The dimensions can be matched to the hardware. Tensor parallelism usually stays within one host, where fast GPU interconnects reduce its communication cost, while pipeline parallelism can distribute stages across hosts. Combining dimensions also reduces bottlenecks such as increasingly inefficient allreduce operations at very large scale. section 16.6

A practical n-dimensional design may combine:

  • Data parallelism for multiple model replicas processing different data batches. section 16.12
  • Model or tensor parallelism for distributing parameters, computation, or individual layers across devices. section 16.12
  • Pipeline parallelism for processing different microbatches concurrently through sequential model stages. section 16.12
  • Context or other specialized dimensions when scaling large language models. section 16.12

A two-dimensional device mesh

Represent two model replicas, each split across four model partitions, with a 2 × 4 mesh. One mesh dimension groups replica devices for parameter synchronization, while the other selects devices for model-parallel computation. PyTorch’s DeviceMesh creates the corresponding process groups and communication patterns. LLaMA 3 demonstrates the larger idea with 4D parallelism combining data, tensor, pipeline, and context parallelism. section 16.6 section 16.6

Figure 16.9 Visualization of a 2 × 4 device mesh, where the rows represent model replicas and the columns represent model partitions. The dashed arrows represent how each device is communicating.
figure

Visualize how rows can represent model replicas and columns can represent model partitions, with communication occurring along each mesh dimension. section 16.6

How Deep Learning with PyTorch, Second Edition covers it

How deep it goes
Explains strategy selection and DeviceMesh process groups, but stops short of a complete production implementation.
Examples
Uses a 2 × 4 DeviceMesh, replica parameter synchronization, model-partition computation, LLaMA 3, and TorchTitan.
What it assumes
Assumes basic data and model parallelism, then builds toward collective communication and multidimensional device coordination.
What you can do after
Evaluate and combine parallelism strategies for model size, hardware placement, communication cost, and training throughput.
How it connects
Connects data, model, pipeline, tensor, context, expert, and fully sharded data parallelism with collective communication.

Also explained in

Compare how 2 books explain n-dimensional parallelism →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with PyTorch, Second Edition. The section links point to the parts of the book it draws on.