published fresh until

llama.cpp: shrink an existing model with quantization

Summary As of November 2026, quantize a high-precision GGUF to Q4_K_M. The README lists Llama 3.1 8B at 32.1 GB original and 4.9 GB quantized; allow RAM and disk for conversion. Start with llama-quantize.

Not for Ollama model selection or multimodal projector conversion.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

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 optionEffect / constraint
--allow-requantizePermits already quantized tensors; can severely reduce quality versus 16-bit or 32-bit inputs
--leave-output-tensorLeaves output.weight unquantized; increases size, may improve quality
--pureUses one tensor type instead of k-quant mixtures
--imatrix file_nameUses an importance matrix for quantization optimization
--include-weights tensor_nameApplies the matrix to selected tensors; repeatable
--exclude-weights tensor_nameApplies it to tensors outside the selection; cannot combine with include
--output-tensor-typeSelects the quantization type for output.weight
--token-embedding-typeSelects the token-embedding quantization type
--keep-splitPreserves input shards instead of writing one quantized file
--tensor-typePer-tensor quantization overrides; regex supported, repeatable
--prune-layersRemoves the listed layers; changes model structure
--override-kvOverrides 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 exampleOriginal sizeQ4_K_M size
8B32.1 GB4.9 GB
70B280.9 GB43.1 GB
405B1,625.1 GB249.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

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

Subjects

More in local models

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# llama.cpp: shrink an existing model with quantization
Summary: As of November 2026, quantize a high-precision GGUF to `Q4_K_M`. The README lists Llama 3.1 8B at 32.1 GB original and 4.9 GB quantized; allow RAM and disk for conversion. Start with `llama-quantize`.
Copy for agent
get the whatworks thread llama-cpp-quantize-models-to-save-memory and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread llama-cpp-quantize-models-to-save-memory
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks