Key Moments

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

Stanford OnlineStanford Online
Education6 min read31 min video
Nov 25, 2026|52 views|2
Save to Pod
TL;DR

Run-to-run variance in deep learning is surprisingly low, with just changing data or initialization accounting for almost all observed variation, not just changing both random seeds.

Key Insights

1

The standard deviation of validation loss between runs, even when changing both random seeds, is approximately 0.003 for the d8 language model.

2

Changing only the initialization or only the data can account for nearly all the run-to-run variance, similar to changing both random seeds.

3

For every doubling of batch size, the training loss fluctuation (noise) increases by approximately 1.4 times, following a 1/sqrt(V) rule where V is batch size.

4

Skipping the learning rate warmup phase results in a loss difference of approximately 0.106 compared to runs with warmup, with the primary change occurring in the activation norm early in training.

5

A shallow learning rate decay schedule, where decay happens over approximately 20% of training time, yields a loss difference of around 0.02 compared to no decay, and this optimal decay percentage appears consistent across model sizes.

Minimal variance from random seeds alone

The session begins by exploring the variance in deep learning model training, specifically focusing on how changes in random seeds impact validation loss. Experiments with the d8 language model revealed that the run-to-run standard deviation in validation loss, even when altering both random seeds, is remarkably low, around 0.003. Further investigations showed that altering only the data or only the initialization of the model could account for nearly all of this observed variance. This suggests that the impact of random seeds alone is less significant than intuition might suggest, a finding supported by prior research like that of Summers, Dean, and Jordan. While the exact magnitude of variance might differ across studies, the principle that single sources of randomness can explain most variation holds true.

Understanding training loss fluctuation

The discussion then delves into training loss jitter or fluctuation. It was observed that the standard deviation for training loss is significantly higher than for validation loss, often around 0.04. This fluctuation is influenced by factors like batch size. A key insight here is that the noise in training loss is approximately proportional to 1/sqrt(V), where V is the batch size. This implies that larger batch sizes lead to less fluctuation. For instance, doubling the batch size does not halve the noise but reduces it by approximately 1.4 times. This relationship is crucial for understanding the stability of training and how different hyperparameter choices affect it. The implication for practitioners is that if high variance is observed in training loss, it might be an artifact of smaller batch sizes rather than a fundamental problem with the model or data.

Impact of learning rate warmup and decay

The session examines the effects of learning rate warmup and decay schedules on model training. Skipping the learning rate warmup phase was found to increase the final loss by approximately 0.106. Analysis of parameter and gradient norms revealed that the primary impact of warmup is on the activation norm, which rises early in training and then decreases. Regarding learning rate decay, experiments with different decay schedules showed that a shallow decay, where the learning rate is reduced over roughly 20% of the training time, can yield significant benefits, reducing the final loss by about 0.02 compared to no decay. This suggests that adequate time for learning rate decay is important for optimal performance. The presenter notes that while a 20% decay period seemed effective in their experiments, the exact optimal percentage can vary and is a hyperparameter worth tuning.

Batch size and learning rate interactions

Further exploration into batch size reveals that larger batch sizes lead to lower training loss fluctuation, a phenomenon that aligns with the 1/sqrt(V) heuristic. When considering learning rate, however, experiments showed that fluctuation is largely independent of the learning rate itself. This suggests that while batch size directly impacts noise, the learning rate's effect on stability is more indirect. The discussion touches upon the idea that the variance of the batch is larger than the variance of the model, a key concept for understanding how batch composition influences training dynamics. This interaction between batch size and learning rate is critical for effective optimization, especially in large-scale training scenarios.

Weight decay and its effect on parameter growth

The role of weight decay in controlling parameter growth is also investigated. It was observed that linear learning rate schedules, compared to constant ones, generally lead to less parameter growth. Similarly, applying weight decay, whether constant or linear, also slows down the increase in parameter norms. A particularly interesting finding is that the combination of both a learning rate schedule and weight decay can actively decrease the parameter norm after a certain point, unlike using either regularization technique alone, which only slows down the growth. This interaction highlights the synergistic effects of different regularization strategies on model complexity and stability. The implication is that these techniques can be used to actively manage the scale of model parameters during training.

Gradient norm behavior and scaling laws

The behavior of gradient norms during training presented some unexpected results. Contrary to some research that suggests gradient norms can grow significantly, especially at the end of training, the experiments in this session did not show such doubling. The gradient norm was observed to start high and not multiply during training. This divergence from some published findings, like those from the 'AdamW' paper, could be due to differences in initialization or training duration. The session also touched upon scaling laws, which attempt to predict model performance based on parameters and data size. While fitting these laws can be tricky and prone to error, they can offer valuable insights into how performance scales, particularly in understanding relative improvements across different configurations, such as feature scaling versus constant learning rate schedules.

The role of QK normalization

The discussion touches on the importance of QK normalization, particularly for stability when using high learning rates and high variance systems. For instance, at higher depths like D9, QK normalization becomes more critical for stable training compared to shallower depths like D4. It was noted that QK normalization can make the training process more sensitive to higher learning rates. While not explicitly detailed in this summary, the implication is that this normalization technique is a key component for ensuring stable training in complex deep learning setups, especially when pushing the boundaries of learning rates and model depth.

Early training variance and initialization sensitivity

Finally, the session highlights that a significant portion of training variance occurs early in the training process. This is attributed to the impact of tokens at that stage. Remarkably, minor changes to a single bit in the initialization of a model can lead to substantial variation in the training run, a phenomenon that is counter-intuitive. This sensitivity to initial conditions underscores the non-linear and often unpredictable nature of deep learning training, reinforcing the need for careful initialization and extensive experimentation to understand model behavior.

Impact of Hyperparameters on Training Variance and Loss

Data extracted from this episode

ConditionStandard Deviation (Validation Loss)Notes
Changing both seeds0.003Baseline measurement
Changing initialization onlySimilar to changing both seedsSuggests initialization is a major source of variance
Changing data onlySimilar to changing both seedsSuggests data variation is a major source of variance

Batch Size vs. Wobble (Variance)

Data extracted from this episode

Batch Size (V)Wobble (Approximate)Theoretical Approximation (1/sqrt(V))
256Higher loss
Larger batch sizesLower wobbleFits 1/sqrt(V) well

Learning Rate vs. Wobble (Variance)

Data extracted from this episode

ConditionWobbleNotes
Varying learning ratePractically unchangedUnlike batch size, learning rate doesn't significantly impact wobble

Warmup Percentage vs. Optimal Learning Rate

Data extracted from this episode

Warmup PercentageOptimal Learning Rate (approx.)Notes
0% or 0.1%2e-3 or 3e-2Default values
30%5e-3Optimal learning rate shifts with increased warmup
20-30%Optimal for current setupHigher than the default 1%

Learning Rate Schedules and Parameter Norm Growth

Data extracted from this episode

ConditionParameter Norm GrowthNotes
Linear scheduleSlower growthLower end-of-training norm
Constant scheduleFaster growthHigher end-of-training norm
Linear schedule + Weight decayDecreases norm after a periodWeight decay overcomes linear LR schedule
Constant schedule + Weight decaySlower growth, but doesn't decreaseWeight decay does not overcome constant LR schedule

Final Extrapolation Values

Data extracted from this episode

ConditionFinal Value Range
Constant learning rate0.18 to 0.4
Feature projection0 to 0.08
Learning rate schedule0.08 to 0.18

Effect of Epochs and QK Normalization on Gap (7B)

Data extracted from this episode

ConditionGap Value
Reference (D9)-0.41
Eight epochs0.23
Without QK normalization0.57
D9 vs D4Worse results

Common Questions

Changing both seeds (initialization and data) results in a validation loss standard deviation of about 0.003. Interestingly, changing only the initialization or only the data source yields similar variance, suggesting these factors are major drivers of training variability.

Topics

Mentioned in this video

More from Stanford Online

View all 195 summaries

Ask anything from this episode.

Save it, chat with it, and connect it to Claude or ChatGPT. Get cited answers from the actual content — and build your own knowledge base of every podcast and video you care about.

Get Started Free