Optimization Hyper-parameter Laws for Large Language Models

Xingyu Xie, Kuangyu Ding, Shuicheng Yan, Kim-Chuan Toh, Tianwen WeiarXiv 2024 · DOI

Abstract

Traditional scaling laws provide a roadmap for model size and data volume but offer limited insight into the optimization process. This paper introduces Opt-Laws, a framework based on Stochastic Differential Equations (SDEs) that predicts the impact of learning rate (LR) schedules and warmup steps on final model loss. By leveraging small-scale pilot experiments, Opt-Laws enable the pre-selection of optimal training configurations for large-scale models, minimizing the risk of divergence and maximizing performance.

Introduction

Training a Large Language Model (LLM) is a high-stakes, resource-intensive endeavor. While existing "Scaling Laws" (e.g., Chinchilla or Kaplan laws) guide practitioners on the necessary model size ($N$) and data volume ($D$), they treat the optimization process as a black box. Consequently, critical decisions regarding time-dependent hyper-parameters—such as peak learning rate and warmup duration—are often made using heuristics or costly trial-and-error.

This research bridges the gap by introducing Opt-Laws, a mathematical framework grounded in Stochastic Differential Equations (SDEs). Opt-Laws allow researchers to predict how specific optimization dynamics will affect final model performance, effectively turning hyper-parameter tuning into a predictable science.

Theoretical Foundation: Opt-Laws

The authors shift from empirical curve-fitting to a continuous-time modeling approach. By approximating discrete optimization steps (SGD and Adam) as continuous-time Itô-SDEs, they derive mathematical bounds for two critical training aspects:

  1. Convergence Speed: The rate at which a model approaches a stationary point in the loss landscape.
  2. Escaping Probability: The model's capacity to transition from "sharp" local minima to "flatter" regions, which typically correlate with better generalization.

From these derivations, the authors extract a 16-dimensional statistical feature vector that captures the complex interactions between model architecture, data scale, and the LR schedule. By fitting a linear regression model to this vector using data from small-scale "pilot" runs (e.g., 0.1B parameter models), the resulting Opt-Law can accurately predict the performance of models orders of magnitude larger.

Experimental Methodology

The framework was validated across three distinct training scenarios using models up to 4B parameters:

  • Pre-training: Utilizing the RedPajama-v2 dataset (up to 300B tokens).
  • Continual Training: Using Chinese Common Crawl data (100B tokens).
  • Fine-tuning: Focused on the Stack-Repo Java code dataset (60B+ tokens).

To address training stability, the authors also introduced a divergence metric ($R$). This metric compares the "effective warmup" time against the duration spent at dangerously high learning rates to predict potential training crashes.

Key Insights: The Dynamics of Optimization

Opt-Laws reveal several counter-intuitive properties of LLM training:

  • The Asymptotic Limit: As the volume of training data increases, the specific choice of LR schedule becomes less critical. The model eventually reaches a performance floor dictated by its parameter capacity. This explains conflicting reports in literature regarding the importance of LR schedules; the impact depends entirely on the model's position on the data-to-parameter curve.
  • Warmup Sensitivity: Fine-tuning is significantly more sensitive to warmup steps than pre-training. Because fine-tuning typically involves a lower token-to-parameter ratio, the training regime is dominated by the "escaping probability" factor, making the initial warmup phase crucial for reaching stable, high-performing regions.
  • Predictable Instability: Training divergence is not merely a product of a high peak LR, but a function of the time spent above a critical threshold relative to the warmup length.
Training loss contours across different token counts (3B to 30B) as a function of normalized peak learning rate and warmup steps.

Empirical Results

The predictive power of Opt-Laws was demonstrated through several key metrics:

  • High Accuracy: The framework predicted the final pre-training loss of 4B-parameter models with a relative error of less than 0.1%.
  • Zero-Shot Ranking: By calibrating on 0.1B models, the authors successfully ranked the effectiveness of various LR schedules for 4B models on unseen tasks, such as Java code fine-tuning.
  • Stability Guarantee: The divergence metric ($R$) achieved 100% accuracy in predicting whether a specific hyper-parameter configuration would lead to a successful run or a catastrophic divergence.

Limitations and Future Directions

While robust, the current iteration of Opt-Laws assumes that gradient noise follows a Gaussian distribution. Future work may explore "heavy-tailed" noise distributions which might more accurately reflect real-world LLM dynamics. Additionally, while the theory is general, the specific coefficients were calibrated for Mixture-of-Experts (MoE) architectures and the AdamW optimizer; further research is needed to extend these constants to alternative architectures like State Space Models or different optimization algorithms.

Summary updated

BibTeX
@misc{xie2024optimization,
  author = {Xingyu Xie and Kuangyu Ding and Shuicheng Yan and Kim-Chuan Toh and Tianwen Wei},
  title = {{Optimization Hyper-parameter Laws for Large Language Models}},
  year = {2024},
  eprint = {2409.04777},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2409.04777},
}
Figure