Skip to content
Launch imminent

Official date to be announced shortlyGPU offers available at launch; figures shown are indicative.

Priority access: sign up

What is the KV cache in LLM inference?

The KV cache stores attention keys and values for every token in context. Learn how to estimate its memory and why long contexts need VRAM.

Glossary3 sections1 min read

What is KV cache?

The KV cache stores the attention keys and values computed for previous tokens so a language model does not recompute them at each new token. Its size grows with context length and batch size.

Why it matters when renting a GPU

Long contexts and many concurrent users can make the KV cache as large as the model weights. Leave VRAM for it when sizing a GPU.

Grouped-query attention, KV cache quantization and paged attention reduce this memory.

Worked example

For an illustrative model with 80 layers, 8 KV heads of dimension 128 and 2-byte values, each token needs 2 × 80 × 8 × 128 × 2 = 327,680 bytes. An 8,192-token context therefore needs about 2.68 GB per sequence.

Frequently asked questions

Does the KV cache depend on batch size?
Yes. Each concurrent sequence has its own cache, so memory grows with batch size times context length.

Be ready on launch day

Create your account now: you can top up your balance and launch a GPU as soon as the market opens.