If you run LLMs locally, you quickly meet quantization. A GGUF model usually comes in a dozen variants: Q8_0, Q6_K, Q5_K_M, Q4_K_M and so on. Which one is right? The rule of thumb is often “Q4_K_M is the best trade-off”, but without numbers that stays an article of faith. This tutorial shows how to run your own GGUF quantization comparison: you create the variants yourself with llama quantize and measure file size, speed, perplexity and KL divergence. I did this with llama.cpp 1.1.0-dev (build 12826) and the model Qwen3.5-0.8B on a machine with 8 CPU cores and no GPU. All measurements are from 2 December 2026. An important caveat up front: they apply to this one small model on this CPU and cannot be carried over unchecked to larger models or a GPU.
What GGUF and quantization mean
GGUF is the file format in which llama.cpp expects models. Besides the weights, it contains the tokenizer and the metadata, so a single file is enough. The GGUF specification describes the layout. Quantization converts the weights from 16 bits per number (BF16 or FP16) to fewer bits, for example 4-bit. The model gets smaller and reads less data from memory, but it loses precision. The question is always how much quality loss you accept for how much space and speed.
The names of the variants can be decoded. In Q4_K_M, Q4 stands for roughly four bits, K for the k-quants method, and M for a medium mix. Mixed means that not all tensors get the same type. I counted this in the log of llama quantize. For Q4_K_M, 132 tensors were stored as q4_K and 27 as q6_K; for Q2_K, 101 as q2_K, 32 as q3_K, 25 as q4_K and one as q6_K. The more sensitive tensors get more bits. That is why the bits per weight that the program prints do not match the number in the name.
Ollama uses the same GGUF files, so the numbers here can help you pick a variant there too, but I measured with llama.cpp only. Other formats such as AWQ or GPTQ are meant for GPU inference with other programs, for example vLLM, and do not appear here. I did not test them. Repositories like unsloth/Qwen3.5-0.8B-GGUF list further variants such as IQ4_XS (one of the i-quants); I did not test those either.
Create the quantizations yourself
As a starting point you need a lossless version, here the BF16 file of the model from Hugging Face. With llama quantize you create the variants from it, as described in the documentation of the quantize tool. The last number is the thread count:
curl -L -O https://huggingface.co/ggml-org/Qwen3.5-0.8B-GGUF/resolve/main/Qwen3.5-0.8B-BF16.gguf
for t in Q8_0 Q6_K Q5_K_M Q4_K_M Q3_K_M Q2_K; do
llama quantize Qwen3.5-0.8B-BF16.gguf q08-$t.gguf $t 8
done
Each conversion took only a few seconds. There is one trap with the source material: llama quantize explicitly warns against requantizing already quantized models with --allow-requantize, because that can severely reduce quality. Always start from the 16-bit file. At the end of the log you find the size and the bits per weight, for example for Q4_K_M:
llama_model_quantize_impl: model size = 1475.05 MiB (16.0104 BPW)
llama_model_quantize_impl: quant size = 511.50 MiB ( 5.5519 BPW)
GGUF quantization comparison, part 1: file size and bits
The first measurement is the simplest. File sizes compared with the BF16 file:
| Variant | File size | Bits per weight |
|---|---|---|
| BF16 | 1558 MB | 16.01 |
| Q8_0 | 834 MB | 8.52 |
| Q6_K | 647 MB | 6.58 |
| Q5_K_M | 595 MB | 6.05 |
| Q4_K_M | 547 MB | 5.55 |
| Q3_K_M | 481 MB | 4.87 |
| Q2_K | 439 MB | 4.43 |
At 5.55 bits per weight, Q4_K_M takes up clearly more than “4 bit” suggests. For this small model there is a concrete reason: the embedding matrix token_embd.weight with its 248,320-token vocabulary is huge and makes up about a third of the model. It is 485 MiB in the BF16 file and was reduced only to q6_K (199 MiB) even in Q4_K_M. In large models its share is smaller, and the bits per weight come closer to the number in the name. So do not extrapolate the size of a 7B or 70B model from my table. I did not measure that. For comparison I measured the 4B model Qwen3.5-4B in Q4_K_M: 3.02 GB for 4.2 billion parameters, which is about 5.75 bits per weight.
Part 2: speed, because fewer bits are not always faster
I measured speed with llama bench: 512 prompt tokens (pp, processing the input) and 128 generated tokens (tg, the actual text output), five repetitions, 8 threads:
llama bench -m q08-Q4_K_M.gguf -p 512 -n 128 -t 8 -r 5
| Variant | Prompt (tokens/s) | Output (tokens/s) |
|---|---|---|
| BF16 | 588 | 41.2 |
| Q8_0 | 911 | 100.9 |
| Q6_K | 963 | 64.1 |
| Q5_K_M | 1177 | 77.9 |
| Q4_K_M | 1198 | 92.2 |
| Q3_K_M | 1160 | 98.9 |
| Q2_K | 1020 | 108.6 |
The picture is less clear than I expected. Every quantization is faster than BF16, and Q8_0 generates text more than twice as fast. But Q8_0 (100.9 tokens/s) is faster than Q6_K (64.1) and Q5_K_M (77.9) even though it is larger. Q4_K_M is the fastest at processing the input, Q2_K at output. A plausible explanation is that the k-quant formats cost the CPU more work when unpacking, but I did not verify that. Note the spread, too: for BF16 the standard deviation of the output was 5.4 tokens/s, and other processes were running on the machine at times. A first series with three repetitions under higher load had given 87 tokens/s for Q8_0 and 37 for Q6_K, clearly different values. So measure on a quiet system and repeat the runs. The takeaway, and it holds for any benchmark: on a CPU you have to measure speed yourself, because file size alone does not predict it. On a GPU it can look different, where VRAM is often the first limit. I did not test that.
How strongly model size drives speed shows in the comparison: the 4B model in Q4_K_M generates 24.3 tokens/s on the same CPU, the 0.8B model in Q4_K_M 92.2. The choice of model therefore matters more than the choice of quantization. Large models like the 4B one cost speed and memory, small ones like the 0.8B are fast but less capable. The answer quality you need decides the model size first and the quantization second.
Part 3: measure the quality loss with perplexity and KL divergence
File size and speed are easy to measure, quality loss is not. llama perplexity offers two measures, neither a benchmark for a specific task but both text metrics. Perplexity says how surprised the model is by a text. Lower is better. I used the WikiText-2 test text with a context of 512 and 120 chunks:
llama perplexity -m q08-Q4_K_M.gguf -f wikitext-2-raw/wiki.test.raw --chunks 120 -t 8
| Variant | Perplexity | Difference to BF16 |
|---|---|---|
| BF16 | 18.98 | – |
| Q8_0 | 19.01 | +0.1 % |
| Q6_K | 19.34 | +1.9 % |
| Q5_K_M | 19.66 | +3.6 % |
| Q4_K_M | 20.10 | +5.9 % |
| Q3_K_M | 23.06 | +21.5 % |
| Q2_K | 92.06 | +385 % |
The order is as expected, and there are two jumps: from Q4_K_M to Q3_K_M the value rises noticeably, and at Q2_K the model is hardly usable. One mistake I almost made: my first run with only 40 chunks showed a worse value for Q5_K_M (17.89) than for Q4_K_M (17.71), the wrong order. The uncertainty of the individual values there was about ±0.5. With 120 chunks and an uncertainty of ±0.35, the order was consistent. If you use few chunks, you can easily fool yourself.
The second measure is more reliable for comparing against the original: KL divergence. It measures how far the probabilities of the quantized version deviate from those of the BF16 version, token by token. You save the output values of the original once and compare each variant against them:
llama perplexity -m Qwen3.5-0.8B-BF16.gguf -f wikitext-2-raw/wiki.test.raw \
--chunks 40 -t 8 --kl-divergence-base kl_base.bin
llama perplexity -m q08-Q4_K_M.gguf -f wikitext-2-raw/wiki.test.raw \
--chunks 40 -t 8 --kl-divergence-base kl_base.bin --kl-divergence
The base file is large: for 40 chunks, kl_base.bin was about 5 GB. Plan for disk space and delete it afterwards. The results:
| Variant | Mean KL divergence | Same top token |
|---|---|---|
| Q8_0 | 0.0080 | 95.7 % |
| Q6_K | 0.0111 | 93.8 % |
| Q5_K_M | 0.0251 | 91.7 % |
| Q4_K_M | 0.0649 | 86.6 % |
| Q3_K_M | 0.1943 | 77.6 % |
| Q2_K | 1.4996 | 46.5 % |
The column “Same top token” (called “Same top p” in the program) says at what percentage of positions the quantized version puts the same token first as the original. That is easier to grasp than the KL divergence itself: with Q4_K_M, roughly every seventh prediction differs from the original, with Q2_K more than every second one. With Q8_0 and Q6_K the deviations stay small. KL divergence is monotonic, even where my first 40-chunk perplexity run got the order mixed up.
A text example: numbers are not answers
To keep the metrics from staying abstract, I gave all variants the same sentence opening and generated the output without randomness (temperature 0). llama completion does this:
llama completion -m q08-Q4_K_M.gguf -p "A lockfile in a package manager is" \
-n 45 --temp 0 -s 1 -no-cnv --no-display-prompt --simple-io -t 8
The outputs (example output, the first words of each):
- BF16: “a file that stores the configuration of a package manager. A lockfile is a file that stores …”
- Q8_0: “a file that contains the configuration for a package manager. A lockfile is a file that contains …”
- Q4_K_M: “a file that stores the configuration of a package manager. It is a file that stores …”
- Q3_K_M: “a file that contains the name of the package manager and the name of the package manager’s source code. …”
- Q2_K: “a file that contains a list of all packages. In a package manager, a lockfile is a file that contains a list of all packages. …”
All five repeat themselves, which is normal for such a small model without a chat format. Something else stands out: Q2_K gives the best sentence in terms of content here, although its perplexity is almost five times that of the original, while Q3_K_M invents a nonsensical definition. A single example proves nothing, but it shows why you should not look at one metric only. Perplexity and KL divergence say something about the distribution over many texts, not about your specific case. So also test a few tasks from your own application.
Plan for memory and VRAM
For hardware planning, file size alone is not what counts. The context (the KV cache) and working buffers come on top of the file. I measured the peak memory of llama bench with a small context (128 prompt tokens, 16 generated tokens):
| Variant | File size | Peak memory |
|---|---|---|
| BF16 | 1558 MB | 1589 MiB |
| Q8_0 | 834 MB | 1759 MiB |
| Q6_K | 647 MB | 1322 MiB |
| Q4_K_M | 547 MB | 1146 MiB |
| Q2_K | 439 MB | 907 MiB |
My machine has 15 GB of RAM, so this was no problem. With a small laptop or a card with 8 GB, the calculation looks different. The need is clearly above the file size, and it shrinks with smaller variants. I did not investigate the outliers for BF16 and Q8_0; I assume the operating system maps the file differently there. The pattern remains: plan a reserve and measure with the context you actually use. On a GPU the same calculation applies to VRAM, except that the model and the cache must fit in completely. I did not test a GPU and therefore give no numbers for a card with 8 or 12 GB. By the way, the tool llama fit-params computes which parameters make a model fit into a device’s memory.
Typical mistakes when comparing
My own runs give five points I would watch for next time. First: too few chunks for perplexity, the order can flip. Second: a busy system during the speed measurement, which made my first series useless. Third: requantizing already quantized files, because that amplifies the quality loss. Fourth: different test texts or context lengths between the variants, which makes the values incomparable. Fifth: concluding from one number to all models. Small models like the one measured here may react more sensitively to 4-bit quantization than large ones. I did not verify that, but it should keep you from reading my tables as law.
Which quantization method to choose?
The numbers give the following for this model and this CPU:
- Q8_0: hardly measurable quality loss (perplexity +0.1 %, 95.7 % same top token), about half the size of BF16 and, on the CPU, even the second-fastest output. The safe choice if memory allows.
- Q5_K_M and Q6_K: smaller than Q8_0 with little loss. On output speed they were slower than Q8_0 and Q4_K_M on my CPU, though.
- Q4_K_M: about 6 % worse perplexity, 86.6 % same top token, at a little over a third of the BF16 size and fast output. A reasonable default when space is tight.
- Q3_K_M: a clear jump in quality loss. Only sensible if Q4_K_M no longer fits into memory.
- Q2_K: not recommended for this small model: the perplexity is almost five times that of the original.
That is not a recommendation for every model. I measured quality on a single small model only, without a GPU and without an importance matrix. The llama package I used does not include an imatrix command (llama help all does not list it), so I could not check that optimization. Nor did I test the other i-quant variants or measure how quantization affects specific tasks. Perplexity and KL divergence measure prediction on a text, not the quality of your answers. So check your application with your own examples before you settle on a variant.
What I did not measure
To make the limits clear, here is what the numbers above do not contain. There is no measurement on a graphics card, neither an RTX card nor Metal on Apple Silicon. On such devices the order of the speeds can look different from my CPU. I measured no larger model with 7B or 70B parameters and no mixture-of-experts model such as Mixtral, where the weights are distributed differently. Whether a model still runs well with 16 GB of RAM depends on the model, the context and the variant, and you can only answer it by trying. Methods such as bitsandbytes, which loads models in Python in 4-bit, work differently from GGUF and are not comparable. And whether a quantized variant is suitable for later fine-tuning, I did not examine.
How to repeat the measurement for your model
To repeat this for your model, you need three things. First, the 16-bit file as a reference and the variants you are considering, either created yourself or downloaded from Hugging Face. Second, llama bench for speed, with at least five repetitions on a quiet system. Third, llama perplexity with enough chunks and, if you have the disk space, with the KL divergence against the original. How to run the model as a server afterwards and connect it through an API is covered in the tutorial Run a Local LLM with llama.cpp Server. How to connect a local model to your own documents is shown in the tutorial Local RAG with Python. We reported on the project’s news itself in the article on llama.cpp v1.0.0. You will find more background on models in the Hugging Face Hub in the GGUF documentation.




