Course contentsShow
← Machine Learning and Deep Learning
Lesson 2663 of 3,53857. Model Compression: QuantizationFree lesson

GPTQ: Post-Training Quantization for LLMs

Layer-wise quantization using optimal brain quantization principles for accurate 4-bit and 3-bit LLM compression.

GPTQ: Post-Training Quantization for LLMs

What you'll learn: How GPTQ enables aggressive quantization of large language models to 4-bit or 3-bit precision while preserving quality through layer-wise optimal reconstruction.

The Core Problem

Large language models contain billions of parameters. When you quantize an entire 175B parameter model naively, the accumulated errors across layers can devastate output quality. GPTQ (Generative Pre-trained Transformer Quantization) solves this by applying optimal brain quantization principles one layer at a time, minimizing reconstruction error before moving to the next layer.

How GPTQ Works

GPTQ treats each transformer layer as an optimization problem:

  1. Layer-wise sequential processing: Quantize layer 1, freeze it, then layer 2, and so on
  2. Optimal weight rounding: Instead of simple rounding (4.3 → 4), GPTQ finds the quantized weights that minimize the difference between original and quantized layer outputs
  3. Calibration data: Uses a small set of representative text (e.g., 128 sequences) to measure reconstruction error
  4. Hessian-based optimization: Leverages second-order information about which weights are most sensitive to quantization

Think of it like tuning a piano string-by-string rather than hitting all keys at once and hoping they sound right together.

Why This Matters for LLMs

GPTQ achieves 4-bit quantization (sometimes 3-bit) with minimal perplexity degradation—around 75% compression from FP16. This makes 70B models runnable on consumer GPUs. The layer-wise approach prevents error accumulation that would otherwise compound through 80+ transformer layers.

Unlike QAT (which requires retraining), GPTQ is post-training only—you quantize a pretrained checkpoint in hours, not weeks.

Key Takeaway: GPTQ uses layer-wise optimal reconstruction to compress LLMs to 4-bit or 3-bit precision without retraining, making massive models practical on limited hardware by treating each layer's quantization as an isolated optimization problem.