Inference EngineeringInteractive lab
Quantisation memory budget
Work out whether that model fits in your GPU
Parameter count, precision, KV cache and context length, turned into the number of gigabytes you actually need - and the precision you would have to drop to.
What this teaches
- Precision formats
- KV cache growth
- VRAM budgeting
The model and the card
80 layers · 64 heads · 8 KV headsHead dimension is 8192 / 64 = 128. This model uses grouped-query attention: 64 attention heads share 8 KV heads, so the cache is 8x smaller than the head count alone would suggest. Assuming one KV head per attention head is the commonest way to conclude a model does not fit when it does.
What serving needs
GiB, not GBLlama-3.1 70B at Q4_K_M with a 8,192 token context needs 41.9 GiB, which fits on H100 80GB.
Fits on H100 80GB with 38.1 GiB to spare. The highest precision that fits here is fp8.
At Q4_K_M on H100 80GB, the longest context that still fits is 133,008 tokens at 1 concurrent sequence. That is solved by inverting the KV term rather than searched for: everything else is fixed and the cache is linear in context, so it is one division.
Every precision, same model
read the answer off the row| Precision | Bytes/param | Weights GiB | Total GiB | Fits 80 GiB? |
|---|---|---|---|---|
| fp32 full precision | 4 | 263.0 | 281.5 | no |
| fp16 / bf16 the serving default | 2 | 131.5 | 142.1 | no |
| fp8 Hopper and newer | 1 | 65.8 | 72.4 | yes |
| int8 weight-only quantisation | 1 | 65.8 | 72.4 | yes |
| Q5_K_M 5.5 bits with block scales | 0.6875 | 45.2 | 50.6 | yes |
| Q4_K_M 4.5 bits with block scales | 0.5625 | 37.0 | 41.9 | yes |
| int4 (naive) 4 bits, scales uncounted | 0.5 | 32.9 | 37.6 | yes |
Q4_K_M is 4.5 bytes per 8, not 4. A block-quantised format stores a scale, and usually a zero-point, for every block of weights it packs, so the real cost is above the nominal bit width. The naive int4 row is there for contrast: it is what a calculator that multiplies by 0.5 tells you, and it understates the weights by 11%, which is exactly the margin a borderline fit turns on.
What context costs
at Q4_K_M, batch 1| Context | KV cache GiB | Total GiB | Fits 80 GiB? |
|---|---|---|---|
| 1k | 0.31 | 39.7 | yes |
| 2k | 0.63 | 40.0 | yes |
| 4k | 1.25 | 40.7 | yes |
| 8k | 2.50 | 41.9 | yes |
| 16k | 5.00 | 44.4 | yes |
| 32k | 10.00 | 49.4 | yes |
| 64k | 20.00 | 59.4 | yes |
| 128k | 40.00 | 79.4 | yes |
| 256k | 80.00 | 119.4 | no |
The KV column doubles when the context doubles - it is linear, and that is the whole shape of this table. Do not carry that intuition across to compute: attention cost grows with the SQUARE of the sequence length while the cache it reads grows linearly. Different quantities, and only the first one is on this page.
What is real here, and what is standing in
Real: the weights term, the KV cache term and the training terms are exact arithmetic on the architecture numbers shown, and you can redo any of them by hand. The layer, head and KV-head counts come from the models' published configuration files. The highest-precision-that-fits and longest-context-that-fits answers are solved, not approximated.
Standing in: activations and workspace are an allowance scaled off the weights and the batch, not a measurement - the real figure swings by gigabytes between one serving stack and another, and it is the reason this page reports headroom instead of a hard yes. The block-quantised rows use representative bits-per-parameter; GGUF, AWQ and GPTQ variants differ from each other. And a real deployment adds a question this page cannot answer: vLLM preallocates its KV pool from a fixed fraction of the card rather than growing it on demand, so "does it fit" there is partly a configuration setting.
Everything on this page runs in your browser. Nothing you type is sent anywhere, there is no account, and it keeps working offline.