# Predicting Seed Variance, Warmup & LR Decay | Stanford CS312 Quiz Review with Suhas Kotha

## Executive summary

This lecture review examines the empirical behavior of large language model (LLM) training, focusing on run-to-run variance, loss jitter, and the effectiveness of learning rate schedules. Key findings include the low run-to-run standard deviation of validation loss (~0.003), the scaling of training loss jitter with batch size ($1/ ext{sqrt}(B)$), and the necessity of tuning warmup and decay phases. The session also covers the role of parameter and gradient norms and the predictive power of scaling laws.

## Key takeaways

- Validation Loss Variance is Low: The run-to-run standard deviation for validation loss was found to be approximately 0.003. Differences near 0.003 are generally considered noise, while a difference of 0.02 or more is likely a real improvement [00:05:15].
- Jitter Scales with Batch Size: Training loss jitter scales roughly as $1/ ext{sqrt}(B)$, where $B$ is the batch size. This suggests that the variance is dominated by sampling variance of the batch, not the model [00:11:50].
- Optimal Decay Period: To achieve within 0.02 loss of the best schedule, the cooldown (decay) period needed to be around 20% of training in the tested setting [00:25:30].
- Warmup Fraction is High: The optimal warmup fraction was found to be closer to 20-30%, significantly higher than the default 1% used in the training code. This suggests that warmup should be treated as a fixed number of steps rather than a percentage [00:37:20].

## Technical details

- Loss Jitter Measurement: Validation loss exhibits far less jitter compared to training loss, making it the cleaner measurement for variance analysis [00:11:50].
- Norm Trajectories: Weight decay slows down parameter growth. The combination of weight decay and learning rate schedules is required to start decreasing the parameter norm after a certain amount of time [00:48:00].
- Scaling Laws and QK Norm: The QK norm is important for stability in larger models (e.g., D9), as it makes the model more sensitive to higher learning rates and high variance regimes [00:56:30].
- Gradient Norm Behavior: In the tested setting, none of the gradient norms doubled over the course of training. The gradient norm starts very high, which is a difference from some published settings [00:46:30].

## Practical implications

- When evaluating LLM performance, focus on validation loss for cleaner measurements of variance.
- Treat learning rate warmup as a fixed number of steps rather than a percentage, as the optimal fraction is often much higher than defaults.
- Hyperparameter choices (like QK norm and learning rate) significantly affect scaling behavior, requiring careful empirical tuning.

## Topics

Deep Learning, Large Language Models (LLM), Optimization, Learning Rate Scheduling, Variance Analysis, Stanford CS312: Deep Learning Alchemy

Source: https://www.youtube.com/watch?v=GaUI0MqNx-Q
