KV-Cache Memory Budget

medium
Unit 15 · Inference I0/1 to milestone

During generation, a Transformer caches the keys and values for every previous token. Serving engineers must budget GPU memory for it.

Pro problem

Unlock this and every premium problem across all tracks — plus hidden-test grading, advanced AI engineering modules and new content every week.

Start 7-day free trial
How LLMs Work· 11 of 19
solution.py · Python 3.13
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
KV-Cache Memory Budget · TechGradify