Models
A model bigger than one GPU
Three ways to split the work, and what each asks of the link
Every GPU worker in the factory so far held a whole model. That stops working as models grow. A model of 72 billion weights takes 145 GB at two bytes per weight, and the largest memory on an H100 is 80 GB. It has to be spread over several GPUs, and there is more than one way to cut it. Each way decides how often the GPUs have to talk and how much they say, and that decides whether they can sit in different servers or must share one. The same choice comes back in training, with one more option. This lesson cuts one model three ways on two servers and counts what crosses the link each time.
- The model
- 72.7 billion weights · 80 layers
- At 2 bytes per weight
- 145 GB
- One H100
- 80 GB
- The question
- where to cut, and what has to cross the cut
Read the whole lesson as text
1. It does not fit
Start with the arithmetic. This model has 72.7 billion weights. Stored as 16-bit numbers that is 145 GB, and they all have to be in GPU memory, because reading them from the server's own memory across the bus would be far too slow. One H100 has 80 GB. Two have 160 GB, which holds the weights and leaves about 14 GB. That remainder is not spare. It is where the KV cache of every conversation lives, at 327,680 bytes per token for this model, so two GPUs leave room for about 44,000 tokens across everyone being served at once. Storing the weights in 8 bits would halve them, and the lesson Prefill and decode shows that trade. Here the weights stay as they are and the model is split.
- The weights alone are 145 GB, and one GPU holds 80.
2. Cut it between layers
The simplest cut follows the model's own shape. A transformer is a stack of blocks, and each block only needs the output of the one below. So put layers 1 to 40 on GPU 0 and layers 41 to 80 on GPU 1. A token goes up through the first 40 layers on one GPU, and what comes out is handed to the other, which runs the rest. What comes out of a layer is one list of 8,192 numbers per token, 16,384 bytes. For a prompt of 1,248 tokens the whole hand-off is about 20 MB, once. During decode it is 16,384 bytes per token written. That is very little to send, so this cut works between servers, over the ordinary fabric.
- GPU 0 finishes its 40 layers for the whole prompt and sends the result across to GPU 1.
- For each token of the answer, 16,384 bytes cross from one server to the other.
3. Cut it inside every layer
The other cut goes the other way. Each layer is mostly a few very large tables of weights, and a table can be sliced down the middle. Give each GPU half of every table in every layer. Now both work on the same layer at the same moment, neither waits for the other, and a pass takes about half as long. But half a table gives half an answer. Inside every layer the GPUs have to add their partial results together before the layer can finish, once after attention and once after feed-forward. With 80 layers that is 160 exchanges for every pass, which during decode means 160 exchanges for every single token written. Each one is small. What hurts is that the GPUs cannot go on until it has arrived.
- Halfway through the first layer each GPU has half an answer, and they must be added together.
- The same happens after feed-forward, and then again in each of the other 79 layers.
4. So chatter stays in the box
A cut that talks 160 times per token needs the shortest and widest path there is. Inside one server, GPUs are joined by NVLink, direct links from GPU to GPU that skip the host and the network. An H100 has 900 GB per second of it. A 400 gigabit network port carries 50 GB per second, and each trip through it adds a network card and a switch on the way. So the rule that falls out is simple. Cut inside the layers when the GPUs share a box. Cut between layers when they do not. Large deployments do both at once: tensor parallel across the eight GPUs of each server, and pipeline parallel from server to server.
- Between servers every exchange has to go out through the network card. Inside one server it would not.
5. One server made of several Pods
On Kubernetes a model split across two machines runs as two Pods, and the usual tools misread them. A Deployment thinks they are two copies of one service and will happily replace one while the other keeps running. But these Pods are halves of a single server. If one restarts it loses its half of the weights and its half of every KV cache, and the other half is useless until the pair is rebuilt together. Scaling out means adding a whole new pair, never one more half. A LeaderWorkerSet describes exactly that: a group with one leader Pod and its workers, created, restarted and scaled as one unit. Each worker is told the leader's address when it starts, and the pair joins up before it takes traffic.
- The worker Pod on node B starts, reads the leader's address and joins it to form one server.
6. Training adds a third way
Training has the same two cuts and one more that serving has no use for. If a model fits on one GPU, give every GPU a complete copy and a different slice of the batch. Each works out its own slopes for every weight from its own text. Then all the GPUs average their slopes, an exchange called all-reduce, and every copy takes the same step, so they stay identical. The run finishes sooner because each step sees more text. It saves time and no memory at all: every GPU still holds everything. And what is exchanged is no longer one list per token. It is a slope for every weight, on every step, between all the GPUs of the job.
- After each step the GPUs exchange their slopes for every weight and average them.
Summary
A model that does not fit on one GPU has to be split, and the way it is split sets the demands on what joins the GPUs. Cut between layers and one small result crosses per pass, so the halves can sit in different servers. Cut inside the layers and both GPUs work at once, at the cost of two exchanges in every layer, which only a direct link inside one server can carry well. Training adds whole copies that exchange a slope for every weight on every step. Real systems nest all three. On Kubernetes the pieces of one model are one unit that must start, restart and scale together, which is what a LeaderWorkerSet is for.
Next lesson: Prefill and decode