Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 08 · AI · Serve the GPT you built · with code: Python · about 13 min to read

Watch: Attention in production: KV cache, MQA, GQA and MLA
▶ VideoPlay it as a journeyTutor comes with a plan

Batching: A Slot That Frees Early

Inference at Scale
Inference at Scale · Open board

The Inference at Scale board shows many replies sharing one card. This lesson builds the part of the engine that decides who sits in which seat, and when a seat is handed on. Stage two of the serving series, mapped in Build Your Own Inference Engine.

Before you start. Build Your Own Inference Engine is the map of the six stages, and Serve 01: The KV Cache gave each reply a cache so a new character costs one row. Later in this track, The Two Clocks (TTFT, TPOT, and why goodput is the number) names the two waits a user feels, and Chunked Prefill (one long prompt must not freeze the room) is the no-code twin of the scheduling ideas here. The small GPT that writes the replies is from Sampling and What Scale Buys. If a queue is new to you, The order slip rail (queues & the utilization cliff) covers it, but nothing here depends on it.

Lesson 72 of 83 in AI

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • July 2022: a batch that could not change
  • Eight seats, and why a full bus is cheap
  • Continuous batching: the seat is handed on at the stop
  • What the numbers say, and what they do not
  • A bus of four, by hand
  • Counting the real bus
  • What the file does at each stop
  • All of it in code
  • Break it

Terms it explains: pass, batch, slot, static batching, padding, 39 percent, continuous batching, stop, row.

Related paper

Review AI