Training Tricks & Debugging
Q: Your model doesn't train. How do you debug it?
- Overfit a tiny batch first — if you can't reach ~0 loss, there's a bug (labels, loss, data pipeline, frozen params).
- Check inputs: normalization, shuffled labels, augmentation bugs, data leakage.
- Learning rate: run an LR range test; use warmup + decay; watch for loss spikes/NaNs.
- Monitor gradient norms, activation statistics, dead units; use gradient clipping.
- Compare against a simple baseline; check the initial loss (
ln(num_classes)for CE). - Scale up gradually: more data/model/epochs only after the small setup works.
Efficiency: mixed precision (bf16/fp16 + loss scaling), gradient accumulation, gradient checkpointing (trade compute for memory), data/tensor/pipeline parallelism, ZeRO/FSDP sharding.