TL;DR
Training quantized neural networks—where weights and activations are compressed into low-precision formats like 4-bit integers—usually relies on a mathematical white lie called the Straight-Through Estimator (STE), which pretends the non-differentiable rounding step has a derivative of 1. This paper introduces Rotated Fourier Surrogate (RFS), a drop-in replacement for STE that rotates the rounding function by $45^\circ$ to turn its jagged staircase into a smooth, periodic wave. The result is a simple, well-conditioned gradient estimator that matches STE's speed and memory footprint while consistently improving accuracy and training stability across LLMs, vision transformers, CNNs, and diffusion models.
What Problem Does This Paper Address?
Quantization shrinks neural networks by mapping high-precision floating-point numbers (like FP32 or BF16) to low-precision discrete values (like INT4, INT2, or FP4). The catch is that quantization relies on round(), a staircase-shaped function whose derivative is zero almost everywhere. Without a usable derivative, standard backpropagation stalls.
The universal workaround is STE, which simply ignores round() during the backward pass and passes gradients straight through unchanged. While fast and simple, STE completely discards the discrete structure of quantization. At aggressive precisions (like 2-bit or 3-bit), this forward–backward mismatch causes biased updates, training instability, and degraded model quality.
Existing alternatives to STE—such as soft tanh relaxations (DSQ), gradient-dependent scaling (EWGS), or truncated Fourier series (FDA-BNN)—come with painful trade-offs: exploding gradient variance, sensitivity to gradient noise, $3\times$ higher memory overhead, or narrow applicability to specific architectures like binary CNNs.
Methods
RFS solves this with a neat geometric trick: if you rotate the graph of $x_q = \text{round}(x)$ counterclockwise by $45^\circ$, the discontinuous staircase becomes a continuous, periodic triangle wave.
Because this rotated wave is continuous and periodic, it has an exact Fourier series representation. Instead of keeping infinite terms, the authors truncate it to just the first-order term ($M = 0$) and introduce a tunable damping amplitude $A$ to control how sharply it approximates rounding. Rotating back to the original coordinates and differentiating yields a clean, closed-form surrogate multiplier:
$$g_{\text{RFS}}(x, x_q, A) = \frac{1 - \sqrt{2}\pi A \cos(\pi(x + x_q))}{1 + \sqrt{2}\pi A \cos(\pi(x + x_q))}$$
Three design choices make RFS practical:
- Strict Generalization of STE: Setting $A = 0$ gives $g_{\text{RFS}} = 1$, recovering STE exactly. By default, the authors use $A \approx 0.184$, which keeps the gradient's condition number bounded ($\kappa = 10$).
- Unified INT and FP Support: By locally normalizing any ordered codebook between adjacent levels, RFS applies identically to uniform integer (INT) and non-uniform floating-point (FP) formats.
- Normalized Activation Variant: For activation quantization—where shared step-size parameters aggregate gradients over many elements—outliers can dominate. RFS divides each activation's surrogate scalar by the batch's empirical mean (with
StopGrad) to preserve the overall gradient scale.
Datasets
The authors evaluate RFS across a wide range of benchmarks:
- Synthetic Benchmark: A 100-dimensional quantized quadratic optimization problem with injected Gaussian gradient noise.
- LLM Pre-training: A 1:1 mix of SlimPajama and FineWeb-Edu.
- Reasoning Post-training: AIME-2025, AIME-90, and MATH-500.
- Generative Recommendation: Amazon Beauty.
- Image Classification: CIFAR-10 (for binary networks) and ImageNet-1K (for QAT and PTQ).
- LLM PTQ & Distillation: WikiText-2, Wikipedia, Alpaca, and common-sense reasoning tasks (ARC-E/C, HellaSwag, PIQA, OBQA, SciQ, WinoGrande).
Key Insights and Ideas
- First-order is enough: Higher-order Fourier truncations ($M > 0$) approximate
round()more tightly, but they reintroduce fine oscillations that hurt optimization under gradient noise. The smooth $M=0$ version hits the sweet spot. - Bounded variance prevents collapse: Unlike DSQ, whose gradient variance explodes to $\infty$ as it sharpens toward
round(), RFS's gradient variance stays strictly bounded ($\approx 0.076$ at maximum sharpness). In practice, this translates to $1.95\text{–}4.60\times$ lower gradient variance than DSQ during W4 QAT. - Noiseless mean preservation: Under zero-mean stochastic gradient noise, EWGS introduces a systematic drift toward the current quantization bin. RFS preserves the zero-mean property and remains smooth everywhere.
Key Results
- Negligible Overhead: Across LLaMA 1B–13B, RFS nearly matches STE in both latency and peak memory, whereas EWGS requires roughly $3\times$ higher peak backward memory.
- LLM Continuous Pre-training (QAT): On LLaMA-3.2-1B (3-bit), RFS achieves 59.93 ± 0.14 average accuracy, beating ParetoQ (58.80 ± 0.63) and avoiding DSQ's training collapses (52.14 ± 10.71).
- Reasoning Post-Training: On DeepSeek-R1-14B (NVFP4 W4A4KV4), RFS improves accuracy over STE by +1.80% to +10.00% across MATH-500, AIME-90, and AIME-2025.
- Post-Training Quantization (PTQ): On LLaMA-2-7B and LLaMA-3-8B (W4A4KV16), RFS boosts FlatQuant by +0.65% and +0.82% average accuracy, respectively. On ImageNet W3A3 PTQ, it improves NWQ by +0.80% (ResNet-18) and +1.78% (MobileNetV2).
- Binary Neural Networks: On ResNet-20 (CIFAR-10, 1-bit), RFS reaches 86.14% best-of-3 accuracy, outperforming FDA-BNN (+0.28%) without extra learnable modules.
Limitations and Future Work
The authors use a fixed damping amplitude $A$ throughout all experiments. While $A \approx 0.184$ works well as a default, the optimal amplitude can vary by model architecture, bit-width, and task. Designing a dynamic or adaptive amplitude scheduler—which could further improve quantized model quality—is left for future work.
Summary updated