Measuring impact of KV quantization on Qwen3.8
I’ve been looking for numbers to quantify the impact of KV cache quantization on Qwen3.8 27B. I’ve come across a lot of details for Qwen3.6 and other models, but not so much on 3.8.
The general consensus is that KV quantized to Q8_0 is quite acceptable, and that quantizing further is problematic, more so on K than on V.
I am summarizing my findings first for brevity, and I will expand on assumptions, methodology and data later.
Summary of results
-
For KV quantization, Q8 is fairly close to F16, and distinctly better than Q4.
-
Dropping from Q4 to Q3 weight quantization (0.07 vs 0.19 mean KLD) is worse than aggressively quantizing cache KV at same weight quantization (0.09 mean KLD at Q4 weights, Q4 KV)
Assumptions
- Assuming Q8_K_XL weight quantization model with f16 dtype KV cache is the source of truth. According to Unsloth blog post for the model, this should be close to ~0.001 mean KLD to the unquantized model, which makes be believe this is not a big assumption. This model size is practically the biggest I can run on my machine.
Methodology
- Using llama-perplexity (commit 465e49b9c) to compute probability/surprise distributions
- Baseline is from Unsloth Qwen3.8-27B-UD-Q8_K_XL.gguf
- Corpus is prose/narrative heavy, conversation, ~450K words
- Context is 20K tokens
Limitations
- The corpus is prose / narrative heavy, results on STEM/code corpus might differ significantly
- Small context window (20K tokens), only 10K have their surprise distribution evaluated, same tokens for all run variations
- No qualitative assessment
- Not testing against a benchmark of known answers
- I am no expert, likely unknown unknowns :)
Discussion
Generally, for KV quantization, F16 and Q8 are fairly close. Q4 departs meaningfully from those two, see the diagonal in the table below.
Q4_K_XL mean KLD by KV quantization
| V \ K | f16 | q8 | q4 |
|---|---|---|---|
| f16 | 0.066 ± 0.005 | 0.069 ± 0.005 | 0.073 ± 0.005 |
| q8 | 0.075 ± 0.006 | 0.072 ± 0.005 | 0.083 ± 0.006 |
| q4 | 0.075 ± 0.006 | 0.080 ± 0.006 | 0.092 ± 0.007 |
Q4_K_XL same top-1 (%) KV quantization
| V \ K | f16 | q8 | q4 |
|---|---|---|---|
| f16 | 92.829 | 92.859 | 92.609 |
| q8 | 92.799 | 92.999 | 92.169 |
| q4 | 92.369 | 92.779 | 91.939 |
Quantizing K and V separately at different dtypes is not as obvious. The error bars are large enough that we shouldn’t read too much into adjacent cells. Frankly, after looking at the data, I am less worried of running K at Q8 and V at Q4.
On Q3 weight quantization model, the probability distribution is already so distinct from the base model, that KV quantization is a much less dominant factor, than in the Q4 weight model.
That is to say, if running Q4 weight quant is an option, deciding on KV quantization for Q3 is not a good use of time.
Q3_K_XL mean KLD by KV quantization
| V \ K | f16 | q8 | q4 |
|---|---|---|---|
| f16 | 0.193 ± 0.010 | 0.186 ± 0.009 | 0.194 ± 0.009 |
| q8 | 0.181 ± 0.009 | 0.176 ± 0.009 | 0.189 ± 0.009 |
| q4 | 0.186 ± 0.009 | 0.186 ± 0.009 | 0.194 ± 0.010 |
Q3_K_XL same top-1 (%) KV quantization
| V \ K | f16 | q8 | q4 |
|---|---|---|---|
| f16 | 88.229 | 88.319 | 87.819 |
| q8 | 88.269 | 88.459 | 87.849 |
| q4 | 88.049 | 88.229 | 87.639 |
I don’t have results for higher bit per weight quantizations, so it’s hard to know if this holds at other quants. If it does, one is better off running the least quantized weight model with an aggressive KV quantization than the other way around.
Results
Q4_K_XL vs Q8_K_XL (17.56 GB weights):
| K / V cache | KV (KiB/token) | mean KLD | median KLD | same top-1 | mean Δp | RMS Δp |
|---|---|---|---|---|---|---|
| f16 / f16 | 64 | 0.0665 | 0.0081 | 92.83% | −0.191% | 7.35% |
| f16 / q8 | 49 | 0.0748 | 0.0084 | 92.80% | +0.363% | 7.18% |
| q8 / f16 | 49 | 0.0692 | 0.0080 | 92.86% | +0.049% | 7.25% |
| f16 / q4 | 41 | 0.0748 | 0.0089 | 92.37% | +0.231% | 7.35% |
| q4 / f16 | 41 | 0.0729 | 0.0092 | 92.61% | +0.013% | 7.22% |
| q8 / q8 | 34 | 0.0720 | 0.0083 | 93.00% | +0.266% | 7.59% |
| q8 / q4 | 26 | 0.0801 | 0.0085 | 92.78% | −0.011% | 7.42% |
| q4 / q8 | 26 | 0.0832 | 0.0096 | 92.17% | +0.226% | 7.96% |
| q4 / q4 | 18 | 0.0923 | 0.0098 | 91.94% | +0.201% | 8.11% |
Q3_K_XL vs Q8_K_XL (13.15 GB weights):
| K / V cache | KV (KiB/token) | mean KLD | median KLD | same top-1 | mean Δp | RMS Δp |
|---|---|---|---|---|---|---|
| f16 / f16 | 64 | 0.1926 | 0.0246 | 88.23% | −1.275% | 11.59% |
| f16 / q8 | 49 | 0.1812 | 0.0238 | 88.27% | −1.169% | 11.47% |
| q8 / f16 | 49 | 0.1860 | 0.0239 | 88.32% | −1.039% | 11.53% |
| f16 / q4 | 41 | 0.1860 | 0.0244 | 88.05% | −1.198% | 11.58% |
| q4 / f16 | 41 | 0.1940 | 0.0248 | 87.82% | −1.078% | 11.85% |
| q8 / q8 | 34 | 0.1765 | 0.0238 | 88.46% | −0.950% | 11.29% |
| q8 / q4 | 26 | 0.1858 | 0.0255 | 88.23% | −1.420% | 11.64% |
| q4 / q8 | 26 | 0.1889 | 0.0247 | 87.85% | −1.280% | 11.58% |
| q4 / q4 | 18 | 0.1939 | 0.0256 | 87.64% | −1.330% | 11.72% |
What next
- Measure Q5 and Q6 weight quantization and compare weight vs KV cache quantization impact
- Vary the corpus
- Larger context window