KV cache sizing with MHA and GQA
NumericalBeginner⏱ 30 minLLM Opskv cachegqamemory
Problem
Model A is 7B with , , 32 attention heads, multi-head attention. Model B is 70B with , , 64 query heads and 8 key/value heads (GQA). Both store the cache in BF16.
- Compute bytes of cache per token for each.
- Compute the cache for one 8192-token conversation in each.
- Compute what model B's cache would have been with full MHA, and state the GQA saving.
Compute the requested quantities and say what they mean. A number without an interpretation is not an answer.
Solution
Opening this before you have a real attempt on paper is the fastest way to feel like you understand something you cannot reproduce.
Related problems
All problems| Solved | Problem | Field | Type | Difficulty | Time |
|---|---|---|---|---|---|
| Implement the cluster sizing formula run | AI Systems | Coding | 30 min | ||
| Product quantisation budget arithmetic | RAG | Numerical | 30 min | ||
| When activations dominate | Fine-Tuning | Numerical | 30 min | ||
| When does attention dominate the MLP? | Deep Learning | Numerical | 30 min | ||
| Will this fine-tune fit? | Fine-Tuning | Numerical | 30 min |