Model Parallelism for Inference: Tensor, Pipeline and Beyond

Model Parallelism for Inference: Tensor, Pipeline and Beyond

Model parallelism for inference is the practice of splitting a single language model across several GPUs so it can run at all, or run faster, when it is too large for one device. When should you use it? Whenever a model does not fit in one GPU’s memory, or when a single GPU cannot meet your latency target, and the split you choose should follow your hardware: fast links inside a server favour tensor parallelism, slower links between servers favour pipeline parallelism.

The need is straightforward. A model with 70 billion parameters in 16-bit precision needs about 140 gigabytes just for its weights, plus memory for the KV cache, and no single mainstream GPU holds that alongside a working cache. The H100, for example, ships with 80 gigabytes of memory.

Without splitting the model, it simply cannot run. Model parallelism is how large models get served at all.

Key takeaways

  • Model parallelism for inference splits one model across several GPUs, because large models do not fit on a single device.
  • Tensor parallelism splits layers across GPUs and needs very fast interconnects, so it usually stays inside one server.
  • Pipeline parallelism splits the model by layers and tolerates slower links, so it can span servers.
  • Data parallelism replicates the whole model and suits many small requests rather than one large model.
  • Expert parallelism splits mixture-of-experts models by expert, and only activates the experts each token needs.

Why one GPU is not enough

Model size has grown faster than GPU memory. Each generation of flagship models is larger than the last, while a single GPU’s memory has grown more slowly. The gap is closed by using several GPUs together, and model parallelism is the set of techniques for doing that well.

There are two distinct reasons to split a model. The first is capacity: the weights and the KV cache together exceed one GPU’s memory, so the model cannot load at all. The second is latency: even if the model fits, one GPU may not process tokens fast enough, and splitting the work can cut the time per token.

Capacity forces the decision; latency shapes which split you pick.

It is worth distinguishing model parallelism from data parallelism, which is often confused with it. Data parallelism puts a whole copy of the model on every GPU and sends different requests to each one. It raises total throughput for many small requests, but it cannot serve a model that does not fit on one GPU.

Model parallelism splits the model itself, so it is the answer when the model is the problem, not the request volume.

Tensor parallelism: splitting inside a layer

Tensor parallelism splits the arithmetic inside each transformer layer across GPUs. In a typical design, the attention heads are divided among the GPUs, and the feed-forward network’s weight matrices are split by columns on the way in and by rows on the way out. Each GPU computes its share, and the results are combined with an all-reduce operation that sums the partial results and returns the total to every GPU.

The technique comes from Megatron-LM, introduced by Shoeybi and colleagues at NVIDIA in 2019, which showed how to split transformer layers with only two all-reduce operations per layer in the forward pass. That low communication cost is what makes tensor parallelism practical, but it still demands a very fast link: every layer needs those synchronisations, dozens of times per token. In practice that means NVLink inside a single server, with bandwidth around 900 gigabytes per second per GPU on Hopper hardware, and tensor-parallel groups almost never span the slower network between servers.

Tensor parallelism also has a natural limit. The split must divide evenly: the number of attention heads and the hidden size must be divisible by the number of GPUs, and with grouped-query attention the number of key-value heads must divide too. Degrees of two, four or eight are common; beyond eight, the communication overhead and the indivisibility of small layers make further splitting unattractive.

Pipeline parallelism: splitting by layers

Pipeline parallelism takes a simpler approach: it cuts the model into consecutive groups of layers, and puts each group on a different GPU. A request flows through the stages in order, like a car moving down an assembly line. Communication happens only at the boundaries between stages, where activations pass from one GPU to the next, so the bandwidth requirement is far lower than tensor parallelism and pipeline stages can span servers.

The drawback is the pipeline bubble: idle time while stages wait for work. When a single request moves through the pipeline, only one stage is busy at a time and the rest wait. The fix is to run several requests, or several micro-batches, at once, so that while one request is in stage three, another is in stage one.

With enough concurrent requests the bubble shrinks to a small fraction of total time, which is why pipeline parallelism suits busy serving with steady traffic.

For inference, pipeline parallelism is often combined with tensor parallelism: tensor parallelism inside each server, where the fast links are, and pipeline parallelism between servers, where they are not. This hybrid is the standard layout for serving very large models across a cluster, and it is the arrangement most serving engines assume.

Glowing fibre-optic cables connecting server racks in a data centre
Fast interconnects decide which split works: tensor parallelism needs NVLink-speed links, while pipeline parallelism tolerates ordinary networking between servers.

Expert parallelism for mixture-of-experts models

Mixture-of-experts models add a third form of splitting. Instead of one large feed-forward network per layer, these models have many smaller expert networks, and a router sends each token to only one or two of them. Expert parallelism places different experts on different GPUs, so each device holds a slice of the total parameters and only the active experts do work for a given token.

The appeal is efficiency: a model with hundreds of billions of total parameters may activate only a fraction of them per token, so the compute per token stays modest while the model’s capacity stays large. The cost is communication, because tokens must travel to the GPU holding their expert and the results must come back. Load balancing matters too: if the router sends most tokens to a few popular experts, those GPUs become bottlenecks while others sit idle.

Expert parallelism is specific to mixture-of-experts architectures and is usually combined with tensor or pipeline parallelism for the non-expert parts of the model. It is increasingly important as more large models adopt the mixture-of-experts design, but it is not a general-purpose technique for dense models.

Model parallelism approaches compared

The table below compares the main approaches on the axes that decide which to use.

Approach What it splits Interconnect needed Main weakness Best for
Tensor parallelism Matrices inside a layer Very fast, NVLink-class Frequent synchronisation Low latency within one server
Pipeline parallelism Layers into stages Moderate, between servers Pipeline bubble when quiet Very large models across servers
Expert parallelism Experts across GPUs Moderate to fast Load imbalance between experts Mixture-of-experts models
Data parallelism Requests, not the model Low Cannot fit a large model Many requests, small models
Sequence parallelism Activations along the sequence Fast, with tensor parallelism Extra communication Very long contexts

Best for: teams serving models above 30 billion parameters, where tensor parallelism inside the server plus pipeline parallelism between servers is the standard layout.

Choosing the right split

Start from the model and the hardware you actually have. Count the memory the weights and a realistic KV cache need, and divide by the memory per GPU: that gives the minimum number of GPUs. Then look at your interconnect.

If all the GPUs sit in one server with NVLink, tensor parallelism is the natural choice for latency. If they span servers, pipeline parallelism between servers is the way to connect them.

Next, consider your traffic. Tensor parallelism cuts latency for a single request, because several GPUs work on the same token at once. Pipeline parallelism raises total throughput for many requests, but a single request still passes through the stages one at a time.

A latency-sensitive chat service will lean towards tensor parallelism, while a high-volume batch service can lean on pipeline parallelism. Tensor parallelism and pipeline parallelism each have their own detailed trade-offs, and the two articles cover them in depth.

Finally, use the serving engine’s defaults before hand-tuning. Engines such as vLLM and TensorRT-LLM choose a tensor-parallel degree and pipeline layout from the model size and the hardware they detect, and those defaults are usually close to optimal. Change them only after measuring, and change one thing at a time so the effect is visible.

Checklist: deploying model parallelism

Use this checklist before splitting a model across GPUs.

  • Confirm the model does not fit on one GPU, including KV cache headroom, before adding parallelism.
  • Map your interconnect: NVLink inside servers, and the network speed between them.
  • Choose a tensor-parallel degree that divides the attention heads and hidden size evenly.
  • Keep tensor-parallel groups inside one server and use pipeline stages between servers.
  • Run enough concurrent requests to keep pipeline stages busy and the bubble small.
  • Measure time to first token and tokens per second, not just total throughput.
  • Test failure handling: a single GPU failure takes down a tensor-parallel group, so plan for it.
  • Revisit the split when the model or the hardware changes, since the right layout depends on both.

Frequently asked questions

Does model parallelism make inference faster?

It can, but not always. Tensor parallelism cuts latency for a single request, while pipeline parallelism mostly raises total throughput. For small models that fit on one GPU, adding parallelism usually slows things down because of the communication overhead.

How many GPUs do I need for a 70 billion parameter model?

It depends on precision and cache headroom. In 16-bit precision the weights alone need about 140 gigabytes, so at least two 80-gigabyte GPUs, and in practice more, once the KV cache and working memory are counted. Quantisation to 8-bit roughly halves the weight footprint.

Can tensor parallelism span two servers?

Technically yes, but in practice no. The all-reduce operations happen at every layer for every token, and ordinary networking between servers is far too slow for that. Tensor-parallel groups stay inside one server, and pipeline parallelism connects servers.

What is the pipeline bubble?

It is the idle time in a pipeline-parallel setup when some stages have no work because a request is still in an earlier stage. Running several requests or micro-batches at once fills the gaps and shrinks the bubble.

Is model parallelism needed for small models?

No. Models that fit comfortably on one GPU are better served with data parallelism, which replicates the model and handles more requests. Model parallelism only pays when the model itself is the constraint.

Distributed AI system architecture covers how these patterns combine at cluster scale.

Model parallelism is not a performance trick to apply everywhere. It is the answer to a specific problem: a model that is too large for one GPU. Choose the split from your hardware, keep tensor parallelism on fast links, pipeline parallelism between servers, and measure latency and throughput on your own traffic before tuning further.

Latest articles

Scroll to Top