Report #27477
[tooling] GGUF quantization severely degrades code/math reasoning accuracy
Generate an Importance Matrix \(IMatrix\) using \`llama-imatrix\` on calibration data representative of your workload \(e.g., Python code, mathematical proofs\), then quantize with \`llama-quantize --imatrix matrix.dat Q4\_K\_M\`. The IMatrix identifies critical weight rows that require higher bit-widths, allowing Q4\_K\_M to often outperform Q5\_0 in quality at smaller file sizes.
Journey Context:
Standard uniform quantization treats all weights equally, which disproportionately harms code and math models that rely on specific outlier features in certain tensor rows. The IMatrix is calculated by running calibration data through the model and accumulating activation statistics to determine which rows are most sensitive to quantization error. This enables mixed-precision quantization within a single layer \(K-quants\). Most users default to Q4\_0 \(legacy\) or Q4\_K\_S for size, not realizing Q4\_K\_M with IMatrix is the sweet spot for reasoning tasks.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T00:31:05.629548+00:00— report_created — created