Table of Contents
Fetching ...

Custom Gradient Estimators are Straight-Through Estimators in Disguise

Matt Schoenbauer, Daniele Moro, Lukasz Lew, Andrew Howard

TL;DR

This work tackles the core challenge of differentiating through quantization in QAT by proving that, at small learning rates, a broad class of gradient estimators yields training dynamics nearly identical to STE after a specific weight reinitialization and learning-rate mapping. For SGD-type optimizers, the authors show a rigorous equivalence after applying a weight map $M$ and scaling the learning rate by $\alpha$, while Adam achieves the same equivalence without reinitialization. They extend the theory to adaptive optimizers and provide empirical validation on MNIST and ImageNet, demonstrating that STE can be a robust surrogate for complex gradient estimators under appropriate conditions. The findings reduce hyperparameter tuning burden and offer practical guidance for deploying QAT, while also clarifying why numerous gradient-estimator proposals may yield improvements primarily through accompanying initialization and LR adjustments. Overall, the paper argues that gradient error concerns in QAT may be less critical than previously thought, given proper initialization and learning-rate design.

Abstract

Quantization-aware training comes with a fundamental challenge: the derivative of quantization functions such as rounding are zero almost everywhere and nonexistent elsewhere. Various differentiable approximations of quantization functions have been proposed to address this issue. In this paper, we prove that when the learning rate is sufficiently small, a large class of weight gradient estimators is equivalent with the straight through estimator (STE). Specifically, after swapping in the STE and adjusting both the weight initialization and the learning rate in SGD, the model will train in almost exactly the same way as it did with the original gradient estimator. Moreover, we show that for adaptive learning rate algorithms like Adam, the same result can be seen without any modifications to the weight initialization and learning rate. We experimentally show that these results hold for both a small convolutional model trained on the MNIST dataset and for a ResNet50 model trained on ImageNet.

Custom Gradient Estimators are Straight-Through Estimators in Disguise

TL;DR

This work tackles the core challenge of differentiating through quantization in QAT by proving that, at small learning rates, a broad class of gradient estimators yields training dynamics nearly identical to STE after a specific weight reinitialization and learning-rate mapping. For SGD-type optimizers, the authors show a rigorous equivalence after applying a weight map and scaling the learning rate by , while Adam achieves the same equivalence without reinitialization. They extend the theory to adaptive optimizers and provide empirical validation on MNIST and ImageNet, demonstrating that STE can be a robust surrogate for complex gradient estimators under appropriate conditions. The findings reduce hyperparameter tuning burden and offer practical guidance for deploying QAT, while also clarifying why numerous gradient-estimator proposals may yield improvements primarily through accompanying initialization and LR adjustments. Overall, the paper argues that gradient error concerns in QAT may be less critical than previously thought, given proper initialization and learning-rate design.

Abstract

Quantization-aware training comes with a fundamental challenge: the derivative of quantization functions such as rounding are zero almost everywhere and nonexistent elsewhere. Various differentiable approximations of quantization functions have been proposed to address this issue. In this paper, we prove that when the learning rate is sufficiently small, a large class of weight gradient estimators is equivalent with the straight through estimator (STE). Specifically, after swapping in the STE and adjusting both the weight initialization and the learning rate in SGD, the model will train in almost exactly the same way as it did with the original gradient estimator. Moreover, we show that for adaptive learning rate algorithms like Adam, the same result can be seen without any modifications to the weight initialization and learning rate. We experimentally show that these results hold for both a small convolutional model trained on the MNIST dataset and for a ResNet50 model trained on ImageNet.
Paper Structure (22 sections, 7 theorems, 64 equations, 3 figures, 5 tables)

This paper contains 22 sections, 7 theorems, 64 equations, 3 figures, 5 tables.

Key Result

Theorem 5.1

Suppose that $E^{(t)}$ is the alignment error for $\hat{Q}$-net and $STE$-net with SGD (Table tab:sgd_model_def). Assume that the following hold: Then we have

Figures (3)

  • Figure 1: Gradient Estimators from left to right: STE Hinton2012lecture, PWL hubara2016binarized, MAD DBLP:conf/icml/SakrDVZDK22, HTGE pei2023quantization, EDE Qin_2020_CVPR. The EDE is for binary quantization, and the others are for multi-bit quantization.
  • Figure 2: The funhouse mirror. The blue figure represents you (a weight in $STE$-net), and the red figure represents your reflection (a weight in $\hat{Q}$-net) on the other side. The reflections line up at the edge of the room.
  • Figure :

Theorems & Definitions (15)

  • Theorem 5.1
  • Theorem 5.2
  • proof : Informal proof of Theorem \ref{['sgd_change_point']}
  • Theorem C.1
  • proof
  • proof : Proof of Theorem \ref{['sgd_change_point']}
  • Theorem D.1
  • proof
  • Theorem D.2
  • proof
  • ...and 5 more