train.galvyn.xyz · lab
read-onlySign in

Pretrained vs scratch

lesson 2.2 · Pretrained vs scratch

How much of answering questions comes from pretraining? Same fine-tuning on our pretrained GPT-2 vs the same model from random weights.

base: A ours:gs://train-galvyn-xyz-checkpoints/runs/1a0cd0c6-df9f-471e-b9fa-096a419cccea/step-0019073.pt vs B scratchbase_step: A 19073 vs B undefinedbase_tokens: A 9999745024 vs B undefined

Run A

done

null · ours:gs://train-galvyn-xyz-checkpoints/runs/1a0cd0c6-df9f-471e-b9fa-096a419cccea/step-0019073.pt · 124M params ·

tokens read

35,055,328

step

4,251 / 0

train loss
2.054
best val
1.948
tokens/s
29k
MFU
–
peak mem
6.1 GB
lr
3.0e-6

0:23:32 · ≈ $0.12 to rent

Run B

done

null · scratch · 124M params ·

tokens read

35,055,328

step

4,251 / 0

train loss
5.206
best val
5.188
tokens/s
29k
MFU
–
peak mem
6.1 GB
lr
3.0e-6

0:24:38 · ≈ $0.12 to rent

Losslower is better · loss on answer tokens only · starts from the pretrained model
51001000200030004000stepB checkpoint @ 0A checkpoint @ 0A checkpoint @ 1000B checkpoint @ 1000A checkpoint @ 2000B checkpoint @ 2000A checkpoint @ 3000B checkpoint @ 3000A checkpoint @ 4000B checkpoint @ 4000A checkpoint @ 4251B checkpoint @ 4251

The machine, live

NVIDIA L4 · gcp-l4-ft3offline · never

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

–

starts with training

RAM

–

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

Run A

  1. Queued

    done

  2. Download data

    already on disk

  3. Tokenize

    already on disk

  4. Build and compile

    done

  5. Warm up

    done

  6. Train

    done

  7. Finished

    done

Run B

  1. Queued

    done

  2. Download data

    already on disk

  3. Tokenize

    already on disk

  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+01e-52e-53e-51000200030004000step
Gradient normbefore clipping to 1.0 · log scale
510201000200030004000step
Throughputtokens per second
10k20k30k1000200030004000step
MFUshare of this precision's peak (bf16 111, fp32 27.8 TFLOPS)
Waiting for data…
GPU memory (measured)peak per log window · dashed = activations + workspace
3.9 GB4.9 GB5.9 GB1000200030004000step
Samplessame prompt and random draw every time, so only the model changes

Run A

 Paris.

Run B

 The first step in the United States is the United States is the United States of the United States. The United States is the United States of the United States,

What happened

  1. BFine-tuning finished: 0.0% → 0.7% of held-out questions. Best val loss on answers 5.188.
  2. BStep 4251: 0.7% of 300 held-out questions, 0/20 hand-written; val loss on answers 5.188.
  3. BStep 4000: 0.3% of 300 held-out questions, 0/20 hand-written; val loss on answers 5.201.
  4. BStep 3000: 0.7% of 300 held-out questions, 0/20 hand-written; val loss on answers 5.287.
  5. BStep 2000: 0.3% of 300 held-out questions, 0/20 hand-written; val loss on answers 5.464.
  6. BStep 1000: 0.7% of 300 held-out questions, 0/20 hand-written; val loss on answers 5.827.
  7. BCheckpoint step 0 copied off the machine to gs://train-galvyn-xyz-checkpoints/runs/08c844ae-62df-4a8c-ba1b-86eca59693d5/step-0000000.pt in 4.4s (in the background; training didn't wait).
  8. BStep 0: 0.0% of 300 held-out questions, 0/20 hand-written; val loss on answers 11.003.
  9. BFine-tuning scratch on 'qa' (136,053 examples, 1 epoch(s), 4,251 steps). Trainable parameters: 124,475,904 of 124,475,904 (100.00%).
  10. AFine-tuning finished: 3.3% → 6.7% of held-out questions. Best val loss on answers 1.948.
  11. AStep 4251: 6.7% of 300 held-out questions, 11/20 hand-written; val loss on answers 1.948.
  12. AStep 4000: 7.0% of 300 held-out questions, 10/20 hand-written; val loss on answers 1.948.
  13. AStep 3000: 6.0% of 300 held-out questions, 10/20 hand-written; val loss on answers 1.964.
  14. AStep 2000: 5.3% of 300 held-out questions, 11/20 hand-written; val loss on answers 1.983.
  15. AStep 1000: 5.0% of 300 held-out questions, 12/20 hand-written; val loss on answers 2.013.
  16. ACheckpoint step 0 copied off the machine to gs://train-galvyn-xyz-checkpoints/runs/52ccf94e-dadb-4ed4-b9e7-f1d26658dfdd/step-0000000.pt in 4.6s (in the background; training didn't wait).
  17. AStep 0: 3.3% of 300 held-out questions, 8/20 hand-written; val loss on answers 2.453.
  18. AFine-tuning ours:gs://train-galvyn-xyz-checkpoints/runs/1a0cd0c6-df9f-471e-b9fa-096a419cccea/step-0019073.pt on 'qa' (136,053 examples, 1 epoch(s), 4,251 steps). Trainable parameters: 124,475,904 of 124,475,904 (100.00%).