AI and Machine Learning · Inference and deployment
Model Quantisation
Also known as model quantization, quantization, post-training quantization, PTQ, quantization-aware training, QAT
Model quantisation converts a model's weights and activations from floating point, usually FP32, to lower-precision types such as INT8. This reduces memory traffic and enables faster integer or low-precision arithmetic, at the risk of some accuracy loss.
Explanation
Linear quantisation maps a real value to an integer through a scale and an optional zero point: real ≈ scale × (q − zero_point). ONNX Runtime uses this form for 8-bit quantisation; TensorRT uses a symmetric scheme in which zero maps to zero and only a scale is needed. Scales can be per tensor or per channel, and NVIDIA recommends per-tensor scales for activations and per-channel scales for weights.
Post-training quantisation (PTQ) sets scales after training: dynamic PTQ computes activation ranges at run time, while static PTQ calibrates them offline on a representative dataset. Quantisation-aware training (QAT) simulates quantisation during training or fine-tuning so the model learns to tolerate it, and is used when PTQ misses the accuracy target. Tooling is changing: TensorRT has deprecated its implicit, calibration-table INT8 mode in favour of explicit quantise/dequantise (Q/DQ) models, and PyTorch is moving quantisation development to its torchao library.
Speed-ups depend on hardware support for low-precision arithmetic; ONNX Runtime warns that older devices can even run slower. Accuracy must be re-measured on the target, and sensitive layers can stay in higher precision.
How it works
Calibration runs representative inputs through the float model and records activation ranges using methods such as MinMax, entropy or percentile. The tool then inserts QuantizeLinear/DequantizeLinear pairs, or quantised operators, with the chosen scales. The inference runtime fuses these into low-precision kernels. Engineers compare float and quantised outputs tensor by tensor to locate where accuracy is lost.
Automotive applications
- Fitting perception networks into ECU memory budgets
- Raising frame rate on NPUs and GPUs
- Reducing power for always-on in-cabin models
- Shrinking model payloads in OTA updates
Example
A segmentation network exported to ONNX is statically quantised to INT8 using a few hundred calibration frames covering day, night and rain. The team compares mIoU with the FP32 model on the same validation set and keeps two precision-sensitive layers in FP16 to stay within the agreed tolerance.
An illustrative example: any figures in it are worked numbers, not measurements.
References
- Quantize ONNX models (opens in a new tab)
- Working with Quantized Types (TensorRT 10.x) (opens in a new tab)
“Use per-tensor quantization for activations and per-channel quantization for weights.”
- Quantization (PyTorch 2.15 documentation) (opens in a new tab)
Definitions are original summaries. Standards text is not reproduced; follow the links for the official publications.