Zero Bubble (Almost) Pipeline Parallelism

Penghui Qi, Xinyi Wan, Guangxing Huang, Min LinICLR 2024

TL;DR: Training massive AI models often leaves GPUs sitting idle during "pipeline bubbles." This paper introduces a novel scheduling strategy that achieves near-zero idle time by splitting the backward pass into two parts, allowing weight updates to fill the gaps without sacrificing training stability.

The Challenge of Pipeline Bubbles

When training Large Language Models (LLMs), engineers frequently rely on Pipeline Parallelism (PP). In this setup, a massive model is sliced into sequential stages and distributed across multiple GPUs. However, because each stage depends on the output of the previous one, GPUs inevitably spend time waiting for data to arrive. This idle time is known as a "pipeline bubble."

While previous methods like GPipe or 1F1B (One-Forward-One-Backward) reduced these bubbles, they were largely considered an unavoidable "tax" on synchronous training. Asynchronous methods can eliminate bubbles but often lead to unstable training or "stale" gradients. The core challenge addressed by this research is: How can we achieve zero pipeline bubbles while maintaining the mathematical exactness of synchronous training?

A "Divide and Conquer" Approach to the Backward Pass

The authors' primary innovation is rethinking the backward pass. Traditionally, the backward pass is treated as a single, monolithic block of computation. The authors propose splitting it into two distinct phases:

  1. B (Backward-for-Input): Calculates gradients for the activations to pass to the previous layer. This step is time-critical because the previous GPU in the pipeline is waiting for it.
  2. W (Backward-for-Weights): Calculates gradients for the model's parameters. Crucially, this is not immediately needed by other layers to continue their backward passes.
Splitting the backward pass into Backward-for-Input (B) and Backward-for-Weights (W)

By decoupling $B$ and $W$, the authors realize that while activation gradients ($B$) have strict sequential dependencies, weight gradients ($W$) are essentially independent tasks. They can be moved around like Tetris blocks to fill gaps in the GPU's schedule.

Novel Scheduling Strategies

Leveraging this split, the authors introduce new handcrafted schedules to "hide" the $W$ computations inside the idle bubbles:

  • ZB-H1: Matches the memory usage of the standard 1F1B schedule but reduces the bubble size by a third.
  • ZB-H2: Achieves a "zero bubble" state by using more microbatches and slightly more memory.

Because manual scheduling is difficult for complex, real-world setups, they also developed an automated algorithm using Integer Linear Programming to find the optimal schedule for any given model size and memory limit.

Bypassing Optimizer Synchronization

Normally, all GPUs must pause and synchronize at the end of a batch to check for numerical errors (like NaNs). To prevent this from creating a new bubble, the authors propose a post-update validation with an in-place rollback mechanism. GPUs proceed speculatively; if an error is detected later, they "undo" the step arithmetically. This treats numerical stability checks as a "lazy" process, only paying the cost of a rollback in the rare event of a failure.

Key Results and Throughput Gains

The paper evaluates this method using transformer models analogous to GPT-3, ranging from 1.5B to 28.3B parameters, on clusters of up to 32 NVIDIA A100 GPUs.

Throughput comparison showing Zero Bubble schedules outperforming 1F1B across various model sizes
  • Zero Bubbles: In theoretical and profiled executions, the ZB-2p (Zero Bubble) schedule reduced the bubble rate from ~12-26% down to less than 1%.
  • Throughput Gains: Compared to the industry-standard 1F1B schedule, the "Zero Bubble" approach improved throughput by up to 15% under similar memory constraints. When memory limits were relaxed, throughput gains reached up to 30%.
  • Efficiency with Fewer Microbatches: The method allows for high efficiency even with a smaller number of microbatches, which is traditionally a major bottleneck for pipeline parallelism.

Limitations and Future Work

While groundbreaking, the approach comes with trade-offs:

  • Memory Overhead: Achieving a true "zero bubble" (ZB-H2) requires roughly double the activation memory compared to 1F1B. The authors suggest this can be mitigated by techniques like ZeRO or Tensor Parallelism, but it remains a consideration.
  • Implementation Complexity: The schedules are significantly more complex than standard 1F1B, requiring sophisticated software orchestration. Fortunately, the authors have open-sourced their implementation based on Megatron-LM.
  • Communication Bottlenecks: The method eliminates computation bubbles but does not solve the physical limits of data transfer between nodes, though it provides more opportunities to overlap communication with computation.

Overall, this research marks a major step forward in harnessing the true potential of pipeline parallelism, proving that the long-accepted "bubble tax" is no longer inevitable.

Summary updated

BibTeX
@inproceedings{qi2024zero,
  author = {Penghui Qi and Xinyi Wan and Guangxing Huang and Min Lin},
  title = {{Zero Bubble (Almost) Pipeline Parallelism}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=tuzTN0eIO5},
}
Figure