Module 08 · AI · Serve the GPT you built · with code: Python · about 15 min to read
Continue where you left off ×
The Engine, Whole
Inference Engineering · Open board
The Inference Engineering board follows one message through a serving system, from the front door to the card and back. This lesson puts the front door on the engine you built and measures the trip. Closes the serving series that began at Build Your Own Inference Engine .
Before you start. Five stages built the kitchen. Serve 01: The KV Cache saved each character’s keys and values, Batching: A Slot That Frees Early handed a seat on to the next reply the moment one freed, Paged Attention: The Cache in Blocks cut the memory into blocks, The Prefix Cache: Computed Once computed a shared opening once, and Speculative Decoding: The Bigram Drafts, the GPT Checks let a cheap guesser draft ahead. Later in this track, The Two Clocks (TTFT, TPOT, and why goodput is the number) names the two waits a user feels. This lesson measures both on your own machine.
The idea in 30 seconds
Streaming means the server writes each character as its own chunk the moment the engine makes it.
One engine thread owns the 16 slots, and each request gets a handler thread that waits on its own queue.
TTFT is the wait for the first character and TPOT is the gap between the rest.
A p99 is the slow request in a hundred, and a median alone hides that user.
Past 16 clients on 16 slots, TTFT p50 jumped from about 30 ms to about 830 ms, because it became a queue.
Goodput was 0% at the busiest load, where plain throughput was highest.
Read the story
Lesson 76 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 plans Already a member? Sign in
Or start free : a free account opens lessons 2 and 3 of every track.
In this lesson 20 June 2023: the same model, half the cards Streaming: the reply arrives one chunk at a time TTFT and TPOT: the two clocks on a stopwatch The sweep: 1, 4, 16 and 64 clients Goodput: the number that caught the lie One process, one lock: why the numbers are a shape What vLLM has that this engine does not What does the customer’s stopwatch read? Why does the last customer wait about 1.5 seconds? What does each column of the log say? All of it in code Terms it explains: streaming, chunk, engine, handler, TTFT, TPOT, percentile, Goodput, engine thread, handler thread.
Review AI
Mark as read Saved in this browser, and to your account when you sign in.