← technical blogs

all about quantization

a guide into how quantization occurs in llms

quantization reduces the precision used to store a model’s weights and, sometimes, its activations. a 32-bit floating-point weight can often be represented with 16, 8, or 4 bits. smaller weights use less memory and can reduce the bandwidth needed during inference.

the basic idea

choose a scale and map a range of floating-point values onto a smaller set of integers. a common affine form is q = round(x / scale) + zero_point. to approximate the original value, use x ≈ scale × (q − zero_point).

the trade-off

fewer bits mean smaller models, but rounding introduces error. the effect depends on the model, the layers being quantized, and the data used to calibrate the range. compare quality and speed on your own workload before choosing a format.

common approaches

post-training quantization converts a trained model. quantization-aware training simulates lower precision during training so the model can adapt. weight-only quantization leaves activations at higher precision; weight-and-activation quantization compresses both.

the original medium article is currently unavailable. this replacement is a concise overview of the same topic.