You photograph a receipt to email it. The original is 12 megapixels; you send it at 2. Every word is still readable, the file is a sixth the size, and nobody complains. You would not do the same to a photo going on a billboard.
Quantization is that decision applied to model weights — and, like the photo, the right answer depends entirely on what the result is for.
What it is
A model's weights are numbers, and numbers need bits. Training typically uses 16 bits per weight. Quantization stores them with fewer — 8 bits, or 4 — so the same model occupies a fraction of the memory.
The information loss is real: a coarser scale can't represent every value the finer one could, so each weight is stored as the nearest available step. Modern methods are clever about where to spend precision, which is why the memory savings are large and proportional, while the quality loss is usually much smaller than the bit reduction suggests.
The arithmetic you'll be asked for
The calculation is parameters × bytes per parameter, and interviewers do ask you to do it out loud:
| Precision | Bytes/param | 7B model | 13B model | 70B model |
|---|---|---|---|---|
| fp16 / bf16 | 2 | ~14 GB | ~26 GB | ~140 GB |
| int8 | 1 | ~7 GB | ~13 GB | ~70 GB |
| int4 | 0.5 | ~3.5 GB | ~6.5 GB | ~35 GB |
That table is the difference between "needs a data-centre GPU" and "runs on a laptop". A 7B model at 4-bit fits in a few gigabytes, which is why local model apps exist at all.
Wait — weights aren't the whole story
This is where most candidates stop, and where the interesting half begins. Weights are a fixed cost. Serving also needs memory that grows with your traffic:
- The KV cache — stored attention keys and values for tokens already processed, so each new token doesn't recompute the whole sequence. It grows with sequence length and with the number of concurrent requests.
- Activations and framework overhead — a gigabyte or two.
Weights set the floor on memory; the KV cache sets the ceiling on concurrency. A 13GB int8 model on a 24GB card leaves roughly 9–10GB for cache and overhead — and that remainder, not the model size, is what decides how many users you can serve at once.
💡 Practical rule: budget weights plus at least 25–40% headroom, and more if your prompts are long or your concurrency is high. Sizing a GPU by weights alone is how a deployment ends up refusing requests under load.
What it costs in quality
Honest summary: 8-bit is usually near-lossless for most tasks. 4-bit is noticeable but often acceptable. Below that, degradation becomes hard to ignore.
But the degradation is not uniform across tasks, and that is the part worth saying:
| Tolerates quantization well | Suffers most |
|---|---|
| Chat, summarisation, classification | Long multi-step reasoning — small errors compound over many tokens |
| Extraction with a clear schema | Precise code generation, where every token must be exactly right |
| Short, forgiving outputs | Mathematical work and anything with a single correct answer |
So the only correct answer to "is 4-bit good enough?" is run your own evaluation set on both and compare per-category. A published benchmark delta tells you about someone else's workload.
from transformers import AutoModelForCausalLM, BitsAndBytesConfig
quant = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_compute_dtype="bfloat16", # compute in higher precision
bnb_4bit_quant_type="nf4", # a 4-bit format suited to weights
bnb_4bit_use_double_quant=True, # quantize the quantization constants
)
model = AutoModelForCausalLM.from_pretrained(
"<model-id>", quantization_config=quant, device_map="auto"
)Result
Note compute_dtype: weights are stored at 4 bits but arithmetic happens at higher precision. That is a common misconception worth correcting if it comes up — quantization is primarily about storage.
PTQ vs QAT
| Post-training quantization (PTQ) | Quantization-aware training (QAT) | |
|---|---|---|
| What | convert a finished model to lower precision | simulate low precision during training so the model adapts |
| Cost | minutes; no training | a full training run |
| Quality | good, especially at 8-bit | better, especially at aggressive precisions |
| Who does it | almost everyone | model producers, or teams with a hard precision target |
When someone says "a quantized model", they almost always mean PTQ.
Where it matters
Self-hosted inference — this is the main event. Quantization decides which GPU you need, how many concurrent requests fit alongside the weights, and therefore your cost per request. It is one of the most direct cost levers available.
Fine-tuning — QLoRA quantizes the frozen base so adapters can be trained on modest hardware (lesson 4).
Local and on-device — running a model on a laptop or a phone is only possible at reduced precision.
Hosted APIs — irrelevant to you. The provider chose, and you pay per token regardless.
🎯 Selection-round radar: two questions recur. "What is quantization and what does it cost?" → fewer bits per weight, proportionally less memory, a usually-small and task-dependent quality loss. And the practical one: "how much GPU memory does a 7B model need?" → do the arithmetic out loud (7B × 2 bytes ≈ 14GB at fp16), then add the line that marks experience: "plus the KV cache, which grows with concurrency and is what actually limits how many users fit."
Common mistakes
- Sizing a GPU from weights alone and running out of memory under load.
- Assuming a benchmark's quantization delta applies to your task.
- Going straight to 4-bit when 8-bit would have fitted and cost less quality.
- Believing arithmetic happens at the storage precision.
- Switching precision in production without an eval comparison and a rollback.
- Quantizing when you use a hosted API, where it has no meaning.
Quick recap
| Concept | One-liner |
|---|---|
| Quantization | store weights at lower precision; memory drops proportionally |
| The arithmetic | parameters × bytes per parameter — 2, 1 or 0.5 |
| KV cache | grows with concurrency and sequence length; caps how many users fit |
| Quality cost | small at 8-bit, noticeable at 4-bit, and task-dependent |
| Worst-affected tasks | long reasoning and exact code, where errors compound |
| PTQ vs QAT | convert afterwards (usual) vs train with it simulated (better, costlier) |
| Where it matters | self-hosting, QLoRA and on-device; invisible on a hosted API |
Practice Zone — PYQs from real selection rounds
Six MCQs, then two tasks: size the hardware for a real deployment, and design the check that decides whether 4-bit is acceptable.
What is quantization in the context of LLMs?
Asked in

What is the trade-off?
Asked in

A rough memory estimate for a 7-billion-parameter model at 16-bit precision is:
Asked in

What is the difference between post-training quantization and quantization-aware training?
Asked in

Where does quantization matter most in practice?
Asked in

Which task type tends to suffer most from aggressive quantization?
Asked in

Hands-on tasks:
You want to self-host a 13B-parameter model for an internal tool: ~20 concurrent users, moderate-length prompts. Work out the memory requirement at fp16, 8-bit and 4-bit, and recommend a configuration.
Asked in

Your team wants to move a production model from 8-bit to 4-bit to halve GPU cost. Design the check that decides it.
Asked in

FAQ
Is a quantized big model better than a full-precision small one?
Frequently yes, at the same memory budget — a 4-bit 13B model often beats an fp16 7B one. But it is genuinely task-dependent, and it is exactly the comparison your own eval set exists to settle. Run both.
Does quantization make inference faster?
Often, though not always for the reason people assume. Less memory traffic helps, and the bigger practical win is that freed memory allows larger batches and more concurrency — throughput improves even when per-token speed doesn't change much.
Can I quantize a model I fine-tuned?
Yes. Fine-tune first, quantize the result for serving, then evaluate the quantized artefact — not the full-precision one — because that is what users will actually get. Skipping that last step is a common way to ship a quality drop you measured away.
Next lesson: putting it all together — a fine-tuning project from decision to production — Lesson 6: Fine-Tuning in Practice →


