GPTQ: Improving LLM Post-Training Quantization with Generalized Gradient Compensation
Organizations: ZTE Corporation · The Chinese University of Hong Kong · Northwestern Polytechnical University · Peking University · Nanjing University of Aeronautics and Astronautics
Abstract
Post-training quantization (PTQ) is a practical approach to reducing the memory and computational footprint of large language models (LLMs) without retraining. GPTQ-based methods have become the de facto standard, yet they suffer from two complementary limitations. Methods with local, layer-wise objectives lack global supervision; while methods with global objectives fix their Hessian estimates at the start and ignore first-order gradients, so their guidance grows stale as quantization proceeds. This paper presents GPTQ, a unified PTQ framework with Generalized Gradient Compensation that integrates both first- and second-order information under a globally supervised, block-wise optimization objective. By refreshing gradient and Hessian estimates before quantizing each Transformer block, GPTQ avoids the staleness of prior global methods. Furthermore, to stabilize the exact first-order compensation, we introduce a trust-region scaling mechanism that dynamically bounds the gradient step to prevent exploding weight updates. Finally, we derive efficient implementations for block-wise Hessian approximation and exact gradient compensation. Experimental results on various model families and bit-widths demonstrate that GPTQ enables better alignment with the full-precision model, outperforming state-of-the-art baselines. Code is available at: https://github.com/G2PTQ/G2PTQ.
Figures & tables
| Algorithm 1: G 2 PTQ quantization for one linear layer |
| Input: Weight matrix , gradient , per-group Hessians (Equation 9 ), row-wise trust-region scaling (Theorem 3 ), block size , and #channel groups Output: quantized weight 0 1: 0 2: 0 3: for each channel group do 0 4: 0 5: 0 6: 0 7: 0 8: (Equation 17 ) 0 9: for do 10: for do 11: 12: \mathbf{E}_{:,t}^{(i)}\leftarrow({\mathbf{W}^{(i)}_{:,t}-\mathbf{\hat{W}}^{(i)}_{:,t}{\color[rgb]{0,0.625,0.8789}-\mathbf{F}_{:,t}}})/{\mathbf{L}^{\top}_{t,t}} 13: \mathbf{W}_{:,t:(b+B)}^{(i)}\leftarrow\mathbf{W}^{(i)}_{:,t:(b+B)}-\mathbf{E}_{:,t}^{(i)}\mathbf{L}^{\top}_{t,t:(b+B)}{\color[rgb]{0,0.625,0.8789}-\mathbf{F}_{:,t:(b+B)}} (Equation 16 ) 14: (Equation 17 ) 15: end for 16: \mathbf{W}_{:,(b+B):}^{(i)}\leftarrow\mathbf{W}_{:,(b+B):}^{(i)}-\mathbf{E}^{(i)}_{:,b:(b+B)}\,\mathbf{L}^{\top}_{b:(b+B),(b+B):}{\color[rgb]{0,0.625,0.8789}-B\cdot\mathbf{F}_{:,(b+B):}} 00: {\color[rgb]{0,0.625,0.8789}+\mathbf{M}_{:,b:(b+B)}\,\mathbf{D}\,\mathbf{L}^{\top}_{b:(b+B),(b+B):}} 17: {\color[rgb]{0,0.625,0.8789}\mathbf{F}_{:,(b+B):}\leftarrow\mathbf{F}_{:,(b+B):}-\mathbf{M}_{:,b:(b+B)}\,\mathbf{L}^{\top}_{b:(b+B),(b+B):}} (Equation 19 ) 18: end for 19: end for |
| Model | Method | W2A16 | W3A16 | W4A16 | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| KL | PPL | QA | KL | PPL | QA | KL | PPL | QA | ||
| Qwen3 0.6B | BF16 | 0 | 11.28 | 49.28 | 0 | 11.28 | 49.28 | 0 | 11.28 | 49.28 |
| RTN | 1.43e+01 | 7.56e+06 | 28.95 | 7.44e+00 | 1.62e+04 | 29.68 | 5.84e-01 | 17.61 | 41.36 | |
| GPTQ | 4.73e+00 | 1.58e+03 | 29.92 | 1.50e+00 | 55.60 | 33.09 | 4.58e-01 | 18.33 | 41.57 | |
| GuidedQ | 2.46e+00 | 143.67 | 30.05 | 4.96e-01 | 17.76 | 38.28 | 1.42e-01 | 12.88 | 45.41 | |
| GPTAQ | 3.33e+00 | 364.96 | 28.61 | 8.92e-01 | 30.40 | 34.58 | 3.03e-01 | 15.85 | 42.85 | |
Appendix figures & tables13 assets
Supplementary material from the paper’s appendix.
Appendix
| Algorithm 2: G 2 PTQ quantization for the entire Transformer model |
| Input: Transformer blocks: ( ), model input , indicator Output: Quantized Transformer model 0 1: 0 2: for do 0 3: Load to GPU 0 4: Set of linear layers to be quantized in 0 5: 0 6: .detach() 0 7: 0 8: if then 0 9: with 10: 11: else 12: with 13: 14: end if 15: Backpropagate to cache output activation gradients for each layer in 16: Backpropagate to cache weight gradients for each layer in 17: , compute Hessian via Equation 8 for each layer in 18: if then 19: Search for via Algorithm 3 and save it to disk 20: else 21: Load from disk 22: end if 23: Compute trust-region scaling factor via Equation 56 24: for each linear layer in do 25: Quantize the linear layer via Algorithm 1 26: end for 27: 28: Offload to CPU 29: end for |
| Algorithm 3: Trust-region threshold autotuning for one Transformer block |
| Input: Transformer block: , search range , step size , quantized block input , full-precision block output Output: Trust-region threshold 0 1: , 0 2: 0 3: for do 0 4: Set of linear layers to be quantized in 0 5: Compute trust-region scaling factor via Equation 56 0 6: for each linear layer in do 0 7: Quantize the linear layer via Algorithm 1 0 8: end for 0 9: 10: if then 11: 12: else 13: 14: end if 15: 16: if then 17: 18: 19: else 20: break 21: end if 22: end for |
| Model Family | Attn Arch | MLP Arch |
|---|---|---|
| LLaMA3 ( Grattafiori et al., 2024 ) | GQA | Dense |
| Qwen3 ( Yang et al., 2025 ) | GQA | Dense |
| Qwen3.5 ( Team, 2026 ) | GQA / GDN | Dense |
| Qwen3-MoE ( Yang et al., 2025 ) | GQA | MoE |
| Qwen3.8-Flash-Next ( Qiu et al., 2026 ) | QSA / GDN | MoE |
| KL | PPL | QA | Mem Cost | Time Cost | |
|---|---|---|---|---|---|
| 1 | 3.43e-01 | 16.66 | 40.77 | 1.00x | 1.00x |
| 2 | 3.39e-01 | 16.33 | 40.11 | 1.00x | 1.03x |
| 4 | 3.33e-01 | 16.12 | 39.83 | 1.01x | 1.20x |
| 8 | 3.31e-01 | 16.25 | 39.81 | 1.02x | 1.47x |
| 16 | 3.23e-01 | 15.77 | 40.53 | 1.04x | 2.00x |
| Method | WikiText2 | UltraChat | NuminaMath | QA Avg. | |||
|---|---|---|---|---|---|---|---|
| KL | PPL | KL | PPL | KL | PPL | ||
| w/ Approx Grad | 7.10e-01 | 35.29 | 5.69e-01 | 12.08 | 3.32e-01 | 5.83 | 37.74 |
| w/ Exact Grad | 4.97e-01 | 32.34 | 3.39e-01 | 10.52 | 1.63e-01 | 5.49 | 39.83 |
| Model | Autotune | WikiText2 | UltraChat | NuminaMath | QA Avg. | |||
|---|---|---|---|---|---|---|---|---|
| KL | PPL | KL | PPL | KL | PPL | |||
| Qwen3-0.6B (W2A16) | ✓ | 1.85e+00 | 125.39 | 1.35e+00 | 26.60 | 5.86e-01 | 7.76 | 32.93 |
| 1.91e+00 | 131.15 | 1.40e+00 | 28.14 | 6.02e-01 | 8.11 | 32.56 | ||
| Qwen3-0.6B (W4A16) | ✓ | 1.60e-01 | 23.98 | 1.01e-01 | 8.56 | 5.35e-02 | 5.03 | 45.80 |
| 1.59e-01 | 23.92 | 1.01e-01 | 8.56 | 5.33e-02 | 5.04 | 46.25 | ||
| Qwen3-0.6B-Base (W3A16) | ✓ | 4.79e-01 | 20.14 | 3.42e-01 | 7.45 | 1.70e-01 | 3.75 | 44.99 |
| Model | H-Scale | WikiText2 | UltraChat | NuminaMath | QA Avg. | |||
|---|---|---|---|---|---|---|---|---|
| KL | PPL | KL | PPL | KL | PPL | |||
| Qwen3-0.6B | 4.97e-01 | 32.34 | 3.39e-01 | 10.52 | 1.63e-01 | 5.49 | 39.83 | |
| ✓ | 4.49e-01 | 32.15 | 2.91e-01 | 10.35 | 1.31e-01 | 5.48 | 41.95 | |
| Qwen3-1.7B | 4.73e-01 | 21.66 | 3.52e-01 | 11.76 | 1.51e-01 | 5.69 | 51.33 | |
| ✓ | 3.89e-01 | 20.28 | 2.94e-01 | 11.50 | 1.09e-01 | 5.72 | 53.14 | |
| Qwen3-4B | 4.10e-01 | 18.38 | 2.43e-01 | 7.88 | 1.07e-01 | 4.84 | 60.30 | |
| Model | Method | WikiText2 | UltraChat | NuminaMath | CommonSense QA | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| KL | PPL | KL | PPL | KL | PPL | ARC-C | ARC-E | C-eval | HellaS | LAMB | PIQA | Wino | Avg. | ||
| Qwen3 8B | BF16 | 0 | 9.72 | 0 | 5.20 | 0 | 3.60 | 56.14 | 80.77 | 79.57 | 74.98 | 64.10 | 77.97 | 67.96 | 71.64 |
| RTN | 4.16e-01 | 12.33 | 3.42e-01 | 5.58 | 2.41e-01 | 3.81 | 44.62 | 64.44 | 64.86 | 66.48 | 48.52 | 73.88 | 64.01 | 60.97 | |
| GPTQ | 2.49e-01 | 11.32 | 1.85e-01 | 5.56 | 1.24e-01 | 3.81 | 52.05 | 75.38 | 69.24 | 69.33 | 57.87 | 75.68 | 64.64 | 66.31 | |
| GuidedQ | 2.54e-01 | 11.44 | 1.87e-01 | 5.59 | 1.25e-01 | 3.83 | 49.83 | 75.29 | 67.16 | 69.21 | 58.33 | 74.81 | 63.54 | 65.45 | |
| GPTAQ | 2.56e-01 | 11.81 | 1.86e-01 | 5.82 | 1.23e-01 | 4.00 | 48.12 | 72.94 | 69.02 | 68.04 | 57.91 | 74.54 | 63.93 | 64.93 | |
| Model | Method | WikiText2 | UltraChat | NuminaMath | CommonSense QA | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| KL | PPL | KL | PPL | KL | PPL | ARC-C | ARC-E | C-eval | HellaS | LAMB | PIQA | Wino | Avg. | ||
| Qwen3 30B-A3B (W2A16) | BF16 | 0 | 8.70 | 0 | 4.79 | 0 | 3.41 | 56.66 | 78.96 | 84.32 | 77.74 | 64.80 | 80.58 | 71.11 | 73.45 |
| GPTQ | 9.83e-01 | 20.13 | 6.24e-01 | 6.84 | 4.42e-01 | 4.65 | 38.99 | 56.78 | 44.73 | 57.62 | 49.82 | 70.24 | 56.12 | 53.47 | |
| G 2 PTQ | 4.93e-01 | 13.89 | 2.86e-01 | 5.68 | 2.48e-01 | 4.18 | 45.48 | 67.26 | 59.73 | 66.61 | 53.79 | 76.06 | 63.93 | 61.84 | |
| G 2 PTQ ∗ | 4.27e-01 | 12.73 | 2.13e-01 | 5.23 | 2.09e-01 | 4.04 | 44.45 | 66.08 | 63.08 | 68.35 | 55.31 | 75.90 | 65.11 | 62.61 | |
| Qwen3 30B-A3B (W3A16) | BF16 | 0 | 8.70 | 0 | 4.79 | 0 | 3.41 | 56.66 | 78.96 | 84.32 | 77.74 | 64.80 | 80.58 | 71.11 | 73.45 |
| Model | Method | WikiText2 | UltraChat | NuminaMath | CommonSense QA | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| KL | PPL | KL | PPL | KL | PPL | ARC-C | ARC-E | C-eval | HellaS | LAMB | PIQA | Wino | Avg. | ||
| Qwen3.8 Flash-Next | BF16 | 0 | 4.67 | 0 | 6.30 | 0 | 3.14 | 64.51 | 79.08 | 89.38 | 87.59 | 72.81 | 82.97 | 71.59 | 78.28 |
| GPTQ | 1.78e-01 | 5.02 | 9.36e-02 | 6.76 | 7.61e-02 | 3.23 | 62.03 | 78.03 | 87.30 | 87.19 | 72.48 | 83.62 | 72.22 | 77.55 | |
| G 2 PTQ ∗ | 1.52e-01 | 4.85 | 7.43e-02 | 5.77 | 6.20e-02 | 3.03 | 62.71 | 79.12 | 88.04 | 87.40 | 72.39 | 84.17 | 71.82 | 77.95 | |
| Model | Method | GPQA-Diamond | Live-Code-Bench | ArXiv-Math | IFBench | Avg. |
|---|---|---|---|---|---|---|
| Qwen3.8 Flash-Next | BF16 | |||||
| GPTQ | 43.37 0.56 | |||||
| G 2 PTQ ∗ | 91.08 1.27 | 92.92 0.33 | 74.22 0.69 | 75.40 0.40 |