Inferensys

Glossary

Pipeline Parallelism

Pipeline parallelism is a model parallelism technique that partitions a neural network's sequential layers (stages) across multiple GPUs, with micro-batches of data flowing through the pipeline to maximize hardware utilization during training and inference.
Data scientist building training data pipeline on laptop, data preprocessing visible, technical workspace.
INFERENCE OPTIMIZATION

What is Pipeline Parallelism?

A model parallelism technique for distributing deep neural networks across multiple accelerators to enable the training and inference of models too large for a single device.

Pipeline parallelism is a distributed training and inference strategy that partitions a neural network's sequential layers into distinct groups, called stages, which are then assigned to different GPUs or other accelerators. Data, processed in micro-batches, flows through this pipeline sequentially, allowing multiple micro-batches to be processed concurrently in different stages to improve hardware utilization. This technique is essential for running large language models (LLMs) and other massive networks that exceed the memory capacity of a single device.

The primary challenge is the pipeline bubble, an interval of idle time introduced at the start and end of processing a batch as the pipeline fills and drains. Optimization techniques like 1F1B (One-Forward-One-Backward) scheduling and interleaved stage placement are used to minimize these bubbles. Pipeline parallelism is often combined with tensor parallelism and data parallelism in 3D parallelism frameworks to scale the largest foundation models across thousands of GPUs efficiently.

PIPELINE PARALLELISM

Key Components of a Pipeline

Pipeline parallelism partitions a model's sequential layers across multiple GPUs, forming a processing pipeline where data flows in micro-batches to maximize hardware utilization. This glossary breaks down its core mechanisms and trade-offs.

01

Pipeline Stages

A pipeline stage is a contiguous set of model layers assigned to a single GPU. The model is split vertically along its depth. For example, a 24-layer transformer might be split into 4 stages of 6 layers each. Each stage operates independently on its assigned micro-batch, passing activations to the next stage via high-speed interconnects like NVLink. The number of stages is typically equal to the number of available GPUs, defining the pipeline's length.

02

Micro-Batches

A micro-batch is a small, fixed-size subset of the overall training batch. The global batch is split into many micro-batches that are fed into the pipeline sequentially. This is critical for keeping the pipeline full: while one micro-batch is in the forward pass of stage 2, another can be in stage 1. Micro-batch size is a key tuning parameter, balancing GPU memory usage against pipeline bubble size. Common sizes range from 1 to 32 samples.

03

Pipeline Bubbles

A pipeline bubble is a period of idle time in a GPU's schedule, representing underutilization. Bubbles occur during pipeline fill (when the first micro-batch is propagating through empty stages) and flush (when the last micro-batch completes). The bubble size is fundamentally determined by the number of pipeline stages. Techniques like 1F1B (One Forward One Backward) scheduling and interleaved scheduling are used to reduce bubble overhead and improve throughput.

04

1F1B Scheduling

1F1B (One Forward One Backward) is the standard scheduling protocol for pipeline parallelism. Each device alternates between performing a forward pass for one micro-batch and a backward pass for another. This pattern:

  • Maintains a steady state where all devices are busy.
  • Ensures memory usage is bounded, as activations for a micro-batch can be discarded after its backward pass.
  • Creates a deterministic schedule that is easier to debug and reason about compared to more complex schemes.
05

Interleaved Scheduling

Interleaved scheduling is an advanced optimization where each physical GPU is assigned multiple virtual pipeline stages. For example, on a 4-GPU system, each GPU might handle 2 virtual stages, creating an 8-stage virtual pipeline. This technique:

  • Reduces the size of pipeline bubbles by increasing the number of micro-batches in flight.
  • Improves GPU utilization at the cost of increased implementation complexity and memory overhead, as each GPU must hold the parameters and activations for multiple model segments.
06

Gradient Synchronization

Gradient synchronization ensures weight updates are consistent across all pipeline stages. During the backward pass, gradients flow backward through the pipeline. Once the backward pass for a micro-batch completes at the first stage, its gradients must be synchronized with the gradients from other micro-batches in the same global batch. This is typically done using an All-Reduce operation across all pipeline-parallel GPUs, often overlapped with computation to hide communication latency.

MODEL PARALLELISM COMPARISON

Pipeline Parallelism vs. Other Parallelism Strategies

A technical comparison of the primary strategies for distributing large neural network computations across multiple accelerators, focusing on communication patterns, memory efficiency, and ideal use cases.

Feature / CharacteristicPipeline ParallelismTensor ParallelismData Parallelism

Primary Partitioning Unit

Model layers (vertical)

Individual tensor operations (horizontal)

Training data batches

Communication Granularity

Between layers (stage-to-stage)

Within layers (all-to-all for activations/gradients)

Between model replicas (gradient synchronization)

Communication Volume

Moderate (activations, gradients)

Very High (full activations, weights)

High (gradients, optionally optimizer states)

Memory Footprint Per Device

Stores one pipeline stage

Stores a shard of all layers

Stores the entire model

Ideal For

Models with many sequential layers (e.g., transformers)

Models with very large individual layers

Training with large, scalable batch sizes

Idle Time ('Bubbles')

Yes, due to pipeline flush/fill

No, devices work concurrently on a layer

No, devices work concurrently on different data

Implementation Complexity

High (requires scheduling, bubble management)

Very High (requires custom kernel sharding)

Low (well-supported in frameworks)

Common Use With

Very large models (>100B parameters)

Extremely wide layers (e.g., large FFN layers)

Scaling training across many identical devices

PIPELINE PARALLELISM

Frequently Asked Questions

Pipeline parallelism is a core technique for distributing large neural networks across multiple accelerators. These questions address its fundamental mechanics, trade-offs, and practical implementation.

Pipeline parallelism is a model parallelism technique that partitions a neural network's sequential layers (or groups of layers) into distinct stages, each assigned to a different GPU or device. Data flows through this pipeline in micro-batches. While the first micro-batch is processed by Stage 2, Stage 1 can begin processing the second micro-batch, creating an assembly-line effect that increases hardware utilization compared to naive model parallelism. The core mechanism involves splitting the model vertically by layer depth rather than horizontally by tensor operations.

Key operational phases:

  1. Forward Pass (F): A micro-batch moves through the stages, with each stage computing its forward pass and passing the activations to the next stage.
  2. Backward Pass (B): Gradients flow in reverse, with each stage receiving gradients from its downstream neighbor, computing its local gradients, and passing them upstream.
  3. Weight Update (U): Optimizer steps are typically applied locally on each device after its backward pass is complete for a micro-batch.

The pipeline is kept full by scheduling multiple micro-batches in flight simultaneously, a process formalized in schedules like GPipe (synchronous) or 1F1B (One-Forward-One-Backward).

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.