GPTQ › Mathematical Details of the Update

Michael BrenndoerferJanuary 13, 20263 min read
Language AI HandbookAll chapters
Part 42 of 67Inference Optimization
Chapter 320GPTQ › Mathematical Details of the Update
Reading section 7 of 17 · Mathematical Details of the Update · 3 minSection 7 of 17 · 3 min

Book contents

Section 7 of 17 · 3 min read

GPTQ › Mathematical Details of the UpdateOne section · Sections in this chapter7 / 17 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

The inverse Hessian update is a necessary mathematical component that lets efficient processing. After quantizing column qq, we need to update the inverse Hessian to reflect that column qq is no longer a free variable. The weight at column qq has been fixed to its quantized value; it can no longer be adjusted to compensate for future quantization errors. Mathematically, we need to compute a new inverse Hessian that covers only the remaining unquantized weights F∖{q}F \setminus \{q\}.

Let HF−1\mathbf{H}_F^{-1} denote the inverse Hessian restricted to the remaining (unquantized) weights. After removing column and row qq, the new inverse is given by the Schur complement formula:

[HF∖q−1]ij=[HF−1]ij−[HF−1]iq[HF−1]qj[HF−1]qq[\mathbf{H}_{F \setminus q}^{-1}]_{ij} = [\mathbf{H}_F^{-1}]_{ij} - \frac{[\mathbf{H}_F^{-1}]_{iq} [\mathbf{H}_F^{-1}]_{qj}}{[\mathbf{H}_F^{-1}]_{qq}}

where:

  • [HF∖q−1]ij[\mathbf{H}_{F \setminus q}^{-1}]_{ij}: the updated inverse Hessian element at row ii, column jj, after removing weight qq
  • [HF−1]ij[\mathbf{H}_F^{-1}]_{ij}: the current inverse Hessian element before the update
  • [HF−1]iq,[HF−1]qj[\mathbf{H}_F^{-1}]_{iq}, [\mathbf{H}_F^{-1}]_{qj}: elements from the qq-th column and row of the current inverse Hessian
  • [HF−1]qq[\mathbf{H}_F^{-1}]_{qq}: the diagonal element corresponding to weight qq
  • i,ji, j: indices ranging over the remaining unquantized weights in F∖{q}F \setminus \{q\}

This formula is a rank-one update, subtracting an outer product that corresponds to removing the degree of freedom at position qq. The intuition is that by fixing weight qq, we eliminate one dimension from our optimization space. The remaining weights must "account for" the fact that they can no longer rely on wqw_q to absorb any future compensation. The Schur complement formula computes exactly how the correlations between remaining weights change when one weight is removed from consideration.

Computing this update naively as a dense matrix operation would cost O(d2)O(d^2) per column. Over all dd columns, this would total O(d3)O(d^3), which is the same as just re-inverting the Hessian from scratch each time. The Cholesky decomposition gives the escape from this cost.

The Cholesky factorization gives us H−1=LLT\mathbf{H}^{-1} = \mathbf{L}\mathbf{L}^T where L\mathbf{L} is lower triangular. This factorization is particularly useful because the triangular structure directly encodes the sequential dependencies between weights. For column qq, the required compensation coefficients [H−1]q+1:,q[\mathbf{H}^{-1}]_{q+1:,q} are exactly the entries in the qq-th column of L\mathbf{L} (below the diagonal). The update formula simplifies to reading off the next column of L\mathbf{L} rather than performing a full matrix update, reducing the per-column cost to O(d)O(d) after the initial O(d3)O(d^3) Cholesky factorization. This is why the total complexity of GPTQ is O(din3)O(d_{in}^3) per layer: dominated by the one-time Cholesky factorization, with all subsequent operations being linear in dind_{in}.