Break it: remove LayerNorm
lesson 1.8 · Break itWhat is LayerNorm doing for training stability?
Run A
donefineweb_edu · 6L·384d · 30M params · bf16
tokens read
16,384,000
step
2,000 / 2,000
- train loss
- 5.287
- best val
- 5.256
- tokens/s
- 74k
- MFU
- 12.5%
- peak mem
- 6.4 GB
- lr
- 3.0e-4
0:04:43 · 0.005 kWh ≈ <$0.01 power · ≈ $0.02 to rent
Run B
failedfineweb_edu · 6L·384d · 30M params · bf16
tokens read
1,433,600
step
175 / 2,000
- train loss
- 7215248.000
- best val
- –
- tokens/s
- 34k
- MFU
- 5.7%
- peak mem
- 6.3 GB
- lr
- 3.0e-3
0:00:44 · 0.001 kWh ≈ <$0.01 power · ≈ <$0.01 to rent
Diverged: loss became NaN at step 175 (gradient norm reached 15,057 at step 160). Without LayerNorm at lr 3e-3, this is the expected result of the lesson.
The machine, live
NVIDIA L4 · gcp-l4-lab2offline · just nowGPU busy
– %
VRAM
– / 22 GB
Power
– / 230 W
Temperature
– °C
SM clock
– MHz
Memory bus
– %
Fan
– %
CPU
– %
PCIe
to GPU –from GPU –
Batches of token ids cross the PCIe bus into the GPU each step; weights never leave it.
Disk
read –write –
Reads: token windows from the tokenized dataset (mostly from page cache). Writes: checkpoints, about 1.5 GB each for GPT-2 124M.
Network
in –out –
In: dataset downloads from Hugging Face. Out: metrics to Supabase and checkpoint uploads to Cloud Storage.
drawing now
–
last 5 minutes
–
from the card's energy counter
this experiment
0.006 kWh
≈ <$0.01 of electricity
RAM
–
of 31.3 GB in WSL
Sampled every 2 s on the box (NVML + psutil) and pushed here over Supabase Realtime. GPU energy is the whole card. Electricity at an assumed $0.15/kWh.
What's happening
What to watch · Without LayerNorm nothing holds the residual stream at a stable scale: watch B's gradient norm and loss for spikes, and a worse final loss.
Run A
Queued
done
Download data
done
Tokenize
done
Build and compile
done
Warm up
done
Train
done
Finished
done
Run B
Queued
done
Download data
done
Tokenize
done
Build and compile
done
Warm up
done
Train
stopped here
Finished
next
Stopped at · Train · Forward, backward, AdamW update, again and again. The learning rate follows a cosine down to a tenth of its peak.
Evaluateevery 200 steps
next 200
loss on held-out text, plus the fact probes (does it know water is a liquid?)
Write a sampleevery 500 steps
last 0 · next 500
continue a fixed prompt so you can read it improve
Checkpointevery 250 steps
last 100 · next 250
save weights + optimizer + RNG, upload to Cloud Storage; it appears in the Playground
The questions
| arithmetic | A 0.56 | B – |
| ice | A 0.54 | B – |
| ocean | A 0.78 | B – |
| orbit | A 0.72 | B – |
| paris | A 0.24 | B – |
| planet | A 0.27 | B – |
| sky | A 0.75 | B – |
| water | A 0.36 | B – |
| whale | A 0.13 | B – |
Prompts include "Q: Is water a liquid at room temperature? A:" (Yes vs No), "The capital of France is" (Paris vs London) and "The largest planet in our solar system is" (Jupiter vs Mars). Full list: trainer/src/galtrain/train.py.
Run A
Water is the most harmful causes of the soil. This can also be the most important factor in preventing water, preventing the health of the plant. Sens and other health products like oil and other pesticides Fry-friendly forms on the plant. Sustriculture is also a source of water. Osteopable water is a vital source of water and water in your body. A process in the body, you can also lead to the best care of the plants. Punging is a free waste chain of the plant. It is a great way to prevent water from your home. The plant needs to be able to make sure you should make a better protection from your plant. Wossing is a good advantage of your water quality in a healthy and healthy life. It is a great part of the system. It consists of the best way to prevent the bacteria. Vene seeds are a good idea to check the water quality. Treat your plant can
Run B
–
What happened
- AFinished 2000 steps. Best val loss 5.256.
- ACheckpoint at step 2000: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.58s.
- AStep 2000: val 5.256, train 5.271 (gap -0.015).
- AStep 1800: val 5.325, train 5.259 (gap +0.066).
- ACheckpoint at step 1750: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.52s.
- AStep 1600: val 5.413, train 5.342 (gap +0.071).
- ACheckpoint at step 1500: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.57s.
- AStep 1400: val 5.452, train 5.401 (gap +0.051).
- ACheckpoint at step 1250: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.52s.
- AStep 1200: val 5.607, train 5.563 (gap +0.044).
- ACheckpoint at step 1000: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.53s.
- AStep 1000: val 5.686, train 5.638 (gap +0.047).
- AStep 800: val 5.810, train 5.808 (gap +0.001).
- ACheckpoint at step 750: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.53s.
- AStep 600: val 6.010, train 6.024 (gap -0.014).
- ACheckpoint at step 500: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.53s.
- AStep 400: val 6.286, train 6.215 (gap +0.071).
- ACheckpoint at step 250: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.52s.
- AStep 200: val 6.619, train 6.598 (gap +0.021).
- BLoss became nan at step 175. Stopping: a too-high learning rate is the usual cause.
- BCheckpoint at step 100: 360.7 MB (weights, AdamW state, schedule position, RNG states) in 1.64s.
- ACheckpoint at step 100: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.53s.
- BCheckpoint at step 50: 360.7 MB (weights, AdamW state, schedule position, RNG states) in 1.64s.
- ACheckpoint at step 50: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.54s.
- BCheckpoint step 0 copied off the machine to gs://train-galvyn-xyz-checkpoints/runs/f23769e1-26f7-44f3-8e06-379c8ecaa5c3/step-0000000.pt in 1.5s (in the background; training didn't wait).
- ACheckpoint step 0 copied off the machine to gs://train-galvyn-xyz-checkpoints/runs/2ec8eb1c-2aec-4cb7-b75c-cf6381e48924/step-0000000.pt in 1.7s (in the background; training didn't wait).
- BCheckpoint at step 0: 120.2 MB (weights, AdamW state, schedule position, RNG states) in 0.52s.
- BLayerNorm removed: nothing keeps the residual stream at a stable scale, so watch the gradient norm.
- BExpected loss before training ≈ ln(vocab) = 10.83.
- BTraining 30.05M params on fineweb_edu for 2000 steps (bf16, batch 32×1, ctx 256).
- ACheckpoint at step 0: 120.3 MB (weights, AdamW state, schedule position, RNG states) in 0.51s.
- AExpected loss before training ≈ ln(vocab) = 10.83.
- ATraining 30.06M params on fineweb_edu for 2000 steps (bf16, batch 32×1, ctx 256).
- BResuming run B from its checkpoint at step 0.
- AResuming run A from its checkpoint at step 0.
- BCheckpoint step 0 copied off the machine to gs://train-galvyn-xyz-checkpoints/runs/f23769e1-26f7-44f3-8e06-379c8ecaa5c3/step-0000000.pt in 1.7s (in the background; training didn't wait).
- ACheckpoint step 0 copied off the machine to gs://train-galvyn-xyz-checkpoints/runs/2ec8eb1c-2aec-4cb7-b75c-cf6381e48924/step-0000000.pt in 1.7s (in the background; training didn't wait).
- BRun crashed: OutOfMemoryError: CUDA out of memory. Tried to allocate 1.54 GiB. GPU 0 has a total capacity of 22.03 GiB of which 1.10 GiB is free. Process 8745 has 12.74 GiB memory in use. Process 8971 has 3.38 GiB memory in use. Including non-PyTorch memory, this process has 4.79 GiB memory in use. Of the allocated memory 4.51 GiB is allocated by PyTorch, and 50.88 MiB is reserved by PyTorch but unallocated.
- ARun crashed: OutOfMemoryError: CUDA out of memory. Tried to allocate 1.54 GiB. GPU 0 has a total capacity of 22.03 GiB of which 1.10 GiB is free. Process 8745 has 12.74 GiB memory in use. Including non-PyTorch memory, this process has 3.38 GiB memory in use. Process 8972 has 4.79 GiB memory in use. Of the allocated memory 3.13 GiB is allocated by PyTorch, and 27.99 MiB is reserved by PyTorch but unallocated.
- ACheckpoint at step 0: 120.3 MB (weights, AdamW state, schedule position, RNG states) in 0.82s.
- BCheckpoint at step 0: 120.2 MB (weights, AdamW state, schedule position, RNG states) in 0.70s.
- BLayerNorm removed: nothing keeps the residual stream at a stable scale, so watch the gradient norm.
- AExpected loss before training ≈ ln(vocab) = 10.83.
- BExpected loss before training ≈ ln(vocab) = 10.83.
- BTraining 30.05M params on fineweb_edu for 2000 steps (bf16, batch 32×1, ctx 256).
- ATraining 30.06M params on fineweb_edu for 2000 steps (bf16, batch 32×1, ctx 256).