Improving Line Search Methods for Large Scale Neural Network Training

Philip Kenneweg, Tristan Kenneweg, Barbara HammerarXiv 2024 · DOI

Abstract

In recent studies, line search methods have shown significant improvements in the performance of traditional stochastic gradient descent techniques, eliminating the need for a specific learning rate schedule. In this paper, we identify existing issues in state-of-the-art line search methods, propose enhancements, and rigorously evaluate their effectiveness. We test these methods on larger datasets and more complex data domains than before. Specifically, we improve the Armijo line search by integrating the momentum term from ADAM in its search direction, enabling efficient large-scale training, a task that was previously prone to failure using Armijo line search methods. Our optimization approach outperforms both the previous Armijo implementation and tuned learning rate schedules for Adam. Our evaluation focuses on Transformers and CNNs in the domains of NLP and image data. Our work is publicly available as a Python package, which provides a hyperparameter free Pytorch optimizer.

Introduction

Training large-scale neural networks is often a process of trial and error, primarily centered around the manual tuning of learning rate schedules. The learning rate is arguably the most critical hyperparameter; an improper setting can lead to slow convergence or total divergence. While adaptive methods like Adam have simplified this, they still typically rely on external schedules (e.g., cosine decay or linear warmup) that require domain expertise to tune.

Line search methods offer a classic alternative by attempting to calculate the optimal step size dynamically. However, previous implementations like Stochastic Line Search (SLS) have struggled with large-scale tasks, particularly those involving Transformers. A primary reason for this failure is the "direction mismatch": these methods often search along the gradient direction while the optimizer actually moves along a momentum-based direction. This discrepancy causes the line search to select ineffective, near-zero step sizes.

The ALSALS Method

To address these limitations, we introduce ALSALS (Automated Large Scale ADAM Line Search). ALSALS integrates Adam-style momentum into the Armijo line search framework, ensuring the search direction aligns with the actual update step.

Key Innovations

  1. Momentum-Aware Search: By performing the line search in the direction of the actual Adam update (incorporating moving averages of past gradients), ALSALS avoids the direction mismatch trap.
  2. Gradient Magnitude Approximation: We introduced a new term, $f_a$, to approximate loss changes when momentum is present, maintaining the validity of the Armijo rule even when the update direction deviates from the immediate gradient.
  3. Conservative Step Selection: Our analysis of the loss landscape revealed that picking the absolute "best" step size for a single mini-batch often leads to global instability. ALSALS prioritizes a "safe zone" for step sizes.
Visualization of the loss decrease landscape over training steps. The green dots indicate the conservative step sizes selected by ALSALS, maintaining stability within the 'safe zone' of loss reduction.
  1. Smoothing: To handle the inherent noise of stochastic mini-batches, we apply exponential moving average smoothing to the Armijo equation.

Experimental Evaluation

We evaluated ALSALS across diverse and demanding benchmarks, including GPT-2 on OpenWebText, BERT fine-tuning on GLUE, and ResNet architectures on CIFAR and ImageNet.

Large-Scale Performance

On ImageNet, ALSALS achieved a final loss of 1.324, outperforming both tuned Adam (1.388) and the previous Adam+SLS (3.493). Notably, Adam+SLS failed to converge properly, highlighting the necessity of our momentum integration.

Training loss comparison on a large-scale task. ALSALS (purple) demonstrates competitive performance with tuned Adam (green) and superior stability compared to the previous Adam+SLS (black) approach.

In NLP tasks, ALSALS successfully trained GPT-2 to a lower final loss (3.078) than tuned Adam (3.135), demonstrating its robustness in handling the sensitivity of large Transformer models.

Discussion and Insights

The success of ALSALS stems from the realization that in a noisy stochastic environment, aiming for the local optimum of a single batch is counterproductive. By using a more conservative estimate (a higher $c$ value in the Armijo rule), ALSALS achieves better global convergence. Furthermore, ALSALS effectively eliminates the need for manual learning rate intervention, "just working" across different architectures like CNNs and Transformers with the same internal settings.

Conclusion

ALSALS provides a robust, hyperparameter-free alternative to traditional learning rate schedules. While it introduces a parameter $c$, we found a value of $0.6$ to be universally effective across our tests. Future work will focus on further reducing the computational overhead of the additional forward passes required by the line search. ALSALS is available as a PyTorch optimizer package for immediate research use.

Summary updated

BibTeX
@misc{kenneweg2024improving,
  author = {Philip Kenneweg and Tristan Kenneweg and Barbara Hammer},
  title = {{Improving Line Search Methods for Large Scale Neural Network Training}},
  year = {2024},
  eprint = {2403.18519},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2403.18519},
}
Figure