Module 3 · Running models in production · Lesson 7
Context windows, KV cache and caching
What happens to your prompt at inference time, why long context costs memory and money, how the KV cache and prompt caching work, and why a million-token window is not a million tokens of attention.
By the end of this lesson you can
- Distinguish prefill from decode and relate each to time-to-first-token and output speed
- Compute the KV-cache size of a model from its config, and explain how grouped-query attention shrinks it
- Explain prompt caching as reuse of a prefix's KV cache, and compute the savings for a realistic workload
- Structure a prompt so the cache hits, and diagnose the common silent invalidators
- Summarise the evidence that model quality degrades with long or cluttered contexts