Inference engineering paper · 2022
Orca
Why early language model servers wasted GPU time and kept users waiting, and how scheduling one step at a time fixed it.
You’ll learn to
- Explain why batching whole requests wastes GPU work and makes new requests wait.
- Describe how iteration-level scheduling and selective batching let requests join and leave a batch after every step.
- Work out how much GPU memory a request’s keys and values need, and why Orca reserves it up front.
- Name what later servers such as vLLM and Sarathi-Serve kept from Orca, and what they replaced.
The idea in short
A language model writes its reply one token at a time, and every token costs one full run of the model. Servers of the day batched whole requests: a batch started together and finished together, so short replies sat finished while long ones ran, and new requests waited outside.
Orca schedules one run of the model at a time instead. After every run, finished requests leave and waiting ones join. To make that work it batches the parts of the model that don’t care which request a token belongs to, and runs attention, the step where each token looks back at earlier tokens of its own request, separately for each request.
The problem
When you send a prompt to a chat model, it doesn’t write the reply in one go. It produces one , a word or piece of a word, adds it to the text, and runs the model again for the next one. This is . Every new token costs one full run of the model through all of its layers. The Orca paper calls one such run an iteration. A 100-token reply is 100 iterations, and nobody knows in advance how many a reply will need: the model stops when it picks a special , or when it reaches a limit the caller set.
Running one request at a time wastes most of a . The usual fix is : run several requests through the model together, so each of the model’s , the numbers it learned in training, is read from memory once and used for all of them. In 2021 a large model was served by two layers of software. A serving system such as NVIDIA Triton took requests and grouped them into batches. An execution engine such as NVIDIA FasterTransformer ran each batch on the GPUs.
The two layers spoke only at batch boundaries. The serving system handed over a batch, the engine ran it until every request in it was done, and then all the results came back at once. That suits an image classifier, where every input takes the same single pass. For text generation it fails twice. A request that finishes early can’t leave: its reply is ready, but the GPU keeps computing for it until the longest request in the batch is done. And a request that arrives just after a batch starts waits outside until the whole batch ends, even once an early finisher has left a place in the batch idle.
The authors, from Seoul National University and FriendliAI, asked what changes if the serving system schedules one iteration at a time instead of one request at a time. Their system, Orca, reported 36.9 times the of FasterTransformer on GPT-3 175B (175 billion weights) at the same .