Quantization
INT8/INT4 weight compression to shrink VRAM and speed inference with quality trade-offs.
In plain words
Store the model's numbers with fewer digits so it takes less memory and runs faster, accepting a tiny loss of precision.
Think of it like…
Saving a photo as a smaller JPEG: the file shrinks and loads faster, and at moderate compression you can't tell the difference. Push the compression too far, or use a poor method, and fine detail turns blocky, usually in the places that mattered.
Where you’ve seen it
A team wants to self-host a 70B model. In 16-bit its weights need about 140 GB (two 80 GB GPUs, with little left for KV cache). AWQ 4-bit brings weights to about 38 to 40 GB, fits one 80 GB GPU with room for a large KV cache, and doubles the concurrent users. On their 500-question evaluation, accuracy falls from 84.1 to 83.2 percent, which is acceptable; a 3-bit variant dropped to 79 and was rejected.
Words you’ll hear
- INT8 / INT4
- 8-bit and 4-bit integer representations of weights, with per-group scales to map back to real values.
- PTQ vs QAT
- Post-training quantisation (no retraining) vs quantisation-aware training.
- GPTQ / AWQ
- Post-training methods that use calibration data; AWQ protects weights with large activations.
- Calibration set
- A few hundred representative samples used to measure activation ranges.
Visual diagram
Theory & deep dive
How weight quantisation works
A weight tensor is split into small groups (commonly 64 or 128 values). For each group, a scale (and sometimes a zero point) maps the floating-point range onto integers: with 4 bits there are only 16 levels, so each value is rounded to the nearest level and stored as a 4-bit integer plus the group's scale. At run time the kernel dequantises on the fly or uses integer arithmetic directly. Memory per parameter is about bits/8 plus a small overhead for the scales.
Naive rounding hurts because a few outlier values stretch the range and waste levels. GPTQ quantises layer by layer and adjusts remaining weights to compensate for earlier rounding error using second-order information; AWQ observes which weights see the largest activations on calibration data and scales them up before rounding so they lose less precision. FP8, supported on recent GPUs, offers 8-bit floating point with less accuracy loss and can quantise activations too. Newer GPUs also support 4-bit floating-point formats (MXFP4, NVFP4), and some open-weight models now ship natively in them.
FP16: 140 GB. INT8: about 70 GB. INT4 with group size 128: about 38 to 40 GB. Add KV cache and activations on top, which is why the saved memory often matters most for concurrency.
Quality, speed and what to quantise
8-bit weight quantisation is usually near-lossless. 4-bit is the common sweet spot for serving, with small losses that vary by model and task and show up more in reasoning, code and long-context behaviour than in generic perplexity. Below 4 bits quality drops faster. Smaller models tolerate quantisation worse than large ones. Always evaluate on your own tasks against the FP16 baseline, including edge cases such as long inputs, structured output and non-English text.
Speed gains come mostly from reading fewer bytes: decode is memory-bandwidth-bound, so 4-bit weights can give up to roughly 2 to 3 times faster token generation, if the kernels are good. Prefill, which is compute-bound, benefits less unless activations are quantised too. You can also quantise the KV cache to INT8 or FP8 to fit more concurrent sequences. Formats matter for tooling: GGUF for llama.cpp and CPU/Apple devices, AWQ and GPTQ for GPU servers such as vLLM, and FP8 for newer data-centre GPUs.
Run 500 task questions on FP16 and INT4. Accept the quantised model only if accuracy drops by less than 1.5 points and structured-output validity stays above 99%; otherwise try group size 64, AWQ instead of GPTQ, or 8-bit for the most sensitive layers.
How it works, step by step
Step 1 of 41. Set a memory and quality target
Decide GPU budget and the accuracy drop you'll accept, using a task-specific evaluation set.
- Baseline
- FP16 score first
When to use it & trade-offs
What it is
Quantisation stores model numbers in fewer bits: weights (and sometimes activations or the KV cache) move from 16-bit floating point to INT8 or INT4, shrinking memory by 2 to 4 times and often speeding up inference, since decoding is limited by how fast weights can be read from memory. The cost is rounding error, so quality can drop, especially at 4 bits or below. Methods such as GPTQ and AWQ use a small calibration dataset to choose scales and protect the weights that matter most.
Why it matters: Quantisation is why a 70B model can run on two consumer GPUs instead of a rack, and why serving cost per token falls. Every self-hosting decision involves it: which format (GGUF, AWQ, GPTQ, FP8), what bit width, and how to verify that quality still meets the bar on your tasks. It's a core topic for deployment and cost-optimisation interviews.
When to reach for it
- Self-hosting large models on limited GPUs
- Raising concurrency by freeing memory for the KV cache
- Running models locally on laptops and edge devices
When to avoid or be careful
- Judging quality by perplexity alone
- Quantising small models aggressively without testing
- Calibrating on data unlike production traffic
Common quantisation choices
Strengths: Small quality loss; 2× memory reduction.
Watch out: Less compression than 4-bit.
Strengths: ≈ 4× smaller; fast decode.
Watch out: Task-dependent quality loss; needs calibration and checks.
Strengths: Many bit widths; runs without a GPU.
Watch out: Different tooling; lower throughput than GPU servers.
Interview signals & numbers to know
When this topic comes up
- “Fit a 70B model on one GPU”
- “GPTQ vs AWQ”
- “Quality dropped after quantising”
- GGUF and llama.cpp
- KV cache quantisation
Benchmarks & rules of thumb
- bits / 8
- bytes per parameter (plus scale overhead)
- ≈ 2×, 4×
- memory reduction for INT8 and INT4 vs FP16
- 64 – 128
- typical group sizes
Common mistakes & follow-ups
Common interview mistakes
- Accepting a quantised model because its perplexity is fine, then finding JSON validity or code accuracy dropped.
- Using English-only calibration data for a multilingual product.
- Quantising weights to 4-bit and forgetting the KV cache is still FP16 and now the main memory cost.
Likely interviewer follow-ups
- Why does quantisation speed up decoding?
- How do AWQ and GPTQ differ?
- How would you decide whether a 4-bit model is good enough?
Knowledge check
Put it into practice
Practice related interview Q&A
Apply Quantization with generative AI interview Q&A and hands-on practice.