GPTQ › Worked Example: Error Compensation in Three Weights
Language AI HandbookAll chapters GPTQ › Worked Example: Error Compensation in Three WeightsOne section · Sections in this chapter5 / 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
To make the OBQ compensation formula concrete, let us walk through a tiny numerical example with just three weights. This example strips away all the complexity to show exactly how error compensation works step by step.
Suppose a row has three weights and the calibration data gives the following inverse Hessian:
We use 4-bit symmetric quantization with scale (so quantized values are integer multiples of in the range ).
Step 1: Quantize .
Rounding to the nearest multiple of gives . The error is . Because the error is zero, no compensation is needed. The other weights remain unchanged: .
Step 2: Quantize .
Rounding gives . Again the error is zero. Still no compensation needed.
Step 3: Quantize .
Rounding gives . Error is zero. This example happened to be perfectly aligned with the grid.
Let us now change the example slightly to see real compensation. Suppose instead .
Step 1: Quantize .
Rounding to the nearest gives . The error is .
The optimal compensation for the remaining weights is:
After compensation, the adjusted weights are and .
Step 2: Quantize adjusted .
Rounding to the nearest gives . The error is .
The optimal compensation for (the only remaining weight) is:
After compensation, .
Step 3: Quantize adjusted .
Rounding gives . The error is .
No compensation is needed because there are no remaining weights.
Comparing the two approaches. With naive round-to-nearest, the quantized weights would be with total squared weight error . With GPTQ, the quantized weights are with the same integer representations, but GPTQ's intermediate adjustments ensured that each rounding decision accounted for the correlations between weights in the Hessian. In a more complex example with finer grid spacing or larger off-diagonal Hessian elements, GPTQ would choose different integer values than naive rounding for weights and precisely because the compensation shifted their effective values before rounding. The key point is that the compensation changes the value of each weight before it is rounded, so later weights end up being rounded to different and better integer codes than they would have been under naive quantization.