Quantization
Summary
Quantization — compression of high-precision model weights (e.g., 16 bits) to low precision (8 or 4 bits) to reduce memory requirements at the cost of slight quality loss.
Why is it needed
A full model with 70 billion parameters takes up tens of gigabytes of video memory. It simply won't fit on a regular PC. Quantization compresses each number storing a weight, and the model 'slims down' by 2–4 times.
How it works
Imagine that a weight is a number with 16 decimal places. Quantization rounds it to a number with 4 decimal places. Precision drops slightly, but the meaning remains, and it takes up much less space.
| Precision | Model Size (example for 70B) | Quality |
|---|---|---|
| FP16 (16 bits) | ~140 GB | Maximum |
| INT8 (8 bits) | ~70 GB | Almost indistinguishable |
| INT4 (4 bits) | ~35 GB | Minor losses |
| NF4 (4 bits, QLoRA) | ~35 GB | Optimal for fine-tuning |
Where it is applied
- Local launch: thanks to quantization, models with 7–8B parameters run on regular gaming PCs.
- QLoRA: quantizing the base model before fine-tuning allows it to be trained even in free Google Colab.