esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • AI papersPages
  • Interview KitPages
  • Book a callContact
  • Download ResumeContact
Let’s talk

I’ll build the agent for it.

What Is Quantization?

What quantization is, how it shrinks a model's memory, what it costs in accuracy, explained simply for your AI interview.

In short

Quantization stores a model's weights in fewer bits, such as 8 or 4 instead of 16, so the model needs less memory. The price is some accuracy, so test the smaller model on your own task before you ship it.

10 min readIntermediateVery common · estimateFacts checked 26 November 2026

Say it out loud

Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.

Quantization stores a model's numbers in fewer bits. A 16-bit weight becomes 8-bit or 4-bit, so the model needs less memory and can run on cheaper hardware. The price is some accuracy. So I never ship a quantized model without testing it on our own tasks first, and I check the speed on the hardware we really use.

What is quantization, in plain words?

A language model is built from billions of numbers called weights. Each weight is learned during training and usually loaded with 16 bits. Quantization stores those numbers in fewer bits, such as 8 or 4, so the model takes less memory and can run on cheaper hardware.

Think of a hospital pharmacy that keeps a dose to three decimal places in its main system, but prints it on the label rounded to the nearest half milligram. The label is shorter and easier to handle, and the rounding costs a little precision. Quantization makes the same trade with a model's weights.

On a real team this is a deployment choice. A hospital wants a note summariser to run on one server in its own building. The full model doesn't fit in that server's memory. Stored in fewer bits, it does, and the team then checks the summaries against its own review set.

Key words

Weight
One learned number inside the model. A model has billions.
Bit
The smallest unit of storage, a 0 or a 1. More bits give more possible values.
Scale
A multiplier that turns stored whole numbers back into real weight values.
Calibration
Running sample data through a model to choose the scale and the rounding.
Outlier
A rare, very large number inside the model that a simple rounding scheme handles badly.

How does quantization shrink a model?

Hugging Face's docs define it in one line. Activations, named in that line, are the numbers passed between the model's layers while it works:

  • “Quantization stores a model's weights, and sometimes its activations, in fewer bits so the model needs less memory.”

    Hugging Face Transformers docs

  • “Moving from floating-point representations to low-precision fixed integer values represented in four bits or less holds the potential to reduce the memory footprint and latency by a factor of 16x”

    Gholami and colleagues, 2021 survey

The memory maths is simple. Models are usually loaded in 16-bit numbers, which take 2 bytes per weight (a byte is 8 bits). At 8 bits a weight takes 1 byte, and at 4 bits half a byte. So the weight memory halves at 8 bits and halves again at 4 bits, before any space for the cache and the working memory.

Two ways to store the same weights

Model weights

numbers the model learned

Keep 16-bit

Original 16-bit

2 bytes for every weight

Round to 8-bit

Scale and round

one scale per group of weights

Too big for one server

about 14 GB for 7 billion weights

Fits in memory

about 7 GB, then test quality

  1. 1The model keeps its 16-bit numbers as they are.
  2. 2Each weight is rounded to an 8-bit whole number, using a scale shared by its group.
  3. 3At 16 bits, a made-up 7-billion-parameter model needs about 14 GB.
  4. 4At 8 bits, the same model needs about 7 GB, and quality must be checked.
A made-up 7-billion-parameter model, stored two ways. Keeping 16-bit numbers is simple but big. Rounding to 8-bit halves the weight memory, and the trade-off is some loss of accuracy, which must be tested.

Here is the arithmetic in plain Python, on the same made-up model and five of its weights. A scale maps the real numbers onto 256 whole-number values, from -128 to 127. The code then reads them back and measures the error.

Python
# A made-up 7-billion-parameter model, and the size of its weights at three precisions.
PARAMS = 7_000_000_000
for name, bits in [("16-bit", 16), ("8-bit", 8), ("4-bit", 4)]:
    gb = PARAMS * bits / 8 / 1e9
    print(f"{name} weights: {gb:.1f} GB")

# Quantize five weights to 8-bit integers (-128 to 127) with a scale and a zero-point, the whole number that stands for 0.
weights = [-0.42, 1.30, 0.07, -0.88, 0.25]
lo, hi = min(weights), max(weights)
scale = (hi - lo) / 255
zero = round(-128 - lo / scale)
ints = [max(-128, min(127, round(w / scale) + zero)) for w in weights]
back = [(q - zero) * scale for q in ints]
print("8-bit values:", ints)
print(f"largest error: {max(abs(a - b) for a, b in zip(weights, back)):.4f}")

Output

16-bit weights: 14.0 GB
8-bit weights: 7.0 GB
4-bit weights: 3.5 GB
8-bit values: [-74, 127, -17, -128, 4]
largest error: 0.0021

Notice the trade. The model shrinks from 14 GB to 7 GB, but each weight comes back a little off. Real teams judge a quantized model by its answers on their own tasks. The error number above is only a rough hint.

What are the main kinds, and what do they cost?

  • After training

    Post-training quantization

    Shrink a finished model. Most methods that quantize while loading need no calibration data. GPTQ is the exception: it calibrates on a dataset while the model loads, and its paper's title calls it post-training quantization.

  • During training

    Quantization-aware training

    The rounding is simulated while the model trains, so the model learns to cope with it. It costs more training work, and Jacob and colleagues co-designed their training for this.

  • “We also co-design a training procedure to preserve end-to-end model accuracy post quantization.”

    Jacob and colleagues, 2017

  • “We develop a procedure for Int8 matrix multiplication for feed-forward and attention projection layers in transformers, which cut the memory needed for inference by half while retaining full precision performance.”

    LLM.int8() paper, 2022

  • Accuracy

    Fewer bits cost some accuracy, and each method trades memory, speed and accuracy differently. Test on your own task. A general benchmark score is only a rough guide.

  • Speed

    Smaller is not automatically faster. The gain depends on the hardware and its support for that number format. Jacob and colleagues say integer-only maths can be implemented more efficiently, on commonly available integer-only hardware.

  • Outliers

    A few feature dimensions are very large. A feature dimension is one slot in the model's internal numbers. The 2022 LLM.int8() paper kept those outlier dimensions in 16-bit maths and ran more than 99.9% of values in 8-bit. That needed a special mixed-precision step.

  • Hosted models

    Quantization changes weights you host. With a provider's API, which is how your app calls their model, you can't quantize their model, so ask them which precision they serve.

  • Not the same as

    Distillation trains a smaller model to copy a bigger one. Pruning removes parts of a model. Quantization keeps the same model and stores its numbers in fewer bits.

You will meet named formats like INT8 and INT4, and methods like GPTQ, in later questions.

What does the interviewer want to hear?

A strong answer covers

  • A plain definition: fewer bits per number, so less memory.
  • The memory maths: 2 bytes at 16-bit, 1 byte at 8-bit, half a byte at 4-bit.
  • The cost: some accuracy, measured on your own task.
  • Speed depends on hardware, so smaller is not always faster.
  • Post-training versus training-aware, and when each one fits.
  • How it differs from distillation and pruning.

Common traps

  • Trap"Quantization makes the model smarter and faster."

    BetterIt makes the weights smaller. Quality can drop and speed depends on hardware, so measure both.

  • Trap"Going down to 4 bits is safe, so we can skip our own tests."

    BetterLower bits lose more quality. Run your own tests before any quantized build goes live.

  • Trap"It's the same as pruning or distillation."

    BetterThose change the model's structure or size. Quantization keeps the model and uses fewer bits.

Can you spot the problem?

Spot the problem

A colleague's release note for a quantized build has one claim that needs fixing. Which one?

Quick check

A hospital's note summariser must fit on one server. Which change cuts the weight memory most directly?

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 6

What will they ask next?

  1. Q312INT8 vs INT4 vs FP8?14 min
  2. Q313GPTQ, AWQ and GGUF in one line each?Coming soon
  3. Q328Does a 70B model fit on one 80GB GPU?Coming soon
  4. Q327GPU basics: why does memory bandwidth limit decoding?Coming soon
  5. Q285What is QLoRA?10 min
  6. Q055What is the KV cache, and why does it speed up generation?12 min

Learn it in depth

Last updated on 26 November 2026

Hosting a model on your own servers?

I design and build AI products and agents, the screens and the system behind them. Book a short call and say what you need to run, and where.