The Cost of Full Precision
Neural networks are typically trained using 32-bit floating-point numbers, which offer enormous numerical range and precision for the delicate process of gradient descent. But that precision is expensive: a model with 100 million parameters needs roughly 400 megabytes just to store its weights, and every multiplication during inference consumes real energy and time. On a smartphone, smartwatch, or microcontroller with limited RAM, a battery to protect, and no cooling fan, this overhead can make full-precision models simply impractical to run. Shrinking that footprint without discarding the model's learned intelligence became one of the central problems in deploying AI at the edge.
Mapping Floats to Integers
Quantization works by taking the continuous range of floating-point weight values in a layer and mapping them onto a small, fixed set of discrete integer levels, most commonly 8-bit integers offering 256 possible values. This mapping uses a scale factor and a zero-point, together defining a simple linear formula that converts between the original float range and the integer grid, and back again during computation. The payoff is substantial: 8-bit weights need only a quarter of the memory of 32-bit floats, and integer arithmetic runs faster and more efficiently on most processors, including the dedicated neural accelerators found in modern phones. The trade-off is a loss of numerical precision, since many nearby float values now collapse onto the same integer level.
Post-Training vs Quantization-Aware Training
There are two main routes to a quantized model. Post-training quantization (PTQ) takes an already-trained, full-precision model and converts its weights and activations to lower precision afterward, using a small calibration dataset to choose good scale factors; it is fast and requires no retraining, but accuracy can suffer, especially at very low bit-widths. Quantization-aware training (QAT) instead simulates the rounding errors of quantization during the training process itself, so the network's weights adjust to compensate for that noise as it learns. QAT typically preserves much more accuracy at 8-bit or even 4-bit precision, at the cost of extra training time and complexity.
Powering AI in Your Pocket
Quantization is a major reason your phone can run face unlock, live photo captioning, voice recognition, and camera scene detection instantly and offline, without sending data to the cloud. It also underpins AI on smart cameras, hearing aids, and tiny embedded microcontrollers running frameworks like TensorFlow Lite. The trade-offs are real, though: pushing bit-widths too low (such as 4-bit or binary) can noticeably degrade accuracy, and certain layers, particularly the first and last layers of a network, tend to be far more sensitive to quantization error than the layers in between. Engineers often mix precisions across a model, keeping sensitive layers at higher precision while aggressively quantizing the rest, to balance efficiency against accuracy loss.
Frequently asked questions
Does quantization always reduce accuracy?
Not always noticeably. For many models, 8-bit post-training quantization causes only a tiny, often imperceptible drop in accuracy, while going to 4-bit or lower typically requires quantization-aware training to keep performance acceptable. The impact depends heavily on the model architecture and which layers are quantized.
Why use integers instead of just smaller floats?
Integer arithmetic is generally faster and more energy-efficient than floating-point arithmetic on most hardware, and many edge chips include dedicated integer accelerators. Integers also compress more predictably and align well with the fixed memory layouts used in embedded systems, which is why INT8 became the industry standard for edge deployment.
What is the zero-point in quantization?
The zero-point is an integer offset used alongside the scale factor to correctly represent zero within the quantized range, which matters because many neural network operations, like ReLU activations and padding, rely on exact zero values. Without a proper zero-point, these operations would be distorted after quantization.
Try it live
Everything above runs in your browser — open Neural Network Quantization: Shrinking Models for Edge AI and change the parameters while it is running. Nothing is installed, nothing is uploaded, the whole model lives in one tab.
▶ Open Neural Network Quantization: Shrinking Models for Edge AI simulation