64K context for an 8B model with GQA
A document assistant uses an 8B FP16 model on a 48 GB GPU. Each of the two concurrent requests may use 65,536 tokens, with KV width at one quarter of total hidden width.
Jump to resultsInputs
Results
Runs in your browser- Required memory
- 37.161GB
- Minimum GPU count
- 1GPUs Aggregate memory lower bound
- Decode bandwidth ceiling
- 52.08tok/s Ideal aggregate across the batch
Compare measured decode speed with this bandwidth ceiling. Verify the model fits each rank individually.
| Model weights | 16 GB |
|---|---|
| Active KV cache | 17.18 GB |
| Activation and scratch reserve | 3.982 GB |
| Usable memory per GPU | 43.2 GB |
| Usable memory across GPUs | 43.2 GB |
| KV per cached token | 131.072 kB |
| Ceiling per sequence | 26.04 tok/s |
What to try
Two long requests fit the modeled memory on one card. Try a third concurrent prompt to see how quickly long-context admission consumes workspace headroom.
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
Do output tokens also count toward the 64K context allocation?
Yes. Reserve space for the prompt and the generated tokens expected to remain in the active cache at once.
What happens if I model 64K with no grouped-query attention?
With all other settings fixed, switching KV width from 25% to 100% quadruples the estimated cache bytes.