What GPTQ is
GPTQ turns a trained model's 16-bit weights into 4-bit integers after training, one linear layer at a time, from a few hundred calibration sequences and no gradient steps. Plain round to nearest (RTN) moves each weight to its closest level independently. GPTQ rounds the columns of a matrix one after another and, after each, adjusts the columns not yet rounded so that the layer's output on the calibration inputs stays as close as possible to the original's. The weights end up further from the originals than RTN's, and the outputs closer.
This page compares Qwen's own GPTQ-Int4 release of Qwen2.5-0.5B-Instruct with the original bf16 model, and also runs GPTQ here on one matrix, layer 12's down_proj (896 × 4,864), so its steps can be traced.
Groups, scales and zeros
The release is symmetric 4-bit in groups of 128 input columns. Every group of every output row has a scale, and a weight is stored as a code :
For a symmetric quantizer the zero is always 8; the How the file stores it panel shows that the gptq format writes it as zero − 1 = 7, and that one int32 word of qweight holds eight codes, lowest bits first. The fp16 scales add 16 bits per 128 weights, the packed zeros 4 bits per 128 and the g_idx column-to-group table one int32 per input column, so the Bits per weight panel counts 4.19 bits per weight for this matrix against 16 for bf16. The One matrix in 4 bits panel switches between the original weights, the codes, the dequantized weights and their error.
The layer-wise problem
Let be a layer's weight matrix and its calibration inputs. GPTQ looks for the quantized that changes the layer's output least:
The loss is quadratic in each row of and every row has the same Hessian , here built from 32 WikiText-2 training sequences of 512 tokens. Its diagonal says how loud input column is: an error in a column with large inputs moves the output a lot. The Error per input column strip draws on a log scale under the per-column error of RTN and of Qwen's release.
Optimal Brain Surgeon (Hassibi and Stork) solved this problem for removing one weight: set it, then move the remaining weights along the inverse Hessian to cancel as much of the change as a quadratic model allows. Optimal Brain Compression applied the same step to quantizing weights one at a time; GPTQ made it fast enough for billions of weights.
Rounding one column at a time
GPTQ quantizes the columns in a fixed order, the same for every row, so one inverse Hessian serves the whole matrix. With the upper Cholesky factor of , rounding column gives an error that is spread over the later columns:
Rounded columns are final; each later column absorbs part of every earlier error before its own turn. The Cholesky form avoids updating after every column, the updates are applied in blocks of 128 columns to keep the work in large matrix products, and 1 % of the mean diagonal is added to (damp_percent 0.01) so its inverse is stable. The Rounding one column at a time panel steps through 64 columns of the crop: the top grid is the weights now, the lower grid how far each has moved from the original.
Rounding to the nearest level is not what minimises the output error, as AdaRound had shown on ResNets: 11.6 % of the release's codes are not the level nearest the original weight.
Worse weights, better outputs
On this matrix the relative weight error is 12.56 % for RTN, 16.57 % for GPTQ run here and 14.26 % for Qwen's release. The output error on 4,096 held-out tokens goes the other way: 12.26 % for RTN, 9.24 % here and 10.23 % for the release. The Error over the whole matrix histogram shows GPTQ's wider spread of weight errors.
Over the whole model, perplexity on 4,088 WikiText-2 test tokens is 19.93 for the original, 26.28 with every matrix rounded to nearest in the same format, and 23.20 for the GPTQ release; all three answer "The capital of Australia is Canberra." One prompt's next-token distribution is a narrower test: there the release's KL divergence from the original, 0.454 nats, is larger than RTN's, 0.126. The file shrinks from 988 MB to 459 MB, of which the fp16 embedding is 272 MB. Both models ran in float32 on this Mac's CPU, so neither is faster here: GPTQ's speed comes from CUDA kernels that unpack each group inside the matrix product.
Where GPTQ came from
Optimal Brain Damage (1989) and Optimal Brain Surgeon (1992) pruned weights with second-order information. Optimal Brain Compression (2022) turned the surgeon's step into a layer-wise quantizer that was exact but cubic in the row length; GPTQ (2022) fixed the column order, shared the inverse Hessian across rows and batched the updates, and reported quantizing 175-billion-parameter models in about four GPU hours. The same machinery prunes in SparseGPT (the SparseGPT tab). AWQ (the AWQ tab) protects the loud input channels by scaling instead of compensating, and llama.cpp's k-quants (the GGUF tab) use smaller blocks with their own scales.
Papers
- GPTQ: Accurate Post-Training Quantization for Generative Pre-trained Transformers The method: column-by-column rounding with inverse-Hessian error compensation, in a fixed order with Cholesky and lazy batched updates.
- Optimal Brain Compression: A Framework for Accurate Post-Training Quantization and Pruning The layer-wise objective and the one-weight-at-a-time quantizer (OBQ) that GPTQ speeds up.
- Second order derivatives for network pruning: Optimal Brain Surgeon Removing a weight and moving the others along the inverse Hessian to compensate: the update GPTQ applies to every rounded column.
- Up or Down? Adaptive Rounding for Post-Training Quantization Shows that rounding each weight to its nearest level is not optimal for the layer's output, the reason GPTQ's codes differ from the nearest ones.
- Qwen2.5 Technical Report The Qwen2.5 models, including the 0.5B instruct model whose GPTQ-Int4 release this page records.
- A Survey of Quantization Methods for Efficient Neural Network Inference Uniform and non-uniform quantizers, symmetric and asymmetric ranges, granularity and post-training quantization, in one survey.