17 — Scale & Optimize

Quantization#

Optimization✓ Mathematical
◆ The PatternFP32 → INT8 — trading precision for speed

Quantization reduces weight precision from 32-bit floats to 16-bit or 8-bit integers. Post-training quantization (PTQ) is the quick path — just convert. Quantization-aware training (QAT) simulates low precision during training for better accuracy at INT8.

Memory ∝ bits × parameters
INT8 uses 4× less memory than FP32, enabling larger batch sizes and faster inference.
// Interactive — precision vs accuracy vs speed
MethodAccuracy ImpactSpeed Gain
FP16 (half precision)Negligible~2×
PTQ INT80.5–2% drop~3×
QAT INT8<0.5% drop~3×
INT4 (experimental)Variable~5×
Pattern bridge: Quantization trades precision for speed — the same tradeoff as sampling temperature in LLMs (precision vs diversity) or timeframe compression in charts (detail vs overview).
← Previous
Model Compression
Open in the full reader, with the topic sidebar →