A neural network weight is stored as a 16- or 32-bit floating-point number, but it can be written as an 8- or even 4-bit one: the model takes several times less memory, inference runs faster, and quality changes only slightly. Quantised models are therefore the usual way to run an LLM on a single graphics card.
How much memory precision saves
| Precision | Bytes per weight | A 7-billion-parameter model |
|---|---|---|
| FP32 | 4 | ≈ 28 GB |
| FP16, BF16 | 2 | ≈ 14 GB |
| INT8, FP8 | 1 | ≈ 7 GB |
| INT4, FP4 | 0.5 | ≈ 3.5 GB |
That covers the weights only: activations and the KV cache take memory separately, and they can be quantised too. On the other hand, at low weight precision more numbers fit per cycle, so on formats the hardware supports, such as FP8, speed rises as well.
Formats and methods
INT8 is integers: each value is obtained from a float by multiplication by a scale, and the scale is calibrated on a small sample of data. FP8 is 8-bit floating-point formats with two layouts: E4M3 (4 bits of exponent and 3 of mantissa) and E5M2 (5 and 2), that is, a choice between precision and range of values. FP4 and 4-bit integers are an extreme case: quality depends heavily on the compression method.
| Method | How it works |
|---|---|
| RTN | simple rounding to a low-precision grid; the default option in many tools |
| GPTQ | post-training quantisation based on second-order information: compresses a 175-billion-parameter model to 3–4 bits in roughly four GPU-hours without noticeable loss of quality |
| AWQ | finds about 1% of salient weights from the activation distribution and protects them by scaling; no backpropagation needed |
| QAT | quantisation is built into the training or fine-tuning itself, so the loss is smaller |
Quality loss
Quantisation does not preserve quality in full, so the quantised version is compared with the original on one’s own tasks. Sensitive tensors and layers can be kept at higher precision: the tools even point out where the divergence after compression is greatest.
Sources
the term is written from these pages- GPTQ: Accurate Post-Training Quantization (Frantar и др., 2022)arxiv.org/abs/2210.17323(opens in a new tab)
- AWQ: Activation-aware Weight Quantization (Lin и др., 2023)arxiv.org/abs/2306.00978(opens in a new tab)
- ONNX Runtime — Quantization overviewonnxruntime.ai/docs/performance/model-optimizations/quantization.html(opens in a new tab)
Verified 9 Nov