Memory Requirements for Serving Models
Replica parallelism copies the whole model to handle more requests at once, at the cost of more chips; it does not make an individual request faster.
Why a Single Chip Is Not Enough
What do you think happens?
If you copy a model onto a second chip and send half of the incoming requests to each copy, does any single request finish faster?
Reveal answer
No, each request takes the same time, but the service handles more requests at once
Replica parallelism copies the whole model to handle more requests at once, at the cost of more chips. It does not make an individual request faster.
Serving an AI model is a resource problem. Accelerators such as GPUs are built to do many calculations at once, and that property is what makes them useful for serving models. It also gives engineers a set of choices when a service has to grow. Parallelism strategies are the family of methods that spread work across several chips or machines so the service can keep up with demand, or so it can run a model too large for one device.
Serving problems usually arrive in one of two forms. Sometimes there are too many requests, and each request is quick enough on its own, so the goal is to answer more of them at the same time. Other times the model itself is too large to fit on one device, so the goal is to split the model. Some strategies also respond to a third pressure, which is very long input sequences. The rest of this article follows these pressures one at a time, and it tracks where the memory and the work end up in each case.
Copying the Whole Model With Replicas
Replica parallelism is the simplest strategy to put into practice. You make several identical copies of the model you want to serve. Each copy handles its own requests, so the service as a whole can process more requests at the same time than a single copy could.
Trace one request through a replicated service. A request arrives, it is routed to one replica, and that replica runs the full model from start to finish. A second request can be routed to a different replica and run at the same moment. Neither request runs through a shorter path than it would on a single copy. What changes is how many requests are in progress at once.
The trade-off is hardware cost. Every extra replica needs its own chips to run on. More replicas let more simultaneous requests be handled, but the number of chips you pay for grows with them. Replica parallelism therefore scales throughput by buying capacity rather than by making any one request cheaper or faster.
The Placement Question as a Bin-Packing Problem
Once you create replicas, or serve several models at once, you face a placement question. You have a fixed number of chips, and you must decide how many replicas of each model to create and which chip hosts each replica. Chips also differ in how much memory they have, so a model that fits on one chip may not fit on another.
This placement question is called the bin-packing problem. Each chip is a container with a fixed capacity. Each model replica is an item that must be placed. The goal is to arrange the items so they fit without overflowing. The problem gets harder as you add more models, more replicas, and more chips, because the number of possible arrangements grows quickly.
Start with the arithmetic. Assume every model is stored at 8-bit precision, which means each parameter takes one byte. A 13B model therefore needs roughly 13 GB just for its weights. This estimate ignores extra memory used at runtime, so a real placement needs more headroom than the raw numbers suggest.
Can a 70B model fit on a 48 GB chip?
A 70B model is stored at 8-bit precision, so each parameter takes one byte. Decide whether one copy of its weights fits on a chip with 48 GB of memory, ignoring runtime overhead first.
- 1Convert parameters to bytes
70B means 70 billion parameters. At one byte per parameter, the weights need about 70 GB.
- 2Compare with chip capacity
The chip has 48 GB. The weights alone need about 70 GB, which is more than 48 GB.
- 3Check the other chip sizes
The 70 GB of weights does not fit on the 24 GB, 40 GB, or 48 GB chips. Only the 80 GB chip has enough room, and even there about 10 GB remains for runtime needs.
The 70B model cannot be placed on a 48 GB chip. It can only be placed on the 80 GB chip, and it leaves little headroom for runtime memory.
The diagram shows one arrangement that works, and it leaves free space on every chip. The free space is not wasted by accident. It is headroom for runtime memory, which the simple arithmetic ignores. Other arrangements are possible, and choosing among them is the bin-packing problem. A 70B model cannot go on a 24 GB, 40 GB, or 48 GB chip at all, so some chips are simply ruled out for some models before any packing choice is made.
Splitting One Model Across Machines
Sometimes a model is so large that no single machine can hold it. Model parallelism addresses this by splitting the same model across multiple machines. Each machine holds part of the model, so the model as a whole can run even though no single machine could host it alone.
Model parallelism makes placement harder. You are no longer deciding only which chip gets which whole model. You also decide how to cut the model into pieces and how those pieces fit across chips. There are several ways to make the cuts. The two most important for inference are tensor parallelism and pipeline parallelism.
Long Inputs: Context Versus Sequence Parallelism
Context parallelism and sequence parallelism are less common than the strategies above, but both were developed to make the processing of long input sequences more efficient. The two names sound similar, so it helps to remember what each one splits. Context parallelism splits the input. Sequence parallelism splits the operations.
In context parallelism, each device receives a different portion of the input sequence and processes that portion separately. For example, the first half of a long input might be handled on one machine while the second half is handled on another.
In sequence parallelism, the input is not cut into portions. Instead, the operators needed for the whole input are divided. Every part of the input may still need several kinds of computation. If the input requires both attention and feedforward computation, one machine might carry out the attention step while another carries out the feedforward step, with the whole input passing between them.
Mistakes When Choosing a Strategy
Common mistake Expecting replicas to make one request faster
What it looks likeA team adds a second replica and expects each user's response to arrive twice as quickly.
Why it failsReplica parallelism lets more requests run at once. Each request still runs the full model on one copy, so its time does not shrink.
Do this insteadUse replicas when the problem is too many requests, and use tensor parallelism when the goal is lower latency for each request.
Common mistake Assuming pipeline parallelism lowers latency
What it looks likeA model is split into stages across devices, and the team expects single requests to finish sooner.
Why it failsPipeline parallelism divides the model into stages, and each request must pass through every stage in order, which increases latency per request.
Do this insteadChoose pipeline parallelism when the model is too large for one device, and accept that each request will take longer.
Common mistake Ignoring runtime memory when placing models
What it looks likeA 13B model at 8-bit precision is placed on a 13 GB device because its weights need about 13 GB.
Why it failsThe estimate ignores extra memory used at runtime, so there is no headroom for the work the model does while serving.
Do this insteadLeave room above the raw weight size when packing models onto chips.
Common mistake Mixing up context and sequence parallelism
What it looks likeA team splits a long document by sentences across machines and calls this sequence parallelism.
Why it failsSplitting the input among devices is context parallelism. Sequence parallelism instead divides the operators needed for the whole input.
Do this insteadAsk whether the input itself is being divided, which points to context parallelism, or whether the operations are being divided, which points to sequence parallelism.
Choosing a Strategy for a Serving Goal
Each strategy answers a different pressure on a serving system. Match the strategy to the problem you are trying to solve, then check the trade-off you accept in return.
| Strategy | What it splits | Main benefit | Main trade-off |
|---|---|---|---|
| Replica parallelism | Whole copies of the model | More requests handled at once | More chips to pay for; single requests are not faster |
| Tensor parallelism | Tensors inside each layer | Can reduce latency per request | Devices must combine partial results for each layer |
| Pipeline parallelism | Consecutive stages of layers | Lets a model too large for one device run | Increases latency per request |
| Context parallelism | The input sequence | Handles long inputs across devices | Each device processes only part of the input |
| Sequence parallelism | The operators for the whole input | Handles long inputs by dividing the work | Whole input passes between devices for different steps |
Parallelism strategies by what they split and what they cost
A service must answer many more requests per minute, but each request is already fast enough. Which strategy should it choose, and what cost should the team expect to pay?
Hints
- Ask which pressure is present: too many requests, a model too large for one device, or very long inputs.
- Think about what the replica strategy buys and what it costs in hardware.
Trace Review of the Three Pressures
- Too many requests: copy the whole model with replicas, and pay for more chips.
- Model too large for one device: split it with tensor parallelism inside layers, or pipeline parallelism across stages.
- Very long input: split the input with context parallelism, or split the operators with sequence parallelism.
- Placing models of different sizes on chips with different memory is a bin-packing problem that grows harder as models, replicas, and chips increase.
Key Takeaways
- Replica parallelism copies the whole model to handle more requests at once, at the cost of more chips, and it does not make an individual request faster.
- Placing models of different sizes onto chips with different memory is a bin-packing problem, and it gets harder as models, replicas, and chips are added.
- Tensor parallelism splits the tensors inside each layer and can reduce latency, while pipeline parallelism splits the model into sequential stages and increases latency per request.
- Context parallelism divides the input sequence among devices, while sequence parallelism divides the operators needed for the whole input; both target long inputs.
- Choose a strategy by first identifying the pressure, whether too many requests, a model too large for one device, or very long inputs, and then weighing the trade-off that strategy brings.