Notes

Static Quantization

Static quantization is a way to make a trained neural network lighter and faster before it reaches a device. Instead of carrying out most calculations with 32-bit floating-point numbers, the model is prepared to use compact integer values such as INT8—a much better fit for small processors and AI accelerators.

How it works
During conversion, static quantization replaces both the model’s weights and its intermediate activations with integer representations. A converter first runs a small, representative set of sample inputs through the original model. This calibration step observes the numerical ranges produced by each layer, then chooses a scale and zero point that map real values into integers, usually from -128 to 127.

  • Weights are converted once and stored in INT8, greatly reducing model size.
  • Activations use the fixed calibration ranges determined before deployment.
  • Inference can then use integer kernels on a phone CPU, NPU, or embedded accelerator rather than slower floating-point operations.

Why “static” matters at the edge
The word “static” means the activation ranges are decided ahead of time, not computed from each incoming input. This differs from dynamic quantization, which quantizes activations while the model runs. Static quantization usually delivers better speed and lower memory use because the device avoids that extra runtime work. It is particularly valuable for a wake-word model running continuously on a battery-powered Cortex-M device, or an offline smart camera whose object detector must stay within a thermal limit.

The trade-off
Calibration data must resemble real use. If a camera model is calibrated only on bright indoor images, then deployed outdoors at night, activation values can exceed the recorded ranges and accuracy can fall. Developers therefore test the quantized model carefully, use representative calibration samples, and may choose per-channel weight quantization to preserve accuracy. Tools such as TensorFlow Lite and ONNX Runtime provide static quantization workflows for this deployment step.

Static quantization is post-training quantization in which activation ranges are measured on a representative calibration dataset, then fixed quantization parameters convert both weights and activations to low-precision integers, typically INT8. Unlike dynamic quantization, it avoids calculating activation scaling during inference. This enables faster, lower-memory execution on edge accelerators and microcontrollers, provided calibration preserves acceptable model accuracy.

Static quantization is like deciding in advance to pack a suitcase using smaller, standardized containers. Before an AI model is placed on a phone, camera, or sensor, its numbers are converted into a simpler, more compact form using settings chosen ahead of time.

That preparation makes the model take less storage, use less battery, and often respond faster on the device. For example, a security camera can recognize a person without constantly sending video to the cloud. The trade-off is that the pre-chosen settings may be slightly less accurate for unusual inputs, but they work efficiently and predictably on limited hardware.