What is the KV cache and how much memory does it take?

EasyConcept10 minRERSMLE

The question

Explain what the KV cache is in a decoder-only transformer and why inference uses it.

Then estimate the KV cache size for one sequence of 32k tokens in a model with 32 layers, 8 key-value heads of dimension 128, stored in 16-bit floats.

What the interviewer is looking for

  • Explains that keys and values of past tokens are reused so each new token costs one step
  • Knows the cache grows linearly with sequence length and batch
  • Does the memory math correctly and shows units
  • Connects cache size to batch size and serving cost

Your answer

Saved in this browser only. Nobody else sees it.

Why this question

Written by BlogLLM in the style of a publicly reported Mistral AI question type: KV cache, attention variants and why they matter for inference.

Reported in: supacv.com

Practice question written by BlogLLM based on publicly reported interview formats. Not an official Mistral AI question.