GPTQ Is Babai's Nearest Plane, Audited: Bit-Identical Integers, the 1/12 Error Law Holds, Clipping Breaks the Bound at 9% Overflow, and Min-Pivot Ties a 1998 MIMO Ordering
GPTQ is still the default one-shot weight quantizer for LLMs. The usual description is greedy algebra: quantize one input column, use the inverse Hessian to push the rounding error onto the columns not yet quantized, repeat. It has always worked better than a greedy rule should, and it had no worst-case guarantee.
Chen, Shabanzadeh, Crnčević, Hoefler and Alistarh (arXiv 2507.18553, ICLR 2026) explain why. Run GPTQ from the last column to the first and it is exactly Babai's nearest-plane algorithm (1986) for the closest vector problem, on the lattice whose basis is the calibration activations scaled by the quantization step. The error-propagation update is the orthogonal projection onto the nearest hyperplane. That equivalence brings Babai's error bound with it.
I implemented both algorithms from the paper's pseudocode and tested four claims: the equivalence, the bound and its average case, what clipping does to it, and the proposed "min-pivot" ordering. Everything below comes from my own runs (c = 64 input channels, n = 1,024 calibration rows, r = 256 output channels, correlated activations with four 8× outlier channels). The exception is the Qwen3 trace table, which I re-derived from the paper's appendix.
The dictionary
For one output channel i with weights w, per-element scales s and calibration activations X, the layer loss is the squared norm of X·diag(s)·z − X·w, minimized over integer vectors z. That is a closest-vector problem:
- Basis B = X·diag(s). Each column is an input channel's activation vector, stretched by its quantization step.
- Target y = X·w, the full-precision layer output.
- Lattice point B·z, the output of the quantized layer.
Only inner products of basis columns matter, so any factor of the Hessian H = XᵀX gives the same problem up to a rotation. The paper uses that to swap the n×c activation matrix for a c×c Cholesky factor (Theorem 1). Babai's algorithm walks the Gram-Schmidt directions from last to first. At each step it reads off the coefficient along the unnormalized Gram-Schmidt vector, rounds it, and subtracts that basis vector from the residual.
Here are both algorithms, stripped to the parts that matter:
import numpy as np
def gptq(W, S, H, order): # Algorithm 1, no clipping
W, S = W[order].copy(), S[order]
Hi = np.linalg.inv(H[np.ix_(order, order)])
Lc = np.linalg.cholesky(Hi); L = Lc / np.diag(Lc) # unit-lower LDL factor of H^-1
Z = np.zeros_like(W)
for j in range(len(W)):
Z[j] = np.round(W[j] / S[j])
err = Z[j] * S[j] - W[j]
W[j:] += np.outer(L[j:, j], err) # propagate to not-yet-quantized rows
return Z[np.argsort(order)]
def babai(B, y): # Algorithm 2, no LLL reduction
Q, R = np.linalg.qr(B); res = y.copy(); z = np.zeros(B.shape[1])
for j in reversed(range(B.shape[1])):
z[j] = np.round(Q[:, j] @ res / R[j, j])
res -= B[:, j] * z[j]
return zCheck 1: the integers are identical
With absmax/7 scales and no clipping, back-to-front GPTQ and Babai on Xd·diag(s), where Xd is the Cholesky factor of the damped Hessian, agree on 16,384 of 16,384 integers. Front-to-back GPTQ agrees with that Babai run on only 47.4%. It is still Babai, just over the reversed basis. The order changes which lattice point you land on, and that is where all the ordering results below come from.
Check 2: the bound, the 1/3 law, and a closed form the paper skips
Theorem 5: with no clipping, each channel's squared error is at most one quarter of Σⱼ sⱼ²·Dⱼ, where Dⱼ are the pivots of the LDL factorization of H in Babai's order. Geometrically, Dⱼ is the squared length of the j-th Gram-Schmidt vector, and the residual always lies in the box with half-edges ½‖ãⱼ‖. The bound is tight at the box's corners. If the residual is uniform inside the box, the expected error is a third of the worst case, so (1/12)·Σ sⱼ²·Dⱼ (Appendix D.2).
The uniform assumption looks weak but holds: error propagation makes every rounded coefficient continuous, so its fractional part behaves like uniform noise.
| Measurement (256 channels) | Value |
|---|---|
| GPTQ error ÷ (s²·tr(D)/12), mean | 1.020 |
| Worst channel ÷ worst-case bound | 0.631 |
| RTN error ÷ (s²·tr(H)/12), mean | 0.999 |
| GPTQ error ÷ RTN error, measured | 0.475 |
| tr(D) ÷ tr(H), predicted | 0.473 |
The last two rows are the part I find most useful, and the paper never writes it down. Round-to-nearest is the same box argument with the un-orthogonalized lengths, so its expected error is s²·tr(H)/12. Divide the two and, with uniform scales, GPTQ's error relative to RTN's is tr(D)/tr(H). You can compute that from the Hessian alone, before quantizing anything, and it tells you which layers will gain from GPTQ. A layer whose activations are nearly orthogonal has D ≈ diag(H), and GPTQ buys nothing there.
Check 3: clipping breaks the bound, and MSE scales make it clip
The bound needs an unbounded integer grid. Real INT4 clips to [−8, 7], and error propagation pushes weights outward. With absmax scales, RTN never overflows by construction. Unclipped GPTQ, on the same weights, lands 0.22% of integers outside the INT4 range.
Shrinking the scale (MSE-optimized scales, the GPTQ default, sit below absmax) makes it worse quickly:
| Scale vs absmax | Unclipped overflow | Clipped channels over the no-clip bound | Clipped error ÷ bound, mean |
|---|---|---|---|
| 1.0× | 0.22% | 0.0% | 0.34 |
| 0.6× | 8.8% | 60.9% | 3.37 |
| 0.4× | 23.5% | 100% | 35.7 |
So the guarantee covers the regime where GPTQ is least interesting: large scales, coarse grids. That is why the paper's practical methods are about never clipping. SSQR binary-searches a single scale multiplier until the overflow fits a sparse full-precision outlier budget of 1–5%. HPTQ uses one scalar scale over an unbounded grid and Huffman-codes the integers to a target average bitwidth. On Qwen3-8B, HPTQ at 3.125 average bits reaches 10.34 WikiText-2 perplexity against 9.73 for BF16 (their Table 4).
Check 4: ordering, and a 1998 ordering nobody cited
The bound depends on the order through Dⱼ. The product of the pivots is det(H) for every order, but their sum is not fixed. GPTQ's act-order, which quantizes columns in descending Hessian diagonal, is the same as building Gram-Schmidt from the shortest column up. The paper proposes min-pivot instead: at each Cholesky step, pivot on the smallest remaining Schur-complement diagonal. In two dimensions shortest-first is provably right. With lengths a < b at angle θ, shortest-first costs a² + b²·sin²θ, and the other order costs more by (b² − a²)·cos²θ. Whether greedy stays optimal in higher dimensions is not obvious, so I brute-forced all 40,320 orders on 60 random 8-channel Hessians:
| Order (tr(D) ÷ optimum) | Mean | Worst |
|---|---|---|
| natural | 1.662 | 3.986 |
| random (avg of 100) | 1.637 | 3.306 |
| act-order | 1.0028 | 1.041 |
| min-pivot | 1.0000 | 1.0004 |
| V-BLAST (backward, max post-detection SNR) | 1.0002 | 1.0125 |
| max-pivot (adversarial) | 2.421 | 6.280 |
Min-pivot found the exact optimum in 53 of 60 cases and was never more than 0.04% off. The general problem is NP-hard; these instances aren't.
Wireless engineers already had this result. Babai's nearest plane is successive interference cancellation in MIMO detection. The V-BLAST order (Wolniansky et al., 1998) detects the stream with the highest post-cancellation SNR first, which in GPTQ terms means quantizing first the column whose final Gram-Schmidt length is largest. At c = 64 and c = 256, V-BLAST and min-pivot both reach tr(D)/tr(H) = 0.2614 and 0.2618–0.2620. Across 40 Hessians they never produce the same permutation (only 20% of positions agree), yet the traces match to four digits. The paper cites LLL and BKZ but none of the MIMO literature. Its sorted-QR, LLL-aided SIC and sphere decoders are exactly the "import lattice algorithms" roadmap the paper points to.
How much ordering matters depends on the layer. Recomputing the paper's Qwen3-8B block-18 table: act-order cuts tr(D) below back-to-front by 36.7% (Q·K·V), 2.1% (O), 48.8% (Gate·Up) and 7.6% (Down). Min-pivot then adds only 1.04%, 0.78%, 1.02% and 0.08%. That matches my synthetic runs, where act-order is 0.6–0.9% behind min-pivot. Act-order gets nearly all the benefit for free, as the paper concedes.
What to take away
- The equivalence is exact. Bit-identical integers from two codes that share no linear algebra (QR vs. Cholesky of the inverse).
- The 1/12 law gives you a pre-quantization diagnostic: tr(D)/tr(H) predicts GPTQ's gain over RTN to within 0.5% in my runs. Compute it per layer before spending GPU time.
- The guarantee only holds without clipping. At realistic scales, clipped INT4 GPTQ breaks the bound on most channels. If you want the bound, budget for outliers (SSQR) or use an unbounded grid (HPTQ).
- Ordering is solved to within 1%. Use act-order. Min-pivot and V-BLAST are near-optimal and essentially tie each other. The bigger remaining lever is basis reduction (LLL), which the paper leaves out because it depends on the scale and would break the per-layer sharing of Hessian work that makes GPTQ cheap.