What Is Integer Quantization? INT8 and INT4 Guide

Integer quantization is a model optimization technique that compresses deep learning neural networks by converting high-precision floating-point weights and activations into lower-bit integer representations, such as 8-bit (INT8) or 4-bit (INT4). This article covers how integer quantization functions, the underlying binary mechanics of weight compression, the mathematical mapping required to preserve precision, and the trade-offs between computational performance and model accuracy.

The Standard Precision Problem in Deep Learning

Deep learning models are traditionally trained using 32-bit single-precision floating-point values (FP32). In the IEEE 754 standard, each FP32 number consumes 32 bits (4 bytes) of memory, structured as:

While FP32 offers high dynamic range and numerical stability during training, it creates substantial bottlenecks during deployment. Large Language Models (LLMs) and massive vision models with billions of parameters require tens or hundreds of gigabytes of VRAM just to store weights, limiting their ability to run efficiently on edge devices or standard enterprise hardware.

How Quantization Compresses Binary Weights

Integer quantization replaces 32-bit floating-point weights with compact integer formats. This process directly reduces the number of bits allocated to each parameter in the binary number system:

1. INT8 Quantization (4x Compression)

INT8 utilizes an 8-bit signed integer format capable of representing \(2^8 = 256\) distinct values (ranging from -128 to 127). By reducing the bit-width from 32 bits to 8 bits, memory consumption per weight is reduced by a factor of 4. A 7-billion-parameter FP32 model requiring roughly 28 GB of storage is compressed down to approximately 7 GB.

2. INT4 Quantization (8x Compression)

INT4 reduces the precision further to a 4-bit integer, representing \(2^4 = 16\) distinct values (typically ranging from -8 to 7, or 0 to 15 if unsigned). Two 4-bit values can be packed into a single byte of memory. This achieves an 8x reduction in storage and memory bandwidth compared to FP32, allowing a 7-billion-parameter model to fit into under 4 GB of VRAM.

The Mathematical Mapping Process

To compress continuous floating-point weights into a discrete, limited set of integer values, a linear transformation is applied using a scale factor (\(S\)) and a zero-point offset (\(Z\)).

The standard affine quantization formula is:

\[q = \text{round}\left(\frac{x}{S}\right) + Z\]

Where: * \(x\) is the original floating-point weight or activation. * \(S\) (Scale) is a positive floating-point value that defines the step size between consecutive integer values: \(S = \frac{x_{\max} - x_{\min}}{q_{\max} - q_{\min}}\). * \(Z\) (Zero-point) is an integer that maps the real zero to the quantized domain, ensuring that exact zero in floating-point maps without error to a representable integer. * \(q\) is the resulting quantized integer.

To reconstruct the values during computation (dequantization), the inverse formula is used:

\[\tilde{x} = S \cdot (q - Z)\]

In symmetric quantization, the zero-point \(Z\) is set to 0, which simplifies hardware arithmetic at the cost of a slightly reduced dynamic range for asymmetric distributions.

Hardware and Performance Advantages

Compressing weights into INT8 and INT4 formats provides major system-level advantages beyond raw disk storage:

Methods of Implementation

Quantization is typically applied using one of two strategies: