GPTQ: Accurate Post-Training Quantization for Generative Pre-trained Transformers

Elias Frantar, Saleh Ashkboos, Torsten Hoefler, Dan Alistarh

2022 · ICLR

GPTQ: Accurate Post-Training Quantization for Generative Pre-trained Transformers

Problem

Framing

Accurate post-training quantization did not scale to 100B+ transformers; greedy second-order methods were too slow, and cheap rounding collapsed at 3 bits. GPTQ closes this gap with one-shot, row-wise Hessian-aware quantization that keeps OPT-175B near full precision: WikiText2 perplexity 8.37 at 4-bit versus 8.34 FP16.

Currently Used Methods

Direct antecedents

Proposed Method

Architecture

GPTQ is not a new transformer. It quantizes each linear layer row-wise, using a shared input Hessian across rows and processing columns in fixed-order blocks. The key systems change is a Cholesky-form inverse Hessian update plus batched column updates.

Figure: GPTQ quantizes consecutive weight columns using Cholesky-form inverse Hessian information; the current block is quantized while later columns are updated.

Loss / Objective

Each layer solves a reconstruction problem on calibration activations:

W^=argminW^WXW^X22\hat{W} = \arg\min_{\hat{W}} \| W X - \hat{W} X \|_2^2

Algorithm

For the current unquantized set FF, GPTQ quantizes one weight and applies the optimal second-order compensation to the remaining weights:

wq=argminwq(quant(wq)wq)2[HF1]qq,δF=wqquant(wq)[HF1]qq(HF1):,qw_q = \arg\min_{w_q} \frac{(\operatorname{quant}(w_q)-w_q)^2}{[H_F^{-1}]_{qq}}, \qquad \delta_F = -\frac{w_q-\operatorname{quant}(w_q)}{[H_F^{-1}]_{qq}} \cdot (H_F^{-1})_{:,q}

The inverse Hessian is updated after each quantized coordinate by:

Hq1=(H11[H1]qqH:,q1Hq,:1)qH_{-q}^{-1} = \left(H^{-1} - \frac{1}{[H^{-1}]_{qq}} H_{:,q}^{-1} H_{q,:}^{-1}\right)_{-q}

Training Procedure

Evaluation

Datasets

Metrics

Headline results

Table 2: GPTQ runtime for full quantization of the 4 largest OPT and BLOOM models.

Model family13B / 1.7B30B / 3B66B / 7.1B175B / 176B
OPT Runtime20.9m44.9m1.6h4.2h
BLOOM Runtime2.9m5.2m10.0m3.8h

Result plot: LAMBADA accuracy versus model size for OPT and BLOOM; GPTQ stays close to FP16 at 4-bit and degrades far less than RTN at 3-bit.

Ablations

Method Strengths and Weaknesses

Strengths

Weaknesses

Suggestions from the authors

Links

Prior Papers

Further Papers