Which Side of the Line
GPTQ is a post-training quantization method, PTQ for short: it applies to a model that is already trained and frozen, and never retrains it. That is what separates it from QAT, where the low-precision constraint is imposed during training. The price of that choice is clear: you pay for a few hours of calibration instead of days of training, but the model never got a chance to learn to compensate for the rounding, GPTQ has to compensate on its behalf, after the fact.
The GPTQ Revolution
In 2022, a team from IST Austria and ETH Zurich presented GPTQ: a method to compress a model without retraining it, in a matter of hours. The headline result: quantizing OPT-175B (Meta's open-weights replica of GPT-3, 175 billion parameters) and fitting it inside a single GPU for generation, where its FP16 version demanded five 80 GB GPUs.
The arithmetic is one line, and it explains why it is the 3-bit version that fits:
- FP16: 175 × 10⁹ × 2 bytes = 350 GB, i.e. five 80 GB A100 cards
- 4 bits: 175 × 10⁹ × 0.5 bytes = 87.5 GB, still too much for an 80 GB card
- 3 bits: 175 × 10⁹ × 3 ÷ 8 = 65.6 GB, it fits
The paper's own figures, for the record: quantizing 175 billion parameter models in roughly four GPU hours, down to 3 or 4 bits per weight with degradation the authors call negligible, and end-to-end speedups over FP16 of about 3.25x on an A100 and 4.5x on an A6000. Those last two numbers compare the average time per token of the 3-bit model on one GPU against the FP16 model spread across five GPUs, so the gain comes as much from eliminating card-to-card traffic as from the compression itself.
The Brilliant Idea
The naive quantization method is to round each weight independently, round-to-nearest, abbreviated RTN. Imagine an orchestra of 100 musicians: if you ask each one to round their note individually, the overall result sounds off. GPTQ does the opposite: it quantizes weights in a fixed order and, at each step, corrects the weights not yet processed to compensate for the error it just introduced.
To know which weights to protect and how to compensate, GPTQ uses the Hessian matrix, a mathematical tool that measures the sensitivity of the output to each weight. It's a heat map that says: "this weight here, if you move it even slightly, the model's output changes a lot; this other one, you can shake it around and nothing changes."
Reading the formula back in one sentence: take the output the layer produced before compression, subtract the output it produces after, and measure how big the gap is. The two vertical bars denote the length of the gap vector, the everyday notion of distance, extended to a vector with several thousand components. The exponent 2 is there so positive and negative gaps count the same, and so large gaps are penalized more heavily than small ones.
One point that explains everything that follows: what GPTQ minimizes is not the gap between the weights before and after, it is the gap between the outputs before and after. A weight may therefore be pushed well away from its original value if that cancels a neighbour's error. That is precisely what the compensation step does.
How It Works (Simplified)
Step 1: Measure Importance
You pass 128 to 256 text excerpts through the model to compute the Hessian matrix for each layer. It tells you, for each weight: "if you change this one, here's the impact on the output." It's like surveying the ground before building: you know where the soil is fragile.
This matrix does not depend on the weights but on the activations, on what flows through the layer when you feed it text. Hence the need for excerpts: no calibration text, no Hessian. Note the distinction, it recurs throughout this module: weights are learned parameters, frozen since the end of training; activations are computed values, produced from whatever text is currently going through.
Step 2: Quantize Intelligently
For each layer, you process columns in blocks of 128:
- Quantize the weights in the current block (round to the 16 levels available in 4 bits)
- Calculate the error this introduces on the output
- Compensate for this error by adjusting the not-yet-quantized weights, using the inverse Hessian. The Hessian measures the curvature of the loss, the error measure we are trying to reduce: it says which weights are sensitive (a small change moves the error a lot) and which are robust. Its inverse answers the reciprocal question, the only one that matters here: how far must the neighbouring weights move to cancel the error we just made?

The analogy: imagine you're painting a fresco and your palette is limited to 16 colors. As you paint each section, you adjust the tones of neighboring sections so that the final result remains harmonious. That's exactly what GPTQ does: a cascading compensation.
The method GPTQ descends from, OBQ (Optimal Brain Quantization), handled weights one at a time and had never been applied beyond models of 125 million parameters. GPTQ processes columns in blocks of 128, which lets it update many weights at once instead of recomputing at every single weight. That is what brings a 175 billion parameter model within reach of a single GPU in about four hours. For scale, the authors cite a competing method that needed 3 hours for a 1.3 billion parameter model, which extrapolates linearly to several weeks at 175 billion.
Important Parameters
Number of Bits
- 4 bits: the de facto standard (excellent size/quality tradeoff)
- 3 bits: possible, but the degradation becomes visible and is strongly model-dependent. On the OPT family measured in the paper (perplexity on WikiText-2, no grouping), the 175 billion parameter model goes from 8.34 to 8.68 (+4%) and the 30 billion one from 9.56 to 10.27 (+7%), but the 66 billion one jumps from 9.34 to 14.16, i.e. +52%. No general argument predicts an accident like that: you have to measure.
- 8 bits: little interest, plain INT8 rounding already works well
Group Size (group_size)
A reminder of the mechanism, detailed in quantization concepts: weights are cut into groups that share one scale factor and one zero point. Smaller groups mean the scale is tuned more locally (so the rounding is more faithful) but more of those constants to store.
The overhead can be computed. A group of 128 weights at 4 bits costs 128 × 4 = 512 bits of weights, plus a 16-bit scale factor and a 4-bit zero point, so 532 bits for 128 weights: 4.16 bits per weight. With groups of 32, the same 20 bits of constants are spread over four times fewer weights: 148 bits for 32 weights, so 4.63 bits per weight. Hence:
- 128: the reference value, the default everywhere
- 32: slightly more precise, but 11% larger (4.63 ÷ 4.16 = 1.11)
- -1: a single set of constants per whole column, so no groups. Almost no overhead, but markedly larger rounding error.

A group_size of 128 offers the best tradeoff between quality and size: the quality difference against 32 is minimal, while the storage saving (11%) is real and computable. Don't change this value without measuring a concrete gain on your own evaluations.
Calibration Set
- C4 (a cleaned web crawl) and WikiText-2 (Wikipedia articles) are the standard text sets
- 128 to 256 excerpts of 2000 tokens are enough
- Good news: the choice of text set barely affects the final result (GPTQ is robust on this point)
In Practice
from auto_gptq import AutoGPTQForCausalLM
model = AutoGPTQForCausalLM.from_pretrained(
"mistralai/Mistral-7B",
quantize_config=BaseQuantizeConfig(
bits=4,
group_size=128,
),
)
model.quantize(calibration_dataset)
model.save_quantized("mistral-7b-gptq")
In reality, you'll probably never need to quantize yourself. Thousands of GPTQ models are already available on Hugging Face, ready to download and use. Look for the -GPTQ suffix in the model name.
Real Results
The figures below come from table 3 of the paper. Protocol: the OPT model family, perplexity measured on WikiText-2, weights in 4 bits with no grouping. Perplexity is the effective number of words the model is torn between when predicting the next one, lower is better; the definition is laid out in quantization concepts.
| Model | FP16 (reference) | Plain rounding (RTN) | GPTQ |
|---|---|---|---|
| OPT-13B | 10.13 | 11.32 | 10.31 |
| OPT-30B | 9.56 | 10.98 | 9.63 |
| OPT-66B | 9.34 | 110 | 9.55 |
| OPT-175B | 8.34 | 10.54 | 8.37 |
Two things to read here. On the 175 billion parameter model, GPTQ loses 0.03 of a perplexity point where plain rounding loses 2.2, enough to make the compressed 175 billion model worse than the 13 billion model left at full precision, thirteen times smaller. And on OPT-66B, plain rounding does not degrade the model, it destroys it: a perplexity of 110 is the behaviour of a gibberish generator.
On the size side, the gain derives directly (see quantization concepts): 175 × 10⁹ × 0.5 bytes = 87.5 GB at 4 bits, against 350 GB in FP16.

Inference Speed
GPTQ alone doesn't guarantee speed. Mainstream GPUs cannot multiply a 4-bit integer by a 16-bit float directly, so just before each computation the 4-bit weights must be expanded back to 16 bits on the fly. That job falls to kernels, small programs written specifically for the GPU, here in CUDA, NVIDIA's GPU programming language. ExLlama v2 and Marlin are the two most used.
The whole point is that this expansion must cost less than the transport it saves. Done naively, the time gained on reading the weights is lost again on decoding, and the quantized model can end up slower than the original.
GPTQ is optimized exclusively for NVIDIA GPUs. If you're targeting an ordinary processor (CPU) or an Apple-silicon Mac, use the GGUF format from llama.cpp instead. The two formats are complementary depending on your target hardware.
GPTQ vs AWQ vs GGUF Comparison
| Aspect | GPTQ | AWQ | GGUF |
|---|---|---|---|
| Quantization time | Hours | Minutes | Minutes |
| 4-bit quality | Very good | Excellent | Good |
| GPU inference | Excellent | Excellent | Good |
| CPU inference | No | No | Excellent |
GPTQ was the pioneer of post-training quantization for large models. AWQ has largely superseded it for new quantizations, thanks to better quality and faster calibration. But thousands of GPTQ models remain available and in use on Hugging Face.
A GPTQ model without a good inference kernel can be slower than the original FP16 model. Verify that your inference server (vLLM, or TGI, Text Generation Inference, Hugging Face's server) supports ExLlama v2 or Marlin before deploying.
1. When GPTQ quantizes a layer, what quantity is it actually trying to minimize?
2. GPTQ never retrains the model. Why does it still need 128 to 256 text excerpts?
3. Moving from groups of 128 weights to groups of 32 makes the rounding more faithful. Why does 128 remain the default?
4. You deploy a 4-bit GPTQ model and it runs slower than the original FP16 model. What is the most likely explanation?