KV pressure on a 13B full-attention model
A legacy 13B model uses full multi-head attention, rather than GQA. The model is Q4 while the cache still uses two bytes per element for two 16K sequences.
Jump to resultsInputs
Results
Runs in your browser- Required memory
- 41.572GB
- Minimum GPU count
- 2GPUs Aggregate memory lower bound
- Decode bandwidth ceiling
- 108.072tok/s Ideal aggregate across the batch
Compare measured decode speed with this bandwidth ceiling. Verify the model fits each rank individually.
| Model weights | 7.8 GB |
|---|---|
| Active KV cache | 26.844 GB |
| Activation and scratch reserve | 6.929 GB |
| Usable memory per GPU | 21.6 GB |
| Usable memory across GPUs | 43.2 GB |
| KV per cached token | 819.2 kB |
| Ceiling per sequence | 54.036 tok/s |
What to try
The cache footprint is over three times the weight footprint. Compare shorter maximum context or supported KV quantization before changing weight precision again.
How the estimate works
KV bytes = 2 × layers × hidden width × KV-head ratio × bytes × tokens × sequences
The model assumes dense decoder-only attention. FP16 uses two bytes per parameter, FP8 and INT8 use one, and Q4_K_M uses a rough 0.60 bytes to include mixed precision and quantization metadata. Use the actual model file size to check this assumption.
Keys and values grow with the live context and batch. GQA reduces the cached width by the ratio of KV heads to query heads. Workspace is an adjustable percentage of weights plus KV, with a separate allowance for unavailable GPU memory.
The GPU count is a memory lower bound. The decode ceiling assumes perfect sharding and one sweep of weights and active KV per batch step at full bandwidth. Kernel overhead, compute, prefill, cache sharing, allocator fragmentation, and interconnect can lower measured output.
Frequently asked questions
Can a 13B Q4 model use more memory for cache than weights?
Yes. This workload keeps 32,768 total tokens in full-width FP16 KV across two sequences, so the cache outweighs the compressed parameters.
Will switching a full-attention model’s GQA ratio make its cache smaller?
Only if the model architecture actually uses fewer KV heads. Changing a planning input does not alter the model or checkpoint.