Training and parallelism

What is pipeline parallelism? A plain guide

Pipeline parallelism splits a model by depth: each GPU, or stage, holds a consecutive block of layers and passes activations to the next stage. To keep every stage busy, the batch is cut into micro-batches that flow through the stages like an assembly line. It needs little bandwidth, but stages sit idle while the pipeline fills and drains, a cost called the bubble.

Pipeline parallelism defined

A transformer is a stack of similar layers. This method cuts that stack into contiguous groups called stages and places each stage on its own GPU. With 4 stages and an 80-layer model, GPU 0 runs layers 1 to 20, GPU 1 runs 21 to 40, and so on. Each GPU stores only its own layers, so weight and optimizer memory per GPU fall roughly by the stage count.

The only traffic between GPUs is the activations at each stage boundary on the way forward and their gradients on the way back. That is far less than tensor parallelism, which communicates inside every layer. The cost is idle time, not bandwidth.

Google’s GPipe paper in 2018 introduced batch-splitting pipelining and reported almost linear speedup when a model is partitioned across accelerators. Megatron-LM later combined it with tensor and data parallelism to train a 1-trillion-parameter model on 3072 GPUs.

References: GPipe: Efficient Training of Giant Neural Networks using Pipeline Parallelism (arXiv) · Efficient Large-Scale Language Model Training on GPU Clusters Using Megatron-LM (arXiv)

How it works: micro-batches and the bubble

If you push one whole batch through 4 stages, only one GPU works at a time and the other three wait. The fix is to split the batch into micro-batches. Stage 0 processes micro-batch 1 and hands it on, then starts micro-batch 2 while stage 1 works on micro-batch 1. After a few steps every stage is busy on a different micro-batch.

There is still waste at the start, while the pipeline fills, and at the end, while it drains. That idle time is the pipeline bubble. In the Megatron-LM analysis, for p stages and m micro-batches per batch, the bubble adds (p − 1)/m of the ideal compute time. Worked example: 4 stages and 8 micro-batches give 3/8, or 37.5% extra time. Raise micro-batches to 32 and it drops to about 9.4%.

Gradients accumulate across micro-batches, and the optimizer steps once per full batch, so the math matches ordinary training with the same global batch.

How it works: micro-batches and the bubble
Stages (p)Micro-batches (m)Bubble overhead (p−1)/mShare of paid time idle
2812.5%~11%
4837.5%~27%
432~9.4%~8.6%
832~21.9%~18%
864~10.9%~9.9%

References: Efficient Large-Scale Language Model Training on GPU Clusters Using Megatron-LM (arXiv) · DeepSpeed pipeline parallelism tutorial

Schedules: GPipe, 1F1B, interleaved and zero bubble

The schedule decides the order in which stages run forward and backward passes. GPipe runs all forwards, then all backwards, so each stage keeps activations for every micro-batch in flight. One-forward-one-backward (1F1B) alternates them once the pipeline is full, which caps stored activations at roughly the number of stages, per the Megatron-LM paper.

The interleaved schedule gives each GPU several smaller, non-adjacent chunks of layers. The Megatron team reported that it improves throughput by more than 10% with a memory footprint comparable to existing approaches, at the cost of more communication. Zero-bubble schedules split the backward pass and use weight-gradient work to fill the idle slots.

Schedules: GPipe, 1F1B, interleaved and zero bubble
ScheduleActivation memoryBubbleWhere to find it
GPipeAll m micro-batches stored(p−1)/mPyTorch ScheduleGPipe
1F1BAbout p micro-batches stored(p−1)/mPyTorch Schedule1F1B, Megatron default
Interleaved 1F1BAbout p, more messagesSmaller, by chunk countScheduleInterleaved1F1B, Megatron virtual stages
Zero bubbleVariesNear zero in theoryScheduleInterleavedZeroBubble, ScheduleZBVZeroBubble

References: Efficient Large-Scale Language Model Training on GPU Clusters Using Megatron-LM (arXiv) · PyTorch torch.distributed.pipelining documentation

Framework support

PyTorch ships torch.distributed.pipelining, migrated from the PiPPy project and still marked alpha. It splits a model into stages and runs schedules such as ScheduleGPipe, Schedule1F1B, ScheduleInterleaved1F1B, ScheduleLoopedBFS and two zero-bubble variants, cutting each input into n_microbatches automatically.

DeepSpeed wraps a model expressed as a list of layers in PipelineModule with num_stages, and the total GPU count must be divisible by the stage count. You call engine.train_batch(), which pulls gradient_accumulation_steps micro-batches. The partition_method option balances stages by parameters (the default), by layer count with "uniform", or by matching layer types.

Megatron Core uses --pipeline-model-parallel-size and adds virtual stages with --num-layers-per-virtual-pipeline-stage. For inference, vLLM takes --pipeline-parallel-size; its docs note that it splits along layers and supports uneven splits.

References: PyTorch torch.distributed.pipelining documentation · DeepSpeed pipeline parallelism tutorial · Megatron Core parallelism strategies guide · vLLM parallelism and scaling documentation

Costs and trade-offs on rented GPUs

Pipeline parallelism is the friendly choice when links are slow. vLLM’s documentation recommends it on GPUs without NVLink, naming the L40S, and for multi-node serving it suggests tensor parallelism inside each node and pipeline stages across nodes. That keeps per-layer traffic on fast local links and sends only activations over the network. InfiniBand vs Ethernet covers the network side.

The bubble is paid time. Illustrative example with assumed numbers: 8 GPUs at an assumed $2 per GPU-hour cost $16 an hour. With 4 stages and 8 micro-batches, about 27% of that time is idle, roughly $4.36 an hour. At 32 micro-batches the idle share falls to about 8.6%, near $1.37 an hour. More micro-batches need a larger global batch or smaller micro-batches, so check that training still converges.

Balance matters too. The slowest stage sets the pace, and the first and last stages often carry embeddings and the output head. If one stage takes 20% longer, every GPU waits for it.

References: vLLM parallelism and scaling documentation · Efficient Large-Scale Language Model Training on GPU Clusters Using Megatron-LM (arXiv)

Common misconceptions

It lowers latency. For a single request it does not: tokens still pass through every layer in sequence, plus hops between GPUs. It raises how large a model you can serve and, with enough concurrent work, total throughput.

Stages are free to split anywhere. Uneven stages create a slow link in the chain. Profile per-stage time and move layers, or use a parameter- or type-based partition method.

Pipeline parallelism replaces data parallelism. Usually it is combined with it: several pipeline replicas each process a share of the batch, and DeepSpeed adds data parallelism automatically when you have more GPUs than stages.

References: DeepSpeed pipeline parallelism tutorial

Related terms

Data parallelism replicates the model and splits the batch. The tensor approach splits each layer. Micro-batching and gradient accumulation are the mechanics that feed the pipeline. Activation checkpointing trades recomputation for memory and pairs well with stages that hold many micro-batches. For a decision guide, see single GPU vs multi-GPU.

Checklist and next step

Use stages when the model does not fit in one node, or when GPUs lack NVLink. Keep micro-batches at least four times the stage count. Balance stage times with a profiler. Prefer 1F1B or interleaved schedules to limit activation memory. Checkpoint often, since a fault on any stage stops the run.

NeuraMesh rents GPU nodes by the hour with a confirmed quotation before payment: pick a GPU, plan, count, hours and region on rent GPUs, or browse L40S rental for PCIe nodes where stages make sense. The compute advisor can help size the layout.

NeuraMesh prices for these GPUs

NeuraMesh prices per GPU-hour in USD, excluding taxes, as of 2026-11-27. Live prices are on the rental pages.
GPUMemoryData centerValue
RTX 409024 GB$0.46$0.40
L40S48 GB$1.26$0.54
A10080 GB$1.56$0.98
H10080 GB$2.88$2.00

Every order is confirmed in a quotation before you pay. See all GPU prices.

Questions readers ask

What is pipeline parallelism in deep learning?

It places consecutive blocks of layers on different GPUs and streams micro-batches through them like an assembly line. Each GPU stores only its layers, and only activations cross between GPUs.

What is the pipeline bubble?

The idle time while the pipeline fills at the start of a batch and drains at the end. With p stages and m micro-batches it adds about (p − 1)/m of the ideal compute time, so more micro-batches shrink it.

Is it better than tensor parallelism?

Neither is better in general. Stages need less bandwidth but add the bubble; the tensor approach has no bubble but communicates inside every layer. Large runs use the tensor split within a node and stages across nodes.

How many micro-batches should I use?

Enough to make the bubble small, often four or more times the stage count, while keeping each micro-batch large enough to use the GPU well. Measure step time at two settings.

Does vLLM support pipeline parallel inference?

Yes, with --pipeline-parallel-size. Its docs suggest it when GPUs lack NVLink, when the GPU count does not divide the model evenly, and across nodes alongside tensor parallelism.

Sources and editorial notes

Primary documentation reviewed November 24, 2026. Provider descriptions reflect published documentation. Recommendations are our analysis; worked figures are illustrative unless explicitly stated otherwise. No independent provider benchmark or uptime ranking is claimed.

Read the editorial policy.

Need this GPU? Rent it from NeuraMesh: choose a GPU and plan, get a confirmed quotation, and pay only when you approve. See pricing.