Repository navigation
llamap: per-tensor GGUF precision maps from measured output KL (beats Unsloth Dynamic 2.0 at equal size on Llama 3.1 8B / Qwen3-8B) #31549
RedOxer
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi all. This is my first public project in the llama.cpp ecosystem. My background is post-training quantization for embedded CNNs, so I may have missed conventions or prior work here: corrections and critiques are very welcome.
Below, I compare against two references:
UD-Qn_K_XL);--target-bpw/--target-sizemode from PR #15550, which picks per-tensor types under a budget from a weight-based error estimate.What it does. For each block matrix and each format (Q2_K…Q8_0, IQ), llamap estimates the KL divergence at the model output when that matrix alone is quantized. It uses a Fisher approximation: one backward pass, 128 samples. Candidates are quantized in memory through ggml's
ggml_quantize_chunkwith the imatrix, byte-identical tollama-quantize. A multiple-choice knapsack picks one format per matrix under a byte budget, and the result is a--tensor-type-filefor stockllama-quantize. About 15 min for the first budget on an 8B, then about 1 min per extra budget.Validation. Ground truth from the degrade-one protocol (everything Q8_0, one tensor in Q2_K, ΔKL vs BF16), Spearman correlation:
Fisher vs exact on Llama 3.1 8B: 0.998 over 2,464 tensor × format pairs. Measured map KL ≈ sum of costs (1.01 at Q3/Q4, 1.24 at Q2).
Results, at the exact sizes of Unsloth's files (same
token_embd/output, sizes within 0.2 MB; target-bpw and llamap use the same imatrix). KL vs BF16 averaged over 6–7 texts disjoint from calibration: wikitext, a book, code, chat, chat with template, Qwen3 thinking traces.Against Unsloth, every text is better at every budget. Against target-bpw, the gap is small at Q2–Q4 (within noise on some texts) and large at Q5. The maps show why: llamap puts
attn_vin Q8_0 at almost every depth. CUDA speed is unchanged (pp512 within 1 %, tg128 at most −4 %).Limits. Dense
llamaandqwen3only (no MoE yet). It needs the HF weights, PyTorch and a 32 GB GPU for an 8B. It measures KL fidelity, not task scores. Max KL and |ΔPPL| improve in only about 2/3 of cases.Repo, with commits, file revisions, eval texts and every command: https://github.com/RedOxer/Llamap
Most welcome:
All reactions