C.W.K.
Stream
Lesson 03 of 05 · published

Quantization Tradeoffs

~22 min · quantization, gguf

Level 0Downloader
0 XP0/41 lessons0/11 achievements
0/120 XP to next level120 XP to go0% complete

What quantization buys

Quantization compresses model weights to fewer bits per parameter. Trading precision for capacity is the single most effective lever for fitting a model on consumer hardware. A 7B model at FP32 wants 28 GB; the same model at Q4 wants ~4 GB and runs visibly faster because less memory has to stream per token.

The quant ladder you'll actually use

FormatBits7B sizeQualityWhen to pick
FP16 / BF1616~14 GBNegligible lossEval rigs, fine-tuning prep
Q8_08~7 GBNear-losslessFinal answer machines with headroom
Q6_K~6~5.5 GBGood balanceQuality-first daily driver
Q5_K_M~5~4.8 GBAcceptableBig models on tight machines
Q4_K_M~4~4 GBSweet spotDefault daily driver
IQ4_XS~4~3.6 GBSmarter than Q4_0Squeezing a quant smaller
Q3_K_M~3~3 GBNoticeable lossLast resort to fit at all
Q2_K~2~2 GBSignificant lossDemos / curiosity only

K-quants vs I-quants

  • K-quants (e.g. Q4_K_M, Q5_K_S) split the tensor into blocks, then assign each block its own scale and bias. Better than uniform Q4_0 at the same average bit-width.
  • I-quants (e.g. IQ4_XS, IQ3_XXS) use an importance matrix from calibration data to spend bits on the weights that matter. Smaller files at similar quality, but slower to decode on some hardware.

Operating heuristic

Always pick the largest quant that still leaves 15% memory headroom with your target context window. Q4_K_M is the right starting point on consumer hardware; step up to Q5/Q6/Q8 if the model fits, step down to IQ4_XS or Q3_K_M only when you can't fit otherwise.

Code

Compare two quants quickly·bash
# Pull the same model at two quants and time a known prompt
ollama pull qwen2.5:7b-instruct-q4_K_M
ollama pull qwen2.5:7b-instruct-q8_0

for q in q4_K_M q8_0; do
  echo "=== $q ==="
  time ollama run "qwen2.5:7b-instruct-$q" "Summarize the GGUF format in 5 bullets." </dev/null
done

# Compare answer quality side-by-side; check ollama ps for memory difference

External links

Exercise

Pull the same model at Q4_K_M and Q8_0. Run an identical prompt against each, time the response, and write three sentences on what (if anything) you noticed in the answer quality. Note the memory difference from ollama ps.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.