Clipping in the Scale Factor: Adaptive Gradient Clipping as the Range Controller for FP8 Training

Training large models in 8-bit floating point (FP8) roughly halves memory and can raise throughput substantially. The cost is a narrow numeric range: every tensor must be multiplied by a scale factor so its values fit into 8 bits. Finding that scale usually means an extra pass over the tensor to locate its largest entry. Meanwhile, keeping large-model training from blowing up requires a second, separate mechanism. Gradient clipping shrinks a gradient when its size is abnormally large, and the adaptive versions track each tensor's recent gradient size and clip relative to it. Both mechanisms do the same job, which is to decide what range of values a gradient tensor is allowed to occupy, and today they are built and paid for separately.

This note proposes merging them. A per-tensor adaptive clipping threshold is a forecast of how large the next gradient will be, so it can set the FP8 gradient scale before the gradient is computed. Because clipping a tensor multiplies every entry by one number, the clip can be applied after quantization by editing a single scalar rather than rewriting the tensor. The extra amax pass disappears, the clip itself becomes nearly free, and the few entries that overflow the predicted range act as a cheap alarm for gradient spikes. The question is whether one tracked statistic per tensor can safely do both jobs, and how much compute that saves.

Core Claim

Write $g_l$ for the gradient of parameter tensor $l$, and $\bar n_l$ for an exponential moving average of its past norms, as in AdaGC. AdaGC is a per-tensor adaptive clipping method for LLM pretraining that clips each tensor relative to its own norm history. The clip threshold is $\tau_l = \lambda \bar n_l$, where $\lambda$ is a relative multiplier. Suppose the gradient is stored as $g_l \approx s_l q_l$, with $q_l$ the 8-bit values and $s_l$ a high-precision scale. Then the clipped gradient is

$$ \mathrm{clip}(g_l) \approx \big(c_l\, s_l\big)\, q_l, \qquad c_l = \min\!\left(1, \frac{\tau_l}{\|g_l\|}\right), $$

so clipping only rewrites the scalar $s_l$. We propose to predict the scale before the gradient exists:

$$ s_l = \frac{\hat r_l\, \tau_l}{Q_{\max}}. $$

Here $Q_{\max}$ is the largest representable FP8 value, and $\hat r_l$ is a tracked moving average of the ratio between a tensor's largest entry and its norm. That ratio is usually stable for a given layer, which is the assumption the predicted scale rests on. Quantization then runs in one pass, fused into the epilogue of the matrix multiplication that produces the gradient (the final step of the kernel). The norm and the largest entry are accumulated on the fly for the next step. A counter records how many entries saturated, meaning they exceeded the predicted range.

We claim three things. First, saturation is rare except during genuine spikes. Second, when it occurs, a rare fallback that recomputes the scale preserves stability at negligible average cost. Third, the resulting system matches AdaGC-level stability, with no loss spikes, while removing the scaling pass that MOSS showed is costly for weights.

The closest prior work splits the problem in two without joining it. AdaGC supplies the clipping statistic but runs in BF16. Its authors list low-precision numerical drift as a failure it cannot see. MOSS is an FP8 training system that removes the amax pass for weights. It does this by predicting weight growth from the AdamW bound $|\Delta w| \le \eta$ and refreshing scales periodically. Gradients have no such bound, and MOSS uses no clipping, so a spike between refreshes can overflow. Our contribution is the observation that adaptive clipping supplies exactly the missing bound for gradients. Turning that into a working one-pass kernel with a principled overflow policy is the new part.

Research Program

The first stage is measurement in high precision. Before building any kernels, we log per-tensor norms, largest entries, and their ratio $r_l$ throughout BF16 pretraining runs. We then ask how often the gradient would exceed the predicted range $\hat r_l \tau_l$, broken down by tensor type and by training phase. AdaGC's discussion of temporal and spatial mismatch suggests the risk is concentrated early in training and in small tensors such as norm-layer gains and embeddings. This stage alone tells us whether the scale-prediction assumption holds.

The second stage builds the system. We implement a fused gradient-quantization epilogue with a predicted scale, an on-the-fly norm and largest-entry reduction, and a saturation counter. Clipping is applied by rewriting the scale. We will compare three overflow policies. The first lets saturated entries stay saturated, which is effectively an elementwise clip. The second recomputes the step with a just-in-time scale whenever saturation exceeds a small count. The third is a hybrid: it saturates on the first offending step and widens the headroom $\hat r_l$ for that tensor afterward.

Because this signal is visible to the numerics rather than to the gradient alone, the saturation count also partly addresses the "gradient-invisible" failures that AdaGC concedes. We will test whether it predicts loss spikes earlier than norm tracking does.

The third stage evaluates the system in the low-precision regimes the file documents. That means FP8 with two-level microscaling, in the MOSS style, and an FP4 stress setting matching GradientStabilizer.

Baselines

The naive reference point is global norm clipping with a fixed threshold and just-in-time FP8 gradient scaling. Global norm clipping rescales all gradients together using one all-model norm. Just-in-time scaling computes each tensor's largest entry before quantizing it. This is the default anyone would assemble. It pays for an amax pass and a cluster-wide norm reduction, and it is the configuration AdaGC shows to be spike-prone. A BF16 run with global clipping provides the accuracy ceiling.

The strongest stability competitor is AdaGC run unchanged inside an FP8 pipeline, with separate just-in-time gradient scaling. AdaGC reports a spike score of exactly zero across its architectures, up to 4.48% lower end-to-end training time on Llama-2 7B, and a 1.32% downstream accuracy gain on Llama-2 7B over global clipping (AdaGC). Beating this baseline means matching its zero spike score and its loss to within noise, while improving throughput by removing the gradient scaling pass.

The strongest efficiency competitor is MOSS-style FP8 training: two-level microscaling and automatic weight scaling, with ordinary global clipping on gradients. MOSS reports 34% higher throughput than BF16 and 8.7% over just-in-time scaling from automatic weight scaling alone (MOSS). Beating it means higher throughput at equal or better loss and fewer spikes. If the gradient-side savings are small next to MOSS's weight-side savings, we will report that plainly.

For the FP4 stress setting, the reference is GradientStabilizer. It is a threshold-free method that keeps the gradient's direction and rescales its norm using moving averages of past norms. It reports about 2.5 points lower validation perplexity than AdamW for LLaMA-130M and 350M on C4 under FP4. No reported FP8 result was found on Lacuna for GradientStabilizer.

Two ablations isolate the key ingredient. In the first, we replace the clipping-derived threshold $\tau_l$ with a plain history of past largest entries, keeping everything else fixed. This tests whether the optimization-aware statistic matters for setting the range. In the second, we remove the deferred scalar clip and leave only saturation. This tests whether direction-preserving clipping matters compared with elementwise saturation.

All runs share the same data order, token budget, hardware, and precision recipe for weights and activations. Each method gets the same hyperparameter sweep budget over its own knobs: $\lambda$ and the decay rates for ours and AdaGC, the threshold for global clipping, and $\gamma_1, \gamma_2$ for GradientStabilizer. Every method is tuned at the smallest scale and then transferred.

Why not just…?

Why not just stack MOSS and AdaGC as separate components? This is the honest null hypothesis, and it is the AdaGC-in-FP8 baseline above. It would deliver the stability, but it keeps a separate scaling pass for gradients. It also leaves the two statistics free to disagree: the clip can allow a magnitude that the scale has already saturated. The comparison settles whether fusing them buys measurable throughput. If the difference is within noise, the contribution shrinks to an engineering note, and we will say so.

Why not just use delayed scaling from a history of largest entries and let overflow saturate? This is the most serious threat, because it is nearly free and already resembles our policy. It is exactly the first ablation. Delayed scaling never applies a direction-preserving clip, so a spike enters the optimizer's moment estimates as a saturated, direction-distorted vector. Its history also lags spikes, which is the hysteresis problem Differentially Private Learning with Adaptive Clipping documents for adaptive thresholds. Two outcomes could each settle the question: the ablation matches our full method on spike score, or it matches on loss. If either happens, the clipping statistic adds nothing to range control, and we will narrow the claim to the scalar-clip trick alone.

Why not just use GradientStabilizer, which bounds every update by construction? Its bound applies to the update after the norm is known. It does not tell the quantizer in advance what scale to use, so it still needs a scaling pass, plus norm synchronization that its authors note costs something at scale. Its normalized gradient could also be quantized with a predicted scale, so we include it as an FP4 comparator. We will also test our quantizer underneath it. If that combination dominates, the result supports the broader thesis that a stabilizer's statistics should set the numeric range.

Proposed Experiments

The small-scale study pretrains LLaMA-130M and LLaMA-350M on C4, matching GradientStabilizer's setting so its FP4 result is a direct reference point. Runs use FP8 with two-level microscaling and FP4 stress variants, at standard and elevated learning rates; GradientStabilizer reports AdamW diverging at $3\times10^{-3}$. Metrics are validation perplexity, spike score as defined in AdaGC, saturation frequency per tensor and per phase, recompute-fallback rate, and kernel-level time and memory traffic for the gradient path.

The mid-scale study trains Llama-2 1.3B on C4-en, matching AdaGC's setup. If compute allows, we add an OLMo-style 7B run on Dolma, matching MOSS. These report end-to-end throughput, peak memory, final loss, and downstream accuracy against all baselines. A FineWeb-Edu (HuggingFaceFW/fineweb) replicate at 350M checks that conclusions do not depend on the corpus.

Three decisive checks determine whether the idea holds. First, saturation under the predicted scale must stay below roughly one step in a thousand outside spikes. If it does not, the scale-prediction premise fails, and the stage-one logging will show which tensors break it. Second, the full method must keep AdaGC's zero spike score in FP8 while the delayed-scaling ablation does not. Third, removing the gradient scaling pass must yield a throughput gain that exceeds run-to-run variance at 1.3B. If the gain disappears at scale, the efficiency argument is wrong regardless of stability, and the work should be reported as a negative result about where FP8 training time actually goes.