Numerical Computing & Stability

Floating point, overflow, the log-sum-exp trick and the reason your loss became NaN.

Module 01.6 · Beginner
Free

4h · 6 lessons · 1 challenge

Before this: Probability

About this module

Nothing in the source courses teaches this, and everything in them depends on it. Softmax overflows. Cross-entropy takes the log of a zero. A sum of a million small numbers loses its tail. Mixed precision halves your memory and quietly changes your answer.

This module is ours, and it is here because a NaN at step 4000 is otherwise unexplainable.

After this module you can

6 lessons

Lesson 1
1Floating point, precision and representable numbers
Kind
Concept
Length
45 min
Lesson 2
2Overflow, underflow and catastrophic cancellation
Kind
Concept
Length
45 min
Lesson 3
3The log-sum-exp trick, derived
Kind
Concept
Length
40 min
Lesson 4
4NaN Hunt: find the operation that poisoned the run
Kind
Interactive
Length
30 min
Lesson 5
5Mixed precision: float16, bfloat16 and loss scaling
Kind
Concept
Length
45 min
Lesson 6
6Checkpoint: stabilize the computation
Kind
Checkpoint
Length
25 min

The challenge: NaN Hunt

A training run produces NaN at step 4000. Find the operation that did it, from the tensors alone.

Worth 350 XP.

Related modules

All modules