Deep neural networks are highly effective but computationally expensive. Restricting network weights to discrete values—such as binary ($\pm1$) or ternary ($\{-1, 0, 1\}$) representations—can drastically reduce memory footprints and replace power-hungry floating-point multiplications with rapid bitwise operations. This paradigm shift enables high-performance deep learning on low-power edge hardware, as demonstrated in Binarized Neural Networks by Itay Hubara et al.
However, training these networks presents a fundamental mathematical paradox: standard backpropagation relies on smooth, continuous gradients, but discrete quantization functions (like the step or sign function) have a derivative of zero almost everywhere. This creates a "gradient dead-end" that prevents standard optimization algorithms from updating discrete parameters directly.
The Geometry of Discrete Landscapes
To understand why discrete optimization fails standard calculus, consider the loss landscape. In a standard network, the loss landscape is a continuous surface where gradients point toward valleys of lower error. When weights are constrained to discrete values, this smooth surface turns into a jagged, discontinuous stair-step landscape composed of flat plateaus and sudden cliffs.
If you perturb a discrete weight slightly, the output does not change at all, resulting in a zero gradient. If you perturb it enough to cross a threshold, the output jumps discretely. Because standard calculus cannot navigate these flat plateaus, algorithms get trapped in poor local configurations. To overcome this, researchers have developed three core intuitions: tracking hidden continuous states, smoothing the landscape over time, and bypassing gradients entirely.
Shadow Weights and Straight-Through Gradients
The most common strategy to bridge the gap between continuous gradients and discrete weights is a dual-representation framework. During training, the network maintains a hidden set of high-precision "shadow weights." In the forward pass, these shadow weights are quantized to discrete values to compute the model's loss. In the backward pass, the non-differentiable quantization function is bypassed using a Straight-Through Estimator (STE) or a greedy gradient transmission layer, as explored by Chao Zhang et al. in Greedy Hash: Towards Fast Optimization for Accurate Hash Coding in CNN.
Forward Pass: [Shadow Weight (Continuous)] ---> (Quantization) ---> [Discrete Weight] ---> Loss
|
Backward Pass: [Updated Shadow Weight] <--- (Passes Straight Through) <--- [Gradient] <------+
Why does this work? A theoretical analysis by Hao Li 0009 et al. in Training Quantized Nets: A Deeper Understanding reveals that shadow weights act as a running accumulator of small gradient updates. Even if a single update is not large enough to flip a discrete weight's state, the shadow weight slowly drifts across the plateau. Once the accumulated gradient pushes the shadow weight past a threshold, the discrete weight finally flips. This mechanism effectively enables a "greedy search" across the non-convex landscape, allowing the model to refine its configuration as training progresses.
Continuous Relaxation and Continuation
Rather than forcing the network to deal with hard discrete thresholds from day one, another powerful approach is to start smooth and gradually harden the optimization landscape over time. This is known as a continuation method.
For instance, the authors of HashNet: Deep Learning to Hash by Continuation utilize a smooth, differentiable approximation of the sign function that slowly scales up its sharpness during training. Similarly, Jiwei Yang et al. propose Quantization Networks, which treat quantization as a learnable activation function composed of a sum of sigmoids combined with a temperature annealing strategy.
By starting with a highly smooth approximation, the initial optimization landscape remains differentiable, allowing standard backpropagation to navigate toward a strong global region. As the temperature cools or the continuation parameter scales, the landscape gradually morphs into the true, jagged discrete surface. Because the weights are already near a high-quality local minimum, they settle cleanly into the correct discrete states without getting trapped early on.
Alternatively, one can relax the weights probabilistically. In Searching for Low-Bit Weights in Quantized Neural Networks, Zhaohui Yang et al. frame quantization as a search problem over a discrete probability distribution. By optimizing the continuous parameters of this distribution rather than the discrete weights themselves, the objective function becomes fully differentiable.
Bypassing Gradients via Alternative Optimization
If calculating gradients through discrete operations is fundamentally flawed, a third paradigm replaces or complements gradient descent with optimization frameworks designed explicitly for hard constraints.
For example, Cong Leng et al. leverage the Alternating Direction Method of Multipliers (ADMM) in Extremely Low Bit Neural Network: Squeeze the Last Bit Out With ADMM to decouple the structural loss of the network from the discrete constraints. On another front, Daniel Soudry et al. introduce Expectation Backpropagation, a Bayesian framework that propagates the posterior distributions of weights rather than point estimates.
More recently, zeroth-order "perturb-and-evaluate" methods have emerged to optimize quantized models entirely without backpropagation. This is demonstrated by Hoigi Seo et al. for diffusion models and by Zeshuai Deng et al. in Test-Time Model Adaptation for Quantized Neural Networks.
These methods circumvent the zero-gradient problem by changing how updates are calculated:
- ADMM splits the problem into a continuous optimization step and a projection step onto the discrete space, avoiding the need to differentiate through the projection.
- Expectation Backpropagation updates the continuous probabilities of weights being in a given discrete state, maintaining a smooth gradient flow.
- Zeroth-Order Optimization estimates updates by evaluating the loss function at slightly perturbed points in the weight space, completely bypassing the internal non-differentiable operations of the quantized network.