Formats and methods at a glance

One page to come back to. Every number format, every quantization method and every GGUF type in this course, with its bits, its idea and where to read more.

Key idea
Reference tables: number formats, quantization methods, GGUF types, formulas and vocabulary
Real world
The conversion table on the inside cover of a cookbook: cups to grams, Fahrenheit to Celsius. You don’t read it; you look things up.
In an LLM
A model card says “W4A16, AWQ, group size 128” or a file is called IQ3_XXS. Find the row, and you know how many bits each weight takes and what was done to it.

Number formats

FormatBits (sign · exponent · mantissa)Largest valueNotesPage
FP321 · 8 · 233.4×10383.4 \times 10^{38}master weights, optimizer statesfloating point
BF161 · 8 · 73.4×10383.4 \times 10^{38}FP32’s range, less precision; default for trainingfloat formats
FP161 · 5 · 1065,504more precision, small range; needs loss scalinglow-precision training
FP8 E4M31 · 4 · 3448weights and activationsFP8 and FP4
FP8 E5M21 · 5 · 257,344gradientsFP8 and FP4
FP4 E2M11 · 2 · 16only 0, ±0.5, ±1, ±1.5, ±2, ±3, ±4, ±6FP8 and FP4
INT88, two’s complement127−128…127bits and bytes
INT44, two’s complement7−8…7bits and bytes
NF44, lookup table1 (× scale)16 levels at normal quantilesNF4

Block formats

FormatElementsBlockScaleBits per value
MXFP4E2M132E8M0 (power of two)4.25
NVFP4E2M116E4M3, plus FP32 per tensor4.5
MXFP8E4M3 or E5M232E8M08.25
INT4, group 128INT4128FP164.125 (4.25 with zero-points)
NF4 + double quantNF464FP8, with FP32 per 256 blocks≈ 4.127

Methods

MethodWhat it doesWeights / activationsNeedsPage
Round-to-nearest (RTN)scale, round, clampanynothingwhat quantization is
LLM.int8()outlier channels in 16-bit, rest INT8W8A8nothingLLM.int8()
SmoothQuantmove activation range into weightsW8A8calibrationSmoothQuant
GPTQround column by column, fix later columnsW4A16, W3A16calibrationGPTQ
AWQscale up weights that meet large activationsW4A16calibrationAWQ
NF4 / QLoRAnormal-quantile levels; train adapters on topW4, compute in BF16nothingNF4
QuaRot / SpinQuantrotate to remove outliersW4A4KV4calibration (SpinQuant trains rotations)rotations
QuIP# / AQLMcodebooks for groups of 8 weights≈ 2 bitscalibration + fine-tuning2 bits and below
BitNet b1.58ternary weights from the start1.58-bit weights, INT8 activationstraining from scratch2 bits and below
KIVIper-channel keys, per-token values2-bit KV cachenothingKV cache
QATtrain with fake quantizationanytrainingPTQ vs QAT

GGUF types

TypeKindBits per weight (per block)Llama 3 8B fileKLD vs FP16
Q8_0legacy8.57.96 GiB0.0014
Q6_Kk-quant6.56256.14 GiB0.0055
Q5_K_Mk-quant mix5.5 (+ Q6_K tensors)5.33 GiB0.011
Q4_K_Mk-quant mix4.5 (+ Q6_K tensors)4.58 GiB0.031
IQ4_XSi-quant4.254.14 GiB (imatrix)0.036
Q4_0legacy4.54.34 GiB0.072
Q3_K_Mk-quant mix3.4375 (+ Q4_K/Q5_K tensors)3.74 GiB0.10
IQ3_XXSi-quant3.06253.05 GiB (imatrix)0.18
Q2_Kk-quant2.6252.96 GiB0.45
IQ2_XXSi-quant2.06252.24 GiB (imatrix)0.81
IQ1_Si-quant1.56251.88 GiB (imatrix)2.2

File sizes and KLD from the llama.cpp perplexity README.

Names you’ll see

  • W4A16, W8A8, W4A4KV4: bits for weights (W), activations (A) and KV cache (KV).
  • g128, group size 128: one scale per 128 weights.
  • bpw: bits per weight, averaged over the whole model, scales included.
  • PTQ / QAT: quantize after training / train while simulating quantization.
  • Calibration data: a few hundred samples run through the model to measure activations.
  • imatrix: llama.cpp’s per-column activation statistics, used to weight errors.
  • _S, _M, _L: small, medium, large mixes of GGUF types within one file.
  • Dynamic vs static activation quantization: scales computed per token at run time, or fixed in advance from calibration.
going deeper

Formulas

Symmetric (absmax) quantization with bb bits, and asymmetric with a zero-point:

s=max⁡∣x∣2b−1−1,x^=s⋅clamp⁡(⌊xs⌉)s=max⁡x−min⁡x2b−1,z=⌊−min⁡xs⌉,x^=s (q−z)s = \frac{\max |x|}{2^{b-1} - 1}, \quad \hat x = s \cdot \operatorname{clamp}\Big(\Big\lfloor \frac{x}{s} \Big\rceil\Big) \qquad\qquad s = \frac{\max x - \min x}{2^b - 1}, \quad z = \Big\lfloor -\frac{\min x}{s} \Big\rceil, \quad \hat x = s\,(q - z)

Model and KV-cache memory:

weights (bytes)=params×bpw8KV (bytes)=2⋅L⋅hkv⋅dhead⋅T⋅bkv8\text{weights (bytes)} = \frac{\text{params} \times \text{bpw}}{8} \qquad \text{KV (bytes)} = 2 \cdot L \cdot h_{kv} \cdot d_{\text{head}} \cdot T \cdot \frac{b_{kv}}{8}

Per-group storage cost and signal-to-noise of uniform quantization:

bpw=b+bscalegSQNR≈6.02 b+const (dB)\text{bpw} = b + \frac{b_{\text{scale}}}{g} \qquad \text{SQNR} \approx 6.02\,b + \text{const (dB)}

Related

  • gguf - The file format behind local LLMs. A GGUF file holds the tokenizer, settings and every tensor, each stored in blocks with their own scales. Names like Q4_K_M, Q8_0 and IQ3_XXS describe those blocks, and this page decodes them.
  • fp8-fp4 - New GPUs multiply small floats directly. FP8 is now standard for serving and is used in training; 4-bit floats with a shared scale per small block (MXFP4, NVFP4) are the newest step, with hardware support on NVIDIA Blackwell.
  • choosing - Which format for which machine, which tool makes it, and how to check you haven’t broken anything. Rules of thumb, commands, and a picker that does the arithmetic.