Inferensys

Glossary

Quantization Scale and Zero-Point

Quantization scale and zero-point are the two parameters in linear quantization that map floating-point values to a lower-precision integer range, enabling efficient neural network deployment on resource-constrained hardware.
DevOps managing AI deployment pipeline on laptop, CI/CD stages visible, automation-focused workspace.
TINY LANGUAGE MODELS

What is Quantization Scale and Zero-Point?

Quantization scale and zero-point are the two fundamental parameters that define a linear quantization scheme, enabling the conversion of floating-point neural network values into efficient integer representations for microcontroller deployment.

Quantization scale (or scaling factor) is a floating-point multiplier that maps the range of original floating-point values to a target integer range. It is calculated as (max_float - min_float) / (max_int - min_int). Zero-point is an integer offset that aligns the quantized integer range with the original floating-point range, ensuring that a real value of zero can be represented exactly in the quantized space without error, which is critical for operations like padding and ReLU activations.

Together, these parameters enable the reversible transformation: float_value ≈ scale * (int_value - zero_point). In static quantization, scale and zero-point are determined once using a calibration dataset. In quantization-aware training, the model learns to compensate for the error introduced by this mapping. This linear scheme is the core of INT8 inference, drastically reducing model memory footprint and enabling efficient fixed-point arithmetic on microcontrollers.

LINEAR QUANTIZATION

Key Characteristics of Scale and Zero-Point

In linear quantization, the scale and zero-point are the two fundamental parameters that define the mapping between the high-precision floating-point (FP32) domain and the low-precision integer (INT8) domain, enabling efficient integer-only arithmetic.

01

The Scale Factor (S)

The scale factor is a positive floating-point number that defines the ratio between the quantized integer range and the original floating-point range. It acts as the resolution of the quantization grid.

  • Formula: ( S = \frac{(FP_{max} - FP_{min})}{(Q_{max} - Q_{min})} )
  • Purpose: Converts an integer value back to its approximate floating-point equivalent: ( FP \approx S \times (Q - Z) ).
  • Example: If a tensor's values range from -2.5 to 2.5 and it's being quantized to the INT8 range [-128, 127], the scale is ( S = (2.5 - (-2.5)) / (127 - (-128)) = 5.0 / 255 \approx 0.0196 ). This means each integer step represents a change of ~0.0196 in the original floating-point space.
02

The Zero-Point (Z)

The zero-point is an integer value within the quantized range (e.g., within [-128, 127] for INT8) that corresponds exactly to the real value of zero in the floating-point domain.

  • Purpose: Ensures that a real zero (a common value in activations like ReLU outputs) can be represented exactly, preserving the mathematical properties of zero for operations like padding. It aligns the two numerical domains.
  • Formula: ( Z = Q_{min} - \text{round}(FP_{min} / S) ).
  • Result: The dequantization formula becomes ( FP = S \times (Q - Z) ). When ( Q = Z ), ( FP = 0 ).
03

Asymmetric vs. Symmetric Quantization

The choice of how to determine the floating-point range ([FP_{min}, FP_{max}]) defines the quantization scheme.

  • Asymmetric Quantization: Uses the actual min/max of the tensor data. This minimizes quantization error but introduces a non-zero zero-point (Z), adding a small overhead to arithmetic operations.
  • Symmetric Quantization: Forces ( FP_{min} = -FP_{max} ). This simplifies the math by setting the zero-point (Z) to 0, making operations faster. However, it is less efficient if the data distribution is not symmetric around zero, as it wastes part of the integer range.
  • Trade-off: Asymmetric is more accurate for general activations; symmetric is faster and often used for weights.
04

Per-Tensor vs. Per-Channel Quantization

Scale and zero-point can be applied with different granularities, affecting accuracy and hardware compatibility.

  • Per-Tensor Quantization: A single scale and zero-point is calculated for an entire tensor. This is the simplest and most widely supported method.
  • Per-Channel Quantization: A unique scale and zero-point is calculated for each channel (e.g., each output channel of a convolution kernel). This accounts for varying dynamic ranges across channels, significantly improving accuracy, especially for weight tensors. It is more computationally complex to implement.
05

Calibration: Determining S and Z

Calibration is the process of estimating the optimal scale (S) and zero-point (Z) for a pre-trained model, typically using a small, representative dataset.

  • Process: The calibration data is passed through the model to collect statistics (min/max values, histograms) for each tensor to be quantized.
  • Methods:
    • Min-Max: Uses the absolute observed min/max values. Simple but sensitive to outliers.
    • Entropy / KL Divergence: Selects a range that minimizes the information loss between the original and quantized distributions. This is the standard method in frameworks like TensorRT for activation quantization.
  • Output: The calibration process produces a set of constant S and Z parameters for the model, enabling static quantization.
06

Impact on Integer-Only Inference

The core benefit of defining scale and zero-point is enabling integer-only inference, where all computations use low-bit integer arithmetic, eliminating floating-point operations on the target device.

  • Fused Operations: For a layer like a convolution, the integer computation becomes: ( Q_{out} = Z_{out} + \text{multiply_and_shift}( \sum (Q_{weight} - Z_{weight}) \times (Q_{input} - Z_{input}) , \frac{S_{weight} \times S_{input}}{S_{out}} ) ).
  • The Re-quantization Step: The ratio ( (S_{weight} \times S_{input}) / S_{out} ) is a constant that is typically fused into the previous integer operation using a fixed-point multiply-and-shift or rounding operation.
  • Result: This allows the entire network to run using only integer addition and multiplication, which is drastically faster and more energy-efficient on microcontrollers (MCUs) and digital signal processors (DSPs).
QUANTIZATION METHOD COMPARISON

Scale & Zero-Point vs. Other Quantization Schemes

A technical comparison of linear (affine) quantization using scale and zero-point against alternative quantization schemes, highlighting their mechanisms, hardware compatibility, and suitability for TinyML deployment.

Feature / MetricLinear (Scale & Zero-Point)Symmetric QuantizationLogarithmic QuantizationBinary/Ternary Quantization

Core Mechanism

Uses a scale factor (float) and an integer zero-point to map FP range to integer range: Q = round(R / S) + Z

Uses only a scale factor; zero-point is fixed at 0, assuming a symmetric range around zero

Uses a logarithmic mapping, representing values by the exponent of a fixed base

Constrains weights/activations to {-1, 0, +1} (ternary) or {-1, +1} (binary)

Exact Zero Representation

Hardware Arithmetic

Requires integer addition & multiplication, plus zero-point correction

Pure integer multiplication; simpler than affine

Can use bit-shift operations for power-of-two bases

Primarily uses bitwise XNOR and popcount operations

Calibration Overhead

Moderate (requires determining S & Z via min/max or percentile)

Low (requires determining a single symmetric S)

Low (determine base and dynamic range)

Minimal (determine thresholds for binarization)

Typical Accuracy Retention (Post-Training)

High (minimizes clipping error for asymmetric distributions)

Moderate (clipping error for asymmetric activations like ReLU)

Low to Moderate (poor precision for small values near zero)

Low (drastic precision reduction)

Common Precision Target

INT8, INT4

INT8, INT4

Powers-of-two (e.g., 4-bit)

1-bit (binary), 2-bit (ternary)

Runtime Compute Overhead

Low (fixed extra addition per operation)

Very Low (no zero-point addition)

Very Low (bit-shifts)

Extremely Low (bitwise ops)

Primary Use Case

General-purpose deployment (CNNs, Transformers); production standard

Hardware with pure integer units; simpler software stacks

Specialized hardware (e.g., DSPs); ultra-low bit-width scenarios

Extreme compression for binary neural networks on ultra-low-power MCUs

QUANTIZATION SCALE AND ZERO-POINT

Framework and Hardware Implementation

The practical application of linear quantization parameters within software frameworks and hardware accelerators to enable efficient integer-only inference on constrained devices.

01

The Linear Quantization Formula

The core mathematical operation that defines the mapping between real and quantized values. For a real value ( r ), the quantized integer ( q ) is calculated as:

( q = \text{round}(r / S) + Z )

  • ( S ) (Scale): A positive floating-point number representing the ratio between the quantized integer step size and the real-valued step size. It's calculated as ( S = (\text{max}(r) - \text{min}(r)) / (\text{max}(q) - \text{min}(q)) ).
  • ( Z ) (Zero-Point): An integer within the quantized range (e.g., 0-255 for INT8) chosen so that ( r = 0 ) maps exactly to ( q = Z ). This ensures that a real zero (common in padding and ReLU activations) can be represented without error, preserving crucial mathematical properties like zero-padding equivalence.
02

Calibration for Static Scale Determination

The process of determining the optimal scale (S) and zero-point (Z) for each tensor (weights and activations) using a representative dataset. This is a critical step in Post-Training Quantization (PTQ).

  • Weights: Scale is calculated directly from the min/max of the pre-trained weight values.
  • Activations: Require a calibration dataset (e.g., 100-500 unlabeled samples) to observe the dynamic range of layer outputs. Common algorithms include:
    • Min-Max: Uses the absolute observed min/max.
    • Moving Average Min-Max: Tracks a running average to smooth outliers.
    • Entropy (KL Divergence): Selects a range that minimizes the information loss between the original and quantized distributions, often yielding higher accuracy.

Once calibrated, these parameters are baked into the model and remain static during inference.

03

Integer-Only Arithmetic in Kernels

How quantized models execute efficiently on CPUs and MCUs using integer math. The core operation of a quantized fully-connected or convolutional layer is reformulated to avoid floating-point calculations.

The operation for a layer becomes:

( q_3 = Z_3 + \text{multiply_and_shift}( \sum (q_1 - Z_1)(q_2 - Z_2), M ) )

  • ( q_1, q_2 ): Input activation and weight integers.
  • ( Z_1, Z_2 ): Their respective zero-points.
  • ( M ): A pre-calculated fixed-point multiplier that fuses the scales ( S_1 ) and ( S_2 ) from the inputs and weights with the inverse of the output scale ( S_3 ).
  • The multiply_and_shift is a high-performance integer operation that approximates multiplication by ( M ).

This allows the entire inference graph to run with INT8 or INT16 operations, drastically accelerating computation on integer-only hardware.

05

Hardware Accelerator Mapping (NPU/TPU)

How specialized AI accelerators ingest and utilize quantization parameters for peak performance. These chips have dedicated integer arithmetic units (e.g., INT8, INT4 vector processors).

  • Compilation: Frameworks like TensorFlow Lite for Microcontrollers (TFLM) or vendor-specific toolchains (e.g., NVIDIA TensorRT, Qualcomm AI Engine Direct) compile the quantized graph, baking scale and zero-point values into the instruction stream or lookup tables.
  • Asymmetric vs. Symmetric: Many NPUs prefer symmetric quantization (where zero-point Z is forced to 0) for simpler, faster hardware. This requires the framework to perform a graph transformation, absorbing the zero-point operations into bias terms during compilation.
  • Per-Channel Quantization: For weights in convolutional layers, hardware often supports a separate scale and zero-point per output channel, allowing for finer-grained adjustment and higher accuracy. This is a key optimization supported by TFLite and most modern NPUs.
06

Impact on Memory and Bandwidth

The direct resource savings enabled by quantizing with scale and zero-point. This is the primary motivation for TinyML deployment.

  • Model Size Reduction: Converting FP32 parameters (4 bytes each) to INT8 (1 byte each) yields a theoretical 4x reduction in model footprint. With per-tensor scale/zero-point overhead (typically 8 extra bytes per tensor), the net saving is ~3.5-4x.
  • Memory Bandwidth: Loading 8-bit weights and activations from memory consumes one-fourth the bandwidth of 32-bit equivalents. This is often the dominant factor in inference latency and power consumption on microcontrollers, where memory access is energy-intensive.
  • Cache Efficiency: Smaller models and tensors have a higher chance of fitting into faster, smaller on-chip caches (SRAM), reducing stalls and further accelerating inference.

These savings make deploying multi-million parameter models on devices with <1MB of SRAM feasible.

4x
Model Size Reduction
75%
Bandwidth Saving
QUANTIZATION FUNDAMENTALS

Frequently Asked Questions

Linear quantization is a core technique for deploying neural networks on microcontrollers. These questions address the essential parameters—scale and zero-point—that govern this conversion from floating-point to integer arithmetic.

The scale factor (or quantization scale) is a positive, floating-point number that defines the ratio between a unit in the quantized integer space and a unit in the original floating-point space. It is calculated as the ratio of the range of the floating-point values to the range of the target integer representation.

Mathematically, for a floating-point tensor with a clamped range [min_f, max_f] and a target integer range of [q_min, q_max] (e.g., [0, 255] for uint8), the scale S is:

code
S = (max_f - min_f) / (q_max - q_min)

This single value is used to map all values in the tensor. The conversion from float r to quantized integer q is performed as q = round(r / S) + Z, where Z is the zero-point. The scale is critical because it determines the resolution of the quantization; a larger scale means each integer step represents a larger chunk of the floating-point range, leading to potentially higher quantization error.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.