Rethinking Gradient Approximation in Quantization: A Zeroth-Order Expectation Perspective

Wenkang Wang, Jia Zhang, Zelin Wei, Dongxu Liu, Jiabao Li, Wanli Shi, Bin GuNeurIPS 2026

TL;DR

Training quantized Large Language Models (LLMs) hits a mathematical brick wall: rounding weights is a non-differentiable staircase, so we usually fake the derivative using rules of thumb like the Straight-Through Estimator (STE). This paper introduces ZOE-Grad, a mathematical framework proving that these "fake" surrogate gradients are actually the exact expected values of zeroth-order (perturbation-based) gradient estimators. By replacing STE's blind, discrete jumps with smooth, continuous perturbations, we get boundary-aware gradients that consistently boost quantized LLM accuracy.

What Problem Does This Paper Address?

To squeeze massive LLMs onto real-world hardware, we quantize them—mapping high-precision weights onto a small grid of low-bit integers. Whether you are fine-tuning a quantized model or learning optimal scaling factors, you eventually meet the round() function.

Visually, rounding is a staircase: flat everywhere (gradient is zero) with vertical jumps at the half-integer boundaries (gradient is undefined). Standard backpropagation dies here. For over a decade, the default workaround has been surrogate gradients—swapping the broken derivative during the backward pass with a well-behaved stand-in. The reigning champion is the Straight-Through Estimator (STE), which boldly pretends the derivative of rounding is just $1$ everywhere.

While STE works surprisingly well, it is completely blind to where a weight sits relative to a rounding boundary, often causing weights to oscillate wildly across thresholds. Better, curved surrogates exist, but they have largely been invented as isolated heuristics. Until now, we lacked a unified theory explaining where surrogate gradients come from or how to design them systematically.

Methods

The authors bridge two worlds: surrogate gradients and zeroth-order (ZO) optimization. Instead of computing derivatives analytically, ZO methods estimate gradients by nudging a parameter forward and backward by a random noise perturbation ($z$, scaled by $\delta$) and measuring if the output changes.

Notice that if you nudge a weight $u$, the rounded output only changes if the nudge is large enough to cross a half-integer quantization boundary. Instead of actually sampling noisy nudges during training (which is slow and high-variance), the authors take the mathematical expectation over the noise distribution—creating the Zeroth-Order Expectation Gradient (ZOE-Grad).

ZOE-Grad establishes a constructive two-way street:

  1. Perturbation $\rightarrow$ Surrogate: Pick a symmetric, bounded noise distribution (like Uniform or Truncated Normal), compute the expected boundary crossings analytically, and normalize it. Out pops a clean, deterministic surrogate gradient formula you can drop right into PyTorch's backward pass (see Figure 1).
  2. Surrogate $\rightarrow$ Perturbation: Take an existing boundary-aware heuristic—like the Hyperbolic Tangent Gradient Estimator (HTGE)—and reverse-engineer the exact noise distribution that generates it.
Figure 1: Comparison of perturbation distributions. The first two panels correspond to uniform perturbations, while the last two correspond to truncated Gaussian perturbations with C = 3.

Because different models and tasks prefer different gradient shapes, the authors also introduce a lightweight pilot fine-tuning step: running just 256 training steps on 8 to 32 examples to quickly pick the winning surrogate before full training.

Datasets

No new benchmarks are introduced. To evaluate optimization performance across language understanding, reasoning, and reading comprehension, the authors fine-tune and evaluate on standard NLP benchmarks:

  • GLUE: SST-2
  • SuperGLUE: RTE, CB, BoolQ, WSC, WiC, and MultiRC
  • Question Answering: SQuAD
  • Additional W4A4KV4 experiments evaluate ROUGE scores (R-1, R-2, R-L, R-LSum) following the RoSTE setup.

Key Insights and Ideas

  • STE is a degenerate coin flip: Under ZOE-Grad, STE isn't just an arbitrary hack—it is the exact expected gradient of a Rademacher perturbation (flipping a coin to nudge weights by exactly $+1/2$ or $-1/2$). Because a fixed-size jump only preserves the sign of the noise and throws away its magnitude, STE loses all sense of distance to the nearest rounding boundary.
  • Continuous noise unlocks local geometry: Using continuous noise distributions (like Uniform or Normal) means small nudges only cross boundaries if the weight is already close to an edge. This naturally produces smooth, humped gradients peaked right at the quantization boundaries.
  • The "Goldilocks" perturbation scale: Theory suggests setting the perturbation span to roughly match the width of a single quantization bin ($2\delta C \approx 1$). This ensures a weight only "feels" the pull of its single nearest boundary rather than getting muddled signals from multiple steps away.
  • Bounded convergence: Optimizing with these smoothed surrogates is theoretically guaranteed to converge linearly to a bounded neighborhood of the true discrete optimum, with the approximation gap shrinking the further weights settle away from rounding boundaries.

Key Results

Tested on OPT-1.3B, OPT-6.7B, LLaMA-2-7B, and Qwen3-8B under 4-bit weight-only quantization (W4A16, built on OmniQuant), continuous ZOE-Grad surrogates (Uniform, Normal, HTGE) consistently beat STE across every model and task:

  • Substantial accuracy gains: On Qwen3-8B (SQuAD), Uniform ZOE-Grad hits 70.29 F1 vs. STE's 56.88. On OPT-6.7B (CB), Normal reaches 85.71% accuracy vs. STE's 69.64%. On LLaMA-2-7B (SQuAD), Uniform reaches 66.69 F1 vs. STE's 47.33.
  • Fast surrogate selection: Pilot fine-tuning with just 32 examples picks the single best surrogate 54.17% of the time and avoids the worst choice 87.50% of the time.
  • Plays well with full quantization and rotations: On Qwen2.5-0.5B with 4-bit weights, activations, and KV-cache (W4A4KV4) plus outlier rotation, RoUniform improves the average ROUGE score to 23.28 over RoSTE's 21.15.

Limitations and Future Work

  • Training-time compute overhead: Evaluating analytic functions during backpropagation is slower than multiplying by $1$. On LLaMA-2-7B (W3A16), fine-tuning takes ~60–61 minutes for Uniform/Normal vs. ~46.5 minutes for STE—roughly a 30% training time increase, though inference speed is completely unaffected.
  • No universal winner: ZOE-Grad maps out the design space rather than crowning one universally optimal distribution. While the authors formulate distribution learning as a bilevel optimization problem, actually solving that bilevel problem directly—rather than relying on pilot runs over a few candidates—is left for future work.

Summary updated

Abstract

As large language models (LLMs) continue to scale, quantization has become a key technique for efficient deployment. However, multi-bit quantization employs non-differentiable rounding, hindering gradient optimization. Existing methods rely on heuristic surrogate gradients (e.g., STE), which work empirically but lack a unified theory. To address this challenge, we propose the Zeroth-Order Expectation Gradient (ZOE-Grad), a zeroth-order expectation view of quantization surrogate gradients. Specifically, we establish an equivalence between the expectations of zeroth-order gradient estimators and surrogate gradients, providing a unified zeroth-order interpretation of widely used surrogates. Under this framework, STE corresponds to a degenerate, discontinuous perturbation that ignores the local geometry of quantization boundaries, limiting its expressiveness. In contrast, continuous perturbation-based surrogate gradients capture boundary-local information and produce smoother, more structured gradients. We further establish bounded-error convergence guarantees for the quantized objective. Through simulations under multiple perturbation distributions, we verify that the proposed framework accurately captures the relationship between the expectations of zeroth-order gradient estimators and surrogate gradients. Furthermore, extensive experiments on OPT-1.3B, OPT-6.7B, LLaMA-2-7B, and Qwen3-8B show that continuous ZOE-Grad surrogates consistently outperform STE across diverse LLM architectures. Our code is available at https://github.com/wangwk699/ZOE_Grad.
BibTeX
@inproceedings{wang2026rethinking,
  author = {Wenkang Wang and Jia Zhang and Zelin Wei and Dongxu Liu and Jiabao Li and Wanli Shi and Bin Gu},
  title = {{Rethinking Gradient Approximation in Quantization: A Zeroth-Order Expectation Perspective}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=0ZZ3tyBGyc},
}
Figure