Skip to content
Cosvexa – Cosvexa home

Research · Inside modern models

Quantization: running models in fewer bits

Quantization stores a neural network's numbers, mainly its weights, in fewer bits, for example 8 or 4 bits instead of 16. A 4-bit model needs roughly a quarter of the memory of its 16-bit original and usually generates text faster, because less data moves through memory per token. Done well, the loss in quality is small; done aggressively, it becomes noticeable.

Cosvexa team · Published

Abstract illustration of a smooth gradient bar beside the same bar broken into a few distinct steps, with fine dots condensing into larger blocks.

Key points

  • Quantization maps high-precision numbers to a small set of levels using a scale factor.
  • Memory scales with bits per weight: a 70B model needs about 140 GB at 16 bits and about 35 GB at 4 bits, before overhead.
  • Post-training methods such as GPTQ and AWQ quantize a finished model without retraining it.
  • Outlier values are the main obstacle; most LLM-specific methods are ways of handling them.
  • Below about 4 bits per weight, quality usually drops faster, and results vary by model and task.

What quantization is

A trained neural network is mostly a very large collection of numbers. In a large language model these are the weights of its matrices, and during training they are usually kept in 32-bit or 16-bit floating point (FP32, FP16 or BF16). Quantization replaces those numbers with lower-precision versions, typically 8-bit integers (INT8), 8-bit floats (FP8) or 4-bit integers (INT4), and sometimes even fewer bits.

The idea is old in signal processing and was standard for mobile computer-vision models well before LLMs; a widely cited 2017 Google paper by Jacob et al. described integer-only inference for efficient on-device networks. Large language models made it far more important, because their size, not their arithmetic, is usually what stops them from fitting on a given machine.

How it works, with a worked example

The simplest scheme is symmetric linear quantization. Take a group of weights, find the largest absolute value, and choose a scale so that this value maps to the largest integer available. Then divide every weight by the scale and round.

  1. 1

    Choose a group

    Take a small group of weights, for example [0.423, −1.27, 0.051, 0.904]. Real systems use groups of tens or hundreds of weights, or a whole row.

  2. 2

    Compute the scale

    For signed 8-bit integers the largest level is 127. The largest absolute value is 1.27, so the scale is 1.27 / 127 = 0.01.

  3. 3

    Quantize

    Divide by the scale and round: 42.3 → 42, −127, 5.1 → 5, 90.4 → 90. Store the integers [42, −127, 5, 90] plus the single scale.

  4. 4

    Dequantize when computing

    Multiply back: [0.42, −1.27, 0.05, 0.90]. Each value is off by at most half a step (0.005 here). That rounding error is the price of the smaller format.

With 4 bits there are only 16 levels instead of 256, so each step is much larger and the rounding error grows. That is why the choice of groups, scales and rounding matters so much at low bit widths. Asymmetric schemes add a zero-point so the range need not be centred on zero, and non-uniform formats such as the 4-bit NormalFloat (NF4) introduced with QLoRA place levels where weights are densest.

What it saves: memory and speed

FormatBytes per weightWeights of a 7B modelWeights of a 70B model
FP324about 28 GBabout 280 GB
FP16 / BF162about 14 GBabout 140 GB
INT8 / FP81about 7 GBabout 70 GB
INT40.5about 3.5 GBabout 35 GB

These figures are simple arithmetic for the weights alone. Real files are slightly larger because scales and some unquantized layers are stored too, and running a model also needs memory for activations and the KV cache.

Speed improves for a less obvious reason. When a model generates text one token at a time, each step must read essentially all of its weights from memory, and that reading, not the multiplication, is usually the bottleneck. Halving the bytes per weight roughly halves the data moved per token, so generation can get faster, provided the software has efficient kernels for the format. Where hardware supports low-precision arithmetic directly, such as INT8 or FP8 matrix units, computation can speed up as well.

The main approaches

Post-training quantization (PTQ) converts an already-trained model, usually using a small calibration dataset to choose scales. It is cheap and is how most open-weight models are quantized. Quantization-aware training (QAT) simulates quantization during training or fine-tuning so the model learns to tolerate it; it costs more but generally preserves quality better at low bit widths.

Large language models raised a specific difficulty. Dettmers et al. (2022), in LLM.int8(), reported that beyond a certain scale, transformers develop a few activation dimensions with very large magnitudes, called outlier features, and that naive 8-bit quantization breaks down when they appear. Their method keeps these outlier dimensions in 16-bit while multiplying the rest in 8-bit, and they reported 8-bit inference for models up to 175B parameters without performance degradation.

Several later methods became standard tools:

  • GPTQ (Frantar et al., 2022) quantizes weights one layer at a time, using approximate second-order information to adjust the remaining weights and compensate for each rounding error. It made 3- and 4-bit weight quantization of very large models practical.
  • SmoothQuant (Xiao et al., 2022) moves the difficulty of quantizing activations into the weights with a mathematically equivalent rescaling, allowing both weights and activations in 8 bits.
  • AWQ (Lin et al., 2023) observes that a small fraction of weights matter much more than others, identifies them from activation statistics and scales them to protect them during 4-bit quantization.
  • QLoRA (Dettmers et al., 2023) freezes a model in 4-bit NF4 and trains small LoRA adapters on top, which made fine-tuning large models possible on a single high-memory GPU.

In practice, people running models locally meet these ideas through file formats and labels. The llama.cpp project's GGUF format, for example, offers many quantization types with names like Q4_K_M or Q8_0, which describe the bit width and grouping scheme. Server inference engines commonly support GPTQ, AWQ and FP8 checkpoints.

Why it matters

  • Fitting on hardware. A model that needs two high-end accelerators at 16 bits may fit on one at 8 bits, or on a laptop at 4 bits.
  • Lower cost per token. Fewer bytes moved and smaller memory footprints let a server handle more requests, which feeds directly into inference cost and latency.
  • Local and private use. Quantization is a large part of why capable open-weight models and small language models can run on personal computers and phones.

Limits and common misconceptions

"Quantized means just as good." Not automatically. At 8 bits, careful methods are usually very close to the original. At 4 bits, results are often close on common benchmarks but can slip on harder reasoning, long contexts, less common languages or exact recall. Below 4 bits, losses usually grow quickly unless the model was trained for it. Published comparisons differ by model family, so test the specific quantized build on your own tasks.

"Benchmarks tell the full story." Average scores can hide small regressions on particular skills. Perplexity, a common quick check, does not always track how users experience the model.

"Smaller is always faster." Speed depends on kernels and hardware. An unusual format without optimized support can run slower than 16-bit, and very large batches on servers may be limited by computation rather than memory, reducing the gain.

Quantization is not distillation or pruning. Quantization keeps the same network and lowers the precision of its numbers. Knowledge distillation trains a separate, smaller model, and pruning removes weights. The techniques are often combined.

Choosing a quantization level

A practical rule is to start from the largest model that fits your memory at a moderate level, often 4 to 8 bits, rather than a smaller model at 16 bits. Published comparisons have often found that a larger model quantized to around 4 bits beats a smaller model of the same file size kept at higher precision, though this is a tendency, not a law. Then check the tasks you care about: if a 4-bit build makes errors that the 8-bit build does not, the extra memory may be worth it. For fine-tuning, keep in mind that quantization errors and adapter training interact, so evaluate the final combined model, not the parts separately.

Where it is going

Hardware keeps adding support for lower-precision formats, including FP8 and 4-bit floating point types, and training itself increasingly uses 8-bit arithmetic. Research continues on quantizing activations and the KV cache, on mixed precision that gives sensitive layers more bits, and on quantization-aware training for very low bit widths. Some model makers now publish official quantized checkpoints alongside full-precision weights, which reduces the guesswork for users.

Cosvexa's model catalog lists open and closed models side by side; how a provider quantizes a hosted model is often not disclosed, so judging quality on your own prompts with Compare is more reliable than inferring it from the format.

Frequently asked questions

Does quantization make a model worse?

It introduces small rounding errors, so some loss is possible. With good methods at 8 bits the difference is usually negligible, and at 4 bits it is often small on common tasks but can show on harder ones. The only reliable answer for a given model is to test it on your own tasks.

What do Q4 and Q8 mean?

They indicate roughly 4 or 8 bits per weight. In formats such as GGUF, suffixes like K_M or _0 describe the grouping and rounding scheme, which affects both file size and quality.

How much memory does a quantized model need?

Multiply the number of parameters by the bytes per weight: about 2 bytes at 16 bits, 1 at 8 bits and 0.5 at 4 bits. Add some margin for scales, activations and the KV cache, which grows with context length.

What is the difference between GPTQ and AWQ?

Both are post-training methods for low-bit weight quantization. GPTQ compensates for rounding errors layer by layer using second-order information, while AWQ uses activation statistics to find and protect the most important weights.

Can I fine-tune a quantized model?

Yes, commonly with QLoRA: the base model stays frozen in 4-bit and small LoRA adapters are trained in higher precision. This greatly reduces the memory needed for fine-tuning.

References

  1. Jacob et al. (2017). Quantization and Training of Neural Networks for Efficient Integer-Arithmetic-Only Inference
  2. Dettmers, Lewis, Belkada and Zettlemoyer (2022). LLM.int8(): 8-bit Matrix Multiplication for Transformers at Scale
  3. Frantar, Ashkboos, Hoefler and Alistarh (2022). GPTQ: Accurate Post-Training Quantization for Generative Pre-trained Transformers
  4. Xiao et al. (2022). SmoothQuant: Accurate and Efficient Post-Training Quantization for Large Language Models
  5. Lin et al. (2023). AWQ: Activation-aware Weight Quantization for LLM Compression and Acceleration
  6. Dettmers, Pagnoni, Holtzman and Zettlemoyer (2023). QLoRA: Efficient Finetuning of Quantized LLMs

More in this section

Start free: 50 Cosvexa-1 questions a day

Every major model in one workspace; on the Free plan Cosvexa-1 answers 50 questions a day. No card needed to start.