train.galvyn.xyz · lab
read-onlySign in

Checkpoint often vs rarely

lesson 1.7 · Checkpointing

How much work does a crash cost, and does a resume really continue where it left off?

ckpt_every: A 100 vs B 1000

Run A

done

fineweb_edu · 6L·384d · 30M params · bf16

tokens read

24,576,000

step

3,000 / 3,000

train loss
4.869
best val
5.094
tokens/s
33k
MFU
5.5%
peak mem
6.4 GB
lr
1.0e-4

0:08:07 · 0.020 kWh ≈ <$0.01 power · ≈ $0.04 to rent

Run B

done

fineweb_edu · 6L·384d · 30M params · bf16

tokens read

24,576,000

step

3,000 / 3,000

train loss
4.869
best val
5.094
tokens/s
74k
MFU
12.4%
peak mem
6.4 GB
lr
1.0e-4

0:08:17 · 0.018 kWh ≈ <$0.01 power · ≈ $0.04 to rent

Losslower is better · starts near ln(vocab)
681050010001500200025003000stepA checkpoint @ 50B checkpoint @ 50A checkpoint @ 100B checkpoint @ 100A checkpoint @ 200B checkpoint @ 250A checkpoint @ 250A checkpoint @ 300A checkpoint @ 400A checkpoint @ 500A checkpoint @ 600A checkpoint @ 700A checkpoint @ 800A checkpoint @ 900B checkpoint @ 1000A checkpoint @ 1000A checkpoint @ 1100A checkpoint @ 1200A checkpoint @ 1300A checkpoint @ 1400A checkpoint @ 1500A checkpoint @ 1600A checkpoint @ 1700A checkpoint @ 1800A checkpoint @ 1900A checkpoint @ 2000B checkpoint @ 2000A checkpoint @ 2100A checkpoint @ 2200A checkpoint @ 2300A checkpoint @ 2400A checkpoint @ 2500A checkpoint @ 2600A checkpoint @ 2700A checkpoint @ 2800A checkpoint @ 2900B checkpoint @ 3000A checkpoint @ 3000crash test: resumed from 1000crash test: resumed from 1300

The machine, live

NVIDIA L4 · gcp-l4-laboffline · just now

GPU 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.037 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 · Press Crash test on both runs after step 1000. A loses at most 100 steps, B up to 1000. The dashed curve after each resume should sit on the original; the Resume check measures how closely.

Run A

  1. Queued

    done

  2. Download data

    done

  3. Tokenize

    done

  4. Build and compile

    done

  5. Warm up

    done

  6. Train

    done

  7. Finished

    done

Run B

  1. Queued

    done

  2. Download data

    done

  3. Tokenize

    done

  4. Build and compile

    done

  5. Warm up

    done

  6. Train

    done

  7. Finished

    done

solid = train (smoothed) · dots = validation · dashed = after a crash-test resume
Learning ratewarmup, then cosine
0e+05e-41e-350010001500200025003000step
Gradient normbefore clipping to 1.0 · log scale
0.512550010001500200025003000step
Throughputtokens per second
20k40k60k50010001500200025003000step
MFUshare of this precision's peak (bf16 111, fp32 27.8 TFLOPS)
5.0%10.0%50010001500200025003000step
GPU memory (measured)peak per log window · dashed = activations + workspace
5.9 GB6.3 GB50010001500200025003000step
Does it know? Fact probesP(right word) / P(right + wrong): 0.5 = no idea, 1 = sure and right
0.350.40.450.550010001500200025003000step
The questions
arithmeticA 0.39B 0.39
iceA 0.57B 0.57
oceanA 0.66B 0.66
orbitA 0.59B 0.59
parisA 0.38B 0.38
planetA 0.33B 0.33
skyA 0.72B 0.72
waterA 0.54B 0.54
whaleA 0.16B 0.16

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.

Samplessame prompt and random draw every time, so only the model changes

Run A

Water is the most important part of the following:
The area of the body is the main source of water, the body is the main form of water and is a few of the body. The body has the largest side of the body. The body is the first part of the body, and the body is the most frequent form of water. The body is the result of the body, the body is the main function of the body.
The first phase is called the heart.
The body uses the liver to develop a body of the muscles. It is called a muscles that are very soft and is the blood. The body becomes an abnormal body, with the blood. This cell has a blood vessels, body, and the heart muscles.
There is a three types of blood, usually called a blood vessels, where the body is more intense and less slowly.
The body is a hormone called the stomach and is the primary form of blood vessels, the body’s body. It

Run B

Water is the most important part of the following:
The area of the body is the main source of water, the body is the main form of water and is a few of the body. The body has the largest side of the body. The body is the first part of the body, and the body is the most frequent form of water. The body is the result of the body, the body is the main function of the body.
The first phase is called the heart.
The body uses the liver to develop a body of the muscles. It is called a muscles that are very soft and is the blood. The body becomes an abnormal body, with the blood. This cell has a blood vessels, body, and the heart muscles.
There is a three types of blood, usually called a blood vessels, where the body is more intense and less slowly.
The body is a hormone called the stomach and is the primary form of blood vessels, the body’s body. It

Resume check

After a crash, the steps since the last checkpoint are lost and recomputed. If the checkpoint restored everything (weights, AdamW state, schedule, the RNG that picks batches), the recomputed losses match the originals.

  • A · resume 1 steps 1310–1380 (8 points): max |Δloss| 0.0e+0, mean 0.0e+0Bit-identical: the resume reproduced the lost steps exactly.
  • B · resume 1 steps 1010–1490 (49 points): max |Δloss| 0.0e+0, mean 0.0e+0Bit-identical: the resume reproduced the lost steps exactly.

What happened

  1. BFinished 3000 steps. Best val loss 5.094.
  2. BCheckpoint at step 3000: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.54s.
  3. BStep 3000: val 5.094, train 5.086 (gap +0.008).
  4. AFinished 3000 steps. Best val loss 5.094.
  5. ACheckpoint at step 3000: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.53s.
  6. AStep 3000: val 5.094, train 5.086 (gap +0.008).
  7. ACheckpoint at step 2900: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.53s.
  8. BStep 2800: val 5.094, train 5.082 (gap +0.012).
  9. ACheckpoint at step 2800: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.54s.
  10. AStep 2800: val 5.094, train 5.082 (gap +0.012).
  11. BStep 2600: val 5.114, train 5.116 (gap -0.002).
  12. ACheckpoint at step 2700: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.53s.
  13. ACheckpoint at step 2600: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.54s.
  14. AStep 2600: val 5.114, train 5.116 (gap -0.002).
  15. BStep 2400: val 5.163, train 5.143 (gap +0.020).
  16. ACheckpoint at step 2500: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.53s.
  17. ACheckpoint at step 2400: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.53s.
  18. AStep 2400: val 5.163, train 5.143 (gap +0.020).
  19. BStep 2200: val 5.192, train 5.167 (gap +0.025).
  20. ACheckpoint at step 2300: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.53s.
  21. ACheckpoint at step 2200: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.71s.
  22. BCheckpoint step 2000 copied off the machine to gs://train-galvyn-xyz-checkpoints/runs/daba75b6-dca7-488f-b099-f04cf024b841/step-0002000.pt in 1.3s (in the background; training didn't wait).
  23. AStep 2200: val 5.192, train 5.167 (gap +0.025).
  24. BCheckpoint at step 2000: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.54s.
  25. BStep 2000: val 5.234, train 5.252 (gap -0.018).
  26. ACheckpoint at step 2100: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.54s.
  27. ACheckpoint at step 2000: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.54s.
  28. BStep 1800: val 5.328, train 5.269 (gap +0.059).
  29. AStep 2000: val 5.234, train 5.252 (gap -0.018).
  30. ACheckpoint at step 1900: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.54s.
  31. BStep 1600: val 5.429, train 5.361 (gap +0.068).
  32. ACheckpoint at step 1800: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.53s.
  33. AStep 1800: val 5.328, train 5.269 (gap +0.059).
  34. ACheckpoint at step 1700: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.53s.
  35. BStep 1400: val 5.475, train 5.424 (gap +0.051).
  36. ACheckpoint at step 1600: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.53s.
  37. AStep 1600: val 5.429, train 5.361 (gap +0.068).
  38. ACheckpoint at step 1500: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.52s.
  39. BStep 1200: val 5.612, train 5.570 (gap +0.042).
  40. ACheckpoint step 1400 copied off the machine to gs://train-galvyn-xyz-checkpoints/runs/61898328-5722-4fc9-8849-750c0da90d85/step-0001400.pt in 1.4s (in the background; training didn't wait).
  41. ACheckpoint at step 1400: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.53s.
  42. AStep 1400: val 5.475, train 5.424 (gap +0.051).
  43. BResumed at step 1000 from a checkpoint.
  44. AResumed at step 1300 from a checkpoint.
  45. BCrash test: killed the process with SIGKILL (no chance to save). Resuming from the checkpoint at step 1000.
  46. ACrash test: killed the process with SIGKILL (no chance to save). Resuming from the checkpoint at step 1300.
  47. ACheckpoint at step 1300: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.60s.
  48. BStep 1400: val 5.475, train 5.424 (gap +0.051).
  49. ACheckpoint at step 1200: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.53s.
  50. AStep 1200: val 5.612, train 5.570 (gap +0.042).
  51. BStep 1200: val 5.612, train 5.570 (gap +0.042).
  52. ACheckpoint at step 1100: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.57s.
  53. ACheckpoint at step 1000: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.94s.
  54. AStep 1000: val 5.685, train 5.638 (gap +0.047).
  55. BCheckpoint at step 1000: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.61s.
  56. BStep 1000: val 5.685, train 5.638 (gap +0.047).
  57. ACheckpoint at step 900: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.57s.
  58. ACheckpoint at step 800: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.54s.
  59. AStep 800: val 5.786, train 5.790 (gap -0.004).
  60. BStep 800: val 5.786, train 5.790 (gap -0.004).
  61. ACheckpoint at step 700: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.62s.
  62. ACheckpoint at step 600: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.54s.
  63. AStep 600: val 5.981, train 5.996 (gap -0.015).
  64. BStep 600: val 5.981, train 5.996 (gap -0.015).
  65. ACheckpoint at step 500: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.54s.
  66. ACheckpoint at step 400: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.54s.
  67. AStep 400: val 6.270, train 6.198 (gap +0.072).
  68. BStep 400: val 6.270, train 6.198 (gap +0.072).
  69. ACheckpoint at step 300: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.57s.
  70. ACheckpoint at step 250: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.76s.
  71. BCheckpoint at step 250: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.56s.
  72. ACheckpoint at step 200: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 1.59s.
  73. BStep 200: val 6.571, train 6.549 (gap +0.022).
  74. AStep 200: val 6.571, train 6.549 (gap +0.022).
  75. BCheckpoint at step 100: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 2.43s.
  76. ACheckpoint at step 100: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 2.57s.
  77. ACheckpoint at step 50: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 2.58s.
  78. BCheckpoint at step 50: 360.9 MB (weights, AdamW state, schedule position, RNG states) in 2.47s.
  79. BCheckpoint step 0 copied off the machine to gs://train-galvyn-xyz-checkpoints/runs/daba75b6-dca7-488f-b099-f04cf024b841/step-0000000.pt in 0.8s (in the background; training didn't wait).
  80. ACheckpoint step 0 copied off the machine to gs://train-galvyn-xyz-checkpoints/runs/61898328-5722-4fc9-8849-750c0da90d85/step-0000000.pt in 0.8s (in the background; training didn't wait).
  81. BCheckpoint at step 0: 120.3 MB (weights, AdamW state, schedule position, RNG states) in 0.83s.
  82. ACheckpoint at step 0: 120.3 MB (weights, AdamW state, schedule position, RNG states) in 0.83s.
  83. BExpected loss before training ≈ ln(vocab) = 10.83.
  84. AExpected loss before training ≈ ln(vocab) = 10.83.
  85. BTraining 30.06M params on fineweb_edu for 3000 steps (bf16, batch 32×1, ctx 256).
  86. ATraining 30.06M params on fineweb_edu for 3000 steps (bf16, batch 32×1, ctx 256).