Log inStart free
LESSON 11.07 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Where training memory goes

Watch one training step fill memory with weights, activations, gradients and optimizer states.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 11.07 · MEMORY BAYWEIGHTS 512 B · 256 × 2 B
01
Stage 1 of 6 · Weights
The weights stay in memory for the whole step. 256 weights at 2 B each take 512 B.
Explain it simply

Each square in the bottom row is one weight, a number the model learns. The model has 4 layers of 64 weights. In BF16 each weight takes 2 bytes, so all of them take 512 bytes. They stay in memory from the first step to the last.

Four grids of 8 by 8 weights, one per layer, take 512 B. The timeline shows one band for the weights.

weights and statesgradientsactivationspeaknot in memory
layer 1layer 2layer 3layer 4lossweightsBF16 · 2 B02,0484,0966,144bytesforwardbackwardstepweights 512 Btotal 512 B after the startthe tensors in memorymemory over one training stepweights: 256 × 2 B = 512 Blayer 1layer 2layer 3layer 4lossweightsBF16 · 2 B02,0484,0966,144bytesforwardbackwardstepweights 512 Btotal 512 B after the startthe tensors in memorymemory over one training stepweights: 256 × 2 B = 512 B
Toy: 4 layers of 8 × 8 random weights, random data
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
MW=N⋅bW\sy{W}{param}{M_W} = \sy{N}{param}{N} \cdot b_W
MW=256⋅2 B=512 BM_W = 256 \cdot 2\,\mathrm{B} = 512\,\mathrm{B}

Weight memory is the number of weights times the bytes per weight.

Common mix-ups

MYTHMixed precision halves the training memory.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01If the batch grows from 4 to 16, when does memory peak?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.