Splitting a model across machines
When a model is too big for one computer, there are two ways to share it out. Each has a cost.
Some models are too large for any single computer, even after quantisation. The only way to run them is to split them across several machines. There are two ways to do the split.
Way one: everyone works on every layer
A model is a stack of layers. In the first method, each layer is cut into pieces and every machine holds one piece of every layer. Engineers call this tensor parallelism.
For each token, all the machines work at the same moment. Then they exchange results before the next layer can start. This happens after every layer, more than a hundred times for a single token in a large model.
- Good: the answer starts quickly, because the work is shared at every step.
- Cost: the machines talk constantly. Every machine needs a very fast link to every other machine.
Way two: pass it down the line
In the second method, each machine holds a run of whole layers. The first machine does its layers and hands the result to the second, and so on. Engineers call this pipeline parallelism.
- Good: each machine talks only to its neighbour, so the links can be simpler and you can chain more machines.
- Cost: for one request, only one machine is working at a time. The rest wait. The answer starts more slowly.
A pipeline becomes efficient when many requests are in it at once, like a factory line with a job at every station.
The link is the limit
In both methods the machines must move data between them for every token. Ordinary office networking is far too slow for the first method. Paul’s cluster joins its five machines with the fastest desktop cables available, each machine wired directly to every other, using a technique that lets one machine write straight into another’s memory.
More machines is not the same as more speed. Past a point, they spend more time talking than working.
If one machine fails
In either method, the whole model stops. Every piece is needed for every token. A split model is as reliable as its least reliable part.
See it
The Chakra simulator lets you switch between the two methods and watch what happens to the wait before the first token and to the writing speed.
Close the page in your mind, then answer
Do not scroll up. Pulling the answer out of your own head is the step that makes it stay.