ToMotion AI logo
Menu
Back to gallery

Public AI explainer video

Uniform Quantisation: Range and Granularity

Lower-bit models are smaller and faster-but compress a phone image into fewer colour levels, and detail disappears. Quantisation forces tensor values...

Prompt

Source idea used to generate this video.

Uniform quantisation maps floating-point values to a limited set of integer codes. A common equation is: q=round⁡(x/s)+z Here, xis the original value, sis the scale, and zis the zero-point. We can approximately reconstruct the value using: x ̂=s(q-z) The difference between xand x ̂is the quantisation error. Lower bit widths provide fewer representable levels, so the error normally becomes larger. Symmetric quantisation fixes the zero-point at zero and uses a range centred around zero. It simplifies computation and works well for weight distributions that are approximately symmetric. Asymmetric quantisation uses a non-zero zero-point, allowing the integer range to shift. This normally fits skewed activation distributions, such as non-negative outputs after ReLU, more effectively. Quantisation also differs in granularity. Per-tensor quantisation uses one scale and zero-point for the entire tensor. It is simple and hardware efficient, but a few large values can reduce precision for all the smaller values. Per-channel quantisation gives each channel its own quantisation parameters. It usually improves accuracy for CNN weights. Per-group quantisation divides channels into smaller groups. It fits local ranges more accurately and is commonly used for low-bit Transformer and large language model weights, although it requires more metadata.

Narration

Narration used to create this video.

Video narration

Lower-bit models are smaller and faster-but compress a phone image into fewer colour levels, and detail disappears. Quantisation forces tensor values through fewer levels. It maps x to q: q equals round x over s, plus z. Scale sets level spacing; zero-point shifts integer zero. Reconstruct with x-hat equals s times q minus z. The gap is quantisation error. Fewer bits mean fewer levels, so that gap usually grows. The key: error depends on placement, not bit width alone. Symmetric quantisation centres the range at zero, fitting roughly symmetric weights. Asymmetric quantisation uses a non-zero zero-point, shifting the range toward skewed values, such as ReLU activations. Granularity matters. One scale and zero-point per tensor is efficient, but outliers hurt smaller values. Per-channel helps CNN weights; per-group fits local ranges for low-bit Transformer weights, metadata costs. The best scheme matches range and granularity to the values.