Subscribe
AI
10 min read

Pipeline Parallelism in Production LLM Training: Comparing 1F1B, Interleaved 1F1B, Zero-Bubble, and DualPipe Schedules

A technical comparison of pipeline parallelism schedules for production LLM training, evaluating trade-offs between pipeline bubbles, activation memory, network traffic, and GPU utilization.

Diagram comparing pipeline parallelism schedules including 1F1B, Interleaved 1F1B, Zero-Bubble, and DualPipe showing microbatch execution flows and bubble formations
Diagram comparing pipeline parallelism schedules including 1F1B, Interleaved 1F1B, Zero-Bubble, and DualPipe showing microbatch execution flows and bubble formations

Engineering teams select pipeline schedules based on a trade-off between computational efficiency (bubble fraction), memory constraints (peak activation memory), and network overhead. For standard dense models seeking baseline stability with minimal infrastructure changes, 1F1B is the default choice, while Interleaved 1F1B is selected to reduce bubbles at the cost of increased network traffic.

Pipeline Parallelism in Production LLM Training: Comparing 1F1B, Interleaved 1F1B, Zero-Bubble, and DualPipe Schedules

Training modern large language models spanning hundreds of billions of parameters requires distributing model layers across multiple compute nodes. While Tensor Parallelism (TP) partitions individual matrix multiplications across GPUs within a single node, its reliance on high-frequency, all-reduce communications limits its practical scaling to the high-bandwidth domain of NVLink (typically 8 GPUs per node). To scale models beyond single-node memory boundaries, distributed training systems rely on Pipeline Parallelism (PP), which partitions the model depth-wise across successive pipeline stages.

The central engineering challenge in pipeline parallelism is the pipeline bubble: worker GPUs remain idle during pipeline warmup and cooldown while waiting for activations or gradients to propagate across sequential stages. Over the past five years, pipeline scheduling has progressed from naive batching to interleaved virtual stages, decoupled gradient passes, and bidirectional communication-computation overlap.

Pipeline Parallelism Schedules Architecture

The Pipeline Bubble Formulation

In pipeline parallelism, a model with LL layers is partitioned across pp pipeline stages, with each stage hosted on an independent GPU or tensor-parallel group. A global batch is subdivided into mm microbatches.

In the baseline GPipe schedule introduced by Huang et al. (2019), all mm microbatches execute their forward passes sequentially from stage 0 to stage p−1p-1, followed by backward passes in reverse order. The total execution time includes idle intervals during which downstream stages wait for forward activations and upstream stages wait for backward gradients.

The ideal computation time without idle bubbles is:

Tideal=m⋅(tF+tB)T_{ideal} = m \cdot (t_F + t_B)

where tFt_F represents the forward computation time per microbatch on one stage, and tBt_B represents the backward computation time.

In GPipe, the idle bubble duration per iteration spans (p−1)⋅(tF+tB)(p - 1) \cdot (t_F + t_B). The bubble fraction FbubbleF_{bubble} is expressed as:

Fbubble=(p−1)⋅(tF+tB)m⋅(tF+tB)+(p−1)⋅(tF+tB)=p−1m+p−1F_{bubble} = \frac{(p - 1) \cdot (t_F + t_B)}{m \cdot (t_F + t_B) + (p - 1) \cdot (t_F + t_B)} = \frac{p - 1}{m + p - 1}

To reduce FbubbleF_{bubble} below 10%, engineering teams must set m≥9pm \ge 9p. However, scaling mm arbitrarily is constrained by several physical factors:

  1. Global Batch Size Limits: The global batch size is Bglobal=m⋅bmicro⋅DPB_{global} = m \cdot b_{micro} \cdot DP, where bmicrob_{micro} is the microbatch size and DPDP is the data-parallel degree. Expanding mm increases BglobalB_{global}, which can degrade optimization dynamics and validation loss beyond critical batch size thresholds.
  2. Activation Memory Explosion: In GPipe, every stage must store activations for all mm microbatches until backpropagation completes, causing GPU out-of-memory (OOM) failures on long context windows.

1F1B Scheduling (PipeDream)

To resolve the activation memory scaling of GPipe, Narayanan et al. (2019) introduced the One Forward, One Backward (1F1B) schedule in PipeDream and adapted it for memory-efficient LLM pre-training in Megatron-LM (Narayanan et al., 2021).

Execution Mechanics

Instead of batching all forward passes together, 1F1B divides execution into three distinct phases:

  1. Warmup Phase: Stage kk executes p−k−1p - k - 1 consecutive forward passes to fill the pipeline.
  2. Steady-State Phase: Once the first backward pass is received from the subsequent stage, each stage alternates strictly between executing one backward pass and one forward pass (1B→1F1B \to 1F).
  3. Cooldown Phase: After all mm forward passes are completed, stages process the remaining p−k−1p - k - 1 backward passes.
Stage 3:       [F0][F1][F2][F3][B0][F4][B1][F5][B2][F6][B3][B4][B5][B6]
Stage 2:    [F0][F1][F2][F3][F4][B0][F5][B1][F6][B2][B3][B4][B5][B6]
Stage 1: [F0][F1][F2][F3][F4][F5][B0][F6][B1][B2][B3][B4][B5][B6]
Stage 0: [F0][F1][F2][F3][F4][F5][F6][B0][B1][B2][B3][B4][B5][B6]
Time  -->

Resource Characteristics

In 1F1B, the maximum number of in-flight microbatches stored in memory on any stage is capped at pp. Peak activation memory scales with O(p)O(p) rather than O(m)O(m), allowing training with large microbatch counts without exhausting device high-bandwidth memory (HBM).

However, 1F1B maintains the same bubble overhead as GPipe:

Tbubble1F1B=(p−1)⋅(tF+tB)T_{bubble}^{1F1B} = (p - 1) \cdot (t_F + t_B)

The bubble ratio remains approximately p−1m\frac{p - 1}{m}.


Interleaved 1F1B (Megatron-LM 1F1B-I)

To reduce the bubble ratio without increasing global batch size, Megatron-LM introduced Interleaved 1F1B (1F1B-I).

Virtual Stage Partitioning

In 1F1B-I, each physical GPU hosts vv virtual stages (model chunks) rather than a single contiguous block of layers. For example, with p=4p = 4 physical stages and v=2v = 2 virtual stages per device:

  • Device 0 hosts Chunk 0 (layers 0-3) and Chunk 4 (layers 16-19)
  • Device 1 hosts Chunk 1 (layers 4-7) and Chunk 5 (layers 20-23)
  • Device 2 hosts Chunk 2 (layers 8-11) and Chunk 6 (layers 24-27)
  • Device 3 hosts Chunk 3 (layers 12-15) and Chunk 7 (layers 28-31)

Microbatches cycle through all physical devices twice: forward passes travel Device 0→1→2→3→0→1→2→30 \to 1 \to 2 \to 3 \to 0 \to 1 \to 2 \to 3, and backward passes travel in reverse order.

Bubble and Overhead Trade-Offs

Interleaving shortens the pipeline bubble duration by a factor of vv:

Tbubble1F1B−I=(p−1)⋅(tF+tB)vT_{bubble}^{1F1B-I} = \frac{(p - 1) \cdot (t_F + t_B)}{v}

The corresponding bubble fraction decreases to:

Fbubble1F1B−I≈p−1v⋅mF_{bubble}^{1F1B-I} \approx \frac{p - 1}{v \cdot m}

This reduction introduces two engineering costs:

  1. Communication Volume: Point-to-point (P2P) peer transfers over network interfaces scale up by v×v \times, increasing cross-node InfiniBand traffic.
  2. Activation Footprint: Storing activations across multiple virtual chunks increases peak activation memory by (v−1)⋅bmicro(v - 1) \cdot b_{micro} per stage. In production systems, vv is typically constrained to 2 or 4.

Zero-Bubble Pipeline Parallelism (ZB-1P, ZB-2P, ZB-V)

While 1F1B and 1F1B-I treat the backward pass as an indivisible block of time tBt_B, Qi et al. (ICLR 2024) demonstrated that backward computation comprises two distinct operations with differing dependency requirements.

Decoupling Activation and Weight Gradients

For a parameterized layer y=Wxy = Wx, computing the backward pass given incoming gradient ∂L∂y\frac{\partial L}{\partial y} requires:

  1. Activation Gradient (BxB_x or BB):

∂L∂x=∂L∂yWT\frac{\partial L}{\partial x} = \frac{\partial L}{\partial y} W^T This gradient must be transmitted immediately to the upstream pipeline stage so that earlier layers can continue backpropagation.

  1. Parameter/Weight Gradient (BWB_W or WW):

∂L∂W=(∂L∂y)Tx\frac{\partial L}{\partial W} = \left(\frac{\partial L}{\partial y}\right)^T x This tensor is accumulated locally into the gradient buffer for the optimizer update. No other pipeline stage requires this tensor during the forward-backward iteration.

In standard Transformer layers, the computational cost divides roughly as tF≈tB≈tWt_F \approx t_B \approx t_W, where tBt_B (computing ∂L∂x\frac{\partial L}{\partial x}) represents 1/31/3 of total backward computation and tWt_W (computing ∂L∂W\frac{\partial L}{\partial W}) represents the remaining 2/32/3.

Standard Backward (2/3 total step time):
[------------- Backward Step t_B_total -------------]
[-- Activation Grad B_x (t_B) --][-- Weight Grad B_W (t_W) --]
 ^ Required by Stage k-1          ^ Local accumulation only

ZB-1P and ZB-2P Scheduling

Because WW computation does not sit on the critical latency path of backpropagation, Zero-Bubble schedules decouple BB and WW:

  • The activation gradient computation (BB) is executed immediately to keep upstream stages active.
  • The parameter gradient computation (WW) is deferred and scheduled into the idle intervals (bubbles) during warmup, steady state, and cooldown.

In ZB-1P (Zero-Bubble 1-Phase), WW kernels are prioritized such that peak activation memory remains identical to standard 1F1B (pp microbatches). The resulting bubble duration decreases to:

TbubbleZB−1P=(p−1)⋅(tF+tB−2tW)T_{bubble}^{ZB-1P} = (p - 1) \cdot (t_F + t_B - 2t_W)

When tF≈tB≈tWt_F \approx t_B \approx t_W, TbubbleZB−1PT_{bubble}^{ZB-1P} approaches zero in steady state.

In ZB-2P, the schedule allows peak activation memory to reach 2p2p microbatches, enabling an optimizer-validated reordering where all pipeline bubbles are filled by deferred WW passes. ZB-V combines this decoupling with virtual stage interleaving to achieve zero bubble under equivalent memory bounds.


Bidirectional Overlap: DeepSeek DualPipe

In large-scale Mixture of Experts (MoE) architectures such as DeepSeek-V3 and DeepSeek-R1 (DeepSeek-AI, 2024), inter-node All-to-All communication for routed experts introduces substantial network latency. To eliminate both pipeline idle bubbles and communication overheads, DeepSeek introduced DualPipe, an open-source bidirectional pipeline parallelism schedule (GitHub: deepseek-ai/DualPipe).

Bidirectional Microbatch Streams

DualPipe deploys two symmetrical pipelines running simultaneously in opposite directions on the same physical infrastructure:

  • Forward Stream 0: Flows from Stage 0→p−10 \to p - 1
  • Forward Stream 1: Flows from Stage p−1→0p - 1 \to 0

Each physical GPU is assigned two symmetric chunks: one from the first half of the model and one from the second half.

DualPipe Physical Mapping (PP = 4):
GPU 0: Chunk 0 (Layers 0..15)   & Chunk 7 (Layers 96..111)
GPU 1: Chunk 1 (Layers 16..31)  & Chunk 6 (Layers 80..95)
GPU 2: Chunk 2 (Layers 32..47)  & Chunk 5 (Layers 64..79)
GPU 3: Chunk 3 (Layers 48..63)  & Chunk 4 (Layers 64..79)

Overlapped Forward-Backward Kernels (F&BF\&B)

DualPipe integrates the B/WB/W gradient splitting of Zero-Bubble with kernel-level computation-communication overlap. During steady state, DualPipe executes combined F&BF\&B instructions:

  1. As a forward chunk executes its dense matrix multiplications, it simultaneously drives the asynchronous non-blocking All-to-All communication of MoE dispatch for a backward chunk.
  2. The backward pass activation gradient (BB) and weight gradient (WW) are interleaved directly between forward activations.
DualPipe Computation-Communication Overlap:
[---------------- Computation Track ----------------]
[ Forward GEMM (Chunk A) ][ Backward GEMM (Chunk B) ]
[---------------- Communication Track --------------]
[ P2P Recv (Chunk B)     ][ MoE All-to-All (Chunk A) ]
<------- Synchronous Execution over Dual Streams ------>

The bubble duration in DualPipe drops to:

TbubbleDualPipe=(p2−1)⋅(tF&B+tB−3tW)T_{bubble}^{DualPipe} = \left(\frac{p}{2} - 1\right) \cdot (t_{F\&B} + t_B - 3t_W)

where tF&Bt_{F\&B} is the execution time of the fused forward-backward overlap kernel.


Architectural Comparison and Systems Economics

The choice of pipeline parallel schedule determines the trade-off between memory allocation, network pressure, and GPU Model FLOPs Utilization (MFU).

Feature / Metric1F1B (PipeDream)Interleaved 1F1BZero-Bubble (ZB-1P)DeepSeek DualPipe
Bubble Time(p−1)(tF+tB)(p - 1)(t_F + t_B)p−1v(tF+tB)\frac{p - 1}{v}(t_F + t_B)(p−1)(tF+tB−2tW)(p - 1)(t_F + t_B - 2t_W)(p2−1)(tF&B+tB−3tW)\left(\frac{p}{2} - 1\right)(t_{F\&B} + t_B - 3t_W)
Typical Bubble Fraction15%−30%15\% - 30\%5%−12%5\% - 12\%2%−6%2\% - 6\%<1.5%< 1.5\%
Peak Activation Memoryp⋅bmicrop \cdot b_{micro}(p+v−1)⋅bmicro(p + v - 1) \cdot b_{micro}p⋅bmicrop \cdot b_{micro}(p+1)⋅bmicro(p + 1) \cdot b_{micro}
Model Parameter Copies1×1\times1×1\times1×1\times2×2\times (Shared stages per GPU)
P2P Network VolumeBaseline (1×1\times)v×v\times BaselineBaseline (1×1\times)2×2\times Baseline
MoE All-to-All OverlapNoneLimitedNoneFull asynchronous overlap
Kernel ComplexityStandard PyTorchStandard PyTorchCustom autograd engineCustom dual-stream overlap

Implementation Considerations in Production Clusters

When deploying advanced pipeline schedules in production clusters running Megatron-Core, DeepSpeed, or custom frameworks, several systems considerations apply:

  1. Autograd Hook Splitting: Standard PyTorch torch.autograd.backward() bundles tensor and parameter gradient passes into a single execution graph. Implementing Zero-Bubble or DualPipe requires registering manual tensor hooks or custom C++/CUDA backward kernels that emit ∂L∂x\frac{\partial L}{\partial x} and return immediately, queuing ∂L∂W\frac{\partial L}{\partial W} onto a secondary worker queue.
  2. CUDA Stream Synchronization: DualPipe requires multi-stream management (typically separate compute, P2P send, P2P receive, and All-to-All collective streams). Unbalanced microbatch execution times can introduce intra-device synchronization bubbles if GPU SM occupancy is saturated by GEMM kernels during non-blocking communication passes.
  3. Memory Budget Allocation: In MoE pre-training, parameter memory is dominated by routed experts. Because DualPipe assigns two distinct layer chunks to each physical device, the model parameter memory per GPU doubles unless weights are sharded via ZeRO-style distributed optimizers across data-parallel groups.

Sources

Frequently asked questions

What is the peak activation memory requirement for the 1F1B schedule compared to GPipe?

The 1F1B schedule caps the maximum number of in-flight microbatches stored in memory on any stage at p (the number of pipeline stages), resulting in peak activation memory that scales with O(p). This contrasts with the baseline GPipe schedule, where every stage must store activations for all m microbatches until backpropagation completes, causing memory scaling with O(m) and potential out-of-memory failures.

How does Interleaved 1F1B reduce pipeline bubbles without increasing global batch size?

Interleaved 1F1B reduces the bubble ratio by allowing each physical GPU to host v virtual stages (model chunks) rather than a single contiguous block. Microbatches cycle through all physical devices twice, which shortens the pipeline bubble duration by a factor of v according to the formula T_bubble^{1F1B-I} = ((p - 1) * (t_F + t_B)) / v. However, this reduction introduces engineering costs: point-to-peer transfer volumes scale up by v times, and peak activation memory increases by (v - 1) * b_micro per stage.

What mechanism allows Zero-Bubble schedules to approach zero idle time during steady state?

Zero-Bubble schedules decouple the backward pass into two distinct operations: the activation gradient computation (B_x) and the parameter/weight gradient computation (W). Because the weight gradient tensor is accumulated locally and does not sit on the critical latency path of backpropagation, it is deferred and scheduled into idle intervals (bubbles). When forward time t_F, backward activation time t_B, and weight gradient time t_W are approximately equal, deferring the weight gradient fills the bubble entirely, causing the steady-state bubble duration to approach zero.

Why is DeepSeek DualPipe specifically designed for Mixture of Experts (MoE) architectures?

Large-scale MoE architectures like DeepSeek-V3 introduce substantial inter-node All-to-All communication latency for routed experts. DualPipe eliminates both pipeline idle bubbles and this specific communication overhead by deploying two symmetrical pipelines running in opposite directions on the same physical infrastructure. It integrates bidirectional overlap where, as a forward chunk executes dense matrix multiplications, it simultaneously drives the asynchronous non-blocking All-to-All communication for a backward chunk, significantly reducing the total bubble duration.

How does model parameter memory usage differ between standard schedules and DualPipe?

In standard 1F1B and Zero-Bubble schedules, model parameters are copied 1x across the distributed system. In contrast, DualPipe assigns two distinct layer chunks (one from the first half and one from the second half of the model) to each physical device, meaning the model parameter memory per GPU doubles (2x copies shared stages per GPU) unless weights are explicitly sharded via ZeRO-style distributed optimizers across data-parallel groups.

AILLMDistributed TrainingInfrastructure