Lesson 1 · Unit 03
Batching
One pass for many requests, and what it costs each of them
What you practise
- Why one pass over eight requests beats eight passes, padding waste, the latency each request pays to wait for a batch
Try a question from this lesson
Pick one
One decode pass for a single request takes 20 ms. Stack 8 requests into one batch and the pass takes 30 ms. How many tokens per second does the server make each way?
Hint
One pass makes one token for every request in it. How many passes fit in a second?
Correct answer
50 alone, about 267 batched
Why
Alone: 1 token per 20 ms is 50 per second. Batched: 8 tokens per 30 ms is about 267. The pass got 1.5 times slower and did 8 times the work. That gap is why every serious server batches.
The ideas
Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.
Concept
Why a batch is nearly free
A batch is one more dimension on the same matrix multiply. The weights are read once and applied to every request in the batch at the same time.
With a single request most of the hardware sits idle. A batch fills it, until memory or compute runs out.
one request [tokens, width]
a batch [batch, tokens, width]Concept
Padding
A batch is a rectangle: every sequence in it must have the same length. Shorter ones are padded with filler tokens up to the longest.
Padded positions are computed like any other and then ignored. They are pure waste, so batches work best when their members are similar in length.
[The cat sat on the mat]
[Hi PAD PAD PAD PAD PAD]10 more exercises in the app
- 2× multiple choice
- 4× type the answer
- 1× true or false
- 1× fill the blanks
- 1× match the pairs
- 1× order the lines
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.