Everything in one place — the loop you'll copy and adapt
This lesson assembles every pattern from the track into one runnable training loop. Read it once carefully; you'll be cribbing from variants of this for the rest of your career.
What's in the recipe:
- Device selection (CUDA → MPS → CPU fallback)
- AdamW with weight decay split (no decay on bias / norm)
- Cosine LR with warmup
- Mixed-precision (bfloat16 on Ampere+ / Apple Silicon)
- Gradient clipping
- tqdm progress bar with running loss
- Per-epoch validation
- Best-checkpoint saving
- NaN protection
What's intentionally NOT in here (each gets its own dedicated track or lesson):
- Distributed training (DDP / FSDP) — Track 7
- torch.compile() — Track 7
- Experiment tracking (W&B / MLflow) — Track 8