Module 11 · Lesson 1 of 5

A GPU works on a batch

One step, many requests

A GPU writes one token for every request in its batch at each step, so more requests share each step.

Scene 1 of 4 · One request alone

With one request, each step takes 28 ms and writes one token for it.

Waiting requestsWaiting requestsGPUGPU1 in the batch
  • Waiting requests — healthy
  • GPU — healthy — 1 in the batch
Time for one step (the serving lab's numbers)
  • 1 in the batch (highlighted)28 ms
  • 2 in the batch31 ms
  • 3 in the batch34 ms
  • 4 in the batch37 ms
  • 5 in the batch40 ms
  • 6 in the batch43 ms
  • 7 in the batch46 ms
  • 8 in the batch49 ms
  1. One request alone. With one request, each step takes 28 ms and writes one token for it.
  2. 8 at once. With 8, a step takes 49 ms, far less than 8 separate steps of 28 ms.
  3. More work done. Together the 8 get about 163 tokens a second, against 36 for one alone.
  4. Each user slower. Each user's own speed drops, here from 36 to 20 tokens a second, since each step is longer.
  5. Now you try. Set how many requests share the batch. For example: 4 in the batch: 37 ms a step, 108 tokens a second in all, 27 for each user. More requests share each step, so the total rises while each user's own speed drops.

Scene 1 of 4: One request alone. With one request, each step takes 28 ms and writes one token for it.

Key points

  1. Each step writes one token for every request in the batch.
  2. A bigger batch makes each step a little longer.
  3. A bigger batch makes more tokens a second in total.
  4. But each user gets their own tokens more slowly.

Go deeper in the Serving a language model lab →

A is the chip that runs a model's sums (see How a model writes). It does not have to work on one request at a time. A model server gives it a whole group of requests to work on together, in one step. This group is called a batch.

A bigger batch uses the GPU better, since more requests share the same step instead of each waiting for its own. But each step still takes a little longer, because the GPU does a little more work for every extra request in it.

This happens at every step of the batch, each time it writes one more for every request still running.

Example. Illustrative: the lab's default GPU step takes 25 ms plus 3 ms for each request in the batch. A full batch of 8 takes about 49 ms a step, since 25 + 3 × 8 is 49.

In system design: A server batches requests to use the GPU well. Bigger batches raise the work done each step, but each request waits slightly longer for its own step to finish.

Check yourself

A server raises its batch size from 1 to 8. What happens to each single user's tokens per second?