Gradient Descent: The Ultimate Optimizer

Kartik Chandra, Audrey Xie, Jonathan Ragan-Kelley, Erik MeijerNeurIPS 2022

Introduction

Hyperparameter tuning is often considered the "dark art" of deep learning. Choosing the right learning rate ($\alpha$) is a high-stakes balancing act: set it too small, and training takes forever; set it too large, and the model fails to converge.

While previous researchers have derived "hypergradients" to adapt $\alpha$ dynamically during training, these derivations were traditionally done manually. This manual approach is tedious, error-prone, and doesn't scale—every time you change your optimizer (e.g., from SGD to Adam), you have to re-derive the underlying math. Furthermore, these methods often introduce a new hyperparameter (the hyper-step size) that also needs tuning, seemingly just moving the goalposts.

This paper presents a method to automatically tune optimizer hyperparameters—like learning rate and momentum—using gradient descent itself. By leveraging automatic differentiation and recursive "towers" of optimizers, the authors create a system that is significantly more robust to initial hyperparameter choices and can even learn complex, hand-engineered learning rate schedules from scratch.

Methods: Automating Hypergradients

The authors propose a fully automated approach using Reverse-Mode Automatic Differentiation (AD).

1. Selective Detachment in the Computation Graph

In a standard training loop, we compute the gradient of the loss with respect to the weights ($\partial f / \partial w$) and update the weights. To prevent the computation graph from growing infinitely, we "detach" the weights from the graph after each step.

The authors' key insight is to selectively refrain from detaching the hyperparameters. By keeping the edge from the hyperparameter (like $\alpha$) to the weights intact in the computation graph, the AD system can automatically compute the gradient of the loss with respect to $\alpha$ ($\partial f / \partial \alpha$).

HyperSGD computation graph where the hyperparameter alpha remains attached to allow for hypergradient computation.

2. Recursive Stacking

Since the "hyper-optimizer" (the one updating $\alpha$) has its own hyperparameter (the hyper-step size $\kappa$), the authors apply their method recursively. They build "towers" of optimizers where Level 0 optimizes model weights, Level 1 optimizes Level 0's hyperparameters, Level 2 optimizes Level 1's hyperparameters, and so on ad infinitum.

Key Insights and Results

The authors evaluated their "HyperOptimizers" across several standard benchmarks, including MNIST (MLP), CIFAR-10 (ResNet-20), Tolstoy Dataset (Char-RNN), and Caltech-256 (ResNet-152 fine-tuning). The experiments revealed several compelling properties:

The "Tower" Robustness

The most striking finding is that as the stack of optimizers grows taller, the system becomes increasingly indifferent to the initial hyperparameter choice. A 3-level stack can achieve near-optimal results even if the base learning rate is initialized several orders of magnitude away from the "correct" value.

Emergent Schedules

The hyperoptimizer doesn't just find a better constant value; it learns a dynamic schedule. On ResNet-20, the system automatically discovered a learning rate decay schedule that looks remarkably like the hand-engineered schedules used by human experts.

The hyperoptimizer learns a learning rate decay schedule strikingly similar to the one engineered by He et al. (2015).

Generality for Free

Because the method uses AD, it can optimize any continuous hyperparameter—momentum coefficients, Adam's $\beta_1$ and $\beta_2$, or even RMSProp's smoothing constants—without any extra derivation.

Performance Gains and Low Overhead

  • Accuracy: On MNIST, hyperoptimized SGD achieved a test error of ~4.8%, nearly doubling the performance of the standard SGD baseline (~9.0%). In the ResNet-20 experiments, the hyperoptimizer matched or exceeded the performance of the highly-tuned original ResNet training procedure, even when starting from "bad" initializations.
  • Efficiency: Despite the recursive nature, the computational cost is minimal. Each additional level in the optimizer tower adds only about 1-2% to the total runtime, as the extra work only involves the optimizer's update logic, not the model's forward/backward passes.

Limitations and Future Work

While robust, the system isn't invincible. If the initial learning rate is so high that the model diverges in the very first step, the hyperoptimizer won't have enough signal to correct it. Additionally, while the authors provide strong empirical proof of success, they note that a deeper theoretical analysis of the convergence of these nested, non-stationary systems is still needed. Finally, using this in practice requires care with computation graph management (e.g., ensuring loggers don't cause memory leaks by holding onto old graph nodes).

Summary updated

BibTeX
@inproceedings{chandra2022gradient,
  author = {Kartik Chandra and Audrey Xie and Jonathan Ragan-Kelley and Erik Meijer},
  title = {{Gradient Descent: The Ultimate Optimizer}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2022},
  url = {https://openreview.net/forum?id=84GFOqqsUf},
}
Figure