Quantization

LLMs interview question · Medium difficulty

What is quantization in LLMs, and what does it trade off?medium

Status
✓
Type
conceptual
Topic
quantization
Frequency
common
Tags
quantization, INT8, INT4, inference-optimization
Answer

Quantization reduces the numerical precision of model weights and/or activations — typically from FP32 or BF16/FP16 down to INT8 or INT4 — to lower memory usage and speed up inference, at the cost of some potential quality loss.

Explanation

Benefits: lower memory usage, faster inference, cheaper deployment, and the ability to run larger models on smaller hardware — which is why quantization is especially useful for edge deployment, local models, and cost-sensitive production systems. The trade-off is possible quality loss from lower numerical precision, and some tasks degrade more than others under quantization (precision-sensitive tasks tend to be more affected than general conversational tasks). There are different approaches: post-training quantization (quantize after training is done, simplest but can lose more quality), quantization-aware training (the model is trained or fine-tuned with quantization effects simulated, usually preserves more quality), weight-only quantization (only weights are compressed, activations stay higher precision), and activation quantization (activations are compressed too, for maximum savings).

Follow-upWhy does quantization-aware training usually preserve more quality than post-training quantization?
Follow-upWhy would you choose weight-only quantization over quantizing both weights and activations?
Follow-upWhat kind of task would you expect to degrade the most under aggressive INT4 quantization?