The key-value cache avoids recomputing attention for earlier tokens. Its size grows linearly with context length and depends on the model's layer count and number of KV heads. On large contexts it can consume several gigabytes beyond the model weights.
Glossary
What is KV cache?
Memory that stores the attention keys and values for every token in the context.