When you download a local AI model from Hugging Face, you usually face a long list of files: Q2_K, Q3_K_M, IQ4_XS, Q4_K_M, Q5_K_S, Q6_K, Q8_0 and more. They are all the same model, squeezed to different sizes.
Picking the wrong one means either a model that does not fit in your GPU or one that is needlessly dumb.
This guide explains GGUF quantization in plain English. You will learn what the letters and numbers mean, how K-quants differ from I-quants, what an importance matrix (imatrix) does, how much VRAM each type needs, and which file to pick for 8 GB, 12 GB, 16 GB and 24 GB cards.
It also shows how to make your own quants with llama-quantize, using the official llama.cpp documentation as of November 2026, including its benchmark table for Llama 3.1 8B.
- Default pick: Q4_K_M. About 4.9 bits per weight, roughly 30% of the original 16-bit size, with small quality loss.
- Spare VRAM? Q5_K_M or Q6_K for better quality. Q8_0 is close to lossless but about twice the size of Q4.
- Short on VRAM? IQ4_XS or Q3_K_M. Below 3 bits, prefer I-quants made with an imatrix.
- Rule of thumb: file size + 1 to 3 GB for context should fit in VRAM.
- Bigger model at lower quant often beats a smaller model at higher quant, down to about Q3.
- Make your own:
llama-quantize model-bf16.gguf model-Q4_K_M.gguf Q4_K_M.
What Quantization Does
A model is mostly a huge list of numbers called weights. Models are trained and released in 16-bit (BF16 or FP16) or 32-bit precision. Quantization stores those weights with fewer bits, for example 4 bits instead of 16.
- Smaller files: a 4-bit model is roughly a quarter to a third of the 16-bit size.
- Less memory: the model fits on cheaper GPUs, or in system RAM.
- Often faster: text generation is limited by memory bandwidth, so smaller weights usually generate tokens faster.
- Some accuracy loss: measured as perplexity (PPL) or KL divergence (KLD) against the original. The fewer the bits, the bigger the loss.
GGUF is the file format used by llama.cpp and every app built on it, including Ollama, LM Studio, Jan, KoboldCpp and GPT4All. One GGUF file holds the weights, the tokenizer and the model settings.
The llama.cpp docs give a clear example with Llama 3.1. The 8B model shrinks from 32.1 GB (full precision) to 4.9 GB at Q4_K_M, and the 70B from 280.9 GB to 43.1 GB.
How to Read GGUF Quant Names
| Part | Meaning | Example |
|---|---|---|
Q + number |
Roughly the bits per weight for most tensors | Q4 = about 4 bits |
_K |
K-quant: a smarter block-wise method with mixed precision | Q4_K_M |
_S / _M / _L |
Small, Medium, Large mix: how many important tensors get extra bits | Q3_K_S < Q3_K_M < Q3_K_L |
IQ + number |
I-quant: newer, more compact types, best with an imatrix | IQ4_XS, IQ2_M |
XXS / XS / S / M / NL |
I-quant size variants; NL = non-linear | IQ3_XXS, IQ4_NL |
Q8_0, Q4_0, Q5_1 |
Legacy quants: simpler, older methods | Q8_0 is still popular |
F16 / BF16 / F32 |
Unquantized | Source files for making quants |
So Q4_K_M reads as “about 4 bits, K-quant method, medium mix”. The medium mix gives some sensitive tensors (parts of attention and feed-forward layers) more bits, which is why it lands at about 4.9 bits per weight rather than exactly 4.
Every Quant Type Compared
This table comes from the official llama.cpp quantize documentation, measured on Llama 3.1 8B. Speeds depend on hardware, so compare them relative to each other rather than as absolute numbers.
| Quant | Bits/weight | Size (GiB) | Generation t/s | Quality |
|---|---|---|---|---|
| IQ1_S | 2.00 | 1.87 | 79.7 | Very poor, emergency only |
| IQ2_XXS | 2.38 | 2.23 | 79.9 | Poor |
| IQ2_M | 2.93 | 2.74 | 74.4 | Usable on large models |
| Q2_K | 3.16 | 2.95 | 79.9 | Weak |
| IQ3_XXS | 3.25 | 3.04 | 74.0 | Fair |
| Q3_K_M | 4.00 | 3.74 | 71.7 | Fair to good |
| IQ4_XS | 4.46 | 4.17 | 77.5 | Good, compact |
| Q4_K_S | 4.67 | 4.36 | 76.7 | Good |
| Q4_K_M | 4.89 | 4.58 | 71.9 | Good, the usual default |
| Q5_K_M | 5.70 | 5.33 | 67.2 | Very good |
| Q6_K | 6.56 | 6.14 | 58.7 | Excellent |
| Q8_0 | 8.50 | 7.95 | 50.9 | Near lossless |
| F16 | 16.00 | 14.96 | 29.2 | Original |
Two things stand out. First, generation speed roughly tracks file size: F16 is the slowest and the 2 to 4-bit types are fastest. Second, the jump in quality from Q4_K_M to Q8_0 is small compared with the jump in size, which is why Q4_K_M is the community default.
The “Quality” column is a general guide from the community and is not part of the llama.cpp table. Exact loss varies by model, so check the uploader’s perplexity or KLD numbers when they publish them.
K-Quants vs I-Quants vs Legacy
| Family | Examples | Strengths | Weaknesses |
|---|---|---|---|
| K-quants | Q3_K_M, Q4_K_M, Q5_K_M, Q6_K | Great quality per bit, fast on every backend, the safe choice | Not the smallest at very low bits |
| I-quants | IQ2_M, IQ3_XXS, IQ4_XS, IQ4_NL | Best quality at 2 to 4 bits, very compact | Can be slower on some CPUs and older backends; need an imatrix to shine |
| Legacy | Q4_0, Q5_0, Q8_0 | Simple and widely supported; Q8_0 is excellent | Q4_0 and Q5_0 are worse than K-quants of the same size |
In practice, use K-quants from Q3_K_M upwards, Q8_0 when you want near-original quality, and I-quants when you must go below about 4 bits to fit a model.
What Is an Imatrix?
An importance matrix is a small file made by running the model over sample text and recording which weights matter most. llama-quantize then protects those weights when it rounds the rest.
- It improves every quant type, but the gain is biggest at 2 to 3 bits.
- Most good uploaders now publish “imatrix” or “i1” quants. Look for those names in the repo or model card.
- The calibration text matters a little: a quant tuned on English chat text is still fine for coding in most cases, but specialised uploads exist.
When you see two Q4_K_M files from different uploaders, the one made with an imatrix is usually the better pick.
Which Quant to Pick for Your GPU
Use this rule: model file size + context memory + about 1 GB overhead must fit in VRAM. Context (the KV cache) needs roughly 0.5 to 2 GB for 8K tokens on mid-size models and grows with longer context. Our Ollama context length guide explains how to control it.
| VRAM | Good choices (all fully on GPU) |
|---|---|
| 6 GB | 7-8B at Q4_K_M with short context, or 4B at Q6_K |
| 8 GB | 7-8B at Q4_K_M or Q5_K_M; 12-14B at IQ3_XXS or Q3_K_M |
| 12 GB | 12-14B at Q4_K_M; 7-8B at Q8_0 |
| 16 GB | 14B at Q6_K, 20-24B at Q4_K_M, about 30B at IQ3 |
| 24 GB | 27-32B at Q4_K_M or Q5_K_M; 14B at Q8_0 |
| 32 GB and up | 32B at Q6_K/Q8_0, 70B at IQ3 or Q3_K_M |
Mixture-of-experts (MoE) models are a special case. All experts must be loaded, but only a few are active per token, so a MoE model can run acceptably with part of it in system RAM. Size your RAM plus VRAM for the whole file.
A quick size estimate: parameters (billions) x bits per weight / 8 = GB. A 14B model at Q4_K_M (4.9 bits) is about 14 x 4.9 / 8 = 8.6 GB.
Bigger Model or Better Quant?
For the same file size, a larger model at a lower quant usually beats a smaller model at a higher quant, as long as you stay at about Q3_K_M or above. A 14B model at Q4_K_M is generally smarter than an 8B at Q8_0, and they are similar in size.
Below 3 bits the picture flips: quality can drop sharply, models repeat themselves, ignore instructions or break code. Coding and maths suffer first. If a 2-bit quant is the only way to fit a model, try the next size down at Q4 as well and compare.
Make Your Own Quants With llama-quantize
You need llama.cpp built on your machine and its Python requirements. The process has two steps: convert the original model to a 16-bit GGUF, then quantize it. Our convert a model to GGUF guide covers the conversion step in depth.
- Install requirements in the llama.cpp folder:
python3 -m pip install -r requirements.txt - Convert the Hugging Face model to BF16 GGUF:
python convert_hf_to_gguf.py --outfile model-bf16.gguf --outtype bf16 --remote org/model-name(drop--remoteand give a folder path for a local download). - Optional but recommended: create an imatrix with the
llama-imatrixtool and some calibration text. - Quantize:
./build/bin/llama-quantize --imatrix imatrix.gguf model-bf16.gguf model-Q4_K_M.gguf Q4_K_M - Test it:
./build/bin/llama-cli -m model-Q4_K_M.ggufor load it in your favourite app.
Useful llama-quantize options
| Option | What it does |
|---|---|
--imatrix file |
Use an importance matrix |
--dry-run |
Show what would happen without writing a file |
--target-bpw 4.5 |
Let the tool choose types per tensor to hit an average bits-per-weight |
--target-size 1.5g |
Choose types to hit a file size |
--output-tensor-type q8_0 |
Keep the output layer at higher precision |
--tensor-type attn_v=q5_k |
Override the type for matching tensors (regex supported) |
--keep-split |
Keep the same shard layout as the input |
--allow-requantize |
Quantize an already-quantized file (quality suffers; avoid if you can) |
For multimodal models, keep the vision or audio projector (mmproj) at BF16 or Q8_0. The docs explain that it is small, so a smaller quant saves little but can hurt image understanding.
No GPU or setup? The GGUF-my-repo space on Hugging Face makes quants in the browser and syncs with llama.cpp every six hours.
Using Quants in Ollama, LM Studio and llama.cpp
- Ollama: library tags often name the quant, for example
:q4_K_Mor:q8_0. To pull a specific GGUF from Hugging Face, useollama run hf.co/user/repo:Q5_K_M; see our Ollama Hugging Face GGUF guide. - LM Studio: the download panel lists every quant and marks which ones fit your GPU fully, partly or not at all.
- llama.cpp: pass the file with
-m, or pull from Hugging Face with-hf user/repo:Q4_K_M. Our llama-server guide shows the full server setup.
Troubleshooting
| Problem | Fix |
|---|---|
| Model loads but is very slow | Part of it spilled to system RAM. Pick a smaller quant or reduce context so it fits fully in VRAM. |
| Out of memory when loading | File + context is too big. Drop one quant level or halve the context length. |
| Gibberish or endless repetition | Quant too low (often Q2 or IQ1/IQ2 on small models). Move up to Q3_K_M or Q4_K_M. |
| I-quant slower than expected on CPU | Some backends are slower with I-quants. Try a K-quant of similar size. |
| “unknown model architecture” when loading | The app’s llama.cpp is too old for this model. Update the app. |
| Requantized file is poor quality | Always quantize from BF16/F16, not from another quant. |
| Vision model cannot read images well | Use an mmproj at Q8_0 or BF16. |
FAQ
Is Q4_K_M or Q5_K_M better?
Q5_K_M is slightly more accurate and about 16% larger. If it fits fully in VRAM with your context, use it; otherwise Q4_K_M is the better trade.
Is Q8_0 worth it?
Q8_0 is near lossless, but it is almost twice the size of Q4_K_M and generates more slowly. It makes most sense for small models or when you have plenty of VRAM.
What does the K mean in Q4_K_M?
It marks a K-quant, a block-wise method that gives important tensors more bits. The M means a medium mix of those extra bits.
Are I-quants better than K-quants?
At 2 to 4 bits, I-quants made with an imatrix usually give better quality per gigabyte. At 4 bits and above, K-quants are just as good and run fast everywhere.
How much VRAM does a 7B model need?
About 4.5 GB for the file at Q4_K_M plus 1 to 2 GB for context and overhead, so 6 to 8 GB in total.
Does quantization make models faster?
Usually yes for text generation, because less data moves through memory per token. Prompt processing speed changes less.
What is the difference between GGUF and GPTQ, AWQ or EXL2?
GGUF is the llama.cpp format and runs on CPU, Nvidia, AMD, Intel and Apple. GPTQ, AWQ and EXL2 are mainly GPU formats used by other runtimes such as vLLM or ExLlama.




