Skip to content
inference.academy

glossary/memory/kv-cache

KV cache

also key-value cache

The keys and values every layer computed for every token so far, kept in GPU memory so the next token can attend to them without recomputing. It grows with every token of every request in flight, which makes it the memory that scales with users while the weights stay fixed. It is what caps batch size, what paging manages, what a prefix cache shares, and what disaggregation ships between machines.


320 KiB

Per token for Llama 3 70B in BF16: 80 layers, 8 KV heads, 128 dimensions, keys and values, 2 bytes each.


See it happen


Related