Condition Numbers Before You Unfreeze Adapters

On 16 November I spent the morning doing math I should have done before the last fine-tune, not after the loss curve barked.

The task was boring on paper: unfreeze a block, keep LoRA on the rest, train for two more epochs. The failure mode was also boring: one layer went unstable on step 400 and the run never recovered.

What I actually checked

Before touching learning rate, I ran three probes on the block I planned to unfreeze:

  1. Input and output RMS per layer on a fixed eval batch (not train stats).
  2. One power iteration for the top singular value of the weight matrix on GPU (cheap, noisy, good enough).
  3. Gradient norm ratio between the unfrozen block and the LoRA adapters after a single backward on synthetic data.

If the spectral estimate jumps an order of magnitude relative to neighboring layers, I treat the block as ill-conditioned until I see a reason not to.

The napkin inequality I use

For a linear map (W), a step size (\eta), and perturbation (\Delta) from Adam or SGD,

[ |\Delta y| \lesssim \eta \kappa(W) |\nabla_W \mathcal{L}| |x| ]

You do not need a proof every time. You need a habit: if (\kappa) is large, shrink (\eta) on that parameter group before you widen the trainable set.

In PyTorch that is a param group with lr=base_lr / max(1, kappa_hat / kappa_ref).

What changed in the run

Setting Before After
Unfrozen block lr same as LoRA 0.25× LoRA lr
Grad clip global 1.0 global 1.0 + per-layer watchdog
Stopped early? no, wasted GPU yes, at spike

The eval metric moved the same by epoch 2. The difference was not quality; it was not throwing away a day when the optimizer found a stiff direction.

Takeaway for algorithms work

Most "ML engineering" posts talk about data. A fair slice of what breaks in production fine-tuning is numerical linear algebra with AD glued on top. Condition numbers are the part of mathematics that still pays rent in 2026.

If you unfreeze weights this week, run the probe first. It is ten minutes of Python and one plot you can paste into the PR.