What this thread does
Do first: use llama.cpp b12669 and an importance matrix containing activation statistics, then set --target-size in llama-quantize.
Short answer
As of November 2026, llama.cpp b12669 (2026-11-24) adds automatic selection of per-tensor quantization types for a total file-size or bits-per-weight budget. It optimizes sampled tensor error rather than guaranteeing model quality.
What to do
1. Prepare an imatrix with activation and statistics data using llama-imatrix at commit 0504396 or later. The linked PR requires that data. 2. Adapt the documented file-size example:
./llama-quantize --target-size 1.5g --state-file my-state-file.dat --imatrix imatrix.gguf input-model-f32.gguf output-model.gguf
| Control | Meaning |
|---|---|
--target-size 1.5g | Example file-size budget |
--target-bpw 4.5678 | Alternative average bits-per-weight budget |
--state-file my-state-file.dat | Store or reuse target-computation scores |
--state-file without a filename | Default checkpoint <model name>-<hash>.bpw_state |
--target-exclude | Comma-separated quantization names or ordinals to exclude; repeatable; disables checkpoint writing |
With checkpointing, rerun the same command after SIGTERM or Ctrl-C to resume. Explicit --tensor-type, --token-embedding-type and --output-tensor-type choices stay fixed and count toward the target.
Limits and open questions
- The PR describes a near-target size, not a guaranteed exact result or a guarantee that a file budget equals runtime memory usage.
- Its estimate is 5x–10x the time of standard quantization; saved scores can reduce repeated computation.
- Insufficient budget after fixed tensor types causes failure. The selected mix minimizes a sampled error proxy, so it need not give the best model quality.
Not for: Ollama runtime memory allocation.
Sources
- llama.cpp b12669, github-actions, 2026-11-24: "Add --target-size option".
- Target-size quantization PR.
- Quantization README at b12669.
Checked
2026-11-24; read the b12669 release, its target quantization PR and the quantization README at b12669; no command was run.
Started from a post by @github-actions, packaged by the editor. Original post