train.galvyn.xyz

Learning to train models, in public

Notes from pretraining a small GPT from scratch and fine-tuning it (and other small LLMs) to answer questions, on a home RTX A5000 and rented cloud GPUs. Every lesson compares two runs side by side, with the real loss curves.

Learn · explainersGPUDirect: getting data to the GPU without the CPUAnimated paths from storage and between servers, and at what scale it starts to matter.

Latest notes

Phase 1. Pretrain a small GPT from scratch

A ~200-line GPT, 3M to 124M parameters, trained on FineWeb-Edu (educational web text) and compared two runs at a time.

  1. 1.1Overfit one batchTrain loss near zero proves the loop works; val loss rising shows memorising isn't learning
  2. 1.2Baseline, twiceWhat a healthy loss curve looks like, and how big run-to-run noise is
  3. 1.3Learning rateThe most important knob: too low is slow, too high is noisy or diverges
  4. 1.4WarmupEarly steps are fragile: a ramp avoids grad-norm spikes at a high learning rate
  5. 1.5Tokens vs bytesA token carries several bytes of text, so the same model sees more context and learns faster per step
  6. 1.6PrecisionMixed precision: faster and smaller with the same loss
  7. 1.7CheckpointingWhat a crash costs, and what state a checkpoint must hold to resume exactly
  8. 1.8Break itRecognise failures on sight
  9. 1.9ScaleBigger models learn more from the same data; then the full GPT-2 recipe, at home vs on 8× H100

Phase 2. Fine-tune a pretrained small LLM

Teach a pretrained model to answer: supervised fine-tuning of our own GPT-2 first, then open 0.5B–3B models with full fine-tuning vs LoRA.

  1. 2.1Teach it to answerSupervised fine-tuning teaches the format (answer, then stop); the facts come from pretraining
  2. 2.2Pretrained vs scratchThe value of pretraining
  3. 2.3LoRA vs fullQuality vs memory vs speed
  4. 2.4Data mattersWhat fine-tuning changes; forgetting
  5. 2.5OverfittingWhen to stop; picking the best checkpoint
  6. 2.6EvalHeld-out loss vs task accuracy vs vibe checks

Notes appear as each step is run. The lab where the experiments run is app.train.galvyn.xyz (anyone can watch).