---
source: https://iinventedlight.com/library/notes/llamacpp-quantize.md
title: "Quantize a GGUF model with llama-quantize"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT (ggml-org/llama.cpp (GitHub)); Apache-2.0 (Hugging Face Hub docs); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: ggml-org/llama.cpp (GitHub), quantize; Hugging Face Hub docs, GGUF. MIT; Apache-2.0."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-19
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-19
as_of: 2026-11-19
confidence: medium
untested: "Not reproduced (2026-11-19). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-ai: llama.cpp GGUF quantization"
tags: [llama.cpp, gguf, quantize, q4-k-m]
client: Librarian
sources:
  - id: S1
    title: "quantize"
    publisher: ggml-org/llama.cpp (GitHub)
    url: https://github.com/ggml-org/llama.cpp/blob/master/tools/quantize/README.md
    accessed: 2026-11-19
    license: "MIT"
  - id: S2
    title: "GGUF"
    publisher: Hugging Face Hub docs
    url: https://huggingface.co/docs/hub/en/gguf
    accessed: 2026-11-19
    license: "Apache-2.0"
---
# Quantize a GGUF model with llama-quantize
**Answer:** The quantize tool reads a GGUF input model file. That input is typically F32 or BF16, a high-precision starting point, and the output is a quantized format. Quantization is done in two phases: convert the original model to GGUF format, then quantize the converted GGUF file.

## llama-quantize

Quantization reduces the precision of model weights, for example from 32-bit floats to 4-bit integers, which also shrinks the model's size and can speed up inference. This process may introduce some accuracy loss. This can be minimized by using a suitable imatrix file.

For example, quantize to Q4_K_M with llama-quantize. Options include allow-requantize, which can severely reduce quality compared to quantizing from 16bit or 32bit, leave-output-tensor, pure, and imatrix. If the model supports multimodal inputs, you also need to convert and quantize the multimodal encoders and projectors.

## GGUF on the Hub

Hugging Face Hub has built-in features for GGUF format, a then binary format that is optimized for quick loading and saving of models. GGUF encodes both the tensors and a standardized set of metadata. You can use the ggml-org/gguf-my-repo tool to convert or quantize your model weights into GGUF weights. You can also use that Space to build your own quants without any setup.

| llama-quantize | GGUF |
|---|---|
| llama-quantize | Writes a quantized GGUF file |
| Q4_K_M | Example quantization method |
| imatrix | Suitable file that can minimize accuracy loss |
| allow-requantize | Can severely reduce quality |
| gguf-my-repo | Convert or quantize weights into GGUF weights |

## See also

- [llamacpp-gguf](https://iinventedlight.com/library/notes/llamacpp-gguf/)
- [hf-transformers-quantization-overview](https://iinventedlight.com/library/notes/hf-transformers-quantization-overview/)
- [2210-17323-gptq](https://iinventedlight.com/library/notes/2210-17323-gptq/)

## Claims

- id: C1
  claim: llama-quantize takes a high-precision GGUF file and writes a lower-precision quantized file such as Q4_K_M.
  source: S1
  evidence: "Quantization is done in two phases"

- id: C2
  claim: An importance matrix can reduce accuracy loss, and requantizing already-quantized tensors can severely reduce quality.
  source: S1
  evidence: "This can severely reduce quality"

- id: C3
  claim: GGUF on the Hub stores tensors plus standardized metadata, and gguf-my-repo can convert or quantize weights.
  source: S2
  evidence: "GGUF encodes both the tensors and a standardized set of metadata"

## Sources

- [S1] quantize. ggml-org/llama.cpp (GitHub). https://github.com/ggml-org/llama.cpp/blob/master/tools/quantize/README.md . License: MIT. Accessed 2026-11-19.

- [S2] GGUF. Hugging Face Hub docs. https://huggingface.co/docs/hub/en/gguf . License: Apache-2.0. Accessed 2026-11-19.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: ggml-org/llama.cpp (GitHub), quantize; Hugging Face Hub docs, GGUF. MIT; Apache-2.0. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
