Bitpath

Boss lesson · Unit 01

Read the loss curve

Warmup, decay, clipping, and diagnosing a run from its log

13 exercisesabout 3 min

What you practise

  • Warmup, cosine and linear decay computed for given steps, gradient clipping by norm, and diagnosing runs from their curves: diverging, stuck, too slow, overfitting

Try a question from this lesson

Pick one

A transformer run starts at its full learning rate and dies within 20 steps. The same rate works once training is underway. What is the standard fix?

step  lr      loss
   1  3e-4    10.8
   5  3e-4    11.9
  10  3e-4    27.4
  20  3e-4    nan
Hint

The rate is fine later on. What is different about the model and the optimizer's averages in the very first steps?

The ideas

Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.

Concept

A schedule is a function of the step

The learning rate does not have to be one number. A schedule computes it from the step count: warm up from zero to the base rate, then decay back toward zero, so the last steps settle instead of bouncing.

Linear warmup is the base rate times the fraction of the warmup completed.

Python
def lr_at(step, base, warmup):
    if step < warmup:
        return base * step / warmup
    return base    # decay comes next

Concept

Clip the gradient norm

One bad batch can produce a gradient a hundred times the usual size, and one step along it can wreck the weights. Clipping caps the length of the whole gradient: if its norm is over the limit, every entry is scaled down by the same factor.

The direction is kept. Only the length changes.

Python
norm = sum(g * g for g in grads) ** 0.5
if norm > max_norm:
    scale = max_norm / norm
    grads = [g * scale for g in grads]

10 more exercises in the app

  • 3× type the answer
  • 1× fill the blanks
  • 3× multiple choice
  • 1× true or false
  • 1× order the lines
  • 1× match the pairs

Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.

One email when Bitpath is ready to try. Nothing else. Privacy