Quantization: int8, int4 and When Quality Drops
You'll be able to:
You can explain what a quantization scheme actually stores (scales, zero-points, group sizes), say why weight-only 4-bit helps decode but not prefill, compare round-to-nearest, GPTQ and AWQ in terms of what they calibrate, and describe how you would detect that a quantized model has lost quality before users do.
What quantization actually stores
A 16-bit model keeps every weight as a floating-point number with roughly three significant digits. Quantization replaces each weight with a small integer plus a shared scale (and sometimes a zero-point) that tells the kernel how to turn the integer back into a real value: w ≈ scale × (q − zero). The integers are what you store and stream; the scale is stored once per group of weights. An int4 weight with a 16-bit scale shared across a group of 128 therefore costs 4 + 16/128 ≈ 4.125 bits per weight, about one quarter of the original.
Everything else in the subject is about one question: how do you pick the integers and the scales so the model's outputs change as little as possible?
Why 4-bit weights speed up decode but not prefill
From module 1, decode time is set by bytes streamed per step. Weight-only quantization cuts those bytes by two to four times, so decode gets proportionally faster, with the kernel dequantizing on the fly inside the multiply. Prefill is compute-bound; the arithmetic is still done in 16-bit after dequantization, so weight-only schemes save memory there but little time. If you want prefill or large-batch speed-ups you need activations quantized too (W8A8 and similar), which is harder because activations have outliers that change from token to token. The LLM.int8() work from Dettmers and colleagues documented those outlier channels in models above a few billion parameters and handled them with mixed precision; it is the reason naïve 8-bit activation quantization was unreliable at scale.
Round-to-nearest, groups and outliers
The simplest scheme — round-to-nearest (RTN) with one absmax scale per row — breaks the moment a row contains an outlier. A single weight of 12 among values near ±1 forces the scale to 12/7 ≈ 1.7 at 4-bit, so every small weight collapses to 0 or ±1.7 and most of the information is gone. Two fixes are standard:
- Group-wise scales: one scale per 32, 64 or 128 weights instead of per row. The outlier only damages its own group. Smaller groups mean better accuracy and slightly more bits per weight.
- Keep outliers in higher precision or scale them away before quantizing.
Maarten Grootendorst's "A Visual Guide to Quantization" walks through symmetric versus asymmetric mappings and group sizes with pictures that make the error visible; read it before the two papers.
GPTQ and AWQ: calibrating against the real distribution
Both methods are post-training: no gradient updates to the model, only a few hundred calibration samples.
GPTQ quantizes a weight matrix one column at a time and, after rounding each column, adjusts the remaining unquantized columns to compensate for the error, using second-order (Hessian) information from the calibration activations. It is a direct descendant of Optimal Brain Surgeon. The result is a 3- or 4-bit model whose layer outputs stay close to the original's on data that resembles the calibration set.
AWQ starts from an observation: a small fraction of weight channels matter far more because they multiply large activations. Rather than keeping them in 16-bit, AWQ scales those channels up before quantizing (and scales the matching activations down) so rounding error on them shrinks. It needs only activation statistics, not a Hessian, and the resulting weights work with plain integer kernels, which is why AWQ models are easy to deploy.
Neither method is strictly better; results vary by model family and bit width (in the AWQ paper's own comparison AWQ matched or beat GPTQ on perplexity at 3 and 4 bits). AWQ is simpler, calibrates faster and generalises more robustly to text unlike the calibration set. Formats such as the llama.cpp "K-quants" (Q4_K_M, Q5_K_M) use their own mixed-precision layouts optimised for CPU and Apple-silicon kernels.
A numbered procedure for quantizing without regret
- Decide the target: memory fit, decode speed, or both. If prefill latency is the problem, weight-only int4 will disappoint you.
- Pick the scheme and group size. Start at 4-bit with 128-group or Q4_K_M; drop to 8-bit if quality is paramount and memory allows.
- Calibrate on data that looks like production traffic. Calibration on English Wikipedia and deployment on code or another language is a classic quiet failure.
- Measure quality on your own tasks, not only perplexity. Perplexity on a generic corpus can be flat while instruction following, long-context recall or maths degrade.
- Compare outputs side by side with the 16-bit model on a fixed prompt set. Look for repetition, broken formatting and refusals that were not there before.
- Record the exact recipe (scheme, group size, calibration set, library version) next to the artefact. Quantized checkpoints are not reproducible from memory.
What is still unsettled
Below 4 bits the picture is noisy: 2- and 3-bit methods exist and keep improving, but quality loss varies by model family and task, and small models suffer more than large ones at the same bit width. Whether quantizing the KV cache to 8 or 4 bits is safe for long-context reasoning is also model-dependent. Trained quantization-aware models (released natively in low precision) may make post-training schemes less important, but the evaluation discipline above does not change.
What to remember
- Quantization stores integers plus scales; group size trades accuracy against bits per weight.
- Weight-only int4 speeds decode (fewer bytes) but not prefill (still 16-bit compute); W8A8 helps compute-bound phases and is harder because of activation outliers.
- GPTQ compensates rounding error column by column using calibration Hessians; AWQ rescales the channels that multiply large activations. Both need representative calibration data.
- Judge a quantized model on your own tasks and a side-by-side prompt set, never on perplexity alone.
Curated Materials
1.9hThe deep work happens here — the lesson is your briefing.
Live on aiqbench
This lesson's subject on the rest of the site, today.
In the news, last 30 days
- DeepSeek Opens Source Production-Level Ascend Inference Code36Kr ·
- NVIDIA and Cerebras Partner to Accelerate AI Agent Inference with Two-Stage Compute Architecture36Kr ·
- Nvidia unveils Kyber Galaxy, a 72-GPU AI system to launch into orbit with SpaceX next yearDealroom.co ·
Test your knowledge
5 questions in 100 seconds, on a page of its own. Read everything above first.
Test your knowledge →Module Mission
30–40 minTake sixteen made-up weights (write them yourself, including one outlier such as 12.0 among values between -1 and 1). Quantize them to 4-bit integers with a single absmax scale, then again with two groups of eight. Dequantize both and compute the mean absolute error for each. Write three sentences on why the outlier hurt the ungrouped version and what that implies for choosing group size in a real model.
Loading your work…