Q4_K_M Is 4.9 Bits per Weight

🔧 AI Tools 2026-11-29 7 min read
Q4_K_M Is 4.9 Bits per Weight: 6 GGUF Models Measured for 8 to 32 GB

The model fits, the download finished, and the first long prompt still throws an out-of-memory error. The weight file was only half the budget and nobody counted the KV cache.

📜 Table of Contents

📖 Keep reading

Quantization labels tell you roughly how many bits each weight gets. They do not tell you how big the file is, and they say nothing about the KV cache, which is the thing that actually pushes a model off your card.

The measured answer: Q4_K_M costs 4.9 bits per weight, not 4. Q8_0 costs 8.5, not 8. A Qwen2.5-7B and a Llama-3.1-8B are within 5% of each other in file size, yet at 8,192 tokens of context the Llama needs 1.07 GB of KV cache against the Qwen's 0.47 GB, because it keeps twice as many key-value heads. And Qwen2.5-32B at Q4_K_M needs 22.0 GB for 8k context, which is why "it runs on a 24 GB card" and "it runs at 32k" cannot both be true.

Where the numbers came from

File sizes were read from the Hugging Face API for six GGUF repos, summing every split part of a given quant. Quant names were matched with a regex that requires the token to end the filename, so -Q6_K_L and -Q8_0-f16 variants are not counted as Q6_K or Q8_0. Model shapes came from each model's config.json.

KV cache per token is pure arithmetic from that config, in fp16:

2 * n_layers * n_kv_heads * head_dim * 2 bytes

The leading 2 is for the key and value tensors, the trailing 2 is bytes per fp16 element. No benchmark was run here: this post is about capacity, not tokens per second and not quality loss. Those are separate measurements.

Weights: label versus file

ModelParamsQ3_K_MQ4_K_MQ5_K_MQ6_KQ8_0
Qwen2.5-3B-Instruct3.09B1.72 GB / 4.45 bpp2.10 GB / 5.44 bpp2.44 GB / 6.32 bpp2.79 GB / 7.22 bpp3.62 GB / 9.37 bpp
Qwen2.5-7B-Instruct7.62B3.81 GB / 4.004.68 GB / 4.915.44 GB / 5.716.25 GB / 6.568.10 GB / 8.50
Mistral-7B-Instruct-v0.37.25B3.52 GB / 3.884.37 GB / 4.825.14 GB / 5.675.95 GB / 6.577.70 GB / 8.50
Llama-3.1-8B-Instruct8.03B4.02 GB / 4.004.92 GB / 4.905.73 GB / 5.716.60 GB / 6.588.54 GB / 8.51
Qwen2.5-14B-Instruct14.7B7.34 GB / 3.998.99 GB / 4.8910.51 GB / 5.7212.12 GB / 6.6015.70 GB / 8.54
Qwen2.5-32B-Instruct32.5B15.94 GB / 3.9219.85 GB / 4.8923.26 GB / 5.7326.89 GB / 6.6234.82 GB / 8.57

Bits per weight (bpp) is file size times eight, divided by parameter count. From 7B upward the pattern is stable: Q3_K_M lands at 4.0, Q4_K_M at 4.9, Q5_K_M at 5.7, Q6_K at 6.6, Q8_0 at 8.5. Two of those are worth memorising because the labels lie: Q8_0 is a full half-bit above its name, and Q4_K_M is nearly a full bit above "4".

The 3B model breaks the pattern at 5.44 for Q4_K_M. Small models carry proportionally more tensors that K-quants leave at higher precision, so the fixed overhead is a larger share. If you are sizing a 1.5B or 3B model, add about 12% to whatever the bpp table predicts.

KV cache: the half nobody prices in

ModelLayersKV headsHead dimBytes per token4k8k32k128k
Qwen2.5-3B36212836,8640.15 GB0.30 GB1.21 GB4.83 GB
Qwen2.5-7B28412857,3440.23 GB0.47 GB1.88 GB7.52 GB
Mistral-7B-v0.3328128131,0720.54 GB1.07 GB4.29 GB17.18 GB
Llama-3.1-8B328128131,0720.54 GB1.07 GB4.29 GB17.18 GB
Qwen2.5-14B488128196,6080.81 GB1.61 GB6.44 GB25.77 GB
Qwen2.5-32B648128262,1441.07 GB2.15 GB8.59 GB34.36 GB

Two 7-8B models, two very different footprints. Llama-3.1-8B keeps 8 KV heads per layer, Qwen2.5-7B keeps 4, and that single config value makes the Llama's cache 2.3 times larger at every context length. At 32k the Llama spends 4.29 GB on cache, which is 87% of the size of its Q4 weights.

Can it run on my card?

Weights plus cache plus roughly 0.6 GB of runtime overhead (CUDA context and buffers), Q4_K_M only:

Model (Q4_K_M)8k totalCards at 8k32k totalCards at 32k
Qwen2.5-3B2.40 GB8 GB and up3.31 GB8 GB and up
Qwen2.5-7B5.15 GB8 GB and up6.56 GB8 GB and up
Mistral-7B-v0.35.44 GB8 GB and up8.66 GB12 GB and up
Llama-3.1-8B5.99 GB8 GB and up9.21 GB12 GB and up
Qwen2.5-14B10.60 GB12 GB and up15.43 GB16 GB and up
Qwen2.5-32B22.00 GB24 GB and up28.44 GB32 GB and up

The 8 GB row is the interesting one: three of six models fit at 8k with room to spare, and two of them still fit at 32k. The 24 GB row is where marketing claims usually break. A 32B at Q4_K_M does fit at 8k context with about 2 GB left over. Push to 32k and you are 4.4 GB short, and the fallback is offloading layers to system RAM, which trades a large multiple of latency for the extra context.

Four things that bite when you size from filenames instead

Split files. Qwen2.5-7B Q4_K_M is two files totalling 4.68 GB; Qwen2.5-32B Q8_0 is nine files totalling 34.82 GB. Look at one part of the 32B and it reads 3.87 GB, which is exactly how people conclude that a 32B fits in 8 GB.

Variant suffixes. Filename matching that is not anchored will pull in -Q6_K_L, -Q8_0_L and -Q8_0-f16. On the bartowski Llama-3.1-8B repo, a loose Q6_K match summed 6.60 GB and 6.85 GB into 13.45 GB, and the gemma-2-9b repo has a -Q8_0-f16 that turns 9.83 GB into 31.2 GB if you add everything containing "Q8_0". Anchor the pattern to the end of the filename, as the script behind this table does.

Cache type. All numbers above assume fp16 cache, which is the default. Storing K and V at q8_0 halves those columns, so Llama-3.1-8B at 32k drops from 4.29 GB to about 2.15 GB. That is arithmetic, not a measurement, and it costs accuracy in long-context recall, which matters more the longer the context gets.

Parallel slots. Every concurrent request gets its own cache. Two parallel slots at 8k context on Qwen2.5-14B is 2 x 1.61 GB, not 1.61 GB. Inference servers size the cache pool from context length times concurrency, and that is usually what actually OOMs a box that "worked in testing with one user".

The two commands that decide whether it fits

# llama.cpp: 8k context, all layers on GPU, fp16 cache
./llama-server -m model-Q4_K_M.gguf -c 8192 -ngl 99

# halve the cache if you are short on VRAM (q8_0 keys and values)
./llama-server -m model-Q4_K_M.gguf -c 32768 -ngl 99 \
  --cache-type-k q8_0 --cache-type-v q8_0

With Ollama, the same decision is num_ctx in the Modelfile or the API request. The default context is far below what the model supports, which is why a 32B "runs fine" on a 24 GB card until you ask for a long document and the context gets padded to the request size.

FAQ

Does Q4_K_M hurt quality?

This post does not answer that, and nobody should take a size table as evidence either way. Quality depends on the model, the quant mix inside the file, and your task. Measure perplexity or task accuracy on your own prompts before committing a production deployment to a smaller quant.

Why does my downloaded 32B file show 3.9 GB?

It is one part of a split GGUF. Qwen2.5-32B Q8_0 ships as nine parts. Sum the parts, or read the total from the repo listing.

Is the KV cache really fp16 by default?

In llama.cpp and Ollama, yes, and the arithmetic above assumes it. Quantized cache is opt-in through --cache-type-k and --cache-type-v.

What if I have 16 GB and want a 32B?

At Q4_K_M you need 22.0 GB for weights and 8k cache. Partial offload works by keeping some layers on the CPU, but the layers left in system RAM run at memory bandwidth, not VRAM bandwidth, and generation speed drops by a large factor. A 14B at 32k context is the better trade at 16 GB.

Related: embedding models measured on a 1 GB VPS, local LLM setup on Windows, and GGUF against AWQ and GPTQ.

Related Articles
2026-08-17
Best AI Scheduling Assistant for Wedding Photographers 2026: 6 Tools That Book More Shoots
2026-08-29
Best AI Product Photo Generator in Suzhou 2026: 6 Tools for Export Factories
2026-08-07
AI Grammar Checker: LanguageTool + Local LLM for Private Writing
2026-08-10
AI Phone Call Assistant 2026: Screen Spam, Summarize Calls, and Never Miss a Number
2026-08-25
Best AI Cover Letter Generator in Birmingham 2026: 6 Tools for UK Job Hunters
2026-08-01
AI Visibility Checker 2026: Track Whether ChatGPT and Perplexity Cite Your Site

Written by our editorial team; tools listed here are tested or verified against public sources. Links point to official sites or GitHub repos for reference only — no paid placements.

💬 Comments (0)

No comments yet. Be the first!

Login to comment