Bookmarks

PP — pipeline parallelism

A way of running on many GPUs in which the model is split by layers into stages, and data passes through the stages in a pipeline of microbatches.

checked 9 Nov

All terms

Pipeline parallelism (PP) is one of the three main kinds of parallelism in training and serving large models, alongside tensor and data parallelism. It spreads parts of the model across different GPUs and nodes when the model does not fit on a single device, and puts almost no load on the network between nodes.

How the pipeline works

The model is cut by layers into stages: for example, a 64-layer model is placed on 8 GPUs with 8 layers on each. Each batch is divided into microbatches, and the stages work like an assembly line: while the first computes the forward pass of the next microbatch, the second is already processing the previous one.

ElementWhat it is
Stageseveral consecutive layers of the model on one GPU or node
Microbatcha chunk of a batch that goes through the pipeline independently of the others
Bubbleidle time of the stages while the pipeline fills and drains

Bubbles and microbatches

At the start of a step the pipeline fills, at the end it drains — some stages are idle during this time. In Megatron-LM the idle fraction is estimated as (p − 1)/m, where p is the number of stages and m the number of microbatches: with 8 stages and 32 microbatches the idle time is 7/32 ≈ 22% of the time. There are many times more microbatches than stages; in the GPipe schedule, where all forward passes run before the backward ones, activations are kept for all microbatches at once, and memory grows with their number. The interleaved schedule splits the model into v chunks per GPU and reduces the idle time by a factor of v — at the cost of v-fold more communication; in the Megatron-LM paper this added up to 10% throughput at comparable memory.

Where it is used

When training large models, the pipeline is placed between nodes: tensor parallelism is kept within a node with NVLink links, pipeline parallelism between nodes, and data parallelism is added on top. The Megatron-LM authors’ rule: the total model parallelism TP × PP is kept at the minimum at which the model fits in memory, and the rest is made up with data parallelism. In inference the pipeline is enabled with the pipeline_parallel_size parameter: in vLLM it is given the number of nodes, and on GPUs without NVLink pipeline parallelism is preferred over tensor because of less communication. For neural networks the technique was described in the 2018 GPipe paper.

Sources

the term is written from these pages

Verified 9 Nov

Not to be confused with

what it is mixed up with and how it differs

  • TPtensor parallelism

    Tensor parallelism splits the matrices of a single layer and synchronises GPUs after every layer; pipeline parallelism only needs communication at stage boundaries.

  • DPdata parallelism

    With data parallelism each GPU keeps a copy of the whole model and trains on its own share of the data; with pipeline parallelism there is a single model, split across the GPUs.

In depth in the references

where the topic is covered in detail