Understand what happens during inference
Know where the time and memory go when a model answers.
Learn
- Tokens, and the two phases: reading the prompt and writing the answer
- The key-value cache and why memory often limits you
- Latency, time to first token and throughput
- GPU memory, memory speed and compute
- Estimating the memory a model needs
Tools
- Python
- Hugging Face Transformers
- GPU monitoring tools
Build
- Measure time to first token and tokens per second for a small model at different prompt lengths
- A note that estimates the memory a model needs for a given context length
CheckpointYour memory estimate lands close to what the GPU actually shows.