liveBook · Manning

Zero-point

As explained in Quantization and Fast Inference

A zero-point is the integer level corresponding to real zero in an affine quantization mapping.

A zero-point Z is the integer code that represents real zero in affine quantization. Together with scale S, it positions a tensor’s real-valued range on an integer grid: r = S(q − Z). Exact representation of zero preserves ReLU sparsity and supports correct zero-padding. section 2.2 section 2.6

For real bounds r_min and r_max and integer bounds q_min and q_max, first extend the real range to include zero. Calculate S = (r_max − r_min)/(q_max − q_min), then Z = round(q_min − r_min/S). Quantize a value with q = clip(round(r/S + Z), q_min, q_max); reconstruct it with r = S(q − Z). Rounding introduces granular error, while clipping introduces overload error. section 2.2 section 2.6

Unsigned 8-bit ReLU activations

For values from 0 to 6 and integer codes 0 to 255, S = 6/255 ≈ 0.023529 and Z = 0. The value 0.25 maps to 11 and reconstructs to approximately 0.258824; zero maps exactly to 0. section 2.2

A nonzero zero-point adds correction terms to integer dot products. Symmetric weights set the weight zero-point to zero, removing the input-sum correction; weight-dependent corrections can be precomputed. Asymmetric activations can instead use the grid more efficiently for one-sided distributions, at the cost of correction overhead. Check the target hardware and runtime when choosing the scheme. section 2.2 section 2.6

Table 2.3 Affine dot product expansion terms
Term
Formula
Description
Computational Characteristic
1. Core Product
∑(qwqx)
Standard integer dot product
Expensive. Main O(N) MAC operation.
2. Weight Sum
−Zx∑qw
Weights scaled by input zero-point
Pre-computable. ∑qw is constant for trained model.
3. Input Sum
−Zw∑qx
Inputs scaled by weight zero-point
Runtime Cost. ∑qx depends on input.
4. Offset Constant
+N⋅Zw⋅Zx
Constant offset
Pre-computable. Can fold into bias.

The dot-product expansion identifies which zero-point corrections can be precomputed and which depend on runtime inputs. section 2.2

Calibration determines the range used to calculate S and Z. Weight ranges may be known, but activation ranges vary with inputs; percentile clipping or entropy minimization can select more robust boundaries, and distribution drift may require recalibration. section 2.6

How Quantization and Fast Inference covers it

How deep it goes
Derives the affine mapping and calibration parameters, implements a quantizer, and expands dot-product correction costs.
Examples
Quantizes ReLU activations from 0 to 6 with unsigned 8-bit codes and reconstructs their values.
What it assumes
Builds on fixed-point representation and derives affine quantization parameters from first principles.
What you can do after
Evaluate a quantization configuration’s accuracy risks and calculate its scale and zero-point.
How it connects
Connects affine quantization to fixed-point arithmetic, ReLU sparsity, zero-padding, calibration, and symmetric versus asymmetric quantization.

Also explained in

Compare how 2 books explain zero-point →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Quantization and Fast Inference. The section links point to the parts of the book it draws on.