Pipeline Parallelism › The Pipeline Bubble Problem

Michael BrenndoerferJanuary 20, 20265 min read
Language AI HandbookAll chapters
Part 31 of 67Training Infrastructure
Chapter 224Pipeline Parallelism › The Pipeline Bubble Problem
Reading section 3 of 10 · The Pipeline Bubble Problem · 5 minSection 3 of 10 · 5 min

Book contents

Section 3 of 10 · 5 min read

Pipeline Parallelism › The Pipeline Bubble ProblemOne section · Sections in this chapter3 / 10 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

The most important challenge in pipeline parallelism is not communication or memory but time: the problem of stages sitting idle while waiting for work. To understand why this happens, it is worth tracing through exactly what happens when you run a model through a naive pipeline.

Imagine four pipeline stages labeled S1 through S4. A single input mini-batch B1B_1 enters S1 at time step 1. S2 cannot begin until S1 finishes, S3 cannot begin until S2 finishes, and so on. The result is a startup pattern where:

  • At time step 1: S1 is working, S2, S3, and S4 are idle.
  • At time step 2: S2 is working on the result from S1, while S1 is idle (finished its pass and waiting), and S3 and S4 are still idle.
  • At time step 3: S3 is working, while S1, S2, and S4 are all idle.
  • At time step 4: S4 is working, while S1, S2, and S3 are all idle.

After the forward pass completes, the backward pass flows in reverse: S4 computes gradients first, then passes them to S3, and so on back to S1. This also creates a sequential chain of idle time, now in reverse order. The combined result is that the startup and teardown phases of the pipeline are almost entirely wasted: at any given moment, only one stage is doing useful work.

Pipeline Bubble

A pipeline bubble is the idle time that accumulates across pipeline stages due to the sequential dependency between stages. Bubbles appear at the beginning and end of every micro-batch sequence. For a pipeline with DD stages, the naive single-batch approach wastes (D−1)/D(D-1)/D of total device-time on bubbles. With four stages, three-quarters of all device-time is wasted.

To quantify the bubble fraction precisely, consider DD pipeline stages processing MM micro-batches. The startup ramp contributes D−1D - 1 idle time steps before all stages can participate (the first stage begins immediately, but the kk-th stage cannot begin until k−1k - 1 time steps have passed because it must wait for activations from earlier stages). The drain phase at the end is symmetric, contributing another D−1D - 1 idle time steps as gradients move backward through the pipeline. Each stage performs 2M2M useful operations—MM forward and MM backward—and the full schedule lasts 2M+2(D−1)2M + 2(D - 1) time steps. The bubble fraction is therefore:

bubble fraction=2(D−1)2M+2(D−1)=D−1M+D−1\text{bubble fraction} = \frac{2(D-1)}{2M + 2(D-1)} = \frac{D-1}{M + D-1}

where:

  • DD: number of pipeline stages (equal to the number of devices)
  • MM: number of micro-batches processed in each pipeline run
  • 2(D−1)2(D-1): total idle time slots from the startup ramp and teardown drain

For large MM, the denominator is dominated by MM, so the bubble fraction approaches (D−1)/M(D-1)/M, which converges to zero as MM grows. This asymptotic behavior is the key insight: the bubble overhead becomes negligible when MM is much larger than DD.

To see this concretely with numbers: for D=4D = 4 stages and M=1M = 1 micro-batch, the bubble fraction is 3/4=0.753/4 = 0.75. You are paying for four GPUs but using only about 25% of their combined compute capacity. Increasing MM to 8 micro-batches brings the bubble fraction to 3/11≈0.273/11 \approx 0.27. Increasing to 32 micro-batches brings it to 3/35≈0.0863/35 \approx 0.086. The improvement continues, but each additional doubling of MM produces diminishing returns: going from M=32M = 32 to M=64M = 64 reduces the bubble from about 9% to about 4.5%.

It is worth understanding why the bubble cannot be eliminated entirely with any finite number of micro-batches. The startup ramp is unavoidable: the first micro-batch must travel through all DD stages sequentially before the pipeline can be considered "full." During this ramp-up, early stages are idle after finishing their portion of the first micro-batch and before the second micro-batch arrives. Similarly, the drain ramp at the end is unavoidable: after the last forward pass, backward passes flow back through the pipeline, and late stages finish first while early stages wait for gradients to arrive from later stages. As MM grows, these fixed startup and drain costs become a smaller fraction of the schedule and approach zero asymptotically.

Out[3]:
Visualization
Line chart showing decreasing bubble fraction as micro-batch count increases for D=2,4,8,16 stages.
Pipeline bubble fraction as a function of micro-batch count M for different pipeline depths D. All curves follow the formula (D-1)/(M+D-1), converging toward zero as M grows. With M=1, a 4-stage pipeline wastes 75% of device time; increasing to M=32 drops waste below 10%. Deeper pipelines require larger M to reach the same efficiency level.