← All news

News / Learn / Local & open models

What is quantization?

You'll be able to explain what quantization does to a model and judge when its size and quality tradeoff is worth it.

A language model is a large set of numbers called weights. Quantization stores those numbers with fewer bits. Each weight takes less memory, so the whole model is smaller and easier to run. The model keeps most of its behavior, but each number is rounded, so some accuracy is lost.

Model size decides what hardware you need, how fast responses arrive, and what you pay to serve them. Quantization can let a model fit on a laptop or a cheaper cloud GPU. You need to know how much quality it costs, because a small loss can be fine for one feature and a serious problem for another.

A model's weights are normally stored as 16-bit or 32-bit floating-point numbers. Quantization maps those values onto a smaller set of levels, such as 8-bit or 4-bit integers. Each weight becomes a short code plus a scale factor that restores its approximate value. Fewer bits per weight means less memory to load and move.

Memory is often the real bottleneck when a model generates text. Reading fewer bytes per weight usually makes token generation faster on the same hardware. Smaller weights also let you fit a larger model, or a longer context, into the memory you have. Speed gains depend on the hardware and the software that runs the model, so measure them rather than assume them.

The cost is error. Rounding every weight shifts the output a little, and the shifts add up across billions of weights. Simple rounding loses more quality at very low bit widths. Better methods pick scales per small group of weights or use calibration data to choose rounding that protects the most important values. Quality loss is usually small at 8-bit, more noticeable at 4-bit, and can be severe below that.

Quantized models are not always the same as the originals on every task. Errors can show up in arithmetic, long reasoning, rare languages, or exact formatting. Test the quantized model on your own prompts before you ship it.

A rough estimate of weight memory: parameters times bits per weight, divided by 8 for bytes. This ignores the extra memory for the context cache and runtime.

def weight_memory_gb(params_billion: float, bits_per_weight: float) -> float:
    bytes_total = params_billion * 1e9 * bits_per_weight / 8
    return bytes_total / 1e9

for bits in (16, 8, 4):
    print(f"{bits}-bit: about {weight_memory_gb(7, bits):.1f} GB of weights")

A short sketch to show the idea. Check the official docs of the tool you use.

  • Assuming all quantization is equal Methods, bit widths, and group sizes differ. Compare the exact variant you plan to run, not just the bit count in its name.
  • Judging quality by a few demo prompts Build a small test set from your real inputs and compare the quantized and original outputs on it.
  • Forgetting memory beyond the weights The context cache grows with conversation length and can need more memory than the weights at long contexts. Budget for it.
  • Expecting speed gains everywhere Speed depends on your hardware and runtime. Benchmark latency and throughput on the machine you will use.

Read about post-training quantization versus quantization-aware training, and about how group size affects accuracy. Then learn how inference runtimes load quantized weights, since that determines the real speed you get.

Does quantization change what a model knows?

Not in a deliberate way. It rounds the stored numbers, which can shift outputs slightly. The model's knowledge is still there, but some answers may change or degrade, especially on hard tasks.

Is 8-bit quantization safe to use?

It often causes very little measurable loss, but safe depends on your task. Test it against your own examples before relying on it.

Why does a 4-bit model still run on my computer when the original doesn't?

Four bits per weight takes about a quarter of the memory of 16-bit. That can move the model from too large to fits in your available memory.

Does quantization also make the model cheaper to train?

Quantization is mainly applied to models for inference. Training with low precision is a related but separate technique, and it is more involved.

Written with AI by CapyLaunch. Spotted a mistake? Email hello@capylaunch.com.