LLM Quantization Explained: Big Models on Small Hardware

LLM quantization explained: a large 16-bit model compressed into a smaller 4-bit model

If you have ever tried to run an AI model on your own laptop, you have probably hit the same wall: the model is simply too big. Google lists the original Gemma 3 27B model at about 54 GB just to load its weights. That is far more than any consumer graphics card offers. Quantization is the main reason the same model can now run on a 24 GB GPU.

This guide explains what quantization is, how it works, and what it actually costs you in quality. The numbers come from Google's own release notes and two research studies, not from marketing claims.

Quick answer: Quantization stores a model's weights using fewer bits, for example 4 or 8 instead of 16. That cuts weight memory by roughly 2x to 4x. In a large study of Llama-3.1 models, 8-bit floating point was effectively lossless, 8-bit integer lost about 1 to 3 percent per task on average, and 4-bit weight-only quantization performed close to 8-bit integer. For most local setups, a 4-bit K-quant such as Q4_K_M is a sensible starting point.

What Is LLM Quantization?

An AI model is a huge collection of numbers called weights. Models are usually released with each weight stored in 16 bits. Quantization replaces those 16-bit numbers with lower-precision ones, usually 8 bits or 4 bits.

Google describes it with a simple comparison: it is like compressing an image by using fewer colors. You lose a little detail, but the file becomes much smaller. The model is still the same model. It just stores its knowledge in a more compact form.

Why Models Take So Much Memory

The math is simple. Weight memory is roughly the number of parameters multiplied by the bytes used per weight. A 16-bit weight uses 2 bytes, an 8-bit weight uses 1 byte, and a 4-bit weight uses half a byte.

Precision Bytes per weight 8B model 70B model
16-bit (BF16/FP16) 2 about 16 GB about 140 GB
8-bit 1 about 8 GB about 70 GB
4-bit 0.5 about 4 GB about 35 GB

These are simple weight-only estimates. Real files come out slightly larger because quantized formats also store scaling values. In one llama.cpp test, a Llama-3.1-8B model went from about 15 GiB in 16-bit to about 4.6 GiB as a Q4_K_M file. Running the model needs extra memory on top of that (more on this below).

Google's published Gemma 3 figures match the math closely. The 27B model drops from 54 GB in BF16 to 14.1 GB in int4. The 12B model goes from 24 GB to 6.6 GB, and the 4B model from 8 GB to 2.6 GB.

How Quantization Works (Without the Heavy Math)

The basic idea has three steps:

  1. Take a small group of weights, for example 32 of them.
  2. Find a scale factor that maps their range onto a small set of integers, such as the 16 values a 4-bit number can hold.
  3. Store the small integers plus the scale. At run time, the model uses those integers together with the scale, so the result is a close approximation of the original weights.

A January 2026 study of llama.cpp formats describes this as block-wise quantization: each block of weights gets its own scale, and the authors note that finer grouping often improves quality at the same nominal bit-width. That is one reason two "4-bit" files can behave differently.

Some quantization tools go further. They use a small calibration dataset to measure which weights matter most, then try to protect those weights from heavy rounding. This is where methods like GPTQ and AWQ come in.

Post-Training Quantization vs Quantization-Aware Training

There are two ways to get a quantized model.

Post-training quantization (PTQ) takes a finished model and compresses it afterward. It is fast and cheap, and many community GGUF files you download are made this way.

Quantization-aware training (QAT) simulates low precision during training, so the model learns to stay accurate even after compression. Google used this approach for its official Gemma 3 int4 releases. According to Google, QAT reduced the perplexity drop by 54 percent when quantizing to Q4_0, measured with llama.cpp. That is a real gain, but it needs extra training, so it is usually done by the model's creator.

Common Quantization Formats

You will see many names when you browse model pages. These are the ones that matter most:

Format What it is Best for
GGUF The file format used by llama.cpp, Ollama and LM Studio, with weight-only presets like Q4_K_M, Q5_K_M and Q8_0 Running models locally on laptops and desktops
GPTQ A post-training method that adjusts weights using second-order information and calibration data 4-bit weights on GPU serving stacks
AWQ An activation-aware method that protects the most important weights during compression 4-bit weights on GPU inference
FP8 / INT8 (W8A8) Both weights and activations stored in 8 bits High-throughput production serving on modern GPUs
QAT checkpoints Models trained with quantization built in, such as Google's Gemma 3 QAT releases Cases where the vendor ships an official version

How to Read a Name Like Q4_K_M

The "Q4" means roughly 4-bit. The "K" marks the newer K-quant family, which groups weights into larger 256-weight super-blocks with extra scale data to keep quality up. The final letter is the variant size: S, M or L (small, medium, large), where larger variants spend a bit more memory for better quality. Older names such as Q4_0 belong to the original, simpler scheme.

The "4" is also a nominal number. The same study estimates that Q4_K_M works out to about 4.5 bits per weight once the scale data is counted.

One more detail from the Qwen documentation: llama.cpp can use an importance matrix (imatrix) built from sample data to lower quantization error. The documentation warns that skipping it matters most for very low-bit mixtures (1-bit and 2-bit).

How Much Quality Do You Actually Lose?

The best large-scale answer comes from a study by Red Hat AI and the Institute of Science and Technology Austria, published at ACL 2025. The researchers ran over 500,000 evaluations across the Llama-3.1 model family. Their main findings:

  • FP8 (8-bit floating point, weights and activations) was effectively lossless across all model sizes.
  • Well-tuned INT8 (W8A8-INT) lost about 1 to 3 percent per task on average. That is far less than the 10 percent or larger drops reported in earlier work.
  • INT4 weight-only quantization (W4A16-INT) was competitive with 8-bit integer, which surprised many people.
  • In their tests, a simple variant of GPTQ outperformed AWQ on real-world tasks.

The study also looked at speed and cost. It found that 4-bit weights gave the best cost-efficiency for synchronous deployments, while 8-bit formats did better for high-throughput continuous batching on high-end GPUs.

What the llama.cpp Numbers Show

A separate January 2026 study tested llama.cpp's GGUF formats on a single model, Llama-3.1-8B-Instruct, across five benchmarks. The pattern was clear:

  • The 16-bit baseline averaged 69.47 across the benchmarks. Q4_K_M averaged 69.15 and Q8_0 averaged 69.41, so both stayed very close.
  • The smallest 3-bit format (Q3_K_S) fell to an average of 65.49. On the GSM8K math benchmark it dropped from 77.63 to 68.31, about 9 points.
  • Q4_K_M kept GSM8K at 77.41, essentially matching the original.
  • The format mattered, not just the bit count. Different 5-bit formats with nearly the same perplexity scored quite differently on math and instruction-following.

The same study notes that some mid-bit formats scored slightly above the 16-bit baseline, and warns that tiny gains like that can simply be noise. A related line of research cited in the study also suggests that very aggressive low-bit settings can be risky for multi-step reasoning.

An honest caveat: both studies cover specific Llama-3.1 models and specific benchmarks. A different model, a niche language, a long-context workload or a strict coding task can behave differently. Treat the numbers as a strong starting point, then test on your own task.

Quantization Does Not Shrink Everything

A common mistake is assuming a 4-bit model needs exactly one quarter of the memory. Google itself notes that its VRAM figures cover only the model weights. Running the model also needs memory for the KV cache, which stores the ongoing conversation, and that grows with context length.

So a model that loads fine can still run out of memory when you paste in a long document. If you plan to run models on your own machine, leave headroom beyond the file size. Our guide on running LLMs locally covers the hardware side in more detail.

How to Choose the Right Quantization Level

  1. Start with a 4-bit K-quant. Q4_K_M is a common default and stayed very close to the original in the llama.cpp test above.
  2. Move up if you have spare memory. Q5_K_M, Q6_K and Q8_0 get progressively closer to the original model. Q8_0 is described as very close to lossless.
  3. Be careful below 4 bits. In the test above, the smallest 3-bit format lost the most, especially on math. Check results on your real prompts before using it.
  4. Consider a bigger model at 4-bit. Many practitioners find a larger model at 4-bit beats a smaller model at 8-bit on the same hardware. This is a rule of thumb, so run a quick comparison yourself.
  5. Test on your own task. A short set of 20 to 30 real prompts tells you more than any general benchmark.

Quantizing a Model Yourself

With llama.cpp, quantizing a GGUF file is a single command. This example from the Qwen documentation converts a 16-bit model to 8-bit:

./llama-quantize Qwen3-8B-F16.gguf Qwen3-8B-Q8_0.gguf Q8_0

Replace Q8_0 with Q4_K_M or another preset to change the bit level. In most cases, though, you can simply download a ready-made quantized file instead.

Common Mistakes to Avoid

  • Judging by file size alone. Context length and the KV cache add memory on top of the weights.
  • Assuming all 4-bit files are equal. A Q4_0 file, a K-quant and an official QAT model can differ in quality.
  • Trusting one benchmark. Perplexity does not always predict how a model behaves on your own task.
  • Ignoring the hardware. The Red Hat study found that the best format depends on the GPU and the deployment style.

Frequently Asked Questions

What does quantization do to an AI model?

It stores the model's weights in fewer bits, such as 8 or 4 instead of 16. This reduces memory use and file size, usually with a small loss in accuracy.

Is a 4-bit model much worse than the original?

Not necessarily. In the Red Hat and ISTA study, 4-bit weight-only quantization performed close to 8-bit integer quantization, and in the llama.cpp test Q4_K_M stayed close to the 16-bit baseline. Results still vary by model and task, so test your own use case.

Does quantization make models faster?

It can, but not always. Smaller weights mean less data to move, which often helps. The actual gain depends on the format, the hardware and how requests are batched.

What is the difference between PTQ and QAT?

PTQ compresses a finished model afterward. QAT builds quantization into training so the model adapts to low precision. QAT usually keeps quality better but needs extra training, so it is usually done by the model's creator.

Which quantization should a beginner use?

A 4-bit K-quant such as Q4_K_M is a good first choice. If you have extra memory and want a bigger quality margin, try Q5_K_M or Q8_0.

Final Verdict

Quantization is what turns large AI models from data-center-only tools into something you can run on hardware you already own. The data shows that 8-bit formats lose little or nothing (FP8 was effectively lossless, INT8 lost about 1 to 3 percent) and that well-made 4-bit weights are competitive, which is why 4-bit has become the everyday default for local AI. The key is to remember what the numbers cover: specific Llama-3.1 models and specific benchmarks. Pick a sensible starting format, leave memory headroom for context, and test on your real prompts before settling on one.

You Might Also Like

Comments

Popular posts from this blog

AI Evaluation Explained: How to Know If Your AI Agent Is Actually Working

What Is Open-Source AI? Why It's Reshaping the Industry in 2026

What Is Agentic Commerce? How AI Agents Are Starting to Shop in 2026