quantization

Quantization stores and computes a neural network in fewer bits — mapping high-precision FP32 weights and activations onto a small set of low-precision levels (INT8, INT4, FP8) so the model takes less memory and runs faster.\n\n**It is a mapping from a continuous range onto a discrete grid.** A quantizer picks a scale s and a zero-point z, then represents each real value x as the integer q = round(x / s) + z and recovers an approximation x' = s(q - z). INT8 gives 256 levels, INT4 only 16. The art is choosing s — and whether to use one scale per tensor, per channel, or per block — so the grid lands where the weights actually cluster.\n\n**Why it pays off.** Cutting FP32 to INT8 shrinks the model 4x and cuts memory traffic 4x, which — per the roofline — is exactly what helps a memory-bound LLM. The multiplies also become cheap integer or low-precision operations that tensor cores run several times faster. The cost is rounding error: too few levels, or a few outlier values stretching the scale, and accuracy drops.\n\n| Approach | When quantized | Accuracy | Cost | Typical use |\n|---|---|---|---|---|\n| PTQ (post-training) | after training | good with care | minutes | most INT8 deploys |\n| QAT (quant-aware) | during training | best | full retrain | aggressive low-bit |\n| Weight-only | weights only, acts FP16 | high | simple | LLM inference (GPTQ, AWQ) |\n| Dynamic | activations at runtime | good | slight overhead | activation-sensitive nets |\n\n```svg\n\n \n Quantization — snap continuous FP32 values onto a small integer grid\n\n \n FP32 weights: continuous, 32 bits each\n \n \n 0\n min\n max\n\n \n\n \n \n \n INT8 grid: 256 levels (16 shown), 8 bits each\n q = round(x / s) + z s = (max - min) / 255 x' = s(q - z)\n s = scale, z = zero-point. Dashed lines snap each value to its nearest level; the gap is rounding error.\n\n \n \n Fewer bits, less memory.\n INT8 is 4x smaller than FP32 and\n cuts memory traffic 4x -> big win\n for a memory-bound LLM.\n Cheaper math.\n Integer / low-precision multiplies\n run several times faster on\n tensor cores.\n The catch: outliers.\n A few large values stretch the\n scale and coarsen everything else\n - the hard part below INT8.\n \n\n```\n\n**Bit-width is a spectrum, and outliers set the floor.** INT8 is routine; INT4 and FP4 need care because a handful of outlier activations dominate the range and inflate the rounding error for everything else. Per-channel scales, group-wise quantization, and outlier-aware methods (SmoothQuant, AWQ, GPTQ) exist precisely to keep the grid useful as the bit-width shrinks.\n\nRead quantization through a quant lens rather than an accuracy-table lens: it is a knob on arithmetic intensity and model footprint, not merely a compression trick. Every bit removed multiplies effective bandwidth and tensor-core throughput, so the real question is how far levels can drop before rounding error crosses the task's tolerance — a measured bytes-versus-error trade, not an assumed one.

Go deeper with CFSGPT

Get AI-powered deep-dives, save terms, and run advanced simulations — free account.

Create Free Account