Model parallelism divides one model across several devices, so each GPU holds and computes only part of it. It is the answer to a model whose weights, gradients and activations don’t fit in one accelerator’s memory. Contrast data parallelism, where every device holds the whole model and only the data is split.
Where to cut
- By layer: pipeline parallelism. Consecutive layers go to different devices, and activations flow from one stage to the next like an assembly line. Run naively, only one stage works at a time. GPipe fixed much of that by splitting each batch into micro-batches, so different stages can process different micro-batches at once.
- Within a layer: tensor parallelism. The big matrix multiplications inside each layer are split, so every device computes a slice of every layer. Megatron-LM showed this can be done for transformers with a few added communication operations. Because devices must sync inside every layer, it works best over very fast links, typically between GPUs in the same server.
A related idea routes different inputs to different parts of the model: mixture-of-experts models place experts on different devices, a split usually called expert parallelism.
The catch
Splitting a model turns memory problems into communication problems. Pipelines leave some devices idle at the start and end of each batch; tensor splits add traffic to every layer. That’s why large training runs mix model parallelism with data parallelism and sharding, choosing the split that suits each level of the hardware.