Inference engineering paper · 2022

Orca

Yu, Jeong, Kim, Kim and Chun · OSDI 2022

Why early language model servers wasted GPU time and kept users waiting, and how scheduling one step at a time fixed it.

Batching whole requests, x2 holds a place in the batch it no longer needs and x3 waits outside. Scheduling one iteration at a time hands x2’s place to x3 at iteration 3.

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 .

The design choices

Orca’s design answers one question: what has to change so that the batch can change after every iteration? The answer touches the scheduler, the way the model runs a batch, the way memory is handed out and the way the work is spread over many GPUs.

Our biggest sale ever · Black Friday

Flat 50% Off

Pro

Continue reading

Unlock every course, now and later

  • System Design, live
  • AI Engineering, live
  • Data Engineering, live
  • Machine Learning Engineering, live
  • Inference Engineering, coming soon
  • AI Research, coming soon
  • Performance Engineering, coming soon
  • Agent & Harness Engineering, coming soon
  • LLM Fine-tuning, coming soon
  • LLM Pre-training & Post-training, coming soon
  • Reinforcement Learning, coming soon
  • AI Infrastructure & Platform Engineering, coming soon
  • AI Evaluation & Safety, coming soon
  • Forward Deployed Engineering, coming soon
  • Cloud Computing, coming soon
  • DevOps, coming soon

50% off · Annual and Lifetime

BLACKFRIDAY50Applied at checkout

Choose a plan

About the paper

Orca: A Distributed Serving System for Transformer-Based Generative Models by Yu, Jeong, Kim, Kim and Chun, OSDI 2022.

Read the original paper