What is Pipeline parallelism?

Splitting a model's layers across GPUs in sequence, streaming micro-batches to reduce the time GPUs sit idle (the bubble).

Field: AI Hardware & Software Stack

Japanese name: パイプライン並列

Dividing the layers in order

The layers of the model are cut in order from the front into several groups. Each group is called a stage and is assigned to one GPU. In the forward pass, the output of one GPU is sent to the next. In the backward pass, gradients are sent in the opposite direction. What each GPU holds is the weights of its own stage. A large model that does not fit on one GPU can therefore be trained. What passes between GPUs is the data at the stage boundaries.

The bubble and micro-batches

If a batch is sent through as a whole, the other GPUs wait while one is computing. The batch is therefore split into small micro-batches that are sent through one after another. Even so, waiting time remains at the start and the end, and it is called the bubble. Take the forward pass alone in a simple form, with 8 micro-batches flowing through 4 stages and each stage handling one micro-batch per time slot. The whole takes 8 + 4 − 1 = 11 slots, and each GPU works for 8 of them. It waits for 3 slots, a share of 3 ÷ 11, about 27%. With 32 micro-batches the share falls to 3 ÷ 35, about 9%.

Points to watch in design

The more micro-batches there are, the smaller the share of the bubble. If each one becomes too small, however, the GPUs cannot be used efficiently. Gradients are added up over the micro-batches, and the weights are updated once the whole batch is complete. As long as no layer uses statistics of the whole batch, the update therefore uses mathematically the same gradient as when the batch is computed without splitting. It is desirable for the stages to take about the same time, because a heavy stage holds up the flow. In practice it is used together with data parallelism and tensor parallelism.

Try it: questions about Pipeline parallelism

In pipeline parallelism, where a model's layers are split across GPUs in sequence, why is a batch divided into micro-batches?

  1. AMicro-batches reduce the number of computations
  2. BTo reduce the idle time (bubble) in which later GPUs wait for earlier ones, keeping several GPUs busy at once
  3. CMicro-batches eliminate inter-GPU communication
Show answer and explanation

Answer: B. To reduce the idle time (bubble) in which later GPUs wait for earlier ones, keeping several GPUs busy at once

If a whole batch flows through at once, while the first GPU computes, the second and later GPUs can do nothing but wait. Splitting the batch into micro-batches lets the second GPU compute micro-batch 1 while the first computes micro-batch 2, and so on, overlapping the work. Some waiting (the bubble) remains at the start and end, so the number of micro-batches is made large enough.

FAQ

Is it related to pipelining in a CPU?

The idea is similar. Both divide the work into stages and send several pieces of data through, each slightly behind the last. What flows is micro-batches rather than instructions, however, and there is also a reverse flow for backpropagation.

Can the bubble be eliminated?

Not in the basic scheme. At the start the later GPUs have no data to process, and at the end the earlier GPUs have none. The number of micro-batches is increased to make its share of the whole smaller.

Questions that mention Pipeline parallelism (1)

Pipeline parallelism appears in 2 practice questions across 1 topic, including AI Hardware & Software Stack.

  1. Which describes tensor parallelism, which splits a large layer's matrix multiplication too big for one GPU across several GPUs?

Books on AI Hardware & Software Stack Ad

As an Amazon Associate I earn from qualifying purchases.

This page was drafted with AI and fact-checked by a separate AI review before publication. Our Editorial policy explains how we write and check content. If you spot an error, please tell us on our Contact page.

Back to the glossary