Pipeline Parallelism in Large Language Models: How GPipe, 1F1B Scheduling, and Interleaving Tame Memory and Bubbles

Training frontier large language models with tens or hundreds of billions of parameters exceeds the physical memory capacity of any individual GPU. While intra-node sharding strategies such as Tensor Parallelism partition individual matrix multiplications across accelerators over high-speed NVLink interconnects, scaling across multi-node clusters encounters strict hardware boundaries. Tensor Parallelism requires multiple collective All-Reduce communications per transformer layer. Across standar

6 min
Pipeline Parallelism in Large Language Models: How GPipe, 1F1B Scheduling, and Interleaving Tame Memory and Bubbles

Training frontier large language models with tens or hundreds of billions of parameters exceeds the physical memory capacity of any individual GPU. While intra-node sharding strategies such as Tensor Parallelism partition individual matrix multiplications across accelerators over high-speed NVLink interconnects, scaling across multi-node clusters encounters strict hardware boundaries.

Tensor Parallelism requires multiple collective All-Reduce communications per transformer layer. Across standard cluster networking fabrics, such as InfiniBand or RoCE, the latency and bandwidth penalty of cross-node All-Reduce operations collapses training throughput. Meanwhile, standard Data Parallelism and Fully Sharded Data Parallelism (FSDP) incur recurring All-Gather and Reduce-Scatter collective overheads across all ranks.

Pipeline Parallelism (PP) resolves this multi-node scaling constraint by partitioning neural networks along their depth. Rather than splitting individual weight matrices within a layer, Pipeline Parallelism places consecutive sequences of transformer layers onto distinct accelerator stages. Communication between stages is strictly point-to-point, transferring only the boundary activations during the forward pass and activation gradients during the backward pass.

GPipe vs 1F1B Pipeline Scheduling Comparison

The Pipeline Bubble and GPipe Scheduling

The fundamental challenge in pipeline parallelism is device idle time, known as the pipeline bubble. In a naive execution where a single batch is processed sequentially through PP pipeline stages, only one stage is active at any given moment. The remaining P1P - 1 stages sit completely idle while waiting for inputs from upstream stages during the forward pass or gradients from downstream stages during backpropagation.

To overcome this latency stall, Google Brain introduced GPipe (Huang et al., 2019). GPipe subdivides a global training batch into MM smaller, independent micro-batches (MPM \gg P). The first stage computes the forward pass on micro-batch 0 and immediately transmits the resulting activations to stage 1. While stage 1 executes micro-batch 0, stage 0 begins computing micro-batch 1.

Under the standard GPipe schedule (often called the Flush or Forward-then-Backward schedule):

  • Forward Phase: Each stage processes all MM forward micro-batches sequentially, forwarding activation tensors downstream.
  • Backward Phase: Once the final stage computes the loss for all micro-batches, backpropagation begins in reverse order, passing activation gradients back upstream.

While micro-batching dramatically improves hardware concurrency compared to naive sequential execution, GPipe suffers from two major structural constraints:

  1. Bubble Overhead: During the start of the forward pass (pipeline fill) and the end of the backward pass (pipeline drain), stages experience compulsory idle time. For PP pipeline stages and MM micro-batches, the total bubble time across all stages is (P1)(tF+tB)(P - 1) \cdot (t_F + t_B), where tFt_F is forward execution time per micro-batch and tBt_B is backward execution time. Assuming tB2tFt_B \approx 2 t_F, the theoretical pipeline bubble fraction FbubbleF_{\text{bubble}} is:

Fbubble=P1M+P1F_{\text{bubble}} = \frac{P - 1}{M + P - 1}

To reduce the bubble fraction to an acceptable level (such as under 10%), distributed training systems must set M8PM \ge 8P or M16PM \ge 16P.

  1. Activation Memory Explosion: Because GPipe executes all MM forward passes before executing any backward passes, each stage must preserve the intermediate activation tensors for all MM micro-batches in GPU VRAM. As operators increase MM to suppress the pipeline bubble, peak activation memory scales linearly with MM. For large models, this memory footprint triggers out-of-memory errors, restricting the maximum number of micro-batches that can be evaluated.

The 1F1B Schedule: Decoupling Memory from Micro-Batch Count

To break the linear coupling between micro-batch count and activation memory, the One-Forward-One-Backward (1F1B) schedule was proposed in PipeDream (Narayanan et al., 2019) and adapted for synchronous distributed LLM training in Megatron-LM (Narayanan et al., 2021).

Rather than accumulating all forward passes before beginning backpropagation, the 1F1B schedule transitions stages into an alternating steady state:

  • Warmup Phase: Stage ii executes Pi1P - i - 1 forward micro-batches. This primes downstream stages with initial activations.
  • Steady-State Phase: Each stage executes exactly one backward micro-batch (which computes gradients and frees that micro-batch's cached activation memory) for every one forward micro-batch it accepts.
  • Cooldown Phase: Once all MM forward micro-batches have completed, each stage drains its remaining outstanding backward micro-batches.

The mathematical advantage of 1F1B lies in its peak memory bound. In 1F1B, the maximum number of in-flight forward activations stored in memory on any stage is strictly capped at the pipeline depth PP, completely independent of the total micro-batch count MM.

This bounded memory property allows engineering teams to scale MM to large values (such as M=32M = 32 or M=64M = 64) to dilute the pipeline bubble without increasing the per-GPU activation memory footprint.

Interleaved 1F1B: Virtual Stages for Tighter Schedules

While standard 1F1B bounds peak activation memory, the bubble fraction remains (P1)/(M+P1)(P - 1) / (M + P - 1). In large clusters requiring deep pipelines (P=16P = 16 or P=32P = 32), achieving a small bubble fraction demands very large values of MM. However, total batch size equals M×micro-batch size×Data Parallel sizeM \times \text{micro-batch size} \times \text{Data Parallel size}. If MM is forced to be large, the global batch size can exceed the optimal statistical convergence threshold for LLM pretraining.

To address this limitation, the Megatron-LM team introduced the Interleaved 1F1B schedule (Narayanan et al., 2021). In this paradigm, each physical GPU hosts vv virtual stages (chunks) distributed across the model depth rather than a single contiguous block of layers.

For instance, with P=4P = 4 physical devices and a virtual chunk factor of v=2v = 2:

  • Device 0 holds Chunk 0 (Layers 1-4) and Chunk 4 (Layers 17-20).
  • Device 1 holds Chunk 1 (Layers 5-8) and Chunk 5 (Layers 21-24).
  • Device 2 holds Chunk 2 (Layers 9-12) and Chunk 6 (Layers 25-28).
  • Device 3 holds Chunk 3 (Layers 13-16) and Chunk 7 (Layers 29-32).

Because each virtual stage processes fewer layers, activations circulate through physical devices in shorter cycles. The resulting pipeline bubble fraction is reduced by a factor of vv:

Fbubble, interleaved1vP1MF_{\text{bubble, interleaved}} \approx \frac{1}{v} \cdot \frac{P - 1}{M}

For example, using v=2v = 2 cuts the pipeline bubble duration approximately in half for a given micro-batch count MM. The trade-off is communication frequency: interleaving increases point-to-point peer network transfers by a factor of vv, requiring sufficient network bandwidth between adjacent pipeline stages.

Zero-Bubble Pipeline Parallelism: Decoupling Weight and Activation Gradients

Even with interleaving, synchronous pipeline schedules historically faced a theoretical bubble lower bound determined by dependency graphs. In 2024, researchers from Sea AI Lab introduced Zero Bubble Pipeline Parallelism (Qi et al., 2024), demonstrating that pipeline bubbles can be reduced to near-zero while preserving exact synchronous training semantics.

Zero-Bubble scheduling exploits a fundamental mathematical property of backpropagation in neural network layers. The backward pass consists of two independent tensor computations:

  1. Activation Gradient (BB or x\nabla_x): Computes the gradient of the loss with respect to the input activations. This tensor is on the critical execution path because it must be transmitted immediately to the upstream pipeline stage so that earlier layers can continue backpropagation.
  2. Parameter Gradient (WW or w\nabla_w): Computes the gradient of the loss with respect to layer weights. This tensor is not required by any other pipeline stage; it only needs to be accumulated locally prior to the final optimizer step.

In standard 1F1B, BB and WW are computed together in an atomic backward operation. Zero-Bubble algorithms (such as ZB1P, ZB2P, and ZBV) split backward execution into separate BB and WW tasks.

By executing BB passes with high priority to unblock upstream stages and deferring WW passes into the idle time slots of the warmup and cooldown phases, the scheduler fills the pipeline bubbles with useful parameter gradient computation. In empirical benchmarks on Megatron-LM, Zero-Bubble schedules deliver up to 20% to 30% higher training throughput compared to standard 1F1B under equivalent memory budgets.

3D Parallelism Topology and Production Deployment

In production distributed training clusters (such as Megatron-DeepSpeed and PyTorch FSDP setups), Pipeline Parallelism is rarely deployed in isolation. Instead, it forms the third dimension of 3D parallelism:

  • Tensor Parallelism (TP, intra-node): Applied within single 8-GPU servers over high-bandwidth NVLink (900 GB/s to 1.8 TB/s). TP splits attention heads and MLP hidden dimensions where low-latency communication is mandatory.
  • Pipeline Parallelism (PP, inter-node): Applied across multi-node boundaries over standard InfiniBand/RoCE fabrics. Because PP only transmits boundary activations and activation gradients (O(Bsh)O(B \cdot s \cdot h) per micro-batch), it operates efficiently across lower-bandwidth cross-node networks.
  • Data Parallelism / FSDP (DP, cluster-wide): Replicates the TP+PP model pipeline across orthogonal GPU groups, performing asynchronous gradient reductions across pipeline replicas.

By combining intra-node Tensor Parallelism with bounded 1F1B or Zero-Bubble Pipeline Parallelism across nodes, distributed training clusters can scale foundation models to trillions of parameters while maintaining high Model Flops Utilization (MFU).

Sources

Written by

More to read

  • Anthropic Demonstrates Autonomous De Novo Protein Design and Chemical Analysis with Claude

    Anthropic Demonstrates Autonomous De Novo Protein Design and Chemical Analysis with Claude Anthropic has published experimental results demonstrating Claude's ability to autonomously design de novo protein binders with physical wet-lab validation and automate complex analytical chemistry workflows. The findings show frontier LLMs acting as autonomous agents across computational biology and molecular characterization pipelines. In the primary experiment, Anthropic evaluated Claude Mythos Previe

    1 min
  • Cerebras Unveils CS-4 Rack-Scale System Powered by Three WSE-3 Turbo Chips and Nexus Architecture

    Cerebras Unveils CS-4 Rack-Scale System Powered by Three WSE-3 Turbo Chips and Nexus Architecture Cerebras Systems has announced the CS-4, a rack-scale AI accelerator system designed around three of its next-generation Wafer Scale Engine 3 Turbo (WSE-3 Turbo) chips and a modular hardware architecture dubbed Nexus. Cerebras confirmed that initial customer shipments for the CS-4 are scheduled to begin in the current quarter. The new system marks a structural shift from Cerebras's single-wafer CS

    1 min
  • AI FinOps: Cutting LLM Inference Costs by 30-60% Through Model Tiering, Caching, and GPU Optimization

    AI FinOps: Cutting LLM Inference Costs by 30-60% Through Model Tiering, Caching, and GPU Optimization Inference costs have become the second-largest line item in enterprise AI budgets, trailing only talent spend according to RapidData's State of Enterprise AI 2026. This shift represents a fundamental inversion from the 2021-2023 era when training dominated AI expenditure. The compounding nature of serving costs—accumulating every hour as long as users hit the API—means that even modest producti

    1 min