cd /news/large-language-models/q4-k-m-vs-q5-k-m-vs-q8-0-which-gguf-… · home › topics › large-language-models › article
[ARTICLE · art-176398] src=dev.to ↗ pub= topic=large-language-models verified=true sentiment=· neutral

Q4_K_M vs Q5_K_M vs Q8_0: which GGUF quant should you use?

A developer's comparison of llama.cpp GGUF quantization formats recommends Q4_K_M as the default choice, citing llama.cpp figures of 4.89 bits per weight and a +0.1754 perplexity increase on Llama 3.1 8B, versus +0.0569 for Q5_K_M and +0.0026 for Q8_0. The writeup explains that _K k-quants group weights into 256-weight super-blocks with per-sub-block scales, and that _S/_M/_L suffixes control how many sensitive tensors (attn_v, ffn_down) are promoted to higher precision. It notes Q4_K_M costs only about 0.22 GiB more than Q4_K_S while cutting perplexity damage from +0.2689 to +0.1754, and warns that damage jumps sharply below 4 bits, with Q2_K adding roughly 20 times the perplexity of Q4_K_M.

recommendation

Default to Q4_K_M for GGUF serving and step up to Q5_K_M or Q6_K only when the file plus context fits your VRAM; avoid Q3 and Q2 quants, which sharply increase perplexity.

more in playbook: Inference and self-hosting
by read10 min views2 publishedNov 25, 2026

Use Q4_K_M unless your memory budget clearly fits something bigger: llama.cpp's published figures put it at 4.89 bits per weight on Llama 3.1 8B and +0.1754 perplexity on Llama-3-8B, against +0.0569 for Q5_K_M and +0.0026 for Q8_0. On Nodus you can test the quant on the GPU you plan to serve it on, with an RTX 4090 listed at $0.29/hr and an A100 80 GB at $1.09/hr on the Nodus pricing page. Step up to Q5_K_M or Q6_K when the file plus your context still fits, and treat Q3 and Q2 quants as a last resort.

The number is the bit width of most weights, the letter after it is the quantization family, and the suffix is the mix. Q8_0 and Q4_0 are the older "legacy" formats. The Hugging Face GGUF docs describe them as round-to-nearest quantization in blocks of 32 weights, each block with one scale, and note they are "not used widely as of today".

The _K types are k-quants, added to llama.cpp in pull request #1684. They group weights into super-blocks of 256 and store a small scale (and for some types a minimum) per sub-block. Per the Hugging Face table, that gives the base Q4_K type 4.5 bits per weight, Q5_K 5.5, Q6_K 6.5625 and Q2_K 2.625. Q8_0 is still the common 8-bit choice because at 8 bits the simple scheme is already close to lossless.

A file named Q4_K_M is never 4.5 bits everywhere. It is a recipe that keeps some tensors at higher precision, which is why the llama.cpp quantize README measures Q4_K_M at 4.8944 bits per weight on Llama 3.1 8B.

_S, _M and _L mean small, medium and large: how many sensitive tensors get promoted to a higher-bit type. The rules live in src/llama-quant.cpp, and they are short enough to summarize.

In Q4_K_M, the attention value (attn_v) and feed-forward down projection ( ffn_down) tensors are stored as Q6_K in roughly half the layers: the first eighth, the last eighth and every third layer in between. Everything else stays Q4_K.

Q4_K_S only promotes ffn_down to Q5_K in the first eighth of layers and attn_v in the first four. Q5_K_M follows the same pattern as Q4_K_M, with Q6_K on top of a Q5_K base. _L exists only for Q3 (Q3_K_L), where it pushes those tensors to Q5_K.

The cost of _M over _S is small. On Llama 3.1 8B the README lists Q4_K_S at 4.36 GiB and Q4_K_M at 4.58 GiB, about 5% more. The quantize tool's own table lists the perplexity increase falling from +0.2689 to +0.1754 for that step. If you can afford the extra 0.22 GiB, take the _M.

Less than most people expect down to 4 bits, and a lot below 3. The table combines the two figures llama.cpp publishes: bits per weight and file size from the README benchmark on Llama 3.1 8B, and the perplexity change listed in quantize.cpp, measured on Llama-3-8B. Perplexity is how surprised the model is by held-out text, so a bigger increase means more damage.

Quant Bits per weight Llama 3.1 8B file Perplexity change
Q2_K 3.1593 2.95 GiB +3.5199
Q3_K_M 3.9960 3.74 GiB +0.6569
Q4_0 not in README table 4.34 G (quantize.cpp) +0.4685
Q4_K_S 4.6672 4.36 GiB +0.2689
Q4_K_M 4.8944 4.58 GiB +0.1754
Q5_K_M 5.7036 5.33 GiB +0.0569
Q6_K 6.5633 6.14 GiB +0.0217
Q8_0 8.5008 7.95 GiB +0.0026
F16 16.0005 14.96 GiB +0.0020 (on Mistral-7B)

Sources: llama.cpp quantize README and quantize.cpp, checked November 25, 2026.

Damage grows slowly down to Q4_K_M, then jumps: Q2_K adds 20 times the perplexity of Q4_K_M.

Two things stand out. Q4_0 is nearly the same size as Q4_K_S but adds 0.4685 to perplexity instead of 0.2689, so there is little reason to pick it for a new file. And the curve is not linear: going from Q4_K_M to Q3_K_M saves under 0.9 bits per weight and almost quadruples the loss.

Perplexity is one number on one model. It does not tell you how a quant handles your tool calls or your language. Treat these figures as the ranking and your own eval as the verdict.

File size is parameters times bits per weight divided by 8. The README gives the inputs: Llama 3.1 8B is 32.1 GB at F32 (4 bytes per weight), so 32.1 / 4 = 8.03 billion weights. Llama 3.1 70B is 280.9 GB at F32, so 280.9 / 4 = 70.2 billion.

For the 8B at Q4_K_M: 8.03B x 4.8944 / 8 = 4.91 GB. The README's 4.58 GiB is 4.92 GB, so the formula holds. For the 70B at Q4_K_M: 70.2B x 4.8944 / 8 = 42.9 GB, against 43.1 GB in the README's own memory table. The 70B mix differs slightly from the 8B one, so treat the other 70B rows as close estimates.

A 70B at Q4_K_M is 42.9 GB, under a third of the 140.4 GB F16 file.

The same arithmetic for the 70B gives 27.7 GB at Q2_K, 35.1 GB at Q3_K_M, 41.0 GB at Q4_K_S, 50.0 GB at Q5_K_M, 57.6 GB at Q6_K, 74.6 GB at Q8_0 and 140.4 GB at F16. For the 8B: 3.17, 4.01, 4.68, 5.72, 6.59, 8.53 and 16.06 GB.

The file is not the whole bill, because the KV cache grows with context.

Both Llama configs use 8 KV heads of 128 dimensions, with 32 layers in the 8B and 80 in the 70B. At 16 bits that is 2 x 32 x 8 x 128 x 2 = 131,072 bytes per token for the 8B and 2 x 80 x 8 x 128 x 2 = 327,680 bytes for the 70B. An 8,192-token context adds 1.07 GB and 2.68 GB respectively.

Our rule: take the largest quant whose file plus the KV cache for your real context fits, with room left for compute buffers. If two quants fit, take the larger one. The table applies that rule at an 8,192-token context using the numbers above.

Memory 8B model 70B model
8 GB Q5_K_M (5.72 + 1.07 = 6.79 GB), Q4_K_M (5.98 GB) for longer context does not fit
12 GB Q8_0 (8.53 + 1.07 = 9.60 GB) does not fit
16 GB Q8_0, with room for longer context does not fit
24 GB F16 (16.06 + 1.07 = 17.13 GB) does not fit, even Q2_K needs 30.4 GB
48 GB F16 Q4_K_M (42.9 + 2.68 = 45.6 GB), tight
64 GB F16 Q6_K (57.6 + 2.68 = 60.3 GB)
80 GB F16 Q8_0 (74.6 + 2.68 = 77.3 GB), tight
96 GB F16 Q8_0, with room for longer context

Longer contexts shift every row down. At 32,768 tokens the 70B cache alone is 10.7 GB, which pushes a 48 GB card from Q4_K_M to Q3_K_M. For which models fit on common consumer cards, see which LLMs fit in 8, 16 or 24 GB, and for the 70B case in detail, how much VRAM a 70B model needs.

Q4_K_M wins as the default for chat and agents on a fixed memory budget. It is under a third of F16 and the curve is still flat at that point.

Q5_K_M and Q6_K win when the larger file fits with your context. They cut the perplexity increase to +0.0569 and +0.0217, a cheap upgrade if you have 1 to 2 GB to spare on an 8B.

Q8_0 wins as the reference copy. At +0.0026 it is effectively the original model, so when a fine-tune behaves badly, compare against Q8_0 first to learn whether training or quantization caused it.

F16 or BF16 wins as the master file you quantize from. The README warns that requantizing an already-quantized file "can severely reduce quality". Keep the 16-bit GGUF and make every other quant from it.

Speed is a smaller factor than people assume. In the README benchmark on Llama 3.1 8B, text generation ran at 71.93 tokens per second on Q4_K_M, 67.23 on Q5_K_M, 58.67 on Q6_K, 50.93 on Q8_0 and 29.17 on F16. The README does not say which machine produced these, so read them as relative.

Smaller files usually generate faster, because generating each token means reading the weights from memory.

Almost always. Q2_K adds +3.5199 perplexity on Llama-3-8B, 20 times Q4_K_M, to save about 1.7 GB on an 8B. If a model only fits at Q2_K, a smaller model at Q4_K_M or Q5_K_M is usually the better trade. Q3_K_M is defensible when it is the only way a 70B fits and you have tested it on your task.

Below 4 bits, use an importance matrix. The README says accuracy loss "can be minimized by using a suitable imatrix file", which llama-quantize takes through --imatrix.

Convert once to a 16-bit GGUF, then quantize that file as many times as you like. These commands are copied from the llama.cpp quantize README:

python convert_hf_to_gguf.py --outfile gemma-4-E2B-it-bf16.gguf --outtype bf16 --remote google/gemma-4-E2B-it
./build/bin/llama-quantize gemma-4-E2B-it-bf16.gguf gemma-4-E2B-it-Q4_K_M.gguf Q4_K_M

Swap the last argument for Q5_K_M, Q6_K or Q8_0 to get the other files. Plan for memory and disk: the README says the input is loaded fully into memory and gives 280.9 GB for an F32 70B. If you do not want to install anything, the README also points to the GGUF-my-repo space on Hugging Face.

Quantizing is not where the GPU money goes. When we wrote our guide to fine-tuning a model for Ollama, llama.cpp conversion and quantization of our small test model ran on CPU only. That post covers the full export path, so we will not repeat it here.

The GPU time is in two places: training the model and checking the quant. Nodus runs fine-tunes as TrainingJobs on the cheapest capacity that will finish them, with checkpoints and recovery if a machine is lost.

When a Job names a 7B or 8B model, the Nodus Jobs guide sets a default memory floor of 24Gi, enough for a LoRA or QLoRA run. Checking the quant is a short Job on the hardware you will serve on: an hour on an RTX 4090 is listed at $0.29 on the Nodus pricing page, and an A100 80 GB, enough for a 70B at Q6_K with room for context, at $1.09. If the model will serve many users rather than one, compare llama.cpp with a server built for batching in vLLM vs Ollama.

Prices checked November 25, 2026.

For many models it is the common default, and llama.cpp's figures show only +0.1754 perplexity on Llama-3-8B. Code and tool calling punish small errors, so if you have the memory, run your own coding eval on Q4_K_M and Q6_K and keep the smaller one only if it scores the same.

No. Q8_0 is a GGUF format for llama.cpp with one scale per 32 weights, while FP8 or bitsandbytes 8-bit are different formats for different runtimes. A Q8_0 file only loads in GGUF-compatible tools such as llama.cpp and Ollama.

IQ types such as IQ4_XS (4.4597 bits per weight in the README) use an importance matrix, per the Hugging Face GGUF docs, and the family reaches down to about 2 bits. They make most sense below 4 bits. At 4 bits and above, the K-quants are the simpler default.

Yes. Run the fine-tune as a TrainingJob on Nodus, download the weights it writes, merge any adapter, then convert and quantize with llama.cpp as shown above. Our Ollama export guide walks through that path.

Originally published on the Nodus blog.

── more in #large-language-models 4 stories · sorted by recency
── more on @llama.cpp 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/q4-k-m-vs-q5-k-m-vs-…] indexed:0 read:10min 2026-11-25 · —