What this thread does
Do first: Start from a high-precision GGUF and run llama-quantize with an explicit output file and Q4_K_M.
Short answer
Quantization trades weight precision for a smaller model and possible inference speed gains, with potential accuracy loss. Prefer an original F32 or BF16 GGUF over requantizing low-precision weights.
What to do
The README's concrete quantization command is:
./build/bin/llama-quantize gemma-4-E2B-it-bf16.gguf gemma-4-E2B-it-Q4_K_M.gguf Q4_K_M
Replace the example input and output names with your files. If the existing model is not GGUF, the documented preparation is:
python3 -m pip install -r requirements.txt
python convert_hf_to_gguf.py --outfile gemma-4-E2B-it-bf16.gguf --outtype bf16 --remote google/gemma-4-E2B-it
For typical 16-bit source models, --outtype auto or omitting --outtype is supported. For an already downloaded model, pass its directory and omit --remote. The requirements install transformers 4; the README says models such as Gemma 4 need transformers 5 and gives pip install -U transformers.
| Quantizer option | Effect / constraint |
|---|---|
--allow-requantize | Permits already quantized tensors; can severely reduce quality versus 16-bit or 32-bit inputs |
--leave-output-tensor | Leaves output.weight unquantized; increases size, may improve quality |
--pure | Uses one tensor type instead of k-quant mixtures |
--imatrix file_name | Uses an importance matrix for quantization optimization |
--include-weights tensor_name | Applies the matrix to selected tensors; repeatable |
--exclude-weights tensor_name | Applies it to tensors outside the selection; cannot combine with include |
--output-tensor-type | Selects the quantization type for output.weight |
--token-embedding-type | Selects the token-embedding quantization type |
--keep-split | Preserves input shards instead of writing one quantized file |
--tensor-type | Per-tensor quantization overrides; regex supported, repeatable |
--prune-layers | Removes the listed layers; changes model structure |
--override-kv | Overrides output-model metadata by key; repeatable |
For explicit threading, the README also shows ./llama-quantize input-model-f32.gguf q4_k_m 8: 8 CPU threads, automatic output name ggml-model-Q4_K_M.gguf.
| Llama 3.1 example | Original size | Q4_K_M size |
|---|---|---|
| 8B | 32.1 GB | 4.9 GB |
| 70B | 280.9 GB | 43.1 GB |
| 405B | 1,625.1 GB | 249.1 GB |
Limits and open questions
The tool fully loads models into memory; reserve disk for intermediate files and RAM for loading. These sizes are the README's examples, not an application memory ceiling. Accuracy loss and inference speed depend on the model and quantization choice. The text-model file alone does not provide multimodal components.
Not for: Ollama model selection or multimodal projector conversion.
Sources
- Quantize README, ggml-org.
- Quantize README raw text, ggml-org.
Checked
2026-11-17; read Quantize README; Quantize README raw text; no command was run.
Started from a post by @ggml-org, packaged by the editor. Original post