How do you calculate LLM KV cache memory?
Multiply two for keys and values by layers, KV heads, head dimension, cached tokens, concurrent sequences, and bytes per cache element. Divide bytes by 1,073,741,824 for GiB.
Instrument 10 / inference cache
Calculate KV-cache memory per token, per sequence, and across concurrent requests—then compare grouped-query attention with a full multi-head cache.
Size one cache
Choose a sourced model preset or enter the exact configuration. Nothing is submitted or stored; every calculation runs in this browser.
Sourced architecture presets
These scenarios use 16-bit KV cache, one full-context sequence, and architecture fields from the publishers' model configurations. Open one, then change context and concurrency.
Cache boundaries
Full context is a ceiling.
Real requests may hold fewer cached tokens at a given moment.
Concurrency multiplies.
Each independent full sequence needs its own cache unless prefixes are shared.
Allocation still matters.
Paged, sliding-window, chunked, and offloaded caches change residency and waste.
Transparent method
Bytes per token2 × layers × KV heads × head dimension × bytes per element
Bytes per sequencebytes per token × cached context tokens
Total cachebytes per sequence × concurrent sequences
GQA comparison replaces KV heads with total attention heads to show the cache a full multi-head-attention architecture would use at the same layer count, head dimension, context, concurrency, and precision.
The arithmetic describes a dense full cache. It does not add model weights, activations, CUDA context, allocator fragmentation, metadata, block rounding, or runtime workspace. Use the LLM GPU Memory Calculator for the combined capacity plan.
Source the inputs
Architecture names vary. Confirm hidden layers, attention heads, KV heads, head dimension, cache format, and any hybrid or sliding-window behavior in the exact model and runtime you plan to serve.
Review the Transformers KV-cache guide → Inspect the Qwen2.5 7B config → Inspect the Qwen2.5 32B config → Inspect the Qwen2.5 72B config → Inspect the Mistral 7B v0.3 config →Multiply two for keys and values by layers, KV heads, head dimension, cached tokens, concurrent sequences, and bytes per cache element. Divide bytes by 1,073,741,824 for GiB.
Grouped-query attention shares key and value heads across multiple query heads. Fewer KV heads means fewer stored elements per token than full multi-head attention.
A dense full cache grows linearly with cached tokens and concurrent sequences. Double either input and the calculated memory doubles.
No. This result isolates the cache. Add weights and deployment-specific runtime allocations before deciding whether the full workload fits.
Infrastructure without the benchmark theatre
ResearchAudio turns model releases, hardware claims, and serving constraints into practical decisions for engineers and builders.