Inferensys

Glossary

Quantization Scale and Zero-Point

Quantization scale and zero-point are the two parameters that define the linear mapping between floating-point and integer values in neural network quantization, enabling efficient integer-only inference on NPUs and edge devices.
Engineer deploying small language model to edge device, IoT sensor visible on desk, technical hardware setup in bright workspace.
MIXED-PRECISION COMPUTATION

What is Quantization Scale and Zero-Point?

The fundamental parameters that define the linear mapping between floating-point and integer number systems during neural network quantization.

Quantization scale and zero-point are the two parameters in affine quantization that define a linear transformation for converting between floating-point and integer values. The scale (s) is a positive floating-point number that determines the step size, or the amount of real value each integer step represents. The zero-point (z) is an integer that corresponds exactly to the real value zero in the floating-point domain, ensuring that zero can be represented without error, which is critical for operations like padding and ReLU activations.

Together, they enable the mapping formula: real_value = scale * (integer_value - zero-point). The scale is calculated from the observed range (min, max) of the tensor being quantized. The zero-point is chosen to align the integer and real number lines, making the transformation asymmetric. This is distinct from symmetric quantization, where the zero-point is forced to 0. Proper calibration of these parameters on a representative dataset minimizes quantization error, enabling efficient INT8 or INT4 inference on NPUs and other accelerators with integer-only arithmetic units.

AFFINE QUANTIZATION PARAMETERS

Key Characteristics of Scale and Zero-Point

The scale and zero-point are the fundamental parameters in affine quantization that define a linear, reversible mapping between floating-point and integer domains, enabling efficient integer-only inference.

AFFINE QUANTIZATION MODES

Symmetric vs. Asymmetric Quantization

A comparison of the two primary methods for defining the linear mapping between floating-point and integer number systems in neural network quantization.

FeatureSymmetric QuantizationAsymmetric Quantization

Core Principle

Quantization range is symmetric around zero.

Quantization range is offset to match the data distribution.

Zero-Point (Z)

Typically fixed at 0.

A non-zero integer representing the quantized value for real zero.

Mathematical Mapping

Q = round(R / S)

Q = round(R / S) + Z

Range Utilization

Potentially inefficient if data is not symmetric.

Efficient; can map the full integer range to the exact min/max of the data.

Integer Arithmetic Complexity

Simpler; zero-point of 0 eliminates many addition operations.

More complex; requires additional zero-point addition/subtraction in operations.

Hardware Support

Universally supported; simpler to implement in fixed-function units.

Widely supported, but may require more logic or specialized instructions.

Typical Use Case

Weights (often symmetric around zero). Activations after ReLU.

General activations with skewed distributions (e.g., after non-zero biases).

Accuracy Impact

May introduce clipping error if data range is not symmetric.

Generally higher accuracy for asymmetric data, minimizing clipping error.

MIXED-PRECISION COMPUTATION

Framework and Hardware Implementation

Quantization scale and zero-point are the core parameters of affine quantization, defining the linear mapping between floating-point and integer domains. Their implementation is critical for efficient execution on modern NPUs and AI accelerators.

01

Affine Transformation Formula

The mathematical relationship is defined by the affine transformation: real_value = scale * (quantized_value - zero_point). The scale is a positive floating-point number that determines the resolution of the mapping. The zero-point is an integer within the quantized range (e.g., 0-255 for INT8) that corresponds exactly to the real value of zero, allowing for efficient representation of asymmetric data distributions.

02

Symmetric vs. Asymmetric Quantization

This distinction is defined by the zero-point:

  • Symmetric Quantization: Zero-point is forced to 0. The quantization range is symmetric around zero (e.g., [-127, 127] for INT8). This simplifies arithmetic but is inefficient if the tensor's value distribution is not symmetric.
  • Asymmetric Quantization: Zero-point is calculated from the observed min/max values. This allows the quantized range to precisely match the tensor's distribution, minimizing clipping error. It is the standard method for activations, which often have skewed, non-zero-centered distributions (e.g., after a ReLU activation).
03

Calibration for Parameter Determination

Scale and zero-point are not guessed; they are calibrated using a representative dataset. Common algorithms include:

  • Min-Max: scale = (float_max - float_min) / (quant_max - quant_min); zero_point = quant_min - round(float_min / scale). Simple but sensitive to outliers.
  • Entropy / KL Divergence: Selects parameters to minimize the information loss between the original and quantized distributions, often yielding higher accuracy.
  • Percentile: Uses a percentile (e.g., 99.99%) of the observed range to mitigate outlier effects. Calibration is a one-time, offline process for static quantization.
04

Hardware Acceleration with Integer Units

The primary purpose of these parameters is to enable integer-only inference. NPUs contain dedicated integer arithmetic logic units (ALUs) that are faster and more power-efficient than floating-point units. The scale and zero-point allow the core computation, such as a matrix multiplication Y = X * W, to be performed entirely in the integer domain using adjusted formulas. The final integer result is then dequantized back to floating-point only if necessary for downstream layers or output.

05

Granularity: Per-Tensor vs. Per-Channel

Quantization parameters can be shared at different granularities, trading accuracy for complexity:

  • Per-Tensor: A single scale and zero-point for an entire tensor. Simple but can lead to high error if the tensor's channels have widely varying ranges.
  • Per-Channel: A unique scale and zero-point for each output channel of a weight tensor (common for convolutions and linear layers). This dramatically improves accuracy by adapting to each filter's distribution but requires more parameter storage and slightly more complex hardware support.
06

Framework Support and APIs

Major ML frameworks provide explicit APIs for handling these parameters:

  • PyTorch: torch.quantize_per_tensor(), torch.quantize_per_channel(). The QuantizedTensor object stores int_repr, scale, and zero_point.
  • TensorFlow / TFLite: The TFLiteConverter calculates parameters during conversion. The flatbuffer model format stores them for each relevant tensor.
  • ONNX: Uses QuantizeLinear and DequantizeLinear operators in the graph, which explicitly carry scale and zero-point as inputs. These abstractions allow developers to define quantization schemes that are later executed by optimized backends like TensorRT, OpenVINO, or vendor-specific NPU SDKs.
QUANTIZATION PARAMETERS

Frequently Asked Questions

Quantization scale and zero-point are the fundamental parameters that enable efficient integer computation by defining a linear mapping between floating-point and integer number systems. This FAQ addresses common questions about their role, calculation, and impact on model performance.

Quantization scale and zero-point are the two parameters in affine quantization that define a linear transformation between floating-point (FP32) and integer (INT8) value ranges. The scale (a floating-point number) determines the size of each integer step in the original floating-point space, while the zero-point (an integer) represents the integer value that corresponds exactly to the real number zero in the floating-point range. This mapping is expressed as real_value = scale * (quantized_value - zero_point). Together, they allow a continuous range of high-precision values to be represented by a discrete set of low-bit integers with minimal information loss.

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.