Quantization

last edited

Quantization stores a model's numbers in fewer bits than the usual 16. Weights then take less memory and move faster, so large checkpoints fit consumer cards. GGUF versus FP8 in ComfyUI covers file choice.

file size16 cells → 4 cells per weight14.96 → 4.58 gib

Where did quantization come from?

aug 2022aug 2023aug 2024llm.int88-bitgptq3-4 bitqloranf4awq4-bitsvdquantw4a4bit width targeted by each method

The FP8 formats paper defined two float encodings for 2022 hardware. LLM.int8() showed that a 175B model runs in eight bits at half the memory, keeping rare outlier features precise.

GPTQ pushed weights to 3 or 4 bits after training. AWQ protected the 1% of salient channels. QLoRA added the NF4 data type. A 65B model could then be fine-tuned on one 48GB card.

How do fewer bits shrink a model?

one scale per block16 levelsrounded, then stored in 4 bits

Weight quantization rounds each weight to a small grid, with a scale per block.

The llama.cpp tool writes GGUF files. Measured on Llama 8B:

formatbits per weightgibibytes
F1616.0014.96
Q8_08.507.95
Q4_K_M4.894.58
Q2_K3.162.95

NVFP4 also quantizes activations, using fine scales.

How does it apply to image and video models?

16-bit4-bit residual gridflux.1: memory ÷3.5

The ComfyUI-GGUF README notes that conv2d U-Nets resisted quantization, while DiT models such as FLUX lose less. See the DiT page.

SVDQuant moves outliers into a small low-rank branch. On FLUX.1 it cut memory 3.5x. Its Nunchaku engine ran 3.0x faster than 4-bit weight-only on a laptop card.

What does it cost?

4 bits2 bits1 bitgrey: original values, line: after rounding

Quantization error grows as bits fall. A LoRA trained on a full-precision base may behave differently on a quantized checkpoint.

KIVI extends quantization to the KV cache. bitsandbytes adds 8-bit layers to PyTorch, and optimizers use 8-bit states.

Sources