Flatter, faster: scaling momentum for optimal speedup of SGD

Aditya Cowsik, Tankut Can, Paolo Glorioso

TL;DR

Researchers have identified a "Goldilocks" scaling rule for momentum in Stochastic Gradient Descent (SGD): scaling the momentum hyperparameter $1-\beta$ with the learning rate $\eta$ to the power of $2/3$ ($1-\beta \sim \eta^{2/3}$) provides the maximum possible training speedup. This specific scaling allows models to converge faster while still finding the "flatter" minima that lead to superior generalization in overparametrized neural networks.

What Problem Does This Paper Address?

In modern deep learning, we often use models with far more parameters than data points. These overparametrized models don't just have one "best" solution; they possess a continuous manifold of global minimizers—a vast "valley" in the loss landscape where the training error is zero.

The challenge is two-fold:

  1. Generalization: Not all points in this valley are equal. Points in "flatter" regions (where the loss changes slowly if you move the parameters) tend to generalize better to new data. Plain SGD is known to eventually drift toward these flatter regions, but it is notoriously slow.
  2. Speed: Adaptive methods like Adam are fast but often generalize worse than SGD. Adding momentum to SGD (SGDM) can bridge this gap, but practitioners lack a principled way to tune the momentum hyperparameter $\beta$ relative to the learning rate $\eta$.

The authors aim to find the optimal relationship between these two hyperparameters to maximize speed without losing the "implicit regularization" (the drift toward flat minima) that makes SGD so effective.

Methods

The authors develop an architecture-independent theoretical framework by modeling SGDM as a continuous-time drift-diffusion process. They analyze the dynamics near the zero-loss manifold using two distinct timescales:

  • $\tau_1$ (Equilibration): The time it takes for the parameters to relax back to the valley after being pushed away by noise.
  • $\tau_2$ (Drift): The time it takes for the parameters to move along the valley toward flatter regions.

By setting the momentum scaling as $\beta = 1 - C\eta^\gamma$, they analytically derive how these timescales behave as the learning rate $\eta$ goes to zero. They use the mathematical framework of Katzenberger (1991) to show that the optimal training speed occurs when these two timescales are balanced—specifically, when they "meet" at $\gamma = 2/3$.

Datasets

The authors validated their theoretical scaling rule across a variety of tasks:

  • Synthetic Regression: Matrix sensing and a "vector UV model" (a 2-layer linear MLP) used to precisely measure convergence timescales.
  • Image Classification:
    • CIFAR-10 using a ResNet-18 architecture.
  • FashionMNIST using a 6-layer MLP.

Key Insights and Ideas

  • The Timescale Collision: The most important finding is that training speed is limited by the slower of the two timescales ($\tau_1$ and $\tau_2$). As you increase momentum ($\beta \to 1$), the drift along the valley ($\tau_2$) speeds up, but the relaxation back to the valley ($\tau_1$) slows down. The "sweet spot" is the intersection where neither process bottlenecks the other.
  • Universality: The $2/3$ power law appears robust across different activation functions (Linear, Tanh, ReLU) and architectures.
  • Optimal Generalization via Speed: Interestingly, the momentum scaling that leads to the fastest training also leads to the best test accuracy. This is because faster transport along the manifold allows the optimizer to reach flatter, more stable regions within a fixed number of training steps.
Figure 1: Timescale of training as a function of γ. a): theoretical prediction with blue line repre- senting the timescale for equilibration while the black line shows the timescale of the drift along Γ. The maximum of these two gives the overall timescale. In b), c), and d) we demonstrate this result with the vector UV model with linear, tanh and Relu activations respectively.

Key Results

  • Theoretical Match: In experiments with the UV model, the measured convergence power matched the theoretical prediction almost perfectly. For $\gamma < 2/3$, the timescale scales as $\eta^{-2(1-\gamma)}$, and for $\gamma > 2/3$, it scales as $\eta^{-\gamma}$.
  • ResNet-18 on CIFAR-10: The authors found that the optimal momentum $\beta_*$ followed the power law $1 - \beta_* \propto \eta^{0.66}$, which is remarkably close to the predicted $2/3 \approx 0.667$.
  • Prefactor $C$: The theory also provides a way to estimate the constant $C$. For a ResNet-18 on CIFAR-10, they found $C \approx 0.11$. Notably, if the learning rate $\eta=1$, this yields $\beta \approx 0.9$, which aligns with the standard heuristic used by practitioners for years, now given a theoretical foundation.

Limitations and Future Work

  • Small Noise Limit: The theoretical derivation assumes a limit of small noise and small learning rates. While the results hold well in practice, the dynamics might shift in high-noise or very large learning rate regimes (e.g., the "catapult" phase).
  • Label Noise Focus: The study focuses heavily on "algorithmic" label noise as the source of stochasticity. While common in theoretical studies, extending this to the mini-batch noise typical of standard SGD is a natural next step.
  • Adaptive Algorithms: The authors suggest that this principle could be extended to design new schedules for adaptive algorithms like Adam, potentially helping them achieve SGD-like generalization without losing their speed advantage.

Summary updated

BibTeX
@inproceedings{cowsik2023flatter,
  author = {Aditya Cowsik and Tankut Can and Paolo Glorioso},
  title = {{Flatter, faster: scaling momentum for optimal speedup of SGD}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
  url = {https://openreview.net/forum?id=3IXDfzaJ2LF},
}
Figure