ZClip: Adaptive Spike Mitigation for LLM Pre-Training

Abhay Kumar, Louis Owen, Nilabhra Roy Chowdhury, Fabian Güra
4/3/2025
cs.LGcs.CL

Official code: bluorion-com/ZClip (153 stars, Apache-2.0, last commit 2025-11-20).

Abstract

Training large language models (LLMs) presents numerous challenges, including gradient instability and loss spikes. These phenomena can lead to catastrophic divergence, requiring costly checkpoint restoration and data batch skipping. Traditional gradient clipping techniques, such as constant or norm-based methods, fail to address these issues effectively due to their reliance on fixed thresholds or heuristics, leading to inefficient learning and requiring frequent manual intervention. In this work, we propose ZClip, an adaptive gradient clipping algorithm that dynamically adjusts the clipping threshold based on statistical properties of gradient norms over time. Unlike prior reactive strategies, ZClip proactively adapts to training dynamics without making any prior assumptions on the scale and the temporal evolution of gradient norms. At its core, it leverages z-score-based anomaly detection to identify and mitigate large gradient spikes, preventing malignant loss spikes while not interfering with convergence otherwise. Our code is available at: https://github.com/bluorion-com/ZClip.

View on arXivView PDF

Code Implementations(1)

bluorion-com/ZClipOfficial100%
Apache-2.0

Official implementation of the paper: "ZClip: Adaptive Spike Mitigation for LLM Pre-Training".

15311Shell, PythonMar 21, 202511 months agoApache-2.0
adaptive-clippingadaptive-gradient-clippingenable-high-learning-rategradient-clippinggradient-norm-clipping+8 more

Similar Papers

Cite this paper

@article{kumar2025zclip,
  title  = {ZClip: Adaptive Spike Mitigation for LLM Pre-Training},
  author = {Abhay Kumar and Louis Owen and Nilabhra Roy Chowdhury and Fabian Güra},
  year   = {2025},
  eprint = {2504.02507},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2504.02507v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2504.02507.svg)](https://codeofpaper.com/paper/2504.02507)

Discussion