Model parallelism
Model parallelism splits one neural network across several chips, either by dividing each layer's calculations between them (tensor parallelism) or by giving each chip a different set of layers (pipeline parallelism).
The simplest way to train on many GPUs is data parallelism: every GPU holds a full copy of the model and works on a different slice of the data. That stops working once the model, its gradients and its optimiser state no longer fit in one chip's memory. Model parallelism splits the model itself. There are two main ways to do it, and most large training runs use both.
Tensor parallelism cuts individual layers apart. The large matrix multiplications inside a transformer layer are sliced, each GPU computes its slice, and the results are combined. NVIDIA researchers showed this at scale in the 2019 Megatron-LM paper, training models of up to 8.3 billion parameters on 512 GPUs with only a few added communication operations in PyTorch, and sustaining 15.1 petaFLOPs at 76 per cent scaling efficiency. Because the GPUs must swap results inside every layer, tensor parallelism needs the fastest links available.
Pipeline parallelism gives each GPU a consecutive block of layers, like stations on an assembly line. Done naively, only one GPU works at a time while the others wait. Google's GPipe paper of November 2018 split each batch into smaller micro-batches so different stages can work on different micro-batches at once, reporting almost linear speedup and training a 6 billion parameter, 128-layer transformer. Some idle time, known as the pipeline bubble, remains, because stages still have to wait for one another at the start and end of each batch.
Frontier runs combine these with data parallelism. A 2021 Megatron-LM paper combined tensor, pipeline and data parallelism to train a 1 trillion parameter model at 502 petaFLOP/s on 3,072 GPUs, 52 per cent of theoretical peak per GPU. Meta's Llama 3 405B, trained on up to 16,384 H100 GPUs, used four dimensions: tensor, context, pipeline and data parallelism. Meta ordered them by network requirements, with tensor parallelism, across groups of eight GPUs, innermost and data parallelism outermost.
This is why AI chip announcements dwell on interconnects. The way a model is split decides which chips must talk constantly, and the size of the fast-linked group limits how a model can be divided. The same techniques are used to serve models too large for one GPU, where tensor parallelism spreads a single request across several chips.
In data parallelism every GPU holds a complete copy of the model and processes different training examples, then they average their updates. In model parallelism the model itself is divided, so each GPU holds only part of it. Large training runs usually use both at once. Tensor parallelism splits the calculations inside each layer across GPUs, which needs very fast, frequent communication. Pipeline parallelism assigns whole groups of layers to different GPUs and passes results along like an assembly line, which needs less communication but leaves some GPUs idle at times. It is the idle time in pipeline parallelism when some stages have no work, typically at the start and end of each batch while data is still flowing through the pipeline. Splitting batches into many micro-batches, as GPipe did, shrinks the bubble but cannot remove it entirely. Yes. When a model's weights do not fit in one GPU's memory, it has to be split across several to run at all. Tensor parallelism is commonly used for this, and Hugging Face documents it for both training and inference.Common questions
What is the difference between data parallelism and model parallelism?
What is the difference between tensor parallelism and pipeline parallelism?
What is a pipeline bubble?
Is model parallelism used for inference as well as training?
Search for "tensor parallelism", "pipeline parallelism", "Megatron-LM" or "3D parallelism" to see how large models are split. The most reliable sources are the original papers on arXiv, documentation from training frameworks such as Hugging Face, PyTorch and DeepSpeed, and the infrastructure sections of model technical reports, which state the actual configuration used.Finding more
Working out what this means for your business?
Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.