To Clip or not to Clip: the Dynamics of SGD with Gradient Clipping in High-Dimensions

Noah Marshall, Ke Liang Xiao, Atish Agarwala, Elliot Paquette

TL;DR

This paper provides a rigorous theoretical framework for gradient clipping in high-dimensional settings, modeling its dynamics through a system of deterministic ordinary differential equations (ODEs). The authors reveal that clipping's effectiveness hinges on a fundamental trade-off between signal reduction and noise suppression, and they propose a simple, near-optimal heuristic for scheduling the clipping threshold during training.

What Problem Does This Paper Address?

Despite being a staple in training modern large-scale models (like GPT-3) and handling exploding gradients in RNNs, gradient clipping has largely remained a "black box" heuristic. We know it works, but we lack a deep theoretical understanding of why it helps in some scenarios and not others, or how to optimally tune the clipping threshold $c$ as models scale.

The authors aim to bridge this gap by analyzing clipped Stochastic Gradient Descent (C-SGD) in the limit of high "intrinsic dimension"—a measure of dimensionality that accounts for the actual structure of the data rather than just the number of parameters.

Methods

The researchers focus on a streaming (one-pass) linear regression problem using mean-squared error (MSE) loss. Their approach involves several key steps:

  1. Homogenization: They approximate the discrete C-SGD steps with a continuous Stochastic Differential Equation (SDE) called Clipped Homogenized SGD (C-HSGD).
  2. Deterministic Limits: In high dimensions, they show that the evolution of the loss (risk) concentrates around a deterministic path described by a system of ODEs.
  3. Reduction Factors: They introduce two unitless factors, $\mu$ (descent reduction) and $\nu$ (variance reduction), which quantify how clipping shrinks the useful gradient signal versus how much it dampens the noise.
  4. Criteria for Success: They derive the Clipped Stability Criterion (CSC) for when clipping improves algorithm stability and the Clipped Comparison Criterion (CCC) for when clipping actually outperforms optimally tuned unclipped SGD.

Datasets

The theory was validated using:

  • Synthetic Data: Gaussian data with various noise distributions, including Gaussian (light-tailed) and Cauchy (heavy-tailed) noise.
  • CIFAR10: Used for a binary classification task via regression.
  • Wikitext2: Processed for next-token prediction using embeddings from a GPT-2 model.

Key Insights and Ideas

  • The Signal-Noise Trade-off: Clipping is essentially a filter. It is beneficial only when it reduces the variance of the gradients ($\nu$) significantly more than it biases the descent direction ($\mu$).
  • Gaussian Noise is the Enemy of Clipping: One of the most striking findings is that if your gradient noise is Gaussian, clipping cannot improve performance over an optimally tuned unclipped SGD. In this regime, the "quality" of a gradient isn't well-correlated with its norm.
  • Heavy Tails are Where Clipping Shines: In settings with heavy-tailed noise (like Cauchy distributions), unclipped SGD often diverges. Clipping acts as a robust estimator, filtering out "outlier" gradients that would otherwise derail training.
  • Predictive Power: The derived ODEs aren't just theoretical constructs; they accurately track the actual risk curves of models trained on real-world datasets like CIFAR10 and Wikitext2.
Figure 1: Comparison of C-SGD, C-HSGD and their deterministic equivalent (ODE) with Gaussian or Cauchy noise, from the Student-t family. The solution to the unclipped ODE for reference in the Gaussian case. Unclipped SGD does not converge under Cauchy noise. We also compare clipped SGD with CIFAR10 as well as Wikitext2 data. In all cases, the deterministic equivalent ODE closely match the actual path of clipped SGD. Experiment details are available in Appendix H.

Key Results

  • Stability and Convergence: The authors proved that for any Gaussian data, one can always find a small enough clipping threshold to satisfy the stability criterion.
  • Optimal Scheduling: The paper proves that the optimal clipping threshold $c$ should change over time. They propose a simple heuristic: $c(t) \propto \sqrt{2R_t + \sigma^2}$, where $R_t$ is the current risk and $\sigma^2$ is the noise variance.
  • Heuristic Performance: In experiments with Rademacher-like noise, their simple heuristic achieved performance nearly identical to the theoretically optimal (but harder to compute) schedule, significantly outperforming standard SGD.

Limitations and Future Work

The primary limitation is the focus on least-squares (linear) problems. While the authors show promising results extending these ideas to non-linear models like ResNet18 and Vision Transformers (ViT) by measuring "intrinsic dimension" during training, a full theoretical treatment of non-convex landscapes remains for future work.

Additionally, the current analysis assumes a "streaming" setup where data is not reused. Extending this to the multiple-epoch regime common in deep learning would be a valuable next step to see how data repetition affects the gradient distribution and clipping dynamics.

Summary updated

Abstract

The success of modern machine learning is due in part to the adaptive optimization methods that have been developed to deal with the difficulties of training large models over complex datasets. One such method is gradient clipping: a practical procedure with limited theoretical underpinnings. In this work, we study clipping in a least squares problem under streaming SGD. We develop a theoretical analysis of the learning dynamics in the limit of large intrinsic dimension-a model and dataset dependent notion of dimensionality. In this limit we find a deterministic equation that describes the evolution of the loss and demonstrate that this equation predicts the path of clipped SGD on synthetic, CIFAR10, and Wikitext2 data. We show that with Gaussian noise clipping cannot improve SGD performance. Yet, in other noisy settings, clipping can provide benefits with tuning of the clipping threshold. We propose a simple heuristic for near optimal scheduling of the clipping threshold which requires the tuning of only one hyperparameter. We conclude with a discussion about the links between high-dimensional clipping and neural network training.
BibTeX
@inproceedings{marshall2025clip,
  author = {Noah Marshall and Ke Liang Xiao and Atish Agarwala and Elliot Paquette},
  title = {{To Clip or not to Clip: the Dynamics of SGD with Gradient Clipping in High-Dimensions}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=jmN1zXMq0O},
}
Figure