DoG is SGD's Best Friend: A Parameter-Free Dynamic Step Size Schedule

Maor Ivgi, Oliver Hinder, Yair Carmon

TL;DR

This paper introduces DoG (Distance over Gradients), a simple, parameter-free step size schedule for Stochastic Gradient Descent (SGD) that eliminates the need for manual learning rate tuning. By automatically adapting the step size based on the model's distance from its starting point and the norm of observed gradients, DoG achieves performance competitive with—and sometimes superior to—carefully tuned SGD and Adam across a wide range of vision and language tasks.

What Problem Does This Paper Address?

Choosing the right learning rate is arguably the most tedious and computationally expensive part of training machine learning models. Standard practice involves "grid searches" or "sweeps," where researchers train the same model multiple times with different learning rates to find the best one. This process can increase the total training cost by an order of magnitude.

While adaptive optimizers like Adam were designed to be more robust, they still require a "base learning rate" parameter that needs tuning for optimal performance. Existing "parameter-free" theoretical methods often rely on unrealistic global assumptions (like gradients being bounded everywhere) or are too complex for practical use. The authors aim to bridge this gap with a method that is both theoretically sound and practically effective without any multiplicative "learning rate" constant.

Methods

The core contribution is the DoG step size formula. For an SGD update $x_{t+1} = x_t - \eta_t g_t$, the step size $\eta_t$ is defined as:

$$\eta_t = \frac{\max_{i \le t} \|x_i - x_0\|}{\sqrt{\sum_{i \le t} \|g_i\|^2}}$$

In plain English, the step size at any moment is the maximum distance the model has traveled from its starting point ($x_0$), divided by the root sum of all squared gradient norms seen so far.

The authors propose three versions:

  1. DoG: The basic version described above.
  2. T-DoG (Tamed DoG): A theoretical variant that adds a logarithmic factor to the denominator. This ensures the iterates stay within a bounded region, allowing the authors to prove convergence guarantees even when gradients are only locally bounded.
  3. L-DoG (Layer-wise DoG): A practical variant that applies the DoG formula independently to each layer of a neural network, similar to how Adam scales updates per parameter.

Datasets

The authors evaluated their methods on a massive testbed of 23 tasks using 8 different model architectures:

  • Natural Language Understanding (NLU): Fine-tuning RoBERTa-base and T5-base on the GLUE benchmark (8 tasks including SST-2, MNLI, and QQP) and the SQuAD 1.1 question-answering dataset.
  • Computer Vision: Fine-tuning five architectures (VGG11, ResNet50, Densenet121, ViT-B/32, ConvNeXt-T) on 12 tasks from the VTAB benchmark (e.g., CIFAR-100, Caltech101, SVHN, Sun397).
  • Large-scale Fine-tuning: Fine-tuning a CLIP ViT-B/32 model on ImageNet.
  • Training from Scratch: Training a Wide ResNet 28-10 on CIFAR-10.

Key Insights and Ideas

  • Distance from Initialization Matters: Most adaptive methods focus solely on gradient statistics. DoG’s use of the distance from $x_0$ is a critical "parameter-free" signal. As the model moves further from its start, it can afford larger steps; as gradients accumulate, the denominator naturally decays the step size.
  • The Universal Constant $c=1$: The authors show that while one could add a constant $c$ to the formula ($\eta_t = c \cdot \dots$), setting $c=1$ is a "universally good" choice. This is the "aha" moment that makes the method truly parameter-free.
  • Stabilization Behavior: As shown in Figure 1, DoG step sizes typically start small, increase rapidly, and then stabilize near the optimal tuned learning rate for the specific problem.
Figure 1: Illustration of DoG for CIFAR-100 classification using logistic regression on last-layer features of a pre-trained ViT-B/32 (left) or end-to-end fine-tuning of the model (right). The top row shows the DoG step size sequence ηt for different values of the initial movement rϵ, and the bottom row shows that DoG attains test error on par with carefully tuned SGD (with cosine annealing), even when varying rϵ by several orders of magnitude. See details in Appendix E.6.
  • Local vs. Global Bounds: Theoretically, T-DoG is significant because it provides convergence guarantees without assuming gradients are bounded globally across the entire space—an assumption that fails even for simple problems like least squares.

Key Results

  • Competitive with Tuned SGD: In almost all 80 model/task combinations, DoG performed as well as SGD with a perfectly tuned learning rate.
  • L-DoG Closes the Adam Gap: While basic DoG sometimes lagged behind tuned Adam, the layer-wise version (L-DoG) significantly closed this gap, often matching or exceeding Adam's performance without any tuning.
  • Robustness: DoG is highly robust to its only minor configuration setting, $r_\epsilon$ (the initial step size), working well across several orders of magnitude.
  • Efficiency: Because it requires no tuning, DoG can save roughly 5x to 7x the total computation time typically spent on learning rate sweeps.

Limitations and Future Work

  • Batch Normalization: The authors noted that models using Batch Normalization (like ResNet50) can sometimes make DoG sensitive to the initial step size. They hypothesize this is due to the scale-invariance BN introduces.
  • Momentum: The current version of DoG does not explicitly incorporate momentum, which is a staple of modern deep learning. Integrating momentum while maintaining parameter-free guarantees is a key next step.
  • Training from Scratch: While successful on CIFAR-10, the authors suggest more extensive testing is needed for training massive models from scratch (rather than fine-tuning).

Summary updated

Abstract

We propose a tuning-free dynamic SGD step size formula, which we call Distance over Gradients (DoG). The DoG step sizes depend on simple empirical quantities (distance from the initial point and norms of gradients) and have no ``learning rate'' parameter. Theoretically, we show that a slight variation of the DoG formula enjoys strong parameter-free convergence guarantees for stochastic convex optimization assuming only \emph{locally bounded} stochastic gradients. Empirically, we consider a broad range of vision and language transfer learning tasks, and show that DoG's performance is close to that of SGD with tuned learning rate. We also propose a per-layer variant of DoG that generally outperforms tuned SGD, approaching the performance of tuned Adam. A PyTorch implementation is available at https://github.com/formll/dog
BibTeX
@inproceedings{ivgi2023dog,
  author = {Maor Ivgi and Oliver Hinder and Yair Carmon},
  title = {{DoG is SGD's Best Friend: A Parameter-Free Dynamic Step Size Schedule}},
  booktitle = {International Conference on Machine Learning},
  year = {2023},
  url = {https://openreview.net/forum?id=BVisv9lsvps},
}
Figure