Part 5 · The Maths III: Training at Scale
The 6ND rule
Every weight participates in exactly one multiply-accumulate per token, so the forward pass costs 2N FLOPs per token for N parameters.
The gradient with respect to the layer’s inputs (to keep propagating backwards) and with respect to its weights (to update them). Each is a matrix product of the same shape class as the forward one.
Over D tokens the run costs C ≈ 6ND FLOPs. Backward is twice forward, which is the fact worth remembering.
The attention score computation, which has no parameters and so contributes nothing to N, yet costs 4Ld per layer per token. From the previous part that stays a minority until L > 6d. 6ND is an excellent approximation at ordinary context lengths and an increasingly bad one at very long ones.