Serving a Model to Many People
Reading the Weights Once for Everybody
Last timeTraffic Does Not Arrive Evenly
The expensive part of producing a word is reading the model, and the reading serves everyone in the group at once. Group size is the single largest lever in serving, and it is a trade.
Producing the next word requires reading every number in the model out of memory and into the processor. On a large model that is tens of gigabytes of reading per word, and it is the slowest thing in the whole operation. The arithmetic performed on those numbers, which is what the hardware is nominally for, finishes long before the next batch of numbers has arrived.
That single fact is the foundation of everything in this lesson. If you have one request in flight, you read all those numbers to produce one word. If you have thirty-two, you read exactly the same numbers once and produce thirty-two words.
| step | the group | words a second | machine time per word | the shared read, split that many ways | what is left over, which nobody can share | what happened |
|---|---|---|---|---|---|---|
| 1 | one at a time | 42 | 1,000 / 42 = 23.8 ms | 23.8 ms, the whole of it | nothing measurable | With one request present there is nobody to share the read with, so take the 23.8 ms as the read itself. |
| 2 | eight together | 260 | 1,000 / 260 = 3.85 ms | 23.8 / 8 = 2.98 ms | 3.85 - 2.98 = 0.87 ms | The same reading of the model, six times cheaper per word, because eight words came out of it instead of one. |
| 3 | thirty-two together | 720 | 1,000 / 720 = 1.39 ms | 23.8 / 32 = 0.74 ms | 1.39 - 0.74 = 0.65 ms | The shared part has now fallen below the unshareable part, which is the moment the returns start flattening. |
| 4 | one hundred and twenty-eight together | 1,150 | 1,000 / 1,150 = 0.87 ms | 23.8 / 128 = 0.19 ms | 0.87 - 0.19 = 0.68 ms | Four times the group for a fifth of a millisecond saved, because what is being waited for is no longer the read. |
Where the gains stop
The shared read is enormous and the unshareable part is small, which is why the early gains are dramatic. Going from one request to eight can increase total output nearly eightfold. Going from sixty-four to one hundred and twenty-eight might gain twenty per cent, because by then the shared read is no longer what you are waiting for.
What caps the group
The group cannot simply be made huge, and the limit is memory rather than compute. Each request in flight holds its own record of the conversation so far, which is consulted at every step and which grows by a fixed amount with each new word. The model itself occupies most of the available memory, and whatever is left is what the records share.
So the cap is a division: the free memory divided by the memory one request's record needs. That denominator grows as conversations lengthen, which means the same service can hold a group of sixty-four short requests or eight long ones, and the group size that worked yesterday can fail today purely because the traffic got wordier.
This has a practical consequence that catches people out. A configured maximum group size is not a promise, it is a ceiling that the memory may refuse to honour at any moment. A service that runs happily at a group of sixty-four for weeks can begin rejecting arrivals the day a few users start pasting long documents in, because those few requests consume the memory that forty others were sharing.
The lesson stops here
4 more paragraphs to go
You have read the opening. The rest of the argument, the problems that check whether it landed, and the lines worth keeping at the end all come with a plan.
The first lesson of every course in the library reads the whole way through, free, so you can see exactly what the rest of them are.
See the planThe contentsThis is the reading half
Starting the course gives you your own copy of it. Every idea on every page has problems standing under it, marked with a reason rather than a tick, and any sentence you do not believe can be opened and argued with. None of that can happen on a page nobody owns.
The contents