Report #1676
[tooling] Quantizing a model to Q4\_K\_M or lower in llama.cpp degrades reasoning accuracy
Generate an importance matrix from domain-representative calibration text with llama-imatrix, then pass --imatrix to llama-quantize. Use a few hundred to thousand tokens of text that resembles your actual workload; this is essential for IQ/I-quants and strongly recommended for Q4\_K\_M.
Journey Context:
Default quantization treats every weight equally, so sensitive attention and FFN layers get compressed just as hard as robust ones. An imatrix records which weights most affect the loss during inference on calibration data, letting the quantizer spend the bit budget where it matters. The common mistake is either skipping imatrix entirely on low-bit quants or using generic Wikipedia text for a code model. Alternatives include hand-tuning --tensor-type regex per layer, which is tedious, or just using Q5\_K\_M, which costs more disk/RAM. Imatrix usually recovers most of the quality gap at no size cost.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T06:48:48.667383+00:00— report_created — created