AI and Machine Learning · Numerical format
INT8
8-bit signed integer
Also known as 8-bit integer, int8 quantisation, S8, UINT8
INT8 is an 8-bit signed integer type with values from −128 to 127. In machine learning it is the most common target for quantised inference, where each tensor is stored as INT8 values plus a floating-point scale factor.
Explanation
An INT8 tensor has only 256 levels, so it approximates the range of the FP32 values it replaces. TensorRT quantises with x_q = round_to_nearest_even(clip(x / s, −128, 127)) and dequantises with x = x_q × s, where s is a scale stored in FP32, FP16 or BF16. ONNX Runtime also supports unsigned 8-bit (UINT8) with a zero point; its default CPU configuration uses signed 8-bit activations and weights in QDQ format.
Compared with FP32, INT8 stores weights in a quarter of the space, reducing memory bandwidth, and lets hardware use integer dot-product units. Jacob et al. (2017) showed that quantisation co-designed with training allows inference to run entirely in integer arithmetic with an improved trade-off between accuracy and on-device latency.
Two error sources compete: rounding error, which shrinks with a finer scale, and clipping error, where outliers outside the range saturate. Choosing the scale trades one against the other, so calibration data must reflect real operating conditions. Per-channel weight scales help when channel ranges differ widely.
How it works
For each tensor, a scale is chosen from calibration statistics or learned during quantisation-aware training. Weights are quantised once offline; activations are quantised at run time with fixed scales. Integer kernels multiply INT8 values, accumulate in a wider integer type to avoid overflow, and rescale the result. QuantizeLinear/DequantizeLinear (Q/DQ) nodes in an ONNX graph mark where conversions happen.
Automotive applications
- Quantised CNN backbones for camera perception
- Driver-monitoring networks on in-cabin NPUs
- Wake-word and keyword detection
- Reducing model size for OTA delivery
Example
A 3D detector's convolution weights are quantised to INT8 with one scale per output channel, while activations use one scale per tensor. On the target GPU the INT8 engine is benchmarked against the FP16 engine for both latency and mAP before the team decides which to deploy.
An illustrative example: any figures in it are worked numbers, not measurements.
References
- Working with Quantized Types (TensorRT 10.x) (opens in a new tab)
- Quantize ONNX models (opens in a new tab)
- Quantization and Training of Neural Networks for Efficient Integer-Arithmetic-Only Inference (Jacob et al., 2017) (opens in a new tab)
Definitions are original summaries. Standards text is not reproduced; follow the links for the official publications.