NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Few-Bit Backward: Quantized Gradients of Activation Functions for Memory Footprint Reduction

Georgii S. Novikov, Daniel Bershatsky, Julia Gusak, Alex Shonenkov, Denis Dimitrov, Ivan V. Oseledets

TL;DR

This paper introduces "Few-Bit Backward," a novel method to significantly reduce memory usage during neural network training by quantizing the gradients of activation functions. By approximating these gradients with piecewise-constant functions using only a few bits, they achieve substantial memory savings (up to 40%) without compromising model accuracy or convergence speed.

What Problem Does This Paper Address?

Training large neural networks demands a massive amount of memory, primarily for storing intermediate "activations" during the forward pass, which are needed for gradient computation in the backward pass. This memory bottleneck limits the size of models that can be trained and the batch sizes that can be used, slowing down research and development. While techniques like checkpointing and offloading exist, this paper focuses on reducing the memory cost associated with pointwise activation functions, which are ubiquitous in modern architectures and contribute significantly to the memory footprint.

Methods

The core idea is to avoid storing the full precision input to activation functions for the backward pass. Instead, the authors propose to store a low-bit representation of the derivative of the activation function. They achieve this by:

  1. Piecewise-Constant Approximation: Approximating the derivative of activation functions with piecewise-constant functions. This means dividing the input range into several intervals and assigning a constant value to the derivative within each interval.
  2. Optimal Quantization: Developing a systematic approach to find the optimal boundaries and values for these piecewise-constant approximations. This is framed as a minimization problem using a weighted L2 norm of the error between the true derivative and the approximation.
  3. Dynamic Programming: Employing dynamic programming to find a good initial approximation, which can then be fine-tuned. This helps overcome the issue of local minima in the optimization process.
  4. Drop-in Replacement: The resulting quantized approximations are designed to be drop-in replacements for standard activation functions, requiring minimal changes to existing deep learning pipelines.

Datasets

The paper evaluates its method on several standard benchmarks:

  • GLUE benchmark: Used for evaluating RoBERTa-base and RoBERTa-large models.
  • Russian Emoji dataset: Used for training the ruDALL-E Malevich model.
  • ImageNet: Used for training ResNet18 models with ReLU replaced by Swish or GELU.

No new benchmarks were introduced.

Key Insights and Ideas

  • Gradients, Not Inputs: The key insight is that for many activation functions, storing a quantized version of their derivative is sufficient for accurate gradient computation, rather than storing the original input tensor itself. This is because the backward pass often involves multiplying the incoming gradient by the derivative of the activation function.
  • Piecewise-Constant is Sufficient: The paper demonstrates that even a simple piecewise-constant approximation of the derivative can yield excellent results, especially with just a few bits. This is a significant simplification compared to trying to precisely represent the complex shapes of some derivatives.
  • Data-Agnostic Optimization: The method for finding optimal piecewise-constant approximations is data-agnostic, meaning it can be pre-computed for any activation function and used universally across different models and tasks. This simplifies implementation and deployment.
  • 3-Bit is Often "Good Enough": The experiments consistently show that using 3 bits for the quantized gradients provides performance very close to, or indistinguishable from, the full-precision version, while offering substantial memory savings.

Key Results

  • Memory Reduction: The proposed "Few-Bit Backward" method achieves significant memory savings, with up to 40% reduction reported in some cases (e.g., GPT2 model with 1-bit quantization). For many models and tasks, 3-bit quantization offers savings of around 15-30% with negligible impact on performance.
  • Accuracy Preservation: Across various models (ResNet, DenseNet, RoBERTa, GPT2) and tasks, the quantized methods (especially 3-bit and 4-bit) show no visible degradation in learning quality or final performance metrics compared to standard full-precision training.
  • Convergence: The training dynamics (loss curves) for quantized models closely mirror those of their full-precision counterparts, indicating that the stochastic optimization process is not negatively affected.
  • Drop-in Replacement: The method is demonstrated to be a practical "drop-in" solution, easily integrated into existing pipelines without extensive retraining or hyperparameter tuning.

Limitations and Future Work

  • Approximation Error: While the paper shows minimal impact, there is an inherent approximation error introduced by quantization. The authors acknowledge that for some tasks or specific activation functions, more bits might be needed to maintain performance.
  • Computational Overhead: While memory is saved, there might be a slight increase in computation due to the lookup and multiplication with quantized values, though this is generally outweighed by the memory benefits.
  • Future Work: The authors suggest exploring convergence rates of these approximations and applying the method to a wider range of architectures and tasks. They also mention that their approach is complementary to other memory-saving techniques like weight quantization and low-rank decomposition.

Summary updated

BibTeX
@inproceedings{novikov2023few,
  author = {Georgii S. Novikov and Daniel Bershatsky and Julia Gusak and Alex Shonenkov and Denis Dimitrov and Ivan V. Oseledets},
  title = {{Few-Bit Backward: Quantized Gradients of Activation Functions for Memory Footprint Reduction}},
  booktitle = {International Conference on Machine Learning},
  year = {2023},
  url = {https://openreview.net/forum?id=m2S96Qf2R3},
}
Figure