Inspect Gradient Norms and Learning-Rate Sensitivity

Calculate global gradient norm, interpret clipping as magnitude control, and compare learning rates under fixed model, data, seed, optimizer, clipping, and step budget.

The gradient gives a direction in parameter space. The optimizer and learning rate turn that direction and stored optimizer state into an update. A finite gradient does not guarantee that the resulting update is useful.

Calculate One Global Norm

For parameter gradients g1,,gmg_1,\ldots,g_m, the global Euclidean norm is

g2=j=1mk(gj)k2.\lVert g\rVert_2= \sqrt{\sum_{j=1}^{m}\sum_k (g_j)_k^2}.

If this norm exceeds threshold cc, norm clipping rescales all gradients by the same factor c/g2c/\lVert g\rVert_2. Their joint direction is preserved while their magnitude is bounded.

For example, a norm of 2.5 clipped at 1.0 receives scale 1/2.5=0.41/2.5=0.4.

Clipping must occur after backward and before the optimizer step. It controls gradient magnitude; it does not repair a wrong target, mask, or loss.

Hold the Experiment Fixed when Comparing Rates

The table below changes only learning rate. Every run uses the frozen model, seeds, sampled corpora, batches, AdamW with zero weight decay, clipping at 1.0, and 250 updates.

Learning rateFinal train lossFinal validation lossReading
02.18982.1918gradients exist, but parameters do not move
0.0011.14621.1528learning occurs slowly in this budget
0.010.53530.5276substantial progress, but not yet at the floor
0.10.54310.5456similar progress under this short budget
1.01.86471.9394updates are too coarse for the same budget

This does not establish a generally safe Transformer learning rate. Model size, optimizer, schedule, batch, precision, and data all change the result.

Interpret Norms with Other Measurements

Gradient observationPossible explanationsNext check
absentdisconnected or unregistered parameternamed parameters and graph path
exactly zeroinactive path, symmetry, or genuine local derivativeactivation and per-parameter norms
finite and smallnear a fit or weak signalloss trend and update-to-parameter ratio
repeatedly above thresholdunstable scale or threshold chosen too lowunclipped norm distribution and loss
non-finiteinvalid forward values or unstable backward computationfirst non-finite activation and gradient

A clipping event is a measurement, not automatically a failure. Persistent clipping can, however, conceal an underlying scale problem.

Q1. Calculate a clipped norm

A global gradient norm is 4 and the threshold is 1. What scale multiplies every gradient, and what is the resulting norm?

Answer it first, then check.

Hint
Use c/gc/\lVert g\rVert.
Solution
The scale is 1/4=0.251/4=0.25, giving global norm 1.
Not attempted
Review

Not marked done.

Research Reference

The paper motivates and tests norm clipping for recurrent networks. This chapter uses the mechanism, not its experiments as a universal Transformer threshold.

Pause and reflect

In your own words, note what you understood, what remains unclear, or what you want to revisit. The note stays with this lesson.

0 of 1 exercises marked done

Review

Not marked done.

LLM PrimerInspect Gradient Norms and Learning-Rate Sensitivityhttps://llmprimer.com/transformers/training-a-tiny-transformer/inspect-gradient-norms-and-learning-rate-sensitivity© 2026 LLM Primer