

How LLM Inference Works
What a model call does on the GPU, token by token, and why that decides your bill and your latency: tokens, prefill and decode, the KV cache, batching, caching and the tricks providers use to go faster.
Watch lesson 01
Free preview01 What happens in one model call
- Lessons
- 20
- Modules
- 4
- Running time
- ~4 hours
- Before you start
- Called an LLM API once
- Free to watch
- 7 lessons
- Last updated
- Nov 4, 2026
Part of
- AI engineer track/Step 1 of 8
[01] Access
[02] Who it's for
- Engineers who build on LLM APIs and want to know why a call costs what it costs and takes as long as it does.
- Developers who see words like KV cache, prefill or prompt caching in pricing pages and docs and want them to mean something.
- No machine learning background is needed. You should be able to read a little Python and a JSON response.
[03] What you'll learn
- 01Follow one model call from your prompt to the last streamed token, and say where the time goes
- 02Count tokens the way the provider does and read a bill or a usage report line by line
- 03Explain why the first token is slow and the rest are fast, using prefill and decode
- 04Size the KV cache for a context window and see why long prompts cost memory, not just money
- 05Know how batching, paged memory, prompt caching and speculative decoding let a provider serve many users at once
- 06Design a feature around cost and latency: prompt layout, caching, model choice and streaming
[04] Syllabus
Module 01
One call
7 lessons/75 min- 0111m
- 0211m
- 0313m
- 0410m
- 0513m
- 0610m
- 078m
Module quiz
5 questions, about 5 minutes
Module 02
Time and memory
4 lessons/50 min- 08
Prefill and decode (locked)
12m - 09
Why output costs more (locked)
14m - 10
The KV cache (locked)
13m - 11
What the KV cache costs (locked)
11m Module quiz
5 questions, about 5 minutes
Module 03
Many calls
7 lessons/82 min- 12
Batching many users (locked)
9m - 13
The limits of a batch (locked)
11m - 14
Service tiers and temperature zero (locked)
10m - 15
Paged memory (locked)
14m - 16
Prompt caching (locked)
14m - 17
Speculative decoding (locked)
12m - 18
Fewer bytes, and fast tiers (locked)
12m Module quiz
5 questions, about 5 minutes
Module 04
Your product
2 lessons/25 min- 19
Where the money goes (locked)
13m - 20
Designing for cost and latency (locked)
12m Module quiz
5 questions, about 5 minutes
[05] How it's made
The curriculum is curated by karnstack and reviewed by senior engineers in the industry before it ships. Narration is an AI voice (ElevenLabs) reading human-written, human-reviewed scripts. Read how courses are made.