GPTQ Cholesky Error-Compensated Quantization
GPTQ · ICLR 2023 · Hard · 40 minutes
Quantize columns in fixed order and compensate remaining columns using the inverse-Hessian Cholesky factor.
The single-block GPTQ core with a supplied upper Cholesky factor and fixed quantization grid; Hessian estimation, damping and factorization are supplied externally.
Functions to implement
gptq_quantize(weight: Tensor, upper: Tensor, scales: Tensor, qmin: int = -7, qmax: int = 7) -> Tensor
GPTQ Cholesky Error-Compensated Quantization
1. Problem
Quantize columns in fixed order and compensate remaining columns using the inverse-Hessian Cholesky factor.
The single-block GPTQ core with a supplied upper Cholesky factor and fixed quantization grid; Hessian estimation, damping and factorization are supplied externally.
Source: GPTQ: Accurate Post-Training Quantization for Generative Pre-trained Transformers · Section 4, Algorithm 1; official gptq.py fasterquant inner column loop.
2. Core equations
$$ H^{-1}=U^TU,\qquad q_j=\Delta,\operatorname{clip}(\operatorname{round}(w_j/\Delta),q_{min},q_{max}),\qquad e_j=(w_j-q_j)/U_{jj},\qquad W_{:,j:}\leftarrow W_{:,j:}-e_jU_{j,j:}. $$
3. From equations to code
gptq_quantize(weight: Tensor, upper: Tensor, scales: Tensor, qmin: int = -7, qmax: int = 7) -> Tensor— Dequantized weights after sequential second-order error compensation.
Clone working weights, save each quantized column, then update the remaining columns with the normalized residual. Divide by the Cholesky diagonal, not the Hessian diagonal; subtract the correction.
4. Conventions
weight:(O,D), upper:(D,D), scales:(O,). upper has zeros below its positive diagonal and represents H^{-1}=U^T U. Use ties-to-even rounding and inclusive integer bounds. Quantize left to right and compensate the current and all later columns. Return dequantized floating weights without mutating inputs; offline PTQ has no gradients.
5. Experiment view
Use two correlated calibration features and two weight rows, sweep fixed quantization steps, and compare output-reconstruction MSE against independent round-to-nearest.
The chart is generated by the actual submitted kernel during T3 and by the reference during export. Values are synthetic teaching measurements, not GPU throughput or full-model quality claims.
6. Run your implementation
Complete the functions in the Python editor on the right, then click Run tests. Inspect each failed check, update your implementation, and run again. Passing every required check marks the problem as solved and unlocks the notes.
7. Further study
Read the cited section and explain which dimensions or scheduling constraints the kernel preserves. Then extend the experiment beyond the stated fixture while retaining the existing contract. Larger models, real devices, and communication costs require separate measurement.