Stanford's Suhas Kotha Maps Loss Basins to Solve Model Averaging Limits
Stanford Online
Weight averaging fails for independently pre-trained models because they occupy separate loss basins, but succeeds for fine-tuned models sharing a basin, while learning rate decay reveals hidden progress by dropping models to the bottom of river valleys.
Weight averaging fails completely between independent pre-training runs—linearly interpolating two identical models trained from different random seeds spikes loss from ~2.93 to ~8.0 (random guessing)—because separate runs inhabit entirely different loss basins. (7:27)
The river valley loss landscape model explains why Warmup-Stable-Decay (WSD) schedules hide progress during high-learning-rate phases: full-batch gradients show near -1.0 cosine anti-correlation ricocheting across steep valley walls, while descent along the flat floor is revealed only when cooling the learning rate or averaging weights. (40:40)
In high-dimensional non-convex optimization, random matrix theory and empirical spectra indicate that critical points are overwhelmingly saddle points rather than local minima, with gradient descent almost surely escaping along negative curvature directions. (59:38)
Combining Exponential Moving Average (EMA) fine-tuning with pre-trained initialization interpolation yields strictly complementary gains, proving that the river valley oscillation model and the shared basin geometry model represent distinct physical phenomena. (72:45)
Detailed notes
## Background
This lecture was published by Stanford Online on YouTube on November 29, 2026, as part of the Stanford CS312: Deep Learning Alchemy course. Taught by PhD student Suhas Kotha, the session breaks down three foundational mental models of loss landscape geometry: shared loss basins, river valley dynamics, and high-dimensional saddle points.
## TL;DR
Kotha addresses fundamental questions in neural network optimization by comparing how models navigate complex parameter spaces. He begins by examining why independently pre-trained checkpoints cannot be weight-averaged while fine-tuned models can, demonstrating how shared basins enable techniques like model soups and task arithmetic. Next, he introduces the Hessian and second-order optimization, using the river valley model to explain how training oscillates across steep walls while making hidden progress along flat corridors, which Warmup-Stable-Decay (WSD) schedules reveal upon cooling down. Finally, he evaluates high-dimensional critical points through random matrix theory, explaining why gradient descent rarely gets trapped by bad local minima or saddles in practice.
## Atmosphere & style
The lecture has the engaging, reflective feel of an advanced academic seminar led by an instructor who bridges rigorous optimization theory with messy practical heuristics. Kotha speaks in an accessible, conversational style, pairing mathematical concepts like Hessian eigenspectra with humorous historical anecdotes, such as Geoffrey Hinton's quip about visualizing high dimensions. The presentation carries a healthy dose of empirical skepticism, with Kotha openly pointing out suspicious paper baselines and questioning whether neat theoretical proofs were simply invented after the fact to justify what practitioners already observed working.
## Bulletin
- [07:27](https://www.youtube.com/watch?v=yYdwC786e1A&t=447s) Weight averaging fails completely between independent pre-training runs—linearly interpolating two identical models trained from different random seeds spikes loss from ~2.93 to ~8.0 (random guessing)—because separate runs inhabit entirely different loss basins.
- [40:40](https://www.youtube.com/watch?v=yYdwC786e1A&t=2440s) The river valley loss landscape model explains why Warmup-Stable-Decay (WSD) schedules hide progress during high-learning-rate phases: full-batch gradients show near -1.0 cosine anti-correlation ricocheting across steep valley walls, while descent along the flat floor is revealed only when cooling the learning rate or averaging weights.
- [59:38](https://www.youtube.com/watch?v=yYdwC786e1A&t=3578s) In high-dimensional non-convex optimization, random matrix theory and empirical spectra indicate that critical points are overwhelmingly saddle points rather than local minima, with gradient descent almost surely escaping along negative curvature directions.
- [01:12:45](https://www.youtube.com/watch?v=yYdwC786e1A&t=4365s) Combining Exponential Moving Average (EMA) fine-tuning with pre-trained initialization interpolation yields strictly complementary gains, proving that the river valley oscillation model and the shared basin geometry model represent distinct physical phenomena.
## Key takeaways
- [00:05](https://www.youtube.com/watch?v=yYdwC786e1A&t=5s) Textbook 1D loss landscape cartoons fail to explain real neural network training dynamics, including flatness, crevice sharpness, and mode connectivity.
- [07:27](https://www.youtube.com/watch?v=yYdwC786e1A&t=447s) Linear interpolation between independently pre-trained checkpoints encounters severe loss barriers, confirming that distinct seeds end up in disjoint basins.
- [08:56](https://www.youtube.com/watch?v=yYdwC786e1A&t=536s) Fine-tuning runs sharing a pre-trained base stay within a single basin, enabling weight-averaging strategies like greedy and uniform model soups that match or beat ensembles at single-model inference cost.
- [19:56](https://www.youtube.com/watch?v=yYdwC786e1A&t=1196s) Permutation symmetry and neuron matching algorithms (such as Git Re-Basin) reduce interpolation barriers, but weight-averaged models still trail prediction ensembles, indicating permutation invariance does not fully explain separate basins.
- [22:29](https://www.youtube.com/watch?v=yYdwC786e1A&t=1349s) Branching pre-training runs from a shared trajectory demonstrates that chaotic basin selection occurs during the initial warm-up phase; subsequent trajectories retain linear mode connectivity.
- [28:32](https://www.youtube.com/watch?v=yYdwC786e1A&t=1712s) Full Newton's method is intractable and unstable due to memory costs and negative Hessian eigenvalues, whereas the positive semi-definite Gauss-Newton matrix isolates positive curvature but still incurs steep computational overhead.
- [31:39](https://www.youtube.com/watch?v=yYdwC786e1A&t=1899s) Transformer Hessian eigenspectra exhibit dominant outlier eigenvalues matching the vocabulary projection size, followed by a long decaying spectral bulk and a non-trivial tail of negative eigenvalues.
- [40:40](https://www.youtube.com/watch?v=yYdwC786e1A&t=2440s) Under the river valley model, high learning rates bounce across sharp transverse walls while slowly progressing along the low-curvature riverbed, generating anti-correlated successive gradients.
- [38:04](https://www.youtube.com/watch?v=yYdwC786e1A&t=2284s) Polyak averaging and WSD cooling schedules both eliminate steady-state risk by collapsing wall oscillations to uncover latent optimization progress along the valley floor.
- [48:12](https://www.youtube.com/watch?v=yYdwC786e1A&t=2892s) Single Warmup-Stable-Decay runs with branched cooldowns allow practitioners to map the optimal performance frontier across varying token horizons without training independent runs for each budget.
- [59:38](https://www.youtube.com/watch?v=yYdwC786e1A&t=3578s) By the Wigner semi-circle law in high dimensions, the ratio of saddle points to local minima grows exponentially, ensuring that high-error critical points almost always retain negative curvature escape directions.
- [01:04:37](https://www.youtube.com/watch?v=yYdwC786e1A&t=3877s) Theoretical analysis in simplified networks shows that gradient descent escapes strict saddles with probability 1, meaning empirical training stalls are typically due to model capacity limits rather than spurious local minima traps.
- [01:12:45](https://www.youtube.com/watch?v=yYdwC786e1A&t=4365s) Stacking EMA iterate averaging with pre-trained weight interpolation (WiSE-FT) produces additive improvements, showing that neither the river valley model nor the basin geometry model alone completely explains fine-tuning dynamics.
## Detailed walkthrough
### [00:05](https://www.youtube.com/watch?v=yYdwC786e1A&t=5s) Unit 3 and the Problem with 1D Loss Landscape Cartoons
Suhas Kotha opens the lecture by introducing Unit 3 of Stanford CS312, which serves as the final optimization unit of the course. The overarching focus of the unit is understanding loss landscapes. While students will encounter several mental models during this session and additional ones in the subsequent lecture, the immediate goal is to critically examine how practitioners visualize optimization. In elementary machine learning lectures, the standard mental model is an intuitive cartoon: the horizontal axis represents a single one-dimensional parameter, the vertical axis plots the scalar loss achieved by that parameter, and gradient descent is depicted as taking successive steps along a local linear approximation until it lands comfortably in a minimum.
```mermaid
flowchart TD
accTitle: Limits of the 1D Loss Landscape Cartoon
accDescr: Diagram contrasting simplistic 1D loss cartoon assumptions with the reality of high-dimensional deep learning.
subgraph S1["1D Textbook Cartoon"]
A["1D Parameter Axis"] --> B["Local Linear Approximation"]
B --> C["Rolls Monotonically into Minima"]
end
subgraph S2["Unanswered Realities"]
D["Degree of non-convexity?"]
E["Are minima sharp crevices or wide flats?"]
F["Do different initializations share a basin?"]
G["Do models get trapped in bad local minima?"]
end
S1 -.->|"fails to explain"| S2
```
Kotha cautions that relying on such simplistic curves is fundamentally misleading for modern neural networks. As Kotha remarks, “However, this mental model is kind of shoddy and is not really good or does not capture like a lot of things that happen in practice and also leaves a lot of questions unanswered about what this loss landscape actually looks like.” In reality, drawing simple one-dimensional lines fails to answer how non-convex the landscape truly is, whether the terrain is violently bumpy or largely flat, how many local minima exist, or whether models get permanently stuck in suboptimal basins far above the global minimum. Furthermore, simple curves cannot reveal whether two models initialized from different points will converge to the same basin or diverge completely, nor do they characterize whether minima are narrow, precarious crevices or broad, forgiving plains.
[02:20](https://www.youtube.com/watch?v=yYdwC786e1A&t=140s) High-Dimensional Chaos and Hinton's Rule for Hyperplanes
The true geometry of neural network loss landscapes is vastly more intricate than textbook drawings suggest, largely because the landscape is heavily confounded by architectural choices. For instance, merely inserting residual connections transforms a landscape that would otherwise be violently jagged and bumpy into a comparatively smooth, navigable terrain. Kotha emphasizes that there are no universal, guaranteed geometric properties that hold a priori. He references a paper where researchers explicitly optimized the parameters of neural networks to craft arbitrary geometric illustrations—demonstrating that virtually any landscape contour, valley, or cartoon picture can be manufactured intentionally within a deep network's parameter space.
Because humans are biologically incapable of visualizing parameter spaces spanning millions or billions of dimensions, deep learning researchers have had to rely on imaginative coping mechanisms and analytical abstractions. Kotha brings up a famous quip from Geoffrey Hinton: “To deal with hyperplanes in a 14-dimensional space, visualize a 3D space and say 14 to yourself very loudly, everyone does it.” Rather than despairing over human perceptual limits, the community has constructed rigorous geometric tools—including isolated low-dimensional slices, directional probes, and summary statistics like Hessians—to build functional heuristics that guide algorithmic development.
[04:20](https://www.youtube.com/watch?v=yYdwC786e1A&t=260s) Three Mental Models: Basins, River Valleys, and Critical Points
To bridge the gap between empirical observation and mathematical theory, Kotha outlines the three core mental models covered in the lecture, ordered along a spectrum from empirical heuristics to formal theoretical geometry:
```mermaid
flowchart LR
accTitle: Three Mental Models of the Loss Landscape
accDescr: Flowchart displaying the three mental models presented in the lecture.
M1["1. Basins & Connectivity"] --> M2["2. River Valleys"]
M2 --> M3["3. Critical Points & Saddles"]
subgraph SG1["Basins"]
M1 --- B1["Weight averaging probes convexity"]
end
subgraph SG2["Rivers"]
M2 --- B2["Oscillations along sharp walls drive river progress"]
end
subgraph SG3["Critical Points"]
M3 --- B3["High-dimensional saddles vs local minima"]
end
```
The first model focuses on **basins and mode connectivity**. While independently trained models might land in separate local minima, practitioners often discover that two fine-tuned checkpoints converge into the very same basin. This behavior can be empirically verified using weight averaging: if interpolating the parameter weights of two models produces an intermediate model that matches or outperforms either endpoint, the loss surface along that path is locally convex.
The second model is the **river valley landscape**, which simplifies the parameter space into two contrasting directions: a flat, gently sloping "river" along which meaningful task progress occurs, and steep, high-curvature "valley walls." Rather than smoothly rolling down the centerline of the valley, real training dynamics bounce aggressively back and forth between the opposing canyon walls. As Kotha highlights, “And one surprising intuition is that it's actually faster to make progress by oscillating along this valley direction rather than going just straight down the river direction.”
The third model analyzes **critical points**, where the gradient equals zero ($\nabla L = 0$). When optimization stalls, it is vital to know whether the network is trapped at a disastrous local minimum or a saddle point—where the loss curves upward in some directions but opens downward in others. The lecture investigates whether gradient descent genuinely risks becoming stranded at these non-optimal stationary points or if the high dimensionality of the space naturally provides escape routes.
[07:27](https://www.youtube.com/watch?v=yYdwC786e1A&t=447s) Basins, Mode Connectivity, and the Sensitivity of Pre-Training
Turning directly to basins and mode connectivity, Kotha reminds the class of the extreme sensitivity observed in their first assignment. In pre-training from scratch, deep learning behaves like a chaotic system: perturbing the data seed, altering the model initialization seed, or even changing a single token in the training pipeline causes the optimization trajectory to diverge into entirely different functional solutions.
As Kotha observes regarding that early assignment, “And even just one small perturbation leads to capturing the full variance of the deep learning spectrum.” This baseline chaos establishes an important tension: if minor perturbations during initial pre-training cast the model into entirely distinct, non-overlapping regions of parameter space, it raises the central question of how and when models can ever find shared basins, maintain mode connectivity, or be combined via simple parameter averaging.
When models are trained completely independently from scratch, conventional intuition suggests they will settle into entirely different local minima scattered across the loss landscape rather than converging to the same basin. Suhas Kotha validates this directly with an experiment matching the class's standard pre-training setup: two models are pre-trained with identical hyperparameters, differing only by their random seeds—seed 42 and seed 43. Evaluated on their own, both models achieve a competitive pre-training loss of approximately 2.93.
```mermaid
flowchart LR
accTitle: Pre-Trained Weight Averaging Failure
accDescr: Interpolating between two independently pre-trained seeds causes loss to spike from 2.93 to random guessing at 8.0.
subgraph S42["Seed 42"]
M1["Model A (Loss ~2.93)"]
end
subgraph S43["Seed 43"]
M2["Model B (Loss ~2.93)"]
end
subgraph Mix["Interpolation: (1-α)A + αB"]
Interp["Midpoint (α = 0.5)<br>Loss spikes to ~8.0<br>(Random Guessing)"]
end
M1 --> Mix
M2 --> Mix
```
However, when taking a linear interpolation of their weights using a mixture parameter $\alpha$ (evaluating $(1 - \alpha)\theta_1 + \alpha\theta_2$), the loss deteriorates catastrophically. Right at the midpoint ($\alpha = 0.5$), the loss shoots up to around 8.0. As Kotha highlights, “In fact, at this middle point over here, the model is basically nonsensical. Eight is like random guessing in our setting.” This massive barrier demonstrates that independently pre-trained checkpoints occupy completely separate basins; if they inhabited a single convex valley or shared basin, linear weight averaging would yield comparable or even superior performance rather than destroying model capability entirely.
- Seed 42 and Seed 43 individual losses: ~2.93
- Weight-averaged loss at midpoint ($\alpha = 0.5$): ~8.0 (equivalent to random guessing)
- Takeaway: Pre-training from scratch with different initial random seeds places models into disconnected basins.
---
[08:56](https://www.youtube.com/watch?v=yYdwC786e1A&t=536s) Model Soups: Weight Averaging Across Fine-Tuning Runs
While naive weight averaging fails completely in the pre-training regime, it turns out to be remarkably effective in fine-tuning. Kotha introduces the seminal "Model Soups" framework, which operates by first taking a base model pre-trained on generic data with an objective like CLIP (Contrastive Language-Image Pre-training) and subsequently fine-tuning it on a downstream target task such as ImageNet. Because the fine-tuning runs branch off from a single pre-trained initialization, the resulting models maintain structural compatibility and remain confined to a shared local basin.
In the Model Soups paper, practitioners explore several distinct ways of aggregating many models trained with different hyperparameters (visualized as green diamond scatter points evaluated on both in-distribution ImageNet accuracy and out-of-distribution held-out sets):
| Aggregation Method | Mechanism | Inference Compute Cost | Relative Performance |
|:--- |:--- |:--- |:--- |
| **Best Individual Model** | Pick the single highest-performing run on validation data | $1\times$ forward pass | Solid baseline; bounded by single-model variance |
| **Ensemble** | Run every model separately and average their output predictions at inference time | $N\times$ forward passes (e.g., $20\times$ for 20 models) | Very high accuracy; significantly superior in-distribution |
| **Uniform Soup** | Average the weight vectors of all trained models into a single parameter set | $1\times$ forward pass | Near best individual model; top out-of-distribution accuracy |
| **Greedy Soup** | Sort models by validation performance; sequentially add models to the weight average only if held-out accuracy improves | $1\times$ forward pass | Dominates every individual model across metrics |
Kotha stresses the operational differences between ensembling and weight soups. An ensemble averages logits or probabilities across $N$ models, requiring $N$ evaluations on every single forward pass—an approach that becomes prohibitive when scaled to 20 or more checkpoints. By contrast, a uniform or greedy soup compiles all checkpoints into a single set of weights, preserving standard inference latency while outperforming any individual model. As Kotha summarizes the findings, “And there if you take the greedy soup, which filters out the bad models in the weight average, you can actually get a model that dominates every individual model you've trained.”
---
[12:20](https://www.youtube.com/watch?v=yYdwC786e1A&t=740s) Ensembles vs. Soups and the Geometry of Fine-Tuning Basins
To strip away hyperparameter noise, Kotha presents a cleaner experiment mirroring the class's setup: five separate models are fine-tuned under the exact same hyperparameter settings, varying solely in random seed. Because runs exhibit low run-to-run standard deviation, each individual fine-tuned run lands at roughly similar baseline performance. Aggregating these models through either ensembling (prediction averaging) or souping (weight averaging) yields substantial improvements over any single checkpoint, with the performance curves continuing an upward trajectory as more models ($K$) are added.
```mermaid
flowchart TD
accTitle: Shared Fine-Tuning Basin Geometry
accDescr: Independent fine-tuning runs depart from a shared pre-trained initialization and explore the rim of a shared basin, where weight averaging pulls the model to the deeper center.
Init["Pre-trained Initialization (θ₀)"] --> Branch1["Fine-tune Run 1 (Seed A)"]
Init --> Branch2["Fine-tune Run 2 (Seed B)"]
Init --> Branch3["Fine-tune Run K (Seed K)"]
Branch1 -.->|"Linear Weight Average"| Center
Branch2 -.->|"Linear Weight Average"| Center
Branch3 -.->|"Linear Weight Average"| Center
```
During the Q&A, students probe the boundaries of weight averaging versus ensembling:
- **Scope of weight averaging**: In response to whether weight averaging always helps, Kotha clarifies that it depends strictly on the geometry: “So as we've seen in this fine tuning setting the averaging the weights led to better performance but in the pre-training setting if we did it naively we didn't get better performance from averaging the weights.” Understanding when weights can be blended provides a diagnostic tool for whether runs occupy a shared basin.
- **Ensembling vs. Basin Membership**: When asked whether ensembling gains imply that models belong to the same basin, Kotha notes that ensembling works almost universally: “In fact, ensembling almost always improves performance, but the weight averaging only works in certain regimes. So to being able to ensemble two models doesn't suggest certain basin.”
- **Intuition for fine-tuning stability**: A student shares an intuition that pre-training explores vast, disparate areas where tiny early discrepancies steer trajectories into different basins, whereas fine-tuning moves only a modest distance from the shared pre-trained base, keeping runs inside a local basin populated by useful "experts." Kotha confirms: “Yeah, that's a great intuition. That's so like something that's consistent with the experiments we have too.”
Geometrically, fine-tuning runs starting from the same initialization ($\theta_0$) diverge along the rim or perimeter of a shared basin. Because loss basins are roughly bowl-shaped, averaging their parameter vectors pulls the resulting model inward toward the center of the basin, achieving a lower loss and better generalization than any individual run resting along the edges.
[16:36](https://www.youtube.com/watch?v=yYdwC786e1A&t=996s) Hyperparameter Diversity and Greedy Model Soups
Suhas Kotha explains an experiment conducted by the authors of the model soups paper to determine exactly when weight averaging provides the largest benefit. Instead of solely changing random seeds, the researchers trained multiple models and measured the geometric angle between their weight vectors. A larger angle signifies that the checkpoints are further apart in parameter space. When tracking the performance difference between the weight-averaged solution and the individual endpoints, the authors observed a clear pattern: greater weight separation yields a substantially larger boost in performance upon averaging. To deliberately exploit this phenomenon, they diversified training by varying hyperparameters—such as learning rates and data augmentation strategies—alongside seeds, pushing models even further apart while keeping them inside the same basin.
Combining these techniques leads to a multi-model evaluation comparing in-distribution (ID) versus out-of-distribution (OOD) accuracy. While uniform soups (averaging all models) already match or beat individual checkpoints, varying hyperparameters increases the risk that an underperforming model degrades the final average. To resolve this, the authors introduced the "greedy soup" algorithm, which sequentially evaluates candidate models and only incorporates a new checkpoint into the running average if it improves validation performance. The resulting trade-off curve demonstrates that greedy soups outperform uniform soups, with ensembling retaining a slight edge on in-distribution performance while weight averaging excels on out-of-distribution robustness without incurring extra inference latency.
```mermaid
flowchart TD
accTitle: Greedy Soup Model Selection Process
accDescr: A flow diagram showing how candidate models are iteratively evaluated and included into the running average only if they improve performance.
subgraph Candidates["Diverse Hyperparameter Runs"]
M1["Model 1 (Top Baseline)"]
M2["Model 2 (High LR)"]
M3["Model 3 (Augmentation B)"]
end
subgraph Soup["Greedy Selection Loop"]
Start["Start with Best Model"]
Eval{"Average candidate with soup.<br/>Does validation metric improve?"}
Keep["Include in Weight Average"]
Discard["Discard Candidate"]
end
- When measuring model weights geometrically, a larger angle between weight vectors directly correlates with a larger performance gain after weight averaging.
- Tuning both hyperparameters and random seeds forces models further apart than varying random seeds alone, unlocking greater improvements from weight averaging.
- Uniform model soups average all trained checkpoints equally, whereas greedy model soups greedily keep only those models whose inclusion improves performance.
- Ensembling retains a marginal lead over model soups on in-distribution metrics, but model soups perform slightly better out-of-distribution while retaining single-model inference cost.
---
[18:23](https://www.youtube.com/watch?v=yYdwC786e1A&t=1103s) Task Arithmetic in the Fine-Tuning Landscape
Kotha highlights that the parameter space immediately surrounding a pre-trained model is exceptionally well-behaved and roughly linear. Because fine-tuning explores a localized, bowl-shaped region, practitioners can treat fine-tuned parameter deltas as modular vectors—a paradigm known as task arithmetic. If a pre-trained base model $\theta$ is fine-tuned on a specific downstream task to obtain $\theta_{\text{FT}}$, the difference vector $\tau = \theta_{\text{FT}} - \theta$ captures that specific capability. Researchers have found that these task vectors can be added together to combine multiple distinct capabilities into a single model, or subtracted to remove specific behaviors.
To illustrate this regularity, Kotha describes experiments where researchers negate a fine-tuning vector: adding $-\tau$ to the base model degrades performance on the target task while leaving unrelated control tasks largely intact. Kotha notes that this provides a practical mechanism for model safety: “And like maybe one application that people would care about for this type of stuff is if you have like a model, you can train it on unsafe data and then you can take this weight vector and apply it to reverse the unsafe behavior and actually make the model more safe.” This linear algebraic predictability confirms that fine-tuning takes place in an orderly basin, posing a striking contrast to pre-training from scratch.
- Task arithmetic allows taking fine-tuning weight deltas ($\theta_{\text{FT}} - \theta_{\text{base}}$) and adding them across multiple tasks to combine skills without retraining.
- Subtracting a task vector selectively degrades that specific task while preserving performance on control tasks.
- Safety applications exploit this property by fine-tuning on undesirable or unsafe behavior and subtracting the resulting delta vector to produce a safer model.
- These arithmetic operations underscore how benign, bowl-shaped, and locally linear the fine-tuning loss landscape is relative to full pre-training.
---
[19:56](https://www.youtube.com/watch?v=yYdwC786e1A&t=1196s) Permutation Symmetry, Git Re-Basin, and Weight Matching
Turning back to pre-training from scratch, Kotha tackles the central puzzle: if weight averaging works reliably for fine-tuning, why does directly averaging two independently initialized pre-training runs completely destroy performance? A prominent hypothesis in deep learning theory posits that separately trained networks learn essentially the same functional representations, but their hidden units end up ordered arbitrarily due to permutation symmetries in neural architectures (e.g., swapping row and column indices across hidden layers leaves the input-output mapping identical). Under this hypothesis, separate models settle into different basins purely because of coordinate permutations; permuting their weights into alignment should place them within the same basin.
Kotha examines papers exploring this concept, such as *Git Re-Basin* and optimal transport-based model fusion. In an experiment where two endpoint models are trained on distinct datasets, simple linear interpolation produces a deep loss spike in the middle—mirroring the nonsensical outputs observed in random-seed pre-training comparisons. Applying algorithmic weight-matching or activation-matching permutes the neurons to align the models, significantly smoothing the interpolation curve and restoring functional performance.
However, Kotha is skeptical that permutation symmetry tells the entire story. Even after alignment, weight-averaged models still trail the performance of a naive prediction ensemble: “And the gap between weight averaging and ensembling suggests that maybe this permutation story captures some of the discrepancy between these two models and why they're in different basins, but clearly it doesn't capture all of the discrepancy.” If the models truly shared the exact same functional basin up to unit permutation, properly aligned weight averages would match or exceed the ensemble. The persistent gap indicates that current weight-matching techniques remain incomplete, or that distinct pre-training runs inhabit fundamentally different functional modes.
- Multilayer perceptrons (MLPs) and Transformers possess permutation symmetries where permuting hidden units along with their corresponding incoming and outgoing weights leaves the underlying function unchanged.
- Works like *Git Re-Basin* attempt to solve the pre-training averaging failure by finding optimal permutation matrices that align weights or hidden activations across runs.
- Simple weight interpolation between unaligned models yields a severe performance drop in the midpoint, whereas permuted weight matching recovers meaningful performance.
- Because weight-matched averages still underperform prediction ensembling, Kotha considers the permutation symmetry hypothesis an incomplete explanation for the barrier separating independent pre-training basins.
---
[22:29](https://www.youtube.com/watch?v=yYdwC786e1A&t=1349s) Shared Initialization Horizons and Mode Connectivity
Kotha outlines an alternative strategy to force independent pre-training trajectories into a common basin: treating pre-training more like fine-tuning by sharing early optimization steps. He reviews a study where a model begins on a single, joint pre-training trajectory before branching off at a specified "spawn epoch" into two independent runs with different data orders or random seeds. By sweeping the spawn point from the very first step of training to the final epochs, researchers can determine the minimum shared training required to maintain linear mode connectivity between the resulting weights.
The empirical results reveal that the landscape is chaotic primarily at the very beginning of training. Once a model navigates past this initial warm-up phase along a shared path, the separate branches stay within the same basin: “In very early in the training run, what you find is that the models actually start ending up in a place where you can average their weights to get similar performance.” Kotha highlights that Stanford CS312 students will directly investigate this trade-off in their class assignment, systematically measuring how many shared optimization steps are necessary before branching runs become averageable.
- Branching experiments train a single shared pre-training run up to a "spawn epoch" before splitting into distinct optimization paths.
- Splitting at epoch zero behaves like averaging two distinct pre-training seeds (yielding unusable models), while splitting late mirrors fine-tuning (yielding seamless weight averaging).
- Studies show that models lock into a shared basin surprisingly early in pre-training, meaning only a fraction of initial training must be shared to preserve averageability.
- In summary, fine-tuning naturally preserves basin connectivity because checkpoints inherit the shared basin of the pre-trained base model, whereas pre-training from scratch exhibits early chaotic divergence that prevents natural mode connectivity across runs.
[24:22](https://www.youtube.com/watch?v=yYdwC786e1A&t=1462s) Model Soups: Greedy vs. Uniform Averaging and Parameter Normalization
Following a discussion on why models from separate training runs can enter a shared basin under the right conditions, an audience member raises a question about fine-tuning: why would keeping the best single set of hyperparameters outperform aggregating multiple models? Suhas Kotha clarifies that intuition generally points the other way: combining different fine-tuned runs ought to outperform individual models. He refers back to an empirical plot showing that a uniform soup (a simple average of all fine-tuned checkpoints) can perform poorly when the pool includes models with substantially degraded performance. In contrast, a greedy soup—which sequentially adds checkpoints only if they improve validation accuracy—consistently beats every individual run. In cleaner regimes without low-performing outliers, a uniform soup can indeed outperform every individual model.
```mermaid
flowchart TD
accTitle: Comparison of Fine-Tuning Model Soups
accDescr: Diagram contrasting uniform soup failure modes against greedy soup selection across multiple fine-tuned models.
subgraph Pool["Fine-Tuned Checkpoints"]
M1["High-performing Models"]
M2["Degraded / Outlier Models"]
end
subgraph Soups["Soup Strategies"]
US["Uniform Soup<br/>(Averages all models)"]
GS["Greedy Soup<br/>(Sequentially adds if validation improves)"]
end
subgraph Outcomes["Performance"]
US_Out["Hurt by poor models<br/>Underperforms best model"]
GS_Out["Discards bad models<br/>Beats every individual model"]
end
M1 --> US
M2 --> US
M1 --> GS
M2 -.->|"Rejected"| GS
US --> US_Out
GS --> GS_Out
```
Another student asks whether varying hyperparameters leads to drastically different parameter magnitudes, and whether weight averaging would benefit from normalizing or re-scaling parameters first. Kotha notes that this aligns with the motivation behind "re-basin" techniques: finding a shared parameterization or permutation under which disparate models align for averaging. While acknowledging that he does not have complete intuition on every re-scaling variant, he points to research exploring weight averaging in the tangent space as a promising avenue for understanding these geometry-aware parameter alignments.
- In fine-tuning pools containing several low-performing runs, greedy soups safeguard performance by rejecting models that degrade validation metrics, whereas uniform averaging naively includes them.
- In well-behaved hyperparameter sweeps without outlier failures, even simple uniform soups can surpass every individual candidate checkpoint.
- Re-basin style methods seek parameter transformations or normalizations that map models with mismatched magnitudes or permutations into a mutually averageable space.
---
[26:14](https://www.youtube.com/watch?v=yYdwC786e1A&t=1574s) Crash Course on the Hessian: Curvature, Eigenvalues, and Critical Points
Transitioning to the lecture’s next two mental models of the loss landscape, Kotha introduces a crash course on the Hessian matrix. He emphasizes that the Hessian is central to analyzing loss geometry and second-order optimization. Mathematically, the Hessian $H$ is the second-order partial derivative matrix of the loss with respect to all parameter pairs. For a scalar loss function defined over $p$ parameters, the Hessian is a $p \times p$ symmetric matrix describing local quadratic curvature around any point in parameter space.
To build intuition, Kotha explains that the most natural way to interpret the Hessian is through its eigenbasis: treating the axes as orthogonal eigenvectors with corresponding eigenvalues describing the directional curvature. As Kotha puts it:
> “So, each eigenvalue corresponds to how sharp or flat the like minimizer is, the critical point is, as well as what direction it faces.”
The magnitude (absolute value) of an eigenvalue indicates sharpness: large eigenvalues denote steep, narrow valleys, while values near zero indicate flat regions. The sign indicates orientation: positive eigenvalues curve upward, while negative eigenvalues curve downward. Kotha categorizes critical points where the gradient vanishes:
- **Positive definite (all $\lambda > 0$):** All directions curve upward; the point represents a local minimum.
- **Negative definite (all $\lambda < 0$):** All directions curve downward; this forms a local maximum. Kotha jokes that “it would be really concerning if all of your eigenvalues were negative,” though neural network training does not settle in such states.
- **Indefinite (mixed signs):** Upward curvature along some eigenvectors and downward along others; this defines a saddle point.
- **Positive semi-definite with zero eigenvalues:** Directions with zero curvature create completely flat ravines where loss remains unchanged locally, while other directions remain sharp.
---
[28:32](https://www.youtube.com/watch?v=yYdwC786e1A&t=1712s) Second-Order Optimization, Newton’s Method, and the Gauss-Newton Matrix
Kotha shows how second-order information modifies standard first-order optimization. In standard gradient descent, updates subtract the gradient scaled by a scalar learning rate. If the full Hessian were known, one could instead execute preconditioned gradient descent—Newton's method—by multiplying the gradient vector by the inverse Hessian, $H^{-1} \nabla L$. This operation rescales the step size along each eigenvector proportionally to its curvature, eliminating oscillations across steep walls and making optimization isotropic across all directions.
In convex quadratic settings, Newton's method yields quadratic convergence ($1/t^2$ error decay over steps $t$, compared to roughly $1/t$ for standard gradient descent). Connecting this to Tatsunori Hashimoto's earlier lecture on the noisy quadratic model, Kotha shows how preconditioning can be parameterized by an exponent $p \in [0, 1]$:
- At $p = 0$ (unpreconditioned gradient descent), progress is strictly constrained by the largest eigenvalue $\lambda_{\max}$ to avoid divergence.
- At $p = 1$ (optimal preconditioning via $H^{-1}$), the curvature-dependent factors collapse to unity, producing uniform progress across all coordinate directions.
```mermaid
flowchart LR
accTitle: Gradient Descent vs Newton Preconditioning
accDescr: Diagram illustrating how multiplying the gradient by the inverse Hessian balances step sizes across sharp and flat curvature directions.
subgraph GD["Vanilla Gradient Descent"]
G1["Gradient Step"] --> B1["Step limited by sharpest direction"]
B1 --> S1["Slow progress on flat directions"]
end
subgraph Newton["Newton Preconditioning"]
G2["H^-1 * Gradient Step"] --> B2["Rescales curvature via eigenbasis"]
B2 --> S2["Uniform, fast convergence across all directions"]
end
```
Despite its theoretical appeal, true Newton updates face two major hurdles in deep learning:
1. **Computational tractability:** Computing and inverting a $p \times p$ matrix when $p$ is billions of parameters requires squaring the parameter count in memory, which is computationally prohibitive.
2. **Negative curvature:** In non-convex landscapes, negative eigenvalues in $H$ cause Newton steps to seek local maxima or shoot toward unbounded loss improvements that do not exist globally.
To circumvent negative eigenvalues, practitioners often replace the Hessian with the **Gauss-Newton matrix**. Taking the Jacobian of the model's pre-softmax activations $Z$ with respect to the parameters, the Gauss-Newton matrix isolates the positive-curvature component of the second derivative. It is guaranteed to be positive semi-definite (all eigenvalues $\ge 0$), providing a well-behaved upward quadratic surrogate that avoids downhill divergence.
---
[31:39](https://www.youtube.com/watch?v=yYdwC786e1A&t=1899s) Empirical Spectra: Dominant Vocab Modes and the Bulk Tail
Kotha presents empirical measurements from the recent paper *In Defense of the Quadratic Model*, which measured the empirical eigenvalue spectra of both the Hessian and Gauss-Newton matrices across real Transformer models trained with Adam on standard datasets at various batch sizes.
```mermaid
flowchart LR
accTitle: Transformer Hessian Spectrum Structure
accDescr: Structural breakdown of the Transformer Hessian eigenvalue spectrum into dominant outlier modes and a decaying bulk.
subgraph Spectrum["Transformer Hessian Eigenvalue Spectrum"]
Dom["Dominant Outliers<br/>(Top eigenvalues up to vocab size)"]
Bulk["Spectral Bulk / Tail<br/>(Decaying eigenvalues beyond vocab size)"]
Neg["Negative Eigenvalues<br/>(Substantial tail on log scale)"]
end
Dom -->|"Reflects output layer rank"| Bulk
Bulk -->|"Nonlinear interactions"| Neg
```
Plotting the spectra reveals key structural properties of real Transformer loss landscapes:
- **Negative eigenvalue presence:** Although a large proportion of eigenvalues are positive, the Hessian exhibits a non-trivial tail of negative eigenvalues, confirming the presence of saddle-like geometry around checkpoints reached by Adam.
- **The dominant vocabulary plateau:** At the top end of the spectrum, a distinct set of exceptionally large eigenvalues forms a high-curvature plateau. Kotha points out that the cutoff of these dominant eigenvalues aligns cleanly with a vertical dotted line marking the vocabulary size of the language model's output projection.
- **The decaying bulk tail:** Beyond the vocabulary-sized dominant modes, the remaining eigenvalues drop off into a continuous, rapidly decaying spectral bulk, showing that the vast majority of directions in parameter space remain relatively flat.
[32:56](https://www.youtube.com/watch?v=yYdwC786e1A&t=1976s) Second-Order Optimization: Newton, Gauss-Newton, and Step Counts
Suhas Kotha resumes by examining the empirical spectra of curvature matrices. By inspecting the eigenspectrum of the true Hessian, one sees both positive and negative eigenvalues, reflecting non-convex curvature. In contrast, measuring the spectrum of the Gauss-Newton matrix reveals that all of its eigenvalues are strictly positive—a property that ensures positive semi-definiteness and makes it an appealing local quadratic approximation.
```mermaid
flowchart TD
accTitle: Comparison of Hessian vs Gauss-Newton Matrices
accDescr: Diagram illustrating the spectral differences between the full Hessian and Gauss-Newton approximations, leading to optimization trade-offs.
subgraph Curvature["Matrix Formulations"]
H["Full Hessian (p × p)"] -->|"Eigenvalues"| H_spec["Mixed (+ and -)"]
GN["Gauss-Newton Matrix"] -->|"Eigenvalues"| GN_spec["Strictly Positive (+)"]
end
subgraph Optimizers["Optimization Trade-offs"]
GN_spec --> GN_opt["Gauss-Newton Optimization"]
GN_opt -->|"Pros"| S50["~50 Steps to Target Loss"]
GN_opt -->|"Cons"| HighCost["Massive Per-Step Compute Cost"]
Adam["First-Order: Adam / AdamW"] --> LongSteps["100s to 1,000s of Steps"]
Adam --> LowCost["Low Per-Step Compute Cost"]
end
```
Kotha references a recent paper investigating the potential of second-order optimization to evaluate how much performance gain is achievable if Newton's method or the Gauss-Newton method were feasible in practice. When plotting loss against step count, the differences appear striking: where optimizers like Adam or AdamW require 100 to 1,000 steps to reach a given target loss, full Gauss-Newton hits the same loss target in roughly 50 steps. While this convergence speed seems remarkable, Kotha highlights the catch: computing the Gauss-Newton update is vastly more expensive per step than AdamW. First-order methods dominate modern pre-training precisely because they rely only on gradient vectors, making them far more computationally practical per unit of compute rather than per data step. To bridge this gap, practitioners also explore layer-wise Gauss-Newton approximations, which treat network layers separately—computing layer-by-layer diagonal blocks rather than the massive full $p \times p$ parameter matrix—a structure students analyze in their course assignments.
---
[34:28](https://www.youtube.com/watch?v=yYdwC786e1A&t=2068s) Class Discussion: Second-Order Approximations and Suspicious Baselines
Fielding audience questions, Kotha clarifies the distinction between global and layer-wise Gauss-Newton methods. A layer-wise implementation decomposes the parameter space into distinct layer blocks, computing smaller individual curvature matrices, whereas a global method operates directly over the gigantic $p \times p$ parameter space. A student then asks about interpreting the empirical eigenspectrum plot, specifically what the horizontal axis represents:
> “So what this means is they first computed like the estimates of the eigenvalue and then a common way to reason about the eigenvalues is to sort all of them from increasing to decreasing. So all this x-axis is doing is sorting all the eigenvalues.”
When asked whether optimizers like Adam already maintain a running history of gradients to approximate curvature, Kotha explains that Adam can be understood as maintaining a diagonal preconditioner rather than a full quadratic approximation of the Hessian. Another student inquires how optimization speed relates to data limits versus compute limits. Kotha points out that under the standard pre-training paradigm of CS312—where data is effectively abundant and streaming—step count mirrors data exposure, so getting somewhere faster equates to finding a better optimum under a fixed token budget. However, if compute were so abundant that steps could be massively parallelized across hardware, step count alone would become the metric that matters most.
Turning back to the benchmark paper comparing Gauss-Newton against first-order baselines, a student asks whether achieving validation loss in fewer steps implies generalizing from fewer samples. Kotha validates the logic but urges deep skepticism toward the specific empirical curves:
> “To be clear, uh I don't want you guys to take this plot too seriously because I find it extremely suspicious that SGD is 10 times faster than AdamW. And so the empirics of this plot are up for question in my opinion.”
While the general theoretical trend—that Gauss-Newton cuts down step count significantly—holds true, he considers the reported 10x lead of standard SGD over AdamW a sign of problematic tuning or methodology in the study.
---
[38:04](https://www.youtube.com/watch?v=yYdwC786e1A&t=2284s) The River Valley Landscape, Steady-State Risk, and Polyak Averaging
Kotha bridges the curvature discussion back to the lecture's core geometric models:
- **River valley landscape:** High eigenvalues in the Hessian correspond to sharp directions (steep valley walls), while low eigenvalues denote flat directions (the riverbed).
- **Critical points:** Saddle points contain a mixture of positive and negative eigenvalues, whereas local minima feature positive eigenvalues.
- **Sharpness:** Later lectures explore how the maximum eigenvalue ($\lambda_{\max}$) evolves across training.
Turning to the river valley mental model, Kotha revisits the noisy quadratic optimization model. Under constant learning rate stochastic gradient descent (SGD), training error decomposes into a convergence term and a steady-state risk term. Crucially, sending the total number of steps $T$ to infinity fails to eliminate the steady-state risk floor unless one scales up to an infinitely large batch size or intervenes in optimization.
```mermaid
flowchart LR
accTitle: Strategies to Eliminate Steady-State Risk in the River Valley
accDescr: Diagram showing two classic approaches by Polyak to eliminate steady-state risk during optimization: learning rate schedules vs Polyak weight averaging.
subgraph Problem["Constant Learning Rate Issue"]
LR["Constant LR (η)"] --> Osc["Oscillation Across Valley Walls"]
Osc --> SSR["Non-Zero Steady-State Risk"]
end
subgraph Solutions["Polyak's Theoretical Approaches"]
direction TB
S1["1. Learning Rate Schedules"] -->|"η → 0"| ZeroRisk1["Steady-State Risk → 0"]
S2["2. Polyak Weight Averaging"] -->|"Running Average of Weights"| ZeroRisk2["Both Convergence & Risk Terms → 0 as T → ∞"]
end
Problem --> Solutions
```
To resolve this steady-state limitation, Kotha presents two classic theoretical techniques popularized by the Soviet mathematician Boris Polyak:
1. **Learning Rate Schedules (Step-Size Reduction):** Because the steady-state risk term scales directly with learning rate, annealing the step size toward zero eliminates the risk floor (albeit at a slight cost to late-stage convergence rate).
2. **Polyak Averaging (Weight Averaging):** Instead of keeping the final iterate, the algorithm maintains an unweighted running average of all parameter weights visited throughout training.
In theoretical bounds for Polyak averaging, both the convergence rate and the steady-state risk vanish as $T \to \infty$. Geometrically, when high learning rates cause iterates to bounce back and forth violently across narrow valley walls, taking the arithmetic mean of those oscillating positions naturally concentrates right along the low-loss center of the riverbed.
---
[40:40](https://www.youtube.com/watch?v=yYdwC786e1A&t=2440s) Anticorrelated Gradients in River Valleys (A Walk with SGD)
To demonstrate how these dynamics manifest empirically in deep networks, Kotha examines the 2018 paper *A Walk with SGD* by Xing et al. The authors ran full-batch gradient descent and tracked the cosine similarity between successive parameter update steps:
Conventional intuition suggests that as optimization makes steady progress toward a minimum, gradients should align constructively, yielding a positive cosine similarity. However, the empirical data reveals a startling phenomenon:
> “You might expect that all the gradients are pointing in the same direction because they're all making progress, right? And that corresponds to the regime where the cosine similarity of these gradients is very high. But surprisingly, after a while into training, they observe that the gradients are almost completely are pointing in completely opposite directions at every gradient update and their cosine similarity is like pretty close to negative one, which is uh pretty surprising I think.”
Rather than advancing smoothly down a gentle slope, the optimizer enters a canyon where the curvature across the walls dwarfs the gentle slope along the floor. At high learning rates, successive updates repeatedly overshoot the ravine floor, ricocheting back and forth across opposing walls while making quiet, hidden forward progress along the valley floor.
- **Observed cosine similarity:** Slumps from positive alignment down to nearly $-1.0$, demonstrating near-perfect anti-correlation across consecutive steps.
- **Mechanism:** The optimizer bounces against steep, high-eigenvalue directions while slowly drifting along the flat, low-eigenvalue floor of the river valley.
[41:23](https://www.youtube.com/watch?v=yYdwC786e1A&t=2483s) Anticorrelated Gradients and the River Valley Picture
When measuring gradient behavior in full-batch gradient descent, successive updates point in almost completely opposite directions, exhibiting a cosine similarity close to -1. While this effect is also present in stochastic gradient descent (SGD), gradient noise confounds the measurement because the cosine similarity between random high-dimensional noise vectors is roughly zero. Despite gradients oscillating across opposite directions at every step, measuring the Euclidean parameter distance from initialization demonstrates that the model is still moving monotonically away from where it began. The optimizer continues making objective progress even while bouncing back and forth across sharp surfaces.
```mermaid
flowchart TD
accTitle: River Valley Loss Landscape Dynamics
accDescr: Diagram illustrating how high learning rate training bounces across valley walls while weight decay or averaging brings the iterate to the flat river bottom.
subgraph HighLR["High Learning Rate Regime (Oscillation)"]
W1["Valley Wall (Step t)"] -->|"Gradient points across"| W2["Opposite Valley Wall (Step t+1)"]
W2 -->|"Gradient points back"| W1
W1 -.->|"Net movement along valley"| HP["Hidden Progress along River Bed"]
end
subgraph AnnealingOrAvg["Decay / Averaging Phase"]
W1 -->|"Cool down LR or Average weights"| RB["River Bed (Valley Bottom)"]
W2 -->|"Cool down LR or Average weights"| RB
RB --> Performance["Sharp Loss Drop / Hidden Progress Revealed"]
end
```
This dynamic directly motivates the "river valley" mental model of the loss landscape. At high learning rates, the optimizer sits high up on the valley walls, aggressively bouncing across steep ravines. In learning rate schedules such as Warmup-Stable-Decay (WSD), training at a sustained high learning rate keeps the loss elevated throughout the stable phase. In contrast, linear or cosine schedules show a smooth, steady decrease in loss. Suhas Kotha notes that the current iterate masks the actual optimization state:
> “In the River Valley landscape, the mental model that you should have is that for most of training at these high learning rates, the model is just doing oscillation and it is making progress on the objective, but that progress is not revealed by the current iterate because all of the progress happens when you get to the bottom of the valley.”
Once the learning rate is cooled down, the oscillation magnitude shrinks, permitting the model to descend to the river bottom. Dropping into this flat river direction uncovers the accumulated hidden progress, causing the abrupt loss drop characteristic of WSD schedules.
---
[43:21](https://www.youtube.com/watch?v=yYdwC786e1A&t=2601s) River Valleys, Quadratics, and Cyclic Schedules
A student raises a question about the theoretical foundations of the river valley model:
> “How much of this actually supports like the WSD schedule support the real valley density? Cuz even if you don't have the real valley like you will learning rate still going to get the same result. Cuz in the for example noisy quadratic setting like even if you like do a WSD you probably will have similar results where you have once you learning rate I states the steady state risk drops.”
Kotha agrees that a noisy quadratic model captures the exact same intuition. In a quadratic landscape where one direction has extreme, sharp curvature and another has exceptionally flat curvature, an optimizer will oscillate along the sharp eigenvector while slowly drifting along the flat one. Boris Polyak’s classical convergence results were derived using quadratic models, confirming that reducing the step size or averaging iterates brings the parameters to the optimal bottom.
```mermaid
flowchart LR
accTitle: Cyclic Learning Rate Transitions in a River Valley
accDescr: Flowchart showing how raising and lowering learning rates moves parameters between valley walls and the river bottom.
A["High LR (Valley Walls)"] -->|"Anneal / Cool Down"| B["Low LR (River Bottom)"]
B -->|"Rewarm LR"| C["Re-enter Valley Walls (Oscillate)"]
C -->|"Re-anneal"| D["Final Convergence at Bottom"]
```
The river valley framework also yields a testable prediction regarding cyclic learning rate schedules: cooling down drops the iterates to the river bottom, but rewarming the learning rate should kick the optimizer back up into the oscillating valley-wall regime. Kotha points to experimental work with cyclic schedules containing repeated annealing and rewarming phases:
- When learning rates are rewarmed, the model resumes oscillating along valley walls while continuing to make hidden progress along the river direction.
- Successive re-annealing phases allow the model to repeatedly access the bottom of the valley, recovering performance without suffering major penalties.
- Students explore in their assignments whether this rewarming process is effectively "lossless" or incurs a performance penalty compared to standard cosine decay.
---
[45:45](https://www.youtube.com/watch?v=yYdwC786e1A&t=2745s) Polyak Averaging vs. Pre-trained Weight Interpolation
Rather than lowering the learning rate to descend into the river bed, one can apply Polyak averaging (or an exponential moving average, EMA) across iterates to cancel out transverse oscillations. Kotha compares this iterate-averaging approach to results from robust fine-tuning papers (such as WiSE-FT). In those works, interpolating weights directly between the pre-trained initialization and a fine-tuned checkpoint traces a distinct curve where an intermediate weight average markedly outperforms both endpoints on out-of-distribution (OOD) evaluations.
```mermaid
flowchart LR
accTitle: Comparing Iterate Averaging and Initialization Interpolation
accDescr: Diagram illustrating the difference between averaging weights along a single training path versus interpolating between pre-trained and fine-tuned checkpoints.
subgraph IterateEMA["Iterate Averaging (River Valley)"]
Iter1["Iterate t"] --> EMA["EMA / Polyak Average"]
Iter2["Iterate t+1"] --> EMA
Iter3["Iterate t+2"] --> EMA
EMA --> ResEMA["Reduces Transverse Oscillation"]
end
subgraph BasinInterpolation["Weight Interpolation (Shared Basin)"]
Pre["Pre-trained Model"] --- Interp["Interpolated Model (Best OOD)"]
Interp --- FT["Fine-tuned Model"]
end
```
The paper finds that while maintaining an EMA of weights along the fine-tuning path helps performance over standard fine-tuning, tracking along an EMA trajectory fails to capture the full benefits achieved by interpolating between the pre-trained model and the fine-tuned model:
- The standard fine-tuned model exhibits baseline in-distribution and out-of-distribution performance.
- EMA fine-tuning improves accuracy over standard fine-tuning, demonstrating the value of damping oscillation.
- Weight interpolation between pre-trained initialization and the fine-tuned model achieves significantly higher OOD performance than EMA alone.
This performance divergence illustrates that the shared-basin mental model and the river-valley mental model are subtly distinct. Kotha advises evaluating conceptual models by combining them:
> “If you have two mental models for why phenomena work and you want to measure whether these two mental models are like equivalent or not, you can try stacking them on top of each other. And if they don't perform any differently stacked on top of each other than separately, then you know that they're basically the same mental model. But if they offer complementary performance gains, then there must be something like separate about these models that it kind of like offers different benefits to training.”
---
[48:12](https://www.youtube.com/watch?v=yYdwC786e1A&t=2892s) Case Study: Training Across Multiple Token Horizons
A practical challenge in model training is evaluating performance across different token horizons to observe how scaling data affects downstream metrics. Standard setups typically demand an independent training run for each target token horizon because conventional cosine schedules require fixing the schedule length in advance. Having to execute dozens of separate runs imposes a heavy computational cost, highlighting the industry's desire for a single training trajectory that can be evaluated at multiple horizon checkpoints without full retraining.
[48:56](https://www.youtube.com/watch?v=yYdwC786e1A&t=2936s) Learning Rate Schedules and Observing Hidden Progress
Evaluating performance benefits per fixed token horizon during pre-training is tricky when using schedules like warmup-stable-decay (WSD) or linear decay. Suhas Kotha points out that early in linear decay, and throughout the extended stable phase of WSD, models operate in a very high learning rate regime without any cool-down. In that state, raw loss measurements mask the true underlying gains:
> “So you don't know all the hidden progress you've made, so you don't know what performance you're actually getting. You're kind of just like estimating the the hidden progress and not the actual observed progress.”
To determine the actual traversed progress without throwing compute away, researchers rely on modified learning rate schedules:
```mermaid
flowchart TD
accTitle: LR Schedules for Tracking Hidden Progress
accDescr: Three approaches to measure true loss progress across token horizons.
subgraph Strategies ["Learning Rate Trajectories"]
A["MiniCPM: Shared WSD<br/>Branch off short cool-downs"]
B["Horizon-Free / Annealed Peak<br/>Slowly decay peak LR + sharp knees"]
C["Cyclic LR Schedules<br/>Repeated cool-down & re-warmup"]
D["Polyak Weight Averaging<br/>Running average along trajectory"]
end
A --> Frontier["Trace out Pareto frontier<br/>at zero learning rate"]
B --> Frontier
C --> Frontier
D --> Frontier
```
- **MiniCPM Approach:** The MiniCPM paper maintains a single long, shared WSD run at a constant learning rate, branching off short cool-downs to zero at various token intervals. Tracing these cool-down endpoints forms an empirical frontier of true model capability.
- **The Fixed-Horizon Tradeoff:** As observed in course assignments, sticking to a single fixed learning rate leaves performance on the table. The optimal peak learning rate shifts depending on the total token budget.
- **Horizon-Free Schedules:** To combat this, practitioners can implement horizon-free schedules that slowly decay the peak learning rate during the stable phase before executing sharp cool-down knees, effectively tuning peak learning rate per horizon.
- **Cyclic Schedules & Polyak Averaging:** Alternating cool-downs and re-warmups or maintaining an exponential moving average (Polyak averaging) of weights similarly drops the optimization path down into the bottom of the valley to harvest hidden progress.
Kotha emphasizes that classical convex optimization concepts—such as Polyak averaging—accurately explain why learning rate decay and weight averaging succeed. They align directly with the river valley mental model: training oscillates violently along high-curvature walls while quietly making real progress along the gentle downhill river bed.
---
[51:40](https://www.youtube.com/watch?v=yYdwC786e1A&t=3100s) Student Q&A: Intuition Behind Hidden Progress and Higher Dimensions
The discussion opens up to questions from the room regarding why progress remains hidden and how to mentally visualize these dynamics. A student asks why bouncing across the top of a river valley translates to downstream improvement if the raw measured loss looks flat:
> “I don't understand the concept of like hidden progress. If you have a high learning rate and you're bouncing along like the top of the river, how would you know that—why would it be getting better as you're bouncing along there?”
Kotha clarifies that if you examine three checkpoints along an unannealed high-learning-rate run, the raw loss delta between them appears minuscule, often looking completely plateaued. However, cooling each checkpoint down to zero learning rate reveals strictly better and better final performance. He offers an alternative geometric picture: envision a river valley whose floor slopes downward while the canyon walls remain flat. While bouncing from wall to wall high above, the model advances into deeper territory; you only witness the depth of that progress once you anneal the learning rate and descend to the canyon floor. When asked what ensures the trajectory actually heads downstream rather than wandering aimlessly, Kotha defers the formal oscillatory dynamics to the next lecture.
A second student asks whether two-dimensional intuitions mislead us when thinking about real parameter spaces. Kotha notes that while the river valley cartoon is three-dimensional (two parameter directions plus loss), toy frameworks like the noisy quadratic model can theoretically stack arbitrarily many independent quadratic dimensions. Nevertheless, intuiting high-dimensional loss landscapes is notoriously difficult, serving as an entry point into the next topic: critical points.
---
[54:18](https://www.youtube.com/watch?v=yYdwC786e1A&t=3258s) Saddle Points vs. Local Minima in High Dimensions
Historically, deep learning practitioners and theorists were paralyzed by the threat of critical points—places where the gradient is zero ($\nabla L = 0$):
> “So when I was learning deep learning back in the day I was taking this Coursera course and then Andrew Ng like when he was drawing like a saddle point he drew this like a little horsey to like show like what a saddle looks like. People were really scared that you would like end up exactly where that guy's sitting and then like you would make any more progress on the loss landscape.”
Early fears held that models would become trapped either in a catastrophic sub-optimal local minimum or perched atop a saddle point where optimization stalled indefinitely. Yet modern deep learning pipelines barely incorporate explicit mechanisms to avoid them. Kotha highlights three theoretical folklore arguments explaining why these bad critical points cause little trouble in practice:
1. **Saddles Greatly Outnumber Minima:** In high-dimensional non-convex optimization, critical points are overwhelmingly saddle points rather than local minima.
2. **Local Minima Are Benign or Nonexistent:** In many theoretical formulations, non-convex objectives have no spurious local minima at all. Where local minima do exist, their loss values lie exceptionally close to the global optimum, meaning the optimizer pays almost zero regret if it lands in one.
3. **Gradient Descent Naturally Escapes Saddles:** Due to gradient descent dynamics and stochasticity, optimization rarely gets trapped at saddle points; it may briefly slow down near them, but it almost invariably escapes along negative curvature directions.
Kotha concludes that relying on low-dimensional sketches misleads researchers: a one-dimensional drawing almost inevitably features bad local minima traps, whereas high-dimensional reality presents a fundamentally different geometry.
[56:38](https://www.youtube.com/watch?v=yYdwC786e1A&t=3398s) Statistical Physics and the Geometry of High Dimensions
```mermaid
flowchart TD
accTitle: Error and Hessian Eigenvalue Spectrum Shift
accDescr: Diagram illustrating how high or low error shifts the Wigner semicircle eigenvalue distribution and alters the fraction of negative eigenvalues.
subgraph SpectrumShift["Eigenvalue Distribution Shift"]
LeftShift["Spectrum shifted LEFT<br/>High Fraction of Negative Eigenvalues (Alpha)"]
RightShift["Spectrum shifted RIGHT<br/>All/Most Eigenvalues Positive (Alpha = 0)"]
end
subgraph CriticalPoints["Resulting Critical Point Type"]
Saddle["Saddle Point<br/>(Escapable directions exist)"]
Minima["Near-Global Local Minimum<br/>(Low error guaranteed)"]
end
While one-dimensional toy diagrams often depict loss landscapes dominated by traps and local minima, high-dimensional spaces behave in fundamentally different ways. To understand the geometry of deep neural networks, researchers frequently turn to tools from statistical physics and random matrix theory, analyzing random Gaussian matrices or random loss landscapes. This mathematical framing is analogous to analyzing initialization dynamics in $\mu$P (Maximal Update Parametrization), where tracing random matrices and their evolution reveals general properties of real-world training runs.
Focusing on foundational theoretical work (such as Dauphin et al., drawing on results by Bray and Dean), Kotha introduces two key quantities used to analyze critical points where the gradient is zero:
1. $\epsilon$ (epsilon): the error, defined as the distance between the current objective's loss and the global minimum.
2. $\alpha$ (alpha): the index, defined as the fraction of Hessian eigenvalues that are negative.
At a saddle point, eigenvalues are both positive and negative, representing open curvature directions facing upward and downward. At a true local minimum, every single eigenvalue must be strictly positive ($\alpha = 0$), meaning the surface curves upward in all directions. For random Gaussian objectives, theory shows a tight, monotonic correspondence between $\epsilon$ and $\alpha$: decreasing error directly correlates with a decreasing fraction of negative eigenvalues.
Consequently, critical points with high error ($\epsilon$) must have a high index ($\alpha$). Because they retain a substantial fraction of negative eigenvalues, high-error critical points are overwhelmingly saddle points rather than local traps. As Kotha humorously remarks about the theoretical limit where nearly every eigenvalue is negative: “in the extreme, if your epsilon was like extremely high, almost basically all your eigen values would be negative and you would be at like one of those of those peak things which seems like really depressing to be at.” Conversely, if a critical point achieves an index of zero ($\alpha = 0$, a local minimum), its error $\epsilon$ must already be close to the global optimum.
- Theoretical models build intuition by substituting intractable deep network landscapes with random Gaussian objectives.
- Error $\epsilon$ measures objective suboptimality: $\epsilon = L(\theta) - L^*$.
- Index $\alpha$ represents the proportion of negative Hessian eigenvalues: $\alpha = \frac{\#\{\lambda_i < 0\}}{p}$.
- The monotonic concentration between $\epsilon$ and $\alpha$ rules out high-error local minima in these idealized high-dimensional landscapes.
[59:38](https://www.youtube.com/watch?v=yYdwC786e1A&t=3578s) Wigner Semi-Circle Law and Dimensional Scaling
The mathematical machinery behind this relationship stems from classical random matrix theory. Independent of deep learning, the eigenvalues of a standard random Gaussian symmetric matrix obey the famous Wigner semi-circle law, distributing evenly across a symmetric semi-circle centered at zero. Under this baseline distribution, any randomly chosen eigenvalue has an exact 50% chance of being positive and a 50% chance of being negative.
Bray and Dean demonstrated that at critical points of random Gaussian landscapes, the Hessian's eigenvalue density preserves this semi-circular shape, but its center shifts horizontally by an offset determined by the error $\epsilon$:
- **Low Error ($\epsilon \to 0$):** The entire semi-circle shifts far to the right, pushing the vast majority of eigenvalues into positive territory. At the global minimum, the entire support moves past zero, driving $\alpha \to 0$.
- **High Error (Large $\epsilon$):** The semi-circle shifts far to the left, forcing almost all eigenvalues to become negative.
Dimensionality dramatically alters the probability of finding saddles versus minima. In a one-dimensional problem, an exact saddle requires the single eigenvalue (the second derivative) to land exactly on zero—an inflection point with probability zero. Thus, low-dimensional drawings give the misleading impression that almost all critical points are minima. However, as the parameter count $p$ grows into high dimensions, the ratio of saddle points to local minima grows exponentially. Each additional dimension provides an independent opportunity for an eigenvalue to be negative, making it exponentially rare for thousands or millions of eigenvalues to align as simultaneously positive unless the error is already extremely low.
When asked by an audience member what a saddle point means in one dimension given that an eigenvalue is either strictly positive or negative, Kotha sketches an inflection point with a zero second derivative: “Yes. So a saddle would look like it would look like this.” The audience member clarifies: “I see. Okay, so you just zero eigen value.” Kotha agrees: “Yeah.”
- In 1D landscapes, almost all critical points sampled are local minima or maxima; saddles are degenerate measure-zero points.
- In high dimensions, the combinatorial requirement that all $p$ eigenvalues be positive causes the number of saddle points to exponentially outstrip local minima.
- Shifts of the Wigner semi-circle spectrum guarantee that an optimization trajectory encountering zero gradients high up on the loss surface is almost guaranteed to be facing a saddle with negative downward-sloping escape routes.
[01:03:07](https://www.youtube.com/watch?v=yYdwC786e1A&t=3787s) Empirical Evidence and Non-Convex Optimization
Addressing a student question regarding how literal practitioners should take these assumptions—given that practical neural network losses are structured rather than drawn from a random Gaussian distribution—Kotha clarifies that random Gaussian objectives are merely a theoretical guidepost. In practice, researchers validate the intuition empirically by taking actual trained deep networks, evaluating the Hessian at discovered critical points, and measuring their error $\epsilon$ against the fraction of negative eigenvalues $\alpha$.
Empirical measurements closely match the theoretical prediction: as the error of a model decreases, the fraction of negative eigenvalues drops in tandem. Points discovered with high training error consistently exhibit mixed eigenvalues, proving they are saddles, whereas true local minima appear only at very low error levels. High-error spurious local minima—the classical fear of non-convex optimization—are largely absent in practice.
Beyond physics-inspired random matrix theory, rigorous computer science and machine learning theory has reached similar conclusions for structured non-convex problems. A well-known example highlighted by Kotha is matrix completion:
- Literature such as the paper *Matrix Completion Has No Spurious Local Minima* provides explicit mathematical proofs that all local minima are globally optimal.
- In these problems, every single sub-optimal critical point contains at least one negative curvature direction, guaranteeing that algorithms capable of escaping saddle points can converge to global solutions.
As Kotha summarizes regarding the relationship between error and local minima in empirical evaluations: “if you have if you're like at a saddle point, like if you have high error, you're probably going to be at a saddle point and you're not going to be at a local minima because if you had high error, then you can't have low alpha.”
[01:04:37](https://www.youtube.com/watch?v=yYdwC786e1A&t=3877s) Theoretical Guarantees: Global Minima, Saddle Points, and Deep Linear Networks
Suhas Kotha walks through theoretical examples that challenge classical intuitions about non-convex optimization. While practitioners historically devised complicated heuristics to avoid bad local traps, theory shows that in specific non-convex formulations, gradient descent is provably guaranteed to reach a global minimum if it converges to a minimum at all. In simplified architectures such as a one-layer multilayer perceptron (MLP), older theoretical work proves that there are no spurious local minima whatsoever—only saddle points and global minima. Kotha emphasizes that while these results offer clean proofs, they remain toy pictures: one can easily construct theoretical models where bad local minima exist, and several papers demonstrate empirical and theoretical instances of genuine local minima in deep landscapes.
Because local minima either rarely exist or exhibit loss values nearly identical to the global minimum, the primary optimization concern shifts to saddle points. Practitioners initially feared getting trapped in saddles and designed explicit escape mechanisms, typically relying on injecting random perturbations into the parameter vector around saddle points to knock the trajectory down a direction of negative curvature. However, Kotha points to a line of theoretical analysis demonstrating that standard gradient descent naturally avoids strict saddle points almost surely:
> “Basically, they can prove that gradient descent with like vanishing probability actually gets stuck at one of these saddles and will almost always will just enter a local minima.”
To understand how saddle points operate over time, researchers frequently analyze deep linear networks. Although they lack non-linear activation functions, deep linear networks preserve non-convex loss surfaces and complex trajectory dynamics. Theoretical analysis of these networks reveals a stepping-stone progression: training moves from one saddle point to the next, with the Hessian accumulating an increasing count of positive eigenvalues at each transition until reaching a local minimum where every eigenvalue is positive.
```mermaid
flowchart LR
accTitle: Saddle Progression in Deep Linear Networks
accDescr: Trajectory showing optimization advancing through saddle points with increasing positive eigenvalues until reaching a local minimum.
subgraph Progression["Deep Linear Network Trajectory"]
S1["Saddle Point 1<br/>(Many negative eigenvalues)"]
S2["Saddle Point 2<br/>(Fewer negative eigenvalues)"]
LM["Local Minimum<br/>(All positive eigenvalues)"]
end
S1 -->|"escape along negative curvature"| S2
S2 -->|"accumulate positive eigenvalues"| LM
```
- In simplified settings like a one-layer MLP, mathematical proofs establish that the landscape contains exclusively saddle points and global minima, completely lacking spurious local minima.
- Escaping saddle points algorithmically often relies on adding random parameter perturbations, though saddles can still slow down training speed.
- In deep linear models, training trajectories systematically progress through a sequence of saddle points, incrementally increasing the number of positive Hessian eigenvalues until reaching a minimum.
---
[01:08:24](https://www.youtube.com/watch?v=yYdwC786e1A&t=4104s) Audience Q&A: Diminishing Returns and Stochasticity at Saddle Points
Following the theoretical synthesis, an audience member asks why training curves eventually level off if local minima are benign and saddle points are avoided. Kotha responds that in practice, loss often continues to drop if runs are extended, but progress eventually stalls due to finite parameter capacity:
> “And the number of parameters in your model might also work make the loss landscape like worse. So this like might slow down training as well.”
Kotha adds that behind contemporary scaling laws lies an informal working belief: provided models are made large enough and paired with well-tuned optimizers, gradient descent can optimize virtually any well-behaved natural target function.
Another student asks whether stochastic gradient descent (SGD) is strictly necessary to escape saddle points compared to full-batch gradient descent. Kotha considers comparing the Hessian index (the count or fraction of negative eigenvalues) across different batch sizes to see whether smaller, noisier batches stay away from regions with negative eigenvalues. Looking at an empirical slide comparing Hessian spectra from small batches on the left to larger batches on the right, Kotha observes that the data is ambiguous, admitting, “Doesn't seem very conclusive.”
---
[01:10:28](https://www.youtube.com/watch?v=yYdwC786e1A&t=4228s) Summary of Mental Models: Basins, River Valleys, and Critical Points
Wrapping up the lecture, Kotha connects the three distinct mental models of deep learning optimization explored throughout the session:
1. **Loss Basins and Weight Averaging:** Models trained within a shared basin (such as fine-tunes of the same foundation checkpoint or runs sharing an early pre-training trajectory) can have their parameters averaged directly to boost performance and out-of-distribution robustness. While ensembling predictions works across completely separate basins, weight averaging is uniquely parameter-efficient and directly diagnoses the connectivity of the underlying landscape.
2. **The River Valley Landscape:** High-learning-rate optimization does not travel smoothly along a single trajectory; instead, it violently oscillates across steep valley walls while making unobserved, steady progress along a flat riverbed. Unlocking that hidden progress requires either annealing the learning rate (as seen in the dramatic loss drops at the end of Warmup-Stable-Decay schedules) or performing weight averaging across the oscillating path.
3. **Saddle Points and Critical Points:** High-dimensional geometry suggests saddle points exponentially outnumber local minima, while gradient descent naturally circumvents strict saddles to reach minima with near-optimal loss.
Reflecting on the relationship between theory and empirical practice, Kotha offers a candid appraisal of critical point theory:
> “And finally our critical point analysis suggests that maybe we don't need to worry too much about local minima and saddle points and we can kind of just train as normal, but obviously this theory theory is like created as a just like a reaction to the fact that in practice people didn't really need to care about it.”
---
[01:11:36](https://www.youtube.com/watch?v=yYdwC786e1A&t=4296s) Preview of Sharpness and Language Model Eigenvalue Spectra
Looking ahead to the next lecture, Kotha introduces the study of loss landscape sharpness, measured via the maximum eigenvalue of the Hessian ($\lambda_{\max}$). Future lectures will explore how sharpness evolves dynamically throughout training—climbing, plateauing, or even falling in phenomena such as progressive sharpening and the edge of stability.
A student asks how the river valley mental model translates to modern language models: does a real model have a single valley direction, or is the landscape composed of many competing axes? Kotha explains that because language models have billions of parameters, the geometry is high-dimensional rather than a simple 2D ravine. The Hessian spectrum naturally separates into a dominant outlier block of large eigenvalues (representing steep, sharp valley walls that cause optimization bounce) and a long tail of tiny eigenvalues:
> “Like smaller eigen values intuitively correspond to flatter directions. So maybe those ones behave more river like and the other directions behave more valley like.”
Kotha cautions that there is no rigid one-to-one mapping assigning individual parameter coordinates to distinct rivers or valleys, but the broader eigenvalue decomposition accurately reflects this mixture of sharp oscillating walls and flat progress corridors.
[01:12:45](https://www.youtube.com/watch?v=yYdwC786e1A&t=4365s) EMA, Initialization Averaging, and the Limits of the River Valley Mental Model
An audience member asks for clarification about an earlier slide discussing exponential moving averages (EMA) and disagreement, noting they did not fully catch the broader practical takeaway or how the theoretical model maps onto real-world training. Suhas Kotha unpacks the slide step by step to clarify the interplay between fine-tuning, EMA, and initialization averaging. Starting from a pre-trained checkpoint, standard fine-tuning on a downstream target task improves in-distribution performance. However, an unexpected weight averaging phenomenon emerges: interpolating between the fine-tuned model and its original pre-trained initialization traces out a curve that achieves strictly better performance than the fine-tuned checkpoint alone.
```mermaid
flowchart TD
accTitle: Weight Averaging Interactions
accDescr: Diagram illustrating standard fine-tuning versus EMA and interpolation with pre-trained initialization.
subgraph Baselines["Standard Approaches"]
A["Pre-trained Model (Initialization)"] -->|"Standard Fine-tuning"| B["Fine-tuned Model"]
A -->|"EMA Fine-tuning"| C["EMA Model (Better ID & OOD)"]
end
subgraph Interpolations["Weight Interpolation (Mixture Sweeps)"]
B -.->|"Average with Init"| D["Improved In-Distribution Model"]
C -.->|"Average with Init"| E["Best Overall Performance"]
end
```
The second key finding involves replacing standard fine-tuning with an exponential moving average. Running fine-tuning with an EMA produces a model that outperforms standard fine-tuning across both in-distribution and out-of-distribution benchmarks, validating the predictive utility of the river valley mental model. In that framework, EMA acts as a continuous weight average that settles toward the valley floor rather than oscillating against the steep walls. Yet the river valley picture reveals its limitations when pushed further: averaging the EMA model back with the original pre-trained initialization yields an even higher level of performance.
Because the river valley framework only accounts for smoothing optimization bounce to capture performance left on the table along the bottom of a trajectory, it cannot fully explain why mixing weights backward toward the pre-trained initialization provides a separate, complementary boost. Suhas highlights this theoretical gap: “So what that means is that the river valley landscape captures some part of the picture, which is that weight averaging is what's leaving some of the performance on the table, but it doesn't capture the full picture because you can get even better performance by averaging with the initialization.” The basin picture still preserves unique explanatory power that the river valley alone cannot account for.
- Standard fine-tuning improves in-distribution metrics over the pre-trained baseline, but linearly interpolating weights between the fine-tuned endpoint and the pre-trained initialization produces an intermediate checkpoint with even higher in-distribution accuracy.
- Fine-tuning with an exponential moving average (EMA) establishes a stronger baseline, improving both in-distribution and out-of-distribution metrics over conventional fine-tuning.
- Linearly mixing the EMA model with the pre-trained checkpoint achieves the highest overall performance, demonstrating that basin geometry (proximity to initialization) and river valley geometry (flattening optimization oscillation) represent distinct mechanisms.
- An audience member clarifies that the performance curves across these models are generated empirically by sweeping mixture weights ($\lambda$) across the interpolation line.
## Notable quotes
> [08:56](https://www.youtube.com/watch?v=yYdwC786e1A&t=536s) If you take the greedy soup, which filters out the bad models in the weight average, you can actually get a model that dominates every individual model you've trained. — Suhas Kotha
## Mentioned
Stanford CS312, Suhas Kotha, Geoffrey Hinton, CLIP, ImageNet, Model Soups, Git Re-Basin, Tatsunori Hashimoto, Boris Polyak, Andrew Ng, In Defense of the Quadratic Model, A Walk with SGD, WiSE-FT, MiniCPM, Adam, AdamW, SGD, WSD (Warmup-Stable-Decay), Yann Dauphin, Alan J. Bray, David S. Dean, Eugene Wigner, Wigner semi-circle law, muP (Maximal Update Parametrization), Matrix Completion Has No Spurious Local Minima
## Video description
Browse Stanford's online courses in deep learning: https://stanford.io/4zhLWFN
Why can you average fine-tuned models but not two models pre-trained from scratch? In this Stanford CS312: Deep Learning Alchemy lecture, PhD student Suhas Kotha presents three mental models of the loss landscape, covering loss basins and mode connectivity, from model soups and task arithmetic to when pre-training runs become averageable, then gives a crash course on the Hessian and second-order methods. Kotha explains the river valley picture of why WSD learning rate decay reveals hidden progress, and closes with saddle points and why gradient descent rarely gets stuck in high dimensions.
Key questions answered in this lecture:
Q: Why can't you average the weights of two separately pre-trained models?
A: Two d8 runs with seeds 42 and 43 each reach about 2.93 loss, but their weight average is basically nonsensical, near random guessing, so they sit in different basins. Kotha finds the permutation symmetry explanation only partly convincing, since matched averaging still trails ensembling.
Q: What are model soups and why does weight averaging work for fine-tuning?
A: Fine-tunes of the same pre-trained model land in a shared basin, so averaging their weights moves toward its center. A uniform soup comes close to the best single model and is best out of distribution; a greedy soup dominates every individual model, and gains grow when the models are further apart.
Q: Is ensembling the same as weight averaging?
A: No. Ensembling averages predictions and almost always helps even for models in different basins, but costs a forward pass per model; weight averaging produces one model and only works when the models share a basin.
Q: What is the river valley loss landscape and how does it explain WSD learning rate schedules?
A: Training at a high learning rate bounces across sharp valley walls while making hidden progress along a flat river direction; full-batch gradient descent shows successive gradients with cosine similarity near -1. Cooling down the learning rate, or averaging weights, drops the model to the river bottom and reveals that progress, which is why WSD loss falls sharply at the end.
Q: Do neural networks get stuck at saddle points or bad local minima?
A: Kotha presents the folklore case that they mostly do not: in high dimensions, saddles outnumber minima by a ratio that grows exponentially, any local minima tend to have error close to the global minimum, and gradient descent almost never gets stuck at a saddle. Kotha cautions that this theory was largely a reaction to practitioners not needing to worry about it.
Q: Why don't we train neural networks with Newton's method?
A: The Hessian is a p by p matrix and can have negative eigenvalues, so practitioners turn to the always-positive Gauss-Newton matrix. One paper shows Gauss-Newton hitting a target loss in around 50 steps versus hundreds or thousands for Adam, but each step costs far more, and Kotha calls the plot suspicious.
Chapters:
0:00 The geometry of the loss landscape
4:20 Three mental models: basins, rivers, saddles
7:24 Averaging two pre-trained seeds fails
8:56 Model soups: weight averaging in fine-tuning
18:23 Task arithmetic in the fine-tuning landscape
19:56 Permutation symmetry and weight matching
22:29 Shared training makes pre-training averageable
26:14 Hessian crash course: eigenvalues and curvature
28:32 Newton, Gauss-Newton, and second-order speedups
38:26 River valley: learning rate decay vs averaging
40:40 Anticorrelated gradients and WSD hidden progress
48:12 Case study: one run for many token horizons
54:18 Saddle points vs local minima in high dimensions
1:10:27 Summary and preview of sharpness
About the speaker:
Suhas Kotha is a Computer Science PhD student at Stanford advised by Percy Liang and Tatsunori Hashimoto, researching language model pre-training, including how to train when compute is abundant relative to data. Suhas co-created CS312: Deep Learning Alchemy and previously studied at Carnegie Mellon University.
Readings:
- Mode connectivity: https://arxiv.org/abs/1802.10026
- River valley: https://arxiv.org/abs/2410.05192
- Dauphin et al. (2014), Identifying and attacking the saddle point problem: https://arxiv.org/abs/1406.2572
Course website: https://deep-learning-alchemy.github.io/
Watch the full CS312 playlist: https://www.youtube.com/playlist?list=PLXRTcAYPI4AU
Recorded October 13, 2026, in CS312: Deep Learning Alchemy, a Stanford University course taught by Tatsunori Hashimoto and Suhas Kotha.
Suhas Kotha argues that standard one-dimensional cartoons misrepresent deep learning optimization, presenting three complementary high-dimensional mental models—basins, river valleys, and critical points—to explain phenomena such as model weight averaging, training oscillations, and the absence of bad local minima.
Basins, Mode Connectivity, and Weight Averaging
Averaging models pre-trained independently from different random seeds fails catastrophically; Kotha highlights an experiment where linear interpolation between two seeds causes loss to spike from 2.93 to roughly 8.0, equivalent to random guessing. In contrast, fine-tuning runs branching from a single pre-trained checkpoint remain within a shared basin. This geometric property allows weight averaging via Model Soups, where combining fine-tuned checkpoints—particularly through greedy selection—matches or beats individual models and enhances out-of-distribution robustness without added inference cost.
This localized basin structure also enables task arithmetic, where fine-tuning weight deltas act as modular vectors that can be added to merge capabilities or subtracted to remove unsafe behaviors. While permutation symmetries (such as Git Re-Basin) explain part of the barrier separating independent pre-training runs, branching experiments show that models lock into a shared, averageable basin surprisingly early if they share just the initial warm-up phase of training.
River Valleys and Hidden Optimization Progress (40:40)
The river valley model simplifies parameter geometry into steep canyon walls (high Hessian eigenvalues) and a flat, gently sloping floor (low eigenvalues). Empirical tracking of full-batch gradient descent demonstrates that consecutive gradient updates become almost perfectly anti-correlated, with cosine similarities approaching -1.0. Rather than rolling smoothly down the riverbed, the optimizer violently ricochets between opposing valley walls while making unobserved, steady progress along the valley floor.
Because high learning rates keep iterates bouncing high along canyon walls, raw training loss appears to plateau and masks underlying gains. Unlocking this hidden progress requires either annealing the learning rate to descend to the floor—as seen in the sharp performance drops at the end of Warmup-Stable-Decay (WSD) schedules—or applying Polyak averaging and exponential moving averages (EMA) across iterates to cancel out transverse oscillations.
Hessian Spectra and Second-Order Optimization Limits (31:39)
The Hessian matrix defines local quadratic curvature through its eigenvalues. Empirical spectra of real Transformers trained with Adam reveal a high-curvature plateau whose cutoff matches the language model's output vocabulary size, followed by a decaying bulk tail and a non-trivial tail of negative eigenvalues that indicates saddle-like geometry.
Second-order methods like Newton's method or the Gauss-Newton approximation (which guarantees strictly positive eigenvalues) eliminate oscillations by rescaling steps across curvature directions. In empirical benchmarks, Gauss-Newton reaches target loss values in roughly 50 steps compared to hundreds or thousands required by Adam. However, the immense computational cost of calculating and inverting massive parameter-scale matrices makes global second-order optimization impractical, leaving optimizers reliant on diagonal preconditioning.
Critical Points: Saddle Dominance in High Dimensions (54:18)
Classical fears that non-convex optimization gets trapped in high-loss local minima are largely unsupported in high dimensions. Grounded in random matrix theory and the Wigner semi-circle law, theoretical models demonstrate that critical point geometry shifts with training error: high-error critical points have many negative eigenvalues, classifying them as saddle points, while true local minima emerge almost exclusively at very low error levels near global optimality.
Because each additional parameter provides an independent direction for negative curvature, saddle points exponentially outnumber local minima in high-dimensional spaces. Theoretical analyses and structured problems (such as matrix completion) prove that standard gradient descent almost surely avoids strict saddles along negative curvature directions, explaining why deep networks train effectively without complex heuristics to bypass local minima.
While random matrix theory and river valley frameworks offer powerful intuition, Kotha emphasizes that empirical neural networks possess multi-axis geometries and architectural confounding factors that low-dimensional analogies cannot fully capture.
Source quotes
[8:56] Suhas Kotha: If you take the greedy soup, which filters out the bad models in the weight average, you can actually get a model that dominates every individual model you've trained.
Original transcript
[0:05] So, today we're starting unit three.
[0:08] Unit three is still another optimization
[0:09] unit. This will be the last remaining
[0:11] optimization. And the general theme of
[0:13] this unit is going to be lost
[0:14] landscapes. And we're going to go over a
[0:16] couple of mental models today and also
[0:18] cover a more mental models on Thursday.
[0:20] And hopefully you guys will have fun
[0:21] with this stuff. The assignment should
[0:23] already be out.
[0:24] Okay, cool. So that's all for
[0:27] announcements. So now we can dive into
[0:28] the content for today. So today we're
[0:30] going to be reasoning about the geometry
[0:32] of the lost landscape. So in the first
[0:34] lecture we saw a cartoon like this,
[0:36] which is kind of like a mental model
[0:37] that people have when they reason about
[0:39] gradient descent. Roughly, if you think
[0:41] of the x-axis as your parameters, and in
[0:43] this case you only have a
[0:44] one-dimensional parameter, and you have
[0:45] the y-axis which is the loss that
[0:47] parameter achieves, you might have some
[0:49] sort of landscape which defines what
[0:50] error you're actually getting.
[0:52] Uh
[0:53] gradient descent, what it does is it
[0:54] takes the loss landscape, computes like
[0:56] a local linear approximation and takes
[0:57] one update in that direction. And by
[0:59] iterating this iterating this procedure,
[1:01] you hope that you arrive in one of the
[1:02] minima.
[1:03] Uh however, this mental model is kind of
[1:06] shoddy and is not really good or does
[1:08] not capture like a lot of things that
[1:11] happen in practice and also leaves a lot
[1:13] of questions unanswered about what this
[1:14] lost landscape actually looks like. So
[1:16] one question is how non-convex the
[1:18] landscape actually is. So in this
[1:21] landscape you'll have two minima and
[1:22] there's this one like mountain in the
[1:24] middle, but for the most part it's just
[1:26] like only two minima. There's a question
[1:28] of how many local minima exist. Is this
[1:30] the loss landscape very bumpy or is it
[1:32] very flat? These are types of the
[1:34] questions that we don't have the answer
[1:36] to by looking at our one-dimensional
[1:37] model.
[1:39] We also don't know if models get stuck
[1:41] anywhere. In this picture we have two
[1:42] local minima and it's really concerning
[1:44] if the model gets stuck at one of these
[1:45] local minima and doesn't actually
[1:47] approach the global minima, which would
[1:48] get the lowest possible loss.
[1:51] We don't know if model would end up in
[1:52] the same minima. So for example, if we
[1:54] initialize the model on the right versus
[1:55] the model on the left, you'd expect them
[1:57] to maybe end up in separate minima, but
[1:59] maybe uh sometimes in learning the
[2:01] models might end up in the same minima,
[2:02] and this is something that we don't know
[2:03] either.
[2:04] And finally, we don't know how sharp or
[2:06] flat this landscape is. We don't know
[2:08] whether these minima are actually really
[2:10] narrow crevices or if they're very flat
[2:11] regions that we can expect to end up in.
[2:13] And these are all sorts of things that
[2:15] we would like to know the answers to,
[2:17] but just drawing these one-dimensional
[2:18] noodles will not give us an answer.
[2:20] So the real loss landscape is actually
[2:22] like a lot more complicated than these
[2:23] pictures. Uh there's a couple reasons
[2:25] why it's so complicated. One thing to
[2:27] note is that the loss landscape itself
[2:29] is confounded by the models that we
[2:30] choose to train. So for example, by
[2:33] adding uh simply adding residual
[2:34] connections, we can change the loss
[2:36] landscape to look from very very bumpy
[2:38] to look that to something that's like a
[2:40] lot more smooth.
[2:41] And in fact, the loss landscape isn't
[2:43] guaranteed to have any properties a
[2:44] priori. There's this really cool paper
[2:46] what they do is they simply optimize the
[2:49] loss landscape itself and find that you
[2:51] can construct all sorts of cartoons in
[2:53] the loss landscape, and you can have
[2:54] whatever like uh regions or whatever
[2:57] [clears throat] pictures you want happen
[2:58] in the loss landscape. And roughly the
[3:00] point that we want to emphasize here is
[3:02] there's no properties that are like
[3:03] guaranteed about the loss landscape a
[3:04] priori. It's just like natural object
[3:06] that we're analyzing, and we're hoping
[3:07] to find some nice things in the standard
[3:09] deep learning training that we do, but
[3:11] the actual loss landscape might be this
[3:13] extremely chaotic, extremely complicated
[3:15] picture that we can't really visualize
[3:16] in our heads.
[3:19] So given all this, how are we going to
[3:21] form intuition about this really
[3:23] high-dimensional, really complicated
[3:24] loss landscape that depends on so many
[3:25] moving variables?
[3:27] So uh there's a quote from uh Jeffrey
[3:29] Hinton, who is the guy who invented deep
[3:31] learning, and what he said was to deal
[3:33] with hyperplanes in a 14-dimensional
[3:35] space, visualize a 3D space and say 14
[3:37] to yourself very loudly, everyone does
[3:39] it. So uh this is uh you know this makes
[3:42] this probably feel pretty bad that we
[3:44] can't do anything more than three
[3:45] dimensions as humans, but the other
[3:47] counterpart is that people have worked
[3:49] really hard to develop these like
[3:50] natural intuitions for what the loss
[3:52] landscape looks like, maybe by taking
[3:53] like very isolated parts of the deep
[3:55] learning landscape or by taking slices
[3:57] of the landscape or by taking these
[3:59] summary statistics of what the landscape
[4:00] actually looks like.
[4:02] And through these sorts of analytic
[4:03] tools, people have actually came up with
[4:05] these like nice heuristics that actually
[4:07] allow you to design algorithms and
[4:08] capture some aspects of how empirics
[4:10] works. And a lot of optimization
[4:12] research in this front tries to develop
[4:13] a better mental model of what the
[4:15] landscape actually looks like.
[4:18] So uh we're going to go over a couple of
[4:19] these models today and uh they're going
[4:21] to range in today's lecture they're
[4:22] going to range from very empirical to
[4:24] very theoretical and we'll cover uh kind
[4:26] of a spectrum of uh different types of
[4:27] models you can have for what the
[4:28] landscape looks like. So for the three
[4:30] models that we're going to go over
[4:31] today, the first model the mental model
[4:33] is basins. So there's an intuition that
[4:35] if you do training and you train two
[4:37] separate models, they might end up in
[4:39] local minima, but a surprising fact is
[4:41] that sometimes they end up in the same
[4:43] local minima. And if they end up in the
[4:45] same local minima, there's this
[4:46] interesting property you can use to like
[4:48] test for this. You can average the two
[4:50] weights and if the average of the two
[4:51] weights performs better than each of the
[4:53] endpoints, that means that you're in
[4:55] regime of the loss which is convex.
[4:58] So by doing this averaging trick you can
[5:00] you can understand a bit of what the
[5:01] shape of the landscape looks like and
[5:03] we're going to be doing a lot of probing
[5:04] on whether these models can be averaged
[5:06] to get better models or if they can't be
[5:08] averaged and this will tell us when the
[5:09] loss landscape has shared minima or
[5:12] separate minima.
[5:14] Another mental model that we've talked
[5:15] about a little bit so far is the river
[5:17] valley landscape. One geometric
[5:19] intuition people have is that the loss,
[5:21] which you can consider on the y-axis
[5:22] over here, can be defined in terms of
[5:24] two components or obviously in the
[5:27] actual case there would be many high
[5:28] dimensional components, but for this
[5:30] mental model we only think about two
[5:31] components. One is this river direction
[5:33] which corresponds to actual progress on
[5:35] the loss on the loss function which is
[5:37] like where a lot of training progress
[5:39] happens. And there's this valley
[5:40] direction which is really sharp and high
[5:42] curvature and you probably don't want to
[5:45] make that much progress on this
[5:46] direction. There's you kind of just need
[5:48] to be in the river you need to be making
[5:49] progress along the river direction.
[5:51] Maybe if you look at this picture you
[5:52] would imagine that deep learning kind of
[5:54] like
[5:55] traverses down the wall of this valley
[5:57] and will slowly just monotonically make
[5:58] progress in one direction towards the
[6:00] bottom.
[6:01] Interestingly the actual training
[6:03] dynamics look a lot more oscillatory and
[6:05] in these sharp corrections, we expect
[6:06] that the model oscillates a lot,
[6:08] bouncing between valley to valley while
[6:09] also making progress among the river
[6:11] direction. And one surprising intuition
[6:13] is that it's actually faster to make
[6:14] progress by oscillating along this
[6:16] valley direction rather than go
[6:19] going just straight down the river
[6:20] direction.
[6:23] And then the third mental model that
[6:24] we're going to have is reasoning about
[6:25] critical points. So when we're thinking
[6:28] about is deep learning getting stuck in
[6:29] certain parts of the loss landscape,
[6:31] this would mean that the gradient is
[6:32] equal to zero. So at these critical
[6:34] points where the gradient is equal to
[6:35] zero, it's important to like think about
[6:39] whether these points are actually what
[6:40] we want to converge to. Obviously, the
[6:42] global minima is one place where the
[6:43] gradient is equal to zero, but there are
[6:45] many other places where the gradient is
[6:46] equal to zero which you don't might not
[6:47] want to end up in. For example, in a
[6:49] local minimum, the gradient is also
[6:51] zero, but you don't want to stop in a
[6:52] local minima. And an even more exotic
[6:54] thing is a saddle point. So a saddle
[6:55] point is where one of the directions
[6:57] open at least one of the directions
[6:58] opens downward and one of the directions
[7:00] opens upward. In these middle of the
[7:02] saddle point, you would also have
[7:04] gradient zero and you wouldn't make
[7:05] progress. And this would also be pretty
[7:07] concerning if deep learning got stuck in
[7:08] these saddle points. So we're going to
[7:09] reason about whether deep learning
[7:11] enters these saddle points or these
[7:12] local minima before entering the global
[7:14] minima or if at all.
[7:17] So we've just gone over these mental
[7:18] models. Any questions about what we'll
[7:19] be going over today?
[7:25] Okay, cool.
[7:27] So we'll start off with basins and mode
[7:29] connectivity.
[7:31] So
[7:32] traditionally, as you might have
[7:34] reasoned about in assignment one, the
[7:35] deep learning landscape is very like
[7:38] chaotic.
[7:39] If we remember if you recall from
[7:41] assignment one, even perturbing just one
[7:42] token or perturbing just the model seed
[7:45] or just the data seed leads to high
[7:46] variance. It leads to models ending up
[7:49] in different functions. And even just
[7:52] one small perturbation leads to
[7:54] capturing the full variance of the deep
[7:55] learning spectrum. So from this kind of
[7:58] like experiment, we have this sense that
[8:00] the landscape is extremely chaotic. And
[8:02] maybe from this picture, we would expect
[8:04] that models when trained separately of
[8:06] each other would not end up in the same
[8:07] minima and it would end up in all sorts
[8:09] of functions over the loss landscape.
[8:12] So this intuition naively just does
[8:15] apply to our setting. So in this plot,
[8:17] what we're doing is we're taking our
[8:18] standard training setting and we're
[8:20] training two models just with different
[8:22] seeds. So with seed 42 and seed 43.
[8:25] And we measure their loss. So the loss
[8:27] is around like 2.93-ish. And when you do
[8:30] the mixture of their weights, so when
[8:31] you average their weights with some
[8:32] mixture weight alpha, what you find is
[8:34] that the loss of the model is pretty
[8:36] bad. In fact, at this middle point over
[8:38] here, the model is basically
[8:39] nonsensical. Eight is like random
[8:41] guessing in our setting. So this
[8:43] suggests that these two models that
[8:44] we've trained are not in the same like
[8:46] local minima or in the same basin
[8:48] because if they weren't in the same
[8:49] basin, you should be able to average
[8:51] them and expect actually even better
[8:52] performance.
[8:56] Interestingly, even though this didn't
[8:58] work this model averaging did not work
[9:00] for our basic pre-training setting,
[9:02] there's actually many settings where
[9:03] this type of model averaging leads to
[9:04] better performance. So the best example
[9:07] that we can do for this is talk about
[9:08] fine tuning. So fine tuning has a lot of
[9:10] examples where model averaging leads to
[9:13] better performance.
[9:16] So we're going to be closely first
[9:18] following this paper called Model Soups.
[9:20] And Model Soups is in a fine tuning
[9:22] setting. So in this paper, what they do
[9:24] is they first pre-train on something
[9:26] like a clip. So clip is like an image
[9:28] captioning objective where you pre-train
[9:30] on just like generic data to get a
[9:32] better model. And then you'll fine tune
[9:34] on a target task of interest. In this
[9:36] case, the target task of interest is
[9:37] ImageNet. So you'd fine tune this
[9:39] pre-trained model to perform this
[9:40] specific ImageNet task and you'd expect
[9:42] that the pre-training teaches the model
[9:44] something that's useful after the fine
[9:45] tuning.
[9:46] So if you vary the hyperparameters of a
[9:48] ton of different models, you get all of
[9:50] these green diamonds. And these green
[9:52] diamonds represent like different models
[9:54] which have performance evaluated on
[9:56] ImageNet, which is the in-distribution
[9:57] evaluation in this case. And you can
[9:59] also measure evaluation on a different
[10:01] out-of-distribution held-out set. So in
[10:04] this case, if you're fine tuning on
[10:05] ImageNet, it might be of interest on how
[10:07] you would perform on like perturbed
[10:08] versions of ImageNet or data sets that
[10:10] are different from ImageNet. So this is
[10:12] referred to as the out-of-distribution
[10:13] accuracy. You can measure your
[10:15] performance on in-distribution,
[10:16] out-of-distribution, and different
[10:17] hyperparameters get different uh
[10:19] performance.
[10:20] But after you've trained all these
[10:22] models, you can aggregate them in a
[10:23] couple of different ways. So the ways
[10:25] that this paper considers is
[10:27] after you've trained a ton of models,
[10:29] you can select the best possible model
[10:30] that you trained. So just take the very
[10:32] best model.
[10:34] You can also take an ensemble of models.
[10:37] So when you take an ensemble of models,
[10:38] what you do is that you take all of
[10:40] these models and you aggregate their
[10:41] predictions at inference time. So this
[10:43] is not averaging their weights. You keep
[10:45] the models completely separate and every
[10:46] time you want to predict the next token
[10:48] or predict a label, you average the
[10:49] predictions induced by each of the
[10:51] specific models in the ensemble.
[10:54] And this would cost a lot more compute.
[10:56] So for example, if you want to do an
[10:58] ensemble of 20 models, every time you
[11:00] want to run the forward pass of the
[11:01] ensemble, you have to evaluate all of
[11:03] these 20 models on this specific input.
[11:05] And this is one way to aggregate the
[11:06] models.
[11:07] A different way to aggregate the models
[11:09] is similar to this weight averaging
[11:10] intuition we've been talking about so
[11:11] far, which is the uniform suit. So all
[11:14] that is is you take all of this big
[11:16] collection of models and you just
[11:17] average their weights.
[11:19] And this gets you a better model. Uh
[11:20] this gets you a different model that's
[11:23] you compare to all the individual ones.
[11:25] And the final thing is the learned
[11:27] they have like a couple or sorry, greedy
[11:28] suit. Uh the greedy suit, what it does
[11:31] is it takes all of these green diamonds
[11:33] and roughly sorts them by performance
[11:35] and keeps only only keeps soup
[11:38] ingredients that would make your final
[11:39] performance better.
[11:40] So this is a
[11:42] way to maybe filter out bad models that
[11:44] might end up in your suit in your like
[11:46] weight average.
[11:48] So in this plot, as you can see over
[11:50] here, you have all of these models
[11:51] trained with different hyperparameters.
[11:53] And if you do the uniform suit, the
[11:54] uniform suit actually performs
[11:56] remarkably well. So it's close to the
[11:58] best individual model and it is the best
[12:01] model evaluated on out-of-distribution
[12:02] performance. And there if you take the
[12:05] greedy suit, which filters out the bad
[12:07] models in the weight average, you can
[12:08] actually get a model that dominates
[12:10] every individual model you've trained.
[12:20] So
[12:21] this is like a little messy of an
[12:22] experiment because there's a lot of
[12:23] hyperparameters. So I'll show you an
[12:24] even cleaner version of this experiment.
[12:26] So what this is like a lot more similar
[12:29] to how we've done the random seeds in
[12:30] our class. What we're going to do is
[12:32] we're going to fine tune five different
[12:33] models. So these will be the orange
[12:35] points and we're just going to fine tune
[12:37] them on the exact same like settings and
[12:39] everything. It's just a different seed.
[12:41] So as you can imagine these five models
[12:43] are close to each other in terms of
[12:44] performance. As you guys measure the run
[12:46] to run standard deviation is pretty low
[12:48] for training runs.
[12:49] But if you measure the aggregation of
[12:51] the models either via the ensemble which
[12:53] averages their predictions or via the
[12:55] suit which averages the weights, you
[12:57] result in much better models than each
[12:59] of the individual models themselves. And
[13:00] it seems like this curve would keep
[13:01] going that if you kept adding more
[13:03] models you would continue to get better
[13:04] performance.
[13:05] You can measure the better performance
[13:07] either on the in distribution accuracy
[13:08] or the out of distribution accuracy. It
[13:10] seems like this paper observes this like
[13:12] differing trend where in distribution
[13:15] you expect
[13:16] ensemble to do slightly better and out
[13:18] of distribution you expect to do weight
[13:19] averaging to do slightly better.
[13:21] These types of things are things you're
[13:22] going to be exploring in your assignment
[13:24] because for one of the problems in your
[13:25] assignment is going to be comparing
[13:27] weight averaging and assembling so you
[13:28] can see how well these two methods
[13:30] compare.
[13:33] Yeah.
[13:34] >> Is it in general true that averaging
[13:36] weights give you better performance or
[13:38] it's just in this setting
[13:40] >> So as we've seen in this fine tuning
[13:41] setting the averaging the weights led to
[13:42] better performance but in the
[13:44] pre-training setting if we did it
[13:45] naively we didn't get better performance
[13:46] from averaging the weights.
[13:47] >> I see.
[13:48] >> So it is very setting dependent and the
[13:50] by building an intuition of which
[13:51] settings you can average the weights,
[13:53] you'll understand whether you're in like
[13:54] the basin regime or not the basin
[13:55] regime.
[13:57] Yeah.
[13:58] >> Um so how did they choose K in this
[14:00] study and did they choose per
[14:03] >> Uh how did they choose K as in like the
[14:04] number of models or yeah.
[14:07] In this case
[14:08] I think they just wanted to like make a
[14:10] plot so they just like picked five seeds
[14:12] but you can imagine that you can build
[14:14] these sorts of relationships between how
[14:15] your performance changes [clears throat]
[14:16] as a function of k. And then if you have
[14:19] if you are like have as much compute as
[14:20] you want, you might want to just train a
[14:22] lot of these. But if you're limited by
[14:23] compute, then maybe you only want to
[14:24] train two or three to get like the bang
[14:26] for your buck.
[14:29] Any other questions? Yeah.
[14:31] >> Does like the improvement in the
[14:32] ensemble performance also stress like
[14:34] basin
[14:35] loss landscape or in what shape is that?
[14:37] >> Oh yeah, that's a really good question.
[14:38] So I don't have this
[14:40] we'll show a plot for that later, but
[14:42] ensembling you can ensemble two
[14:43] different models that are not in the
[14:44] same basin and get improved performance.
[14:46] In fact, ensembling almost always
[14:48] improves performance, but the weight
[14:49] averaging only works in certain regimes.
[14:51] So to being able to ensemble two models
[14:54] doesn't suggest certain basin.
[14:57] Yes.
[14:58] >> So with the really questionable
[14:59] observation but
[15:05] Um what was that?
[15:07] Like a pre-fit model
[15:09] larger models
[15:10] randomly perturb the weights
[15:12] um and just get like experts
[15:14] tasks.
[15:15] And so I guess like my intuition for
[15:17] that paper is that
[15:19] you when you pre-train your model like
[15:20] small discrepancies between training and
[15:23] like very different results and when you
[15:24] end up in your loss landscape. But once
[15:26] you've like you know treat your model to
[15:29] increase
[15:30] you like be within this certain basin
[15:32] where there exists like a lot of experts
[15:34] that are you know better than maybe your
[15:36] model in that specific thing. And so at
[15:38] that point when you do fine tuning
[15:41] remove the model that much
[15:44] And so that's why you can like average
[15:46] the models there but not during
[15:47] pre-training because then you beat it
[15:48] like a
[15:50] Yeah, that's a great intuition. That's
[15:51] so like something that's consistent with
[15:53] the experiments we have too. Yeah.
[15:56] Cool.
[15:57] So yeah, one geometric intuition for
[15:59] what's happening in this basin landscape
[16:01] is that in this plot what we can do is
[16:03] we can visualize the initialization of
[16:04] the weights, so theta zero are these
[16:06] stars. And we can visualize two separate
[16:08] fine tunes which have the same
[16:09] hyperparameters and just different
[16:10] seeds.
[16:11] Uh what you'll find is that these like
[16:13] two fine tunes make progress along the
[16:15] loss landscape and like a like your
[16:17] error. But if you look at where these
[16:19] models end up, they're ending up around
[16:21] this like basin shape. And if you can
[16:24] imagine you average the weights, you get
[16:26] closer and closer to the middle of this
[16:27] basin. And by getting closer to the
[16:29] middle of the basin, you're getting even
[16:30] better performance at the fine tune left
[16:32] on the table.
[16:36] So one extra experiment that this paper
[16:39] did is they tried to quantify when is it
[16:42] most helpful to average these two
[16:43] weights. So what they do is they train a
[16:45] bunch of models. And when they train the
[16:47] models, they measure the angle between
[16:49] the weights of the models. So higher
[16:50] angle means that the models are more
[16:52] different in some sense. And they find
[16:54] that when the models are further apart
[16:55] from each other, what you can do is you
[16:56] can measure the delta between the
[16:58] performance of the weight average models
[16:59] versus the best versus like the average
[17:02] performance at the endpoints. And you
[17:03] find that you get a larger gain in
[17:05] performance when the two models are
[17:06] further apart from each other. And this
[17:08] suggests that things that are further
[17:09] apart from each other might have more to
[17:11] contribute to
[17:13] to the final weight average solution.
[17:15] And they specifically exploit this type
[17:17] of structure that more different models
[17:19] lead to better like averages by varying
[17:22] the hyperparameters in addition to the
[17:23] seed. Because when you vary the
[17:24] hyperparameters, you get models that are
[17:26] even more like separate from each other
[17:27] and different from each other. And this
[17:29] is
[17:30] like reflected in higher angles. And
[17:32] this correlation holds that the further
[17:33] apart these models are, either by
[17:34] varying your learning rate or your data
[17:36] augmentation scheme, you can actually
[17:37] get even more performance improvements
[17:39] from doing the weight averaging.
[17:42] When you combine all of their techniques
[17:43] together, you get a final trade-off plot
[17:45] that looks like this. So in this plot is
[17:47] still measuring in distribution out of
[17:49] distribution accuracy, but they have two
[17:51] additional things with respect to our
[17:52] older plot. One is that they've trained
[17:54] a ton of models, but with many different
[17:55] hyperparameters rather than just fixed
[17:57] hyperparameters. And then they also add
[17:59] in the greedy soup method, which
[18:00] basically only keeps in like models that
[18:02] help. Especially when you're varying the
[18:04] hyperparameters, it's easy to get models
[18:06] that might hurt your overall weight
[18:07] average performance. So you can do it in
[18:10] this manner to actually continue
[18:12] improving your performance. And it's
[18:14] better than just doing the uniform soup.
[18:15] And similarly you see a result where
[18:17] ensemble is slightly better in
[18:18] distribution soup is slightly better
[18:20] than Adam distribution.
[18:23] Uh there's uh this weight space around
[18:25] fine tuning is actually like remarkably
[18:27] well behaved and you can do all sorts of
[18:30] crazy things with the weight space. So
[18:31] for example, let's say you took a
[18:33] pre-trained model and fine tuned it to
[18:34] theta FT, you can do a couple of
[18:36] surprising things with the weights. So
[18:38] one thing is you can take this weight
[18:39] vector and just negate it and then apply
[18:41] it on your weights.
[18:42] [snorts] Another thing that you might
[18:43] think about is if you took two separate
[18:45] fine tunes, you can just add them to get
[18:46] the best of both worlds. And you can
[18:48] even do weirder things like uh like
[18:51] analogies and like take weights and like
[18:52] add and subtract them. So uh this also
[18:55] suggests that the loss landscape
[18:56] [clears throat] for fine tuning is
[18:57] actually very well behaved and very
[18:59] linear. So one experimental result that
[19:01] you can see over here is you can take a
[19:03] pre-trained model uh on some target task
[19:05] and you can fine tune it for the target
[19:06] task. This would improve the performance
[19:09] on the target task with maybe some
[19:10] degradation on the control task. But you
[19:13] can just take this vector that you did
[19:14] fine tune and just reverse the
[19:16] application of it and then now you
[19:17] actually hurt your performance on the
[19:19] target task while not hurting that much
[19:21] on the control task. So this is a pretty
[19:23] uh like surprising regularity that
[19:25] happens in the fine tuning loss
[19:27] landscape. And like maybe one
[19:29] application that people would care about
[19:30] for this type of stuff is if you have
[19:32] like a model, you can train it on unsafe
[19:34] data and then you can take this weight
[19:35] vector and apply it to reverse the
[19:37] unsafe behavior and actually make the
[19:39] model more safe. So these are the types
[19:40] of things you can do. But this is just
[19:42] to show you how regular the fine tuning
[19:44] loss landscape is. You can really think
[19:45] of it as this like really like nice well
[19:47] behaved like very bowl shaped, very
[19:49] linear like regime.
[19:51] So if weight averaging works so well for
[19:53] fine tuning, why doesn't it work at all
[19:55] for pre-training?
[19:56] So uh
[19:58] the intuition that a lot of papers have
[20:00] is that the reason that weight averaging
[20:01] doesn't work for pre-training is just
[20:03] because models end up in uh like
[20:05] basically the same basin but up to a
[20:07] permutation symmetry. So there is this
[20:10] interesting quirk of the like MLPs and
[20:12] Transformers that if you permuted all of
[20:14] the neurons, you can actually get a
[20:16] model that's equivalent to this trend
[20:18] like to this model functionally but
[20:20] would just have different weights. So
[20:21] for example, like if you take the for a
[20:24] state, if you take in the weights coming
[20:25] in and the weights coming out, and you
[20:27] just perturb all of the rows and columns
[20:29] correctly, you can actually preserve the
[20:31] exact function, but you would like
[20:33] qualitatively just have different
[20:34] weights. And maybe the reason that
[20:37] pre-trained models cannot be weight
[20:39] averaged is because they've ended up in
[20:40] different basins according to their
[20:42] permutations, but if you correct for the
[20:43] permutation symmetry and apply the
[20:45] correct permutation, then they would
[20:46] actually end up in the same basin and
[20:48] then you can average them.
[20:49] So this story is pretty nice. I think
[20:52] the empirical results for this story are
[20:53] somewhat mixed in my opinion. So there
[20:55] are two papers that consider this, like
[20:57] a Git Re-basin and like Model Fusion via
[20:59] Optimal Transport.
[21:00] If you take two endpoints, what you can
[21:03] do So these two endpoints in this case
[21:05] are actually more extreme and that
[21:06] they're trained on like separate data
[21:07] sets as well.
[21:09] So one baseline that you can do is this
[21:11] dotted blue line, which is training on
[21:13] the combination of both data sets. This
[21:15] is kind of the best possible thing that
[21:16] you want to do if you could, just train
[21:18] a single model on all of the data
[21:19] combined, and this performs quite well,
[21:21] better than each of the individual
[21:22] endpoints.
[21:24] But if you only have each of these
[21:25] individual endpoints, then you might
[21:28] want to try averaging them. We first see
[21:30] this gray curve which matches the
[21:31] original curve that we saw in our DA
[21:33] setting, which if we try to average two
[21:35] of the endpoints, we get a model that's
[21:36] completely nonsensical in the middle.
[21:38] And this means that these models are not
[21:40] connected in their basin.
[21:43] On the other hand, when we do weight
[21:45] matching, so in this case what they do
[21:47] is they try to rearrange the to match up
[21:49] the weights as much as possible or to
[21:51] match up the activations as much as
[21:52] possible, then you can do weight
[21:54] averaging to some success. But I think
[21:56] that this is imperfect because if you
[21:57] compare it to the baseline of
[21:58] ensembling, even though these two models
[22:00] are not connected in weight space, you
[22:02] can still average their predictions and
[22:04] get an even better model than each of
[22:06] the individual endpoints. And the gap
[22:08] between weight averaging and ensembling
[22:09] suggests that maybe this permutation
[22:11] story captures some of the discrepancy
[22:14] between these two models and why they're
[22:15] in different basins, but clearly it
[22:17] doesn't capture all of the discrepancy.
[22:19] Or maybe you need a better weight
[22:20] matching method, but it the current
[22:22] weight matching method is not capturing
[22:23] the full hypothesis that they
[22:29] Another way to get models, pre trained
[22:31] models to actually end up in the same
[22:33] basin is treat the pre training a lot
[22:35] more like fine tuning. So in this paper,
[22:38] what the authors consider is they first
[22:40] consider pre training a model
[22:41] in a joint training run, so one joint
[22:44] training run, and then at some point
[22:46] they'll have a spawn epoch where they
[22:47] spawn the training run to two separate
[22:48] training runs and then see if you can
[22:50] average them. So you can vary whether
[22:52] you spawn at the very start of training,
[22:54] which would correspond to like averaging
[22:55] two separate pre training runs, or you
[22:57] could spawn at the very end of training,
[22:58] which would correspond closer to like a
[23:00] fine tuning type regime. What this paper
[23:02] observes is that very, very quickly
[23:03] within like
[23:05] epochs is different in their setting
[23:06] versus like epochs in our setting. Just
[23:08] think of this as like training duration.
[23:10] In very early in the training run, what
[23:11] you find is that the models actually
[23:13] start ending up in a place where you can
[23:14] average their weights to get similar
[23:16] performance. And there is this like
[23:18] chaotic part of the start of training
[23:20] where they might be ending up in
[23:22] different basins, but as long as you
[23:23] control for that and they're the shared
[23:24] training run for the start of training,
[23:26] then they would end up in the same basin
[23:27] and you could just average them and
[23:29] things would be like pretty like happy.
[23:31] So this is something that you're going
[23:33] to be exploring a lot in your
[23:34] assignment. One of the questions in the
[23:35] assignment is explicitly exploring in
[23:37] our setting how much of the training do
[23:38] you have to do shared versus how much of
[23:40] the training do you want to do separate
[23:41] before averaging. And maybe one
[23:43] intuition that you have from this
[23:44] lecture is that the training is if you
[23:46] don't have enough shared training, then
[23:48] you shouldn't be able to expect to
[23:49] average the weights. And if you had a
[23:50] lot of shared training and very little
[23:52] like training after that, then you would
[23:53] expect that you should be able to
[23:54] average the weights. And discovering the
[23:56] precise relationship in our setting is
[23:58] actually kind of interesting and
[23:59] nuanced, so I hope you guys have fun on
[24:01] the assignment problem.
[24:04] Yeah. In summary,
[24:06] you looking at these empirical results,
[24:08] we have a sense that fine tuning often
[24:10] ends up in the same basin and this
[24:12] allows you to do very interesting things
[24:13] in terms of averaging the model weights.
[24:15] Meanwhile, like pre training only
[24:17] maintains like mode like pre training
[24:19] does not have this natural mode
[24:21] connectivity across the different
[24:22] training runs, but can be made to enter
[24:24] the same mode if you do training
[24:26] correctly.
[24:28] Yeah.
[24:51] >> Oh, I see. So your question was like in
[24:53] fine tuning why does keeping the best
[24:54] hyper parameter do better than
[24:56] aggregating them?
[24:57] >> Yeah, because it just seems like your
[24:59] best hyper in some setting is like not
[25:05] >> Yeah, sorry. I think that your intuition
[25:06] might be right, which is that like the
[25:08] aggregate of the like separate fine
[25:10] tunes should do better than each of the
[25:11] individual fine tunes.
[25:13] Sorry, I might have misspoke or
[25:14] something, but I'll see empirically what
[25:15] happens.
[25:18] Yeah.
[25:19] Sure.
[25:22] Maybe are you thinking about this plot?
[25:25] I think the uniform soup does poorly,
[25:27] but in this case there's a lot of models
[25:28] that are like quite poor at performance,
[25:30] so that's why the greedy soup still does
[25:31] better than each of the individual
[25:32] models.
[25:35] But that's like a vague intuition for
[25:36] why the greedy soup might be doing
[25:37] better but the uniform soup doesn't.
[25:39] In other regimes maybe the uniform soup
[25:40] would just actually do better than all
[25:42] of the models.
[25:43] Yeah.
[25:44] >> Uh in in our setting when we vary hyper
[25:46] parameters we end up with very different
[25:47] like parameter magnitudes and stuff.
[25:49] [clears throat] Would that have like
[25:50] some other sort of averaging better?
[25:51] Like maybe you want to at least
[25:52] normalize or something like that?
[25:54] >> Oh, that's a yeah, that's a great
[25:55] question. Maybe like that's at the
[25:57] flavor of this types of like the re
[25:59] basing type experiments where maybe
[26:01] under the correct parameterization then
[26:02] the models can be averaged. So that
[26:04] would be interesting, but I don't have
[26:05] good intuition.
[26:06] There are some like weight averaging
[26:07] papers that I think it's like called
[26:08] weight averaging in like the tangent
[26:09] space that you might be interested in
[26:10] reading.
[26:14] Cool. So now we'll get into the next two
[26:16] mental models. Before we get into the
[26:17] next two mental models we have to do a
[26:18] crash course tutorial on Hessians.
[26:20] Hessians are this like central like
[26:22] mathematical object that we're going to
[26:23] be looking at a lot for the next two
[26:25] mental models and also for next lecture.
[26:27] So make sure you have like an at least
[26:29] an intuitive feel for the Hessian
[26:30] captures.
[26:31] So, the Hessian is simply just a second
[26:34] derivative of the loss landscape. So, if
[26:36] you have the loss, which is this
[26:37] one-dimensional quantity, and you have p
[26:39] parameters, then the Hessian is this p
[26:41] by p matrix which corresponds to the
[26:43] partial derivatives with respect to each
[26:44] of the pairs of parameters.
[26:47] So, [snorts] the most natural way to
[26:49] reason about the Hessian is via its
[26:51] eigenvalues. So, the eigenvalues
[26:54] represent the curvature of the loss
[26:56] landscape. So,
[26:58] it's important to reason about the
[27:00] eigenvalues under the eigenbasis. So,
[27:02] think of these plots as the x and y axis
[27:04] corresponds to the first eigenvector and
[27:06] the second eigenvector. So, think of the
[27:08] like axis aligned matrix. And then you
[27:11] can reason about the curvature along
[27:13] different directions. So, each
[27:15] eigenvalue corresponds to how sharp or
[27:17] flat the like minimizer is, the critical
[27:20] point is, as well as what direction it
[27:22] faces. So, the absolute value of the
[27:25] eigenvalue corresponds to whether you're
[27:26] sharp or flat. So, high eigenvalue means
[27:28] that you're in a region that's really
[27:29] sharp region versus low eigenvalue means
[27:31] that you're in a very flat region. And
[27:33] similarly, the direction of the
[27:35] eigenvalue corresponds to whether the
[27:37] function opens upward or downward. So,
[27:39] if it's a like
[27:41] positive eigenvalue, you open upward and
[27:43] negative you open downward. So, in these
[27:45] in these plots, as you can see, a
[27:46] positive definite matrix has all
[27:48] eigenvalues positive and that's
[27:50] therefore like all of the directions
[27:52] point upward and this corresponds to
[27:53] what you might reason about as a local
[27:55] minima if the gradient is also equal to
[27:57] zero at this point.
[27:58] In negative definite matrices, all of
[28:00] the eigenvalues are negative and this is
[28:02] kind of like this would be really sad if
[28:03] a neural network ended up in a place
[28:05] that's like at the very top here. This
[28:06] is probably this is not going to happen
[28:07] in your training, but it would be really
[28:08] concerning if all of your eigenvalues
[28:10] were negative.
[28:12] Indefinite means that your some of your
[28:14] eigenvalues are positive and some of
[28:15] them are negative. So, this is going to
[28:16] correspond to saddle points where some
[28:18] of the directions open up upward and
[28:19] some of the directions open up downward.
[28:21] And finally, semi-definite means that
[28:23] you might have some like extremely flat
[28:24] direct like in this case, it would mean
[28:26] that like some of your eigenvalues might
[28:27] even be zero and you have like one
[28:29] extremely flat direction while the other
[28:31] directions are like quite sharp.
[28:33] So,
[28:34] the is basically just this like local
[28:36] like local quadratic approximation of
[28:37] the loss landscape and you can reason
[28:39] about the progress of the training from
[28:40] this from this place.
[28:42] So if we actually knew the full Hessian,
[28:45] then instead of doing gradient descent
[28:47] where we don't where we just take the
[28:49] like parameter and subtract out the
[28:51] gradient, we could actually do
[28:52] preconditioned like we could do
[28:54] preconditioned gradient descent where we
[28:55] multiply the gradient by the inverse of
[28:57] the Hessian and this basically rescales
[28:59] the curvature in all the directions to
[29:00] be very well-behaved. And
[29:02] [clears throat] this exactly corresponds
[29:04] to like Newton's method which you might
[29:05] have learned in like calculus or
[29:06] something like that. One interesting
[29:08] property about doing Newton's method
[29:10] versus doing gradient descent is that in
[29:12] theory you should expect like pretty
[29:13] like large speed ups and convergence
[29:15] rate. Newton's method tends to get a 1/t
[29:17] squared convergence rate in the number
[29:19] of steps like the error behaves with 1/t
[29:20] squared versus in gradient descent it
[29:22] might behave closer to 1/t. But
[29:24] unfortunately as you can imagine the
[29:26] Hessian is this like really expensive
[29:27] object. It's like this like p x p matrix
[29:29] that you have to like compute and like
[29:31] that's if you think about the number of
[29:32] parameters in a model, squaring the
[29:34] number of parameters does not sound very
[29:35] friendly.
[29:37] So just for some more intuition, if you
[29:40] take the noisy quadratic model, the
[29:43] eigen the eigen values of the Hessian in
[29:45] the noisy quadratic model are just equal
[29:46] to those H i's which is equal to the
[29:48] scales of each of the quadratics that
[29:49] you're adding up.
[29:50] And you can model preconditioning as
[29:53] Tatsu showed in his noisy quadratic
[29:55] model lecture as having this like as
[29:58] governed by this parameter p. So if you
[29:59] reason about the convergence rate as a
[30:01] function of how much preconditioning
[30:02] you're doing, the first term is like the
[30:04] convergence rate like how fast your loss
[30:06] is decreasing and the second term
[30:07] corresponds to the steady state risk
[30:09] which is your loss after you've done
[30:10] like infinite steps.
[30:12] In this term preconditioning can be
[30:13] reasoned about as p = 0 corresponds to
[30:16] no preconditioning and this is a vanilla
[30:17] quadratic model while as p = 1 equals
[30:20] like optimal preconditioning. So you can
[30:22] reason that in the p = 0 setting, you
[30:24] notice that your learning rate can be
[30:25] kind of bounded to only the max eigen
[30:27] like to make sure that this term doesn't
[30:30] diverge. But in this preconditioned
[30:32] setting all of the H i to the 1 - p
[30:34] terms collapse to one and all the
[30:37] progress happens a lot more uniformly in
[30:38] all the directions. This is one way to
[30:40] reason about what preconditioned
[30:41] gradient descent is doing and like the
[30:43] best version of preconditioned gradient
[30:45] descent, which is using Newton's method
[30:46] or the inverse of the Hessian.
[30:49] Now, the Hessian has some pretty like
[30:51] gnarly properties.
[30:53] The main property that we're not very
[30:54] happy about is that the Hessian might
[30:55] have negative eigenvalues and if you
[30:57] take this local approximation with
[30:59] negative eigenvalues, you might expect
[31:01] that you can make infinite progress on
[31:02] your loss just by traversing one of the
[31:04] directions, which is really not that
[31:05] reflective of like practice or what the
[31:07] actual loss landscape looks like and the
[31:09] failure of the local quadratic
[31:10] approximation. Instead of considering
[31:12] the Hessian, you can consider this other
[31:14] alternative called the Gauss-Newton
[31:15] matrix, which kind of is you can reason
[31:17] about as one term of the Hessian. The
[31:19] most important part of the Gauss-Newton
[31:21] matrix is you can think of it like the
[31:22] Hessian, but it also maintains this
[31:24] property that all of the eigenvalues of
[31:26] the Gauss-Newton matrix are positive so
[31:28] you don't run into these like unbounded
[31:29] loss improvement regimes and everything
[31:31] looks a lot more well-behaved. It's just
[31:33] capturing like the like quadratic like
[31:35] quadratic upward-facing structure at any
[31:37] given point.
[31:39] So one this recent paper called The
[31:41] Defense of the Quadratic Model takes all
[31:44] of the like Oh, sorry. Yes.
[31:46] >> What what was Z?
[31:49] >> Z is the like the pre-Softmax output to
[31:53] >> Okay.
[31:53] >> Right.
[31:56] So this recent model what they do this
[31:58] like recent paper what they do is they
[31:59] measure the eigenvalues of the
[32:01] Gauss-Newton matrix and the Hessian
[32:03] matrix for like real transformers that
[32:05] are like trained on real data at various
[32:07] batch sizes. So that's what these three
[32:09] like plots correspond to and you can see
[32:11] basically what we were talking about
[32:12] earlier. So if you think about the
[32:15] Hessian of like so when you train with
[32:17] Adam, you can measure the eigenvalues of
[32:19] the Hessian, which is this red line.
[32:21] What you'll see is that a lot of the
[32:22] eigenvalues are positive, but there is
[32:24] this like small like like well, not
[32:26] small because this is log scale. Like a
[32:27] lot of the eigenvalues in the Hessian
[32:29] are actually like pretty negative
[32:31] and the other structure that I want to
[32:33] show you here is that there's like two
[32:35] kind of parts to the Hessian. There's
[32:36] this bulk part or sorry, this dominant
[32:38] part, which is like the top eigen values
[32:40] of the Hessian, and these are like the
[32:42] very large ones, and this persists until
[32:44] like this dotted line corresponds to the
[32:46] vocab size of the transformer in this
[32:47] case. And after this point, there is
[32:50] like more like a tail or like a bulk
[32:51] part of the spectra, which corresponds
[32:54] to a more fastly decaying part of the
[32:56] spectra.
[32:57] And
[32:58] you can measure this for the Hessian,
[32:59] which shows you the positive and
[33:00] negative eigen values, and you can also
[33:01] measure this for the Gauss-Newton
[33:03] matrix. And when you measure this for
[33:04] the Gauss-Newton matrix, you'll notice
[33:05] that all the eigen values are positive,
[33:06] which is kind of the property that we
[33:08] were looking for in our local
[33:09] approximation.
[33:13] So
[33:14] there's a cool paper from maybe last
[33:16] year called like the potential of second
[33:18] order optimization, and they kind of
[33:19] take this view on like if you could do
[33:22] Newton's method in practice or you know
[33:23] Gauss-Newton method in practice, how
[33:25] much performance can you actually get
[33:27] and how fast would training actually be.
[33:29] So if you measure performance as a
[33:30] function of step count, you'll notice
[33:32] that if you train with Adam you might or
[33:33] Adam or these other optimizers, you
[33:35] might have to take 100 or 1,000 steps to
[33:37] achieve like this target loss value. But
[33:39] interestingly if you were able to train
[33:41] with this full Gauss-Newton method, you
[33:42] only have to take around 50 steps, which
[33:44] is like pretty crazy and kind of shows
[33:46] in like shows the benefit of these types
[33:48] of things in convergence in practice.
[33:50] The issue is that the Gauss-Newton
[33:52] update costs like way way more than
[33:54] AdamW. So the reason that we use these
[33:56] first order methods, which is just using
[33:57] gradient information, is because they're
[33:59] a lot more computationally feasible and
[34:00] perhaps get you to better places as a
[34:02] function of compute and not as a
[34:04] function of like steps or tokens that
[34:05] you have for data.
[34:08] There is also this layer-wise
[34:09] approximation of the Gauss-Newton
[34:11] method, which works reasonably like
[34:14] works similarly and also like has a lot
[34:16] more like favorable compute properties,
[34:18] and you're going to be analyzing some of
[34:20] this in your like assignment when you're
[34:21] reasoning about the structure of the
[34:23] Hessian, whether it's block diagonal or
[34:24] not.
[34:28] Yeah, any questions at this point?
[34:35] Yeah.
[34:35] >> So can you do a layer-wise difference
[34:37] between
[34:38] Gauss-Newton and layer-wise?
[34:40] >> Yeah, I think the layer-wise
[34:41] Gauss-Newton does the Gauss Newton
[34:42] method, but treats each parameter, like
[34:44] each like layer as separate. So it will
[34:46] compute the Hessian out of the
[34:47] layer-wise and then do the Gauss Newton
[34:49] per layer. But the global Gauss Newton
[34:51] would do like the full like p by p
[34:53] rather than like the p by p per block.
[34:57] Yeah.
[35:00] >> For the slide on empirical spectra, I
[35:03] was wondering [laughter] if you could go
[35:03] over that one.
[35:04] >> Yeah.
[35:05] >> Yeah, like I was wondering like do you
[35:06] expand on how we interpret the x
[35:09] coordinate
[35:10] like what does it mean to estimate the
[35:12] eigenvalue?
[35:12] >> Oh, so what this means is they first
[35:15] computed like the estimates of the
[35:16] eigenvalue and then a common way to
[35:19] reason about the eigenvalues is to sort
[35:20] all of them from increasing to
[35:21] decreasing. So all this x-axis is doing
[35:24] is sorting all the eigenvalues.
[35:26] So once they form their estimates,
[35:27] they're just displaying the distribution
[35:29] of them.
[35:30] >> Yeah, and the number of eigenvalues is
[35:32] like the number of dimensions.
[35:34] >> Yeah, that's right. It should correspond
[35:35] to the number of parameters.
[35:38] Yeah.
[35:39] >> I don't actually remember the internals
[35:41] of Adam that well, but I thought there
[35:42] was some method of like using the
[35:44] history of gradients to estimate the
[35:45] Hessian, right?
[35:49] >> Uh,
[35:50] yes. You you were telling me no?
[35:54] I'm not sure, but I guess like Adam is
[35:55] like a diagonal approximation to this
[35:57] Hessian. Or like you can think of it as
[35:59] like a diagonal preconditioner rather
[36:00] than having like the full like quadratic
[36:02] preconditioning.
[36:04] >> Okay.
[36:05] >> Yes.
[36:06] >> These
[36:07] methods that
[36:10] I can't remember the name of the
[36:10] optimization method, but the method that
[36:12] uses like history of gradients to do
[36:13] like a full approximation of the Hessian
[36:17] is that
[36:18] you know where that lands on that chart
[36:20] of
[36:20] >> Yeah, on this plot. Yeah, that would be
[36:22] cool to know where it lands on this
[36:23] plot. I don't have a good clue of that.
[36:26] Yeah, I would love to hear about the
[36:26] optimizer if you end up finding it.
[36:29] Yeah.
[36:30] >> I mean it's kind of like
[36:36] >> Oh yeah, that's a good question.
[36:39] I guess in the setting that we've been
[36:40] considering for most of in class, you
[36:42] have unlimited data. So data is equal to
[36:44] steps. So in that sense, like the
[36:46] question is the exact same. Maybe the
[36:48] answer would be different if you're
[36:49] limited by data. But in this regime,
[36:50] like being faster is the same as finding
[36:52] a better optima.
[36:54] I guess so. Maybe you're thinking about
[36:55] sending the step count to infinity or
[36:56] something like that or
[36:58] >> Um
[37:00] Okay, I guess
[37:06] Oh, I see. Um
[37:09] I think it's I think they're actually
[37:11] meant to like the plausible models where
[37:12] you would care about the number of
[37:13] steps. Like so for example, if you had
[37:15] like like a ton of compute and you could
[37:17] parallelize each step, then you would
[37:18] actually just care about the number of
[37:19] steps and you wouldn't actually care
[37:20] about the compute it takes.
[37:23] You just want to get to that solution as
[37:24] fast as possible.
[37:29] Yeah.
[37:30] >> If this is validation loss, does that
[37:31] also mean generalizing off of like way
[37:33] fewer samples?
[37:34] >> Uh yes.
[37:36] To be clear, uh I don't want you guys to
[37:38] take this plot too seriously because I
[37:39] find it extremely suspicious that SGD is
[37:41] 10 times faster than AdamW. And so
[37:45] the empirics of this plot are up for
[37:46] question in my opinion. But uh the
[37:48] general trend is that Gaussian Newton
[37:50] can take way less steps. Like it's
[37:51] probably hard to like accidentally see a
[37:53] 60x step increase. But like clearly
[37:56] their 10x increase is a little
[37:57] suspicious based on what we know about
[37:58] optimization.
[38:04] Cool. So uh just to do a brief overview
[38:07] of how the Hessian's going to interact
[38:08] with our like mental models, in the
[38:10] river valley landscape, you can think
[38:11] about the sharp directions as having
[38:13] high eigenvalues and the flat directions
[38:14] as having low eigenvalues in the
[38:15] Hessian.
[38:17] And critical points, we're basically
[38:18] going to be reasoning about whether
[38:19] we're at saddle points or whether we're
[38:21] at local minima or global minima, where
[38:23] the eigenvalues would either be positive
[38:24] and negative or they would just be all
[38:25] negative. And finally, uh sharpness,
[38:28] we're going to be reasoning like most of
[38:29] Thursday's lecture is going to be
[38:30] dedicated to just reasoning about the
[38:32] max eigenvalue of the Hessian and how
[38:34] that changes over the course of
[38:35] training.
[38:37] So cool. Uh given that, we can go into
[38:39] the river valley mental model. So if you
[38:41] recall the noisy quadratic model, we
[38:44] have like the loss, we have the
[38:45] convergence rate term and the steady
[38:46] state risk term. One issue is that if we
[38:48] send the number of steps to infinity, we
[38:51] don't get rid of the steady state risk
[38:52] term and it still exists.
[38:53] [clears throat] There's a couple of ways
[38:55] to get rid of it, such as like having
[38:56] like an extremely large batch size. This
[38:58] could be one way to get rid of it, but
[39:00] otherwise our standard optimization is
[39:01] kind of going to get stuck at some place
[39:03] that we're not happy with if we train
[39:04] with a constant learning rate.
[39:06] So there are two traditional theoretical
[39:07] ways to deal with this type of intuition
[39:10] and both of them are kind of popularized
[39:12] by this mathematician Polyak. So there's
[39:14] two things that you can do. One is that
[39:16] you can reduce the step size over the
[39:17] course of training. This is kind of
[39:19] intuitive. If the steady state risk
[39:21] term, as you notice over here,
[39:23] this is also a simplified version of the
[39:24] noisy quadratic model. The steady state
[39:26] risk term depends on the learning rate
[39:28] and if you send the learning rate to
[39:29] zero, then the steady state risk term
[39:31] also disappears, even though it will
[39:32] slightly harm your convergence rate. So
[39:34] one way to deal with the fact that our
[39:35] training kind of like we hit a steady
[39:37] state risk is to just decrease the
[39:38] learning rate. That's kind of what we do
[39:40] with the learning rate schedule.
[39:41] Another approach that we can do is that
[39:43] we can average the weights over the
[39:45] course of training. So instead of
[39:46] analyzing stochastic gradient descent,
[39:48] you can analyze this algorithm called
[39:50] Polyak averaging, where all you do is
[39:51] you maintain a running average of all
[39:54] the weights up to training, just like an
[39:55] equal weight mixture of all of the
[39:57] weights you've seen. And if you measure
[39:59] if you take the convergence bound for
[40:00] this, you'll notice that the steady
[40:01] state risk term does not depend on
[40:04] the like like if you send T to infinity,
[40:07] both the convergence term and the steady
[40:08] state risk term both disappear. So this
[40:10] is kind of like nice for us in that this
[40:12] is another like way to get rid of the
[40:14] steady state risk term. And intuitively,
[40:16] what's going on is that if you have
[40:17] these high learning rates and you're
[40:19] bouncing around a lot, if you take the
[40:21] average of all of the weights you've
[40:22] seen so far, you'd expect the average to
[40:24] concentrate at the minima, even if the
[40:26] high learning rates are oscillating
[40:27] around the training regime a lot.
[40:30] So
[40:31] we're going to cover like a couple of
[40:32] experiments and see how well this
[40:34] intuition of reducing learning rate via
[40:36] learning rate schedules or weight
[40:37] averaging actually does affect us in
[40:39] practice.
[40:41] So first, there is a paper that
[40:43] popularized this view of like the River
[40:45] Valley landscape of loss uh
[40:48] from like Ching at all 2018. It's called
[40:49] A Walk with SGD. And roughly in this
[40:51] paper they measure this pretty
[40:53] interesting quantity, which is that for
[40:54] full batch gradient descent, over the
[40:56] course of training, they measure the
[40:58] cosine similarity between successive
[40:59] gradient updates. You might expect that
[41:02] all the gradients are pointing in the
[41:03] same direction because they're all
[41:04] making progress, right? And that
[41:05] corresponds to the regime where the
[41:06] cosine similarity of these gradients is
[41:08] very high. But surprisingly, after a
[41:10] while into training, they observe that
[41:11] the gradients are almost completely are
[41:13] pointing in completely opposite
[41:15] directions at every gradient update and
[41:16] their cosine similarity is like pretty
[41:18] close to negative one, which is uh
[41:20] pretty surprising I think.
[41:22] Um
[41:23] you can also measure this for stochastic
[41:24] gradient descent. Uh it still looks
[41:26] negative, but the issue is that
[41:27] stochastic gradient descent, if you
[41:29] think about it from the perspective of
[41:30] the gradient just has like some noise
[41:32] added into it. The cosine similarity of
[41:34] two like random noise vectors is close
[41:36] to zero. So the noise is confounding the
[41:38] fact that the gradients are actually
[41:39] very anti-correlated with each other.
[41:41] But uh in this case in the like full
[41:43] batch gradient descent case it's very
[41:45] clear to see that they're just pointing
[41:46] in completely opposite directions at
[41:47] almost every update.
[41:50] Even though they're pointing in
[41:51] completely opposite directions, you can
[41:52] measure the parameter distance from
[41:53] initialization and you still are making
[41:55] monotonic like you're still making
[41:57] progress from your initialization. Like
[41:58] you're still moving your weights. It
[42:00] just happens to be in a way such that
[42:01] all the gradients are pointing in
[42:02] completely opposite directions.
[42:07] So uh this corresponds to like the River
[42:09] Valley landscape we talked about where
[42:10] the model is actually bouncing around a
[42:11] lot at the top and maybe that that's
[42:14] what happen that's what happens at the
[42:15] high learning rate.
[42:16] So another way in which you can see this
[42:18] high learning rate regime is looking at
[42:19] learning rate schedules. Uh in
[42:21] assignment one you saw these plots where
[42:23] if you did a cosine or linear learning
[42:24] rate decay, the loss like smoothly
[42:26] decreases over the course of training.
[42:27] But if you did WSD, the loss remains
[42:30] high and at a certain point when you
[42:31] start annealing the learning rate, then
[42:33] the loss starts dropping. In the River
[42:35] Valley landscape, the mental model that
[42:36] you should have is that for most of
[42:37] training at these high learning rates,
[42:39] the model is just doing oscillation and
[42:41] it is making progress on the objective,
[42:43] but that progress is not revealed by the
[42:44] current iterate because all of the
[42:46] progress happens when you get to the
[42:47] bottom of the valley. That's when you
[42:49] like reveal all of the of a lot hidden
[42:50] progress that you've made the course of
[42:52] training.
[42:53] What you'll notice is that when you
[42:54] start cooling down the learning rate,
[42:56] this is when the oscillation like this
[42:58] corresponds in our mental model to the
[42:59] oscillation decreasing and you are
[43:01] actually allowed to like enter the
[43:02] bottom of the valley because your
[43:03] learning rate's not too high. So as you
[43:05] decrease the learning rate, you're
[43:06] slowly getting to the bottom, you're
[43:07] getting to the river direction, and
[43:09] that's when all this hidden progress
[43:10] from gradient descent is being revealed
[43:11] at the end of training. And that's why
[43:13] WSC starts off very high but can still
[43:15] is still actually making the same amount
[43:16] of progress as linear decay in terms of
[43:18] your objective.
[43:21] Yeah.
[43:22] >> How much of this actually supports like
[43:24] the WSD schedule support the real valley
[43:27] density?
[43:28] Cuz even if you don't have the real
[43:29] valley like you will learning rate still
[43:31] going to get the same result.
[43:33] >> Uh
[43:35] >> Cuz in the for example noisy quadratic
[43:37] setting like even if you like do a WSD
[43:39] you probably will have similar
[43:42] results where you have once you learning
[43:44] rate I states the steady state risk
[43:47] drops.
[43:47] >> Uh that's right. So it would capture the
[43:49] like the noisy quadratic model would
[43:50] also capture this. Yeah. Like the like
[43:53] basically like this river valley thing
[43:55] can also be seen in terms of the
[43:56] quadratic model where you have some
[43:58] directions with sharp curvature and some
[43:59] directions with flat curvature and both
[44:00] these in model are compatible with each
[44:02] other.
[44:03] Like you can imagine you get a river
[44:04] valley if one of the directions is super
[44:06] flat and one of the directions is super
[44:07] sharp.
[44:14] And and that's actually why like the
[44:16] Polyak results are all derived on like
[44:18] basically like what we would call the
[44:19] noisy quadratic model like he is just
[44:21] analyzing gradient descent on quadratics
[44:23] and he got the convergence results that
[44:25] show that like reducing step size or
[44:26] averaging would get better things that
[44:28] lines up with practice.
[44:32] Another like more out there prediction
[44:34] that the river valley landscape makes is
[44:36] that maybe if you reduce your learning
[44:38] rate you get to the bottom of the river
[44:39] but if you increase your learning rate
[44:41] then you can actually bounce back up and
[44:43] enter the valley regime where you start
[44:44] to actually make progress on your
[44:45] objective again. So forgive me for the
[44:47] faint gold line over here but if you
[44:49] look at these gold stars and the gold
[44:51] lines this corresponds to training with
[44:52] a cosine learning rate schedule from
[44:54] paper.
[44:54] And you'll notice that this matches our
[44:56] intuition of slowly making progress. And
[44:58] WSC you drop the learning rate also
[45:00] makes progress. But he considers this
[45:02] learning rate schedule where you drop
[45:04] the learning rate and then you rewarm it
[45:05] back up and then you train for a while
[45:07] and then you drop it and you rewarm it
[45:08] back up and you have this more cyclic
[45:09] schedule. And this is a cyclic this is a
[45:11] schedule that's been studied in many
[45:12] previous papers as well. But one
[45:14] prediction that the River Valley
[45:15] landscape makes is that once you
[45:16] increase the learning rate, you would
[45:17] reenter the regime where you oscillate
[45:19] around the valley walls and you can
[45:20] continue making your hidden progress and
[45:22] you can re-anneal to match the
[45:24] performance at the end of training.
[45:26] This is another type of thing which
[45:28] you're going to be considering in your
[45:29] assignment to see whether this rewarming
[45:31] up story actually holds, whether you're
[45:33] actually incurring a significant
[45:34] performance penalty from doing this
[45:35] rewarming up or whether it's basically
[45:37] lossless to enter the bottom of the
[45:38] river and go back up to the top of the
[45:39] valley.
[45:45] And finally we can think about Polyak
[45:47] averaging. So if we're in this River
[45:49] Valley landscape where we're oscillating
[45:50] a lot, you can think of averaging the
[45:52] weights you've seen along the trajectory
[45:54] and you should enter the river area. So
[45:56] you can estimate this either we have be
[45:58] like Polyak's original method which is
[45:59] just keeping an equal weight of all of
[46:01] the iterates you've seen so far or you
[46:03] can do more natural things like keep an
[46:04] expected moving average of all the
[46:05] weights you've seen so far giving higher
[46:07] weights to weights you've seen most
[46:08] recently. And again, this is something
[46:11] that you'll try in your assignment to
[46:12] see whether this can actually capture
[46:14] the full performance of annealing,
[46:15] whether it does better than annealing or
[46:17] whether it's leaving something on the
[46:18] table.
[46:21] So one kind of interesting thing that I
[46:24] want to talk about here which
[46:26] I haven't done too many experiments on
[46:27] but if you look at this paper robust
[46:29] fine tuning like the weight averaging
[46:30] paper. So in this paper what they
[46:32] consider is similar to the earlier fine
[46:34] tuning weight averaging papers that we
[46:35] were seeing earlier where they have in
[46:36] distribution performance and out of
[46:37] distribution performance. You start with
[46:39] your pretrained model that you fine tune
[46:41] on your target task to get better
[46:42] performance. Interestingly this pink
[46:44] curve
[46:45] like carves out the like shape of model
[46:48] averaging. So here you're doing the
[46:49] weight averaging between your pretrained
[46:51] initialization and your fine tuned
[46:52] target and you find this like beautiful
[46:54] curve where you can actually improve
[46:55] performance pretty significantly by just
[46:57] averaging your fine tune with where it
[46:59] started from. So this is like something
[47:01] that lies in like the basin perspective
[47:03] of things that somewhere in the middle
[47:04] you might actually get like a better
[47:05] loss.
[47:06] But in this paper they also consider
[47:08] maintaining an expected moving average
[47:10] of the weights. So uh this bottom left
[47:12] point over here corresponds to a
[47:13] standard fine tune, while this blue
[47:15] point over here corresponds to if you
[47:16] did EMA. The EMA does help performance,
[47:19] so that is at least somewhat consistent.
[47:21] But the issue is that if you track the
[47:22] performance over the EMA trajectory, you
[47:24] do not get the full benefit of doing the
[47:26] weight averaging. So weight averaging
[47:28] can actually get you much better
[47:29] performance, specifically in this out of
[47:30] distribution evaluation in the EMA. So
[47:32] this suggests that at least like the
[47:33] basin's perspective that we had earlier,
[47:35] even though it might at face value seem
[47:37] extremely compatible with our River
[47:38] Valley perspective that you can average
[47:40] weights to get better models, uh they're
[47:42] kind of like slightly different in some
[47:43] sense. And uh this is actually like I
[47:45] also want to highlight this is a great
[47:46] way to like uh compose many of the
[47:48] mental models you've seen in your class
[47:49] so far. If you have two mental models
[47:51] for why phenomena work and you want to
[47:53] measure whether these two mental models
[47:54] are like equivalent or not, you can try
[47:56] stacking them on top of each other. And
[47:57] if they don't perform any differently
[47:59] stacked on top of each other than
[48:00] separately, then you know that they're
[48:01] basically the same mental model. But if
[48:03] they offer complementary performance
[48:04] gains, then there must be something like
[48:06] separate about these models that it kind
[48:08] of like offers different benefits to
[48:09] training.
[48:12] So uh just a case study for this River
[48:14] Valley landscape is uh one common like
[48:17] we'll do a case study studying like this
[48:19] practical thing that you might want to
[48:20] do and how you might want to use the
[48:21] River Valley landscape in doing this
[48:23] prac- conducting these practical
[48:24] experiments. So one thing that's really
[48:26] common in practice is that you want to
[48:27] train a couple of models for different
[48:28] token horizons and see how the
[48:30] performance changes as a function of how
[48:32] much data they can be trained on. And
[48:33] this is like similar to something you
[48:34] did in assignment two where you train
[48:35] models on different horizons.
[48:37] But uh the issue is that you kind of
[48:39] need a separate training run for each
[48:41] like token horizon because each token
[48:42] horizon has its own separate learning
[48:44] rate schedule. So you have to do a bunch
[48:46] of like a ton of different runs to do
[48:47] this. And maybe like one like holy grail
[48:49] that people would like to have is to
[48:51] just have like one single training run
[48:52] that you can do and you can measure the
[48:54] performance along the training run to
[48:56] see what per like uh
[48:58] how much performance benefit you get
[48:59] from a fixed number of tokens.
[49:02] The issue with this is that if you
[49:05] recall, when you're in this high
[49:07] learning rate regime, like either just
[49:08] the start of linear or especially the
[49:10] start of WSD, you're in this regime
[49:12] where your learning rate's really high
[49:13] and you haven't cooled down yet. So you
[49:14] don't know all the hidden progress
[49:16] you've made, so you don't know what
[49:17] performance you're actually getting.
[49:19] You're kind of just like estimating the
[49:20] the hidden progress and not the actual
[49:22] observed progress.
[49:24] So there's a couple of like things that
[49:26] you might want to do. So one thing is
[49:28] there's a paper called Mini CPM. One
[49:30] thing that they do is that they mention
[49:32] they maintain one shared WSD learning
[49:34] rate schedule. So they keep one constant
[49:36] learning rate training and at various
[49:38] points in the training trajectory,
[49:39] they'll do a short cool down. So they'll
[49:41] take the training run and just cool it
[49:42] down to zero so you can actually observe
[49:44] what your like measured progress like
[49:46] your like
[49:47] what your actual traversed progress is
[49:48] on the loss by taking these short cool
[49:50] downs and this might save some compute
[49:52] and you can using this like this dotted
[49:54] black line traces out the frontier of
[49:55] like different cool downs.
[49:58] This is a little complicated because as
[50:00] you found in your second assignment, you
[50:01] leave a lot on the table by not having
[50:03] this like a tuned learning rate per
[50:05] horizon because if you recall, the
[50:07] optimal learning rate per token horizon
[50:08] changed over different token horizons,
[50:11] which is not great because WSD maintains
[50:13] like a constant learning rate over the
[50:14] course of the entire training run.
[50:17] There are a couple of ways to handle
[50:18] this using like horizon free learning
[50:20] rate schedules. So instead of
[50:21] maintaining a constant learning rate
[50:23] over the course of training, if you know
[50:24] that the optimal learning rate decreases
[50:26] as you have larger token budgets, you
[50:28] can maintain a W like you can maintain a
[50:30] stable phase where you're actually
[50:31] slowly decreasing the peak learning rate
[50:33] over the entire course of training and
[50:34] you can still have these sharp knees at
[50:36] the end of training. And this as this
[50:39] paper shows, this can actually might get
[50:41] you like some slightly better
[50:42] performance because you're tuning the
[50:43] peak learning rate per horizon in some
[50:45] sense.
[50:46] Another way to do this type of plot is
[50:48] like cyclic a learning rate schedule
[50:50] where at every point you cool down and
[50:51] you rewarm up.
[50:53] These are two learning rate schedules
[50:54] that I think you're going to be
[50:55] exploring in your assignment as well.
[50:59] And finally, uh the third option that we
[51:02] talked about is doing Polyak averaging.
[51:03] Uh
[51:04] this this is something again you'll
[51:06] estimate yourself.
[51:07] So in summary, the like you you know
[51:10] classic convex optimization like
[51:12] Polyak's intuition is actually really
[51:13] really good at making these predictions
[51:15] about why learning rate schedules help
[51:17] and why weight averaging helps and is
[51:18] consistent with this mental model of the
[51:20] River Valley where a lot of training is
[51:21] oscillating but you're still making
[51:23] progress along the direction that you
[51:24] care about.
[51:26] And uh
[51:27] you know I think these mental models
[51:28] actually do have some bearing into how
[51:29] we would set up our training runs, like
[51:31] how we would tune our learning rates,
[51:32] how we would set our learning rate
[51:33] schedules, how we would do weight
[51:34] averaging. And they're commonly used
[51:36] when reasoning about these sorts of
[51:37] practical considerations.
[51:40] Do you have any questions about the the
[51:42] River Valley intuition?
[51:45] Yeah.
[51:45] >> I don't understand the concept of like
[51:47] hidden progress. If you have a high
[51:49] learning rate and you're bouncing along
[51:50] like the top of the river, how would you
[51:52] know that
[51:54] why would it be getting better as you're
[51:56] bouncing along there?
[51:58] >> So I think like uh maybe the point
[52:00] that's like worth noting is that if you
[52:03] take these three checkpoints which are
[52:05] just
[52:06] in different [clears throat] amounts of
[52:06] training, what you'll notice is that uh
[52:09] the loss improvement between these three
[52:10] checkpoints is like small
[52:12] and you're not actually making that much
[52:13] progress that's visible when you just
[52:15] measure the high learning rate model.
[52:16] But if you were to take these high
[52:17] learning rate models and cool them down,
[52:19] you get better and better performance.
[52:20] Maybe this plot doesn't have it quite
[52:22] exaggerated enough but there's many
[52:23] regimes where this curve actually looks
[52:25] extremely flat. So it's making like
[52:27] really slow progress along the true
[52:29] objective but it will only be revealed
[52:31] if you annealed and entered the bottom
[52:32] of the valley.
[52:33] >> I guess I'm just wondering the intuition
[52:34] as to why that would be the case.
[52:37] >> Uh if I was like
[52:39] maybe here's another visual which is
[52:40] maybe not helpful but uh if you have
[52:42] like the river angled downward but the
[52:44] valley walls stay like flat, then you're
[52:47] bouncing around the top and maybe you're
[52:49] getting into regimes where you can
[52:50] actually anneal even deeper or anneal
[52:52] even better but uh you haven't like
[52:54] entered those regimes until you've like
[52:56] true oscillated around the top of
[52:57] enough.
[52:59] >> Then what about your training process is
[53:00] making sure that you are going towards
[53:02] like a
[53:03] a river that the thing's getting deeper
[53:05] if you are actually going down though,
[53:06] like how do you
[53:07] When is it When does it get better as
[53:09] you train more? Is something about like
[53:11] the top of the river that indicates that
[53:12] you are
[53:13] in the in the river?
[53:15] >> Uh yes.
[53:16] There is. Um I think
[53:18] Okay, I think
[53:20] maybe I'll save this for to a Thursday
[53:21] lecture. I think we will be reasoning
[53:23] about these types of things about why
[53:24] train progress still happens and like
[53:26] what your oscillatory dynamics actually
[53:27] look like.
[53:30] Yeah.
[53:31] >> So for a lot of these we're using like
[53:32] intuition from two-dimensional
[53:34] landscapes.
[53:35] Are there like okay things that happen
[53:37] in like three-dimensional landscapes
[53:38] that like people use or do we do we
[53:40] really just mostly use two-dimensional
[53:43] >> Yeah, that's a great point. So maybe the
[53:44] visual that we have in our head this
[53:46] river valley is like Well, I guess
[53:47] [clears throat] it's three-dimensional
[53:48] cuz there's like two parameters, there
[53:50] are two directions and like a loss. But
[53:51] maybe you want to get to like higher
[53:53] dimensional like landscapes in your
[53:54] head. One way to do it is like the noisy
[53:56] quadratic model as we talked about. You
[53:58] can actually add as many dimensions as
[53:59] you want because those are just
[54:00] independent quadratics that you're
[54:01] adding. So in that sense the noisy
[54:03] quadratic model is like high
[54:04] dimensional. But in general like
[54:06] building these high dimensional
[54:07] intuitions is really hard and segues
[54:08] into our next part pretty nicely
[54:10] actually. So we're going to be reasoning
[54:12] about critical points and we're going to
[54:13] be reasoning about high dimensional
[54:14] spaces that we can't actually really
[54:15] visualize.
[54:19] So uh just to start people in deep
[54:21] learning for a long time, maybe not
[54:23] anymore, used to be really really scared
[54:25] of critical points. Like you might enter
[54:26] a local minima or you might enter a
[54:28] saddle point. So when I was learning
[54:30] deep learning back in the day I was
[54:31] taking this Coursera course and then
[54:32] Andrew Ng like when he was drawing like
[54:34] a saddle point he drew this like a
[54:35] little horsey to like show like what a
[54:37] saddle looks like. Uh people were really
[54:39] scared that you would like end up
[54:40] exactly where that guy's sitting and
[54:42] then like you would make any more
[54:43] progress on the loss landscape. So it
[54:45] would be concerning if you entered this
[54:46] local minima over here and you couldn't
[54:47] make progress towards a global minima or
[54:49] if you entered this point over here
[54:51] where your gradient is still zero so
[54:52] you're not making any progress and but
[54:55] you're not at any like you're not even
[54:56] at a local minima. So these critical
[54:58] points where the gradient is zero are
[54:59] kind of like a little scary and you know
[55:02] it's kind of magical that we don't think
[55:04] about that that much in practice
[55:07] So yeah in practice our methods if you
[55:09] point to any parts of the stack, there
[55:11] aren't that many parts of the stack
[55:12] where we actually explicitly avoided
[55:14] these local minima or avoided these like
[55:16] saddle points. And it's kind of magical
[55:18] that we didn't have to think that too
[55:19] hard about it. And there's like a series
[55:21] of folklore arguments that I want to go
[55:23] over for why people are not that
[55:24] concerned. These arguments on the range
[55:26] of empirical theoretical are a lot more
[55:27] theoretical and a lot more like toy
[55:29] model flavor than a lot of the weight
[55:30] averaging in the river valley
[55:31] experiments that I've shown you up to
[55:32] this point.
[55:33] So there's a couple of intuition that
[55:35] people have. One is that people are a
[55:37] lot think that there's a lot more saddle
[55:39] points than local minima.
[55:41] You can show these results where there's
[55:43] actually many saddle points in the loss
[55:44] landscape relative to the number of
[55:46] local minima that exist, especially for
[55:47] high dimensional landscapes.
[55:50] The next intuition that people have is
[55:52] that local minima, in fact, many times
[55:53] they just don't even exist. There's many
[55:55] theoretical models or non-convex
[55:56] optimization problems where there's no
[55:57] local minima. But even if they did exist
[56:00] and you arrived at them, the local
[56:01] minima are actually really good and have
[56:03] performance that's close to the global
[56:04] minima. So you're actually not paying
[56:05] that much regret to enter lines of these
[56:06] local minima.
[56:08] And another intuition that people have
[56:09] is that gradient descent almost always
[56:11] avoids these saddle points because of
[56:13] the nature of gradient descent, it
[56:14] doesn't actually get stuck in any of
[56:15] these saddle points, even though it
[56:16] might end up close to them and maybe get
[56:17] slowed down by them, but never gets like
[56:18] stuck at any of these saddle points.
[56:21] So this is this unit is going to be like
[56:24] this part of the lecture is going to be
[56:26] an example of our low dimensional
[56:27] intuitions being like horrible. Like if
[56:29] we just drew a loss landscape in one
[56:31] dimension as much as we thought, we are
[56:33] just going to almost always draw one
[56:34] that has like local minima to it and
[56:36] basically never going to draw one that
[56:38] has a saddle point on it. But
[56:39] interestingly, the high dimensional
[56:41] picture is like completely different and
[56:42] doesn't actually behave in the same way
[56:44] our one dimensional picture behaves.
[56:48] So cool. We're going to start with some
[56:49] intuition from statistical physics.
[56:52] So just as some like primer for how this
[56:55] types of stuff works is that one way to
[56:57] build intuition for what the loss
[56:58] landscape actually looks like for like
[57:00] this deep arbitrary deep neural network
[57:02] is to think about what the loss
[57:03] landscape would look like for random
[57:04] Gaussian matrices or for random loss
[57:06] landscapes. So like the loss landscape
[57:08] for like random functions
[57:09] or random objectives. And this type of
[57:12] analysis of randomness of random
[57:14] structures is pretty nice because
[57:16] there's like a lot of mathematical tools
[57:18] that people have developed to do this
[57:19] and often you can actually reason about
[57:20] the properties of real training by
[57:22] reasoning about the training properties.
[57:23] And for example, this was the kind of
[57:25] intuition that we were using in UP. We
[57:26] were reasoning about the random matrices
[57:28] initialization and their evolution over
[57:30] the course of training to reason about
[57:31] what training like methods were. It's
[57:33] going to have or it's going to start
[57:34] with similar flavor to this.
[57:36] So
[57:37] the paper that we're going to start with
[57:38] is Brandeis and they analyze two
[57:40] quantities. They first analyze the error
[57:43] epsilon of your model. So this error is
[57:44] pretty like simple. It's just the
[57:46] distance between your your current
[57:48] objective's loss and the global
[57:50] minimizer of the loss. And you're going
[57:52] to analyze this index. Index is the
[57:54] fraction of eigen values that are
[57:55] negative. If you recall, saddle points
[57:58] are places where the eigen values are
[57:59] both negative and positive because you
[58:00] have open directions facing in different
[58:02] directions. You have openings in
[58:04] different directions. And if all the
[58:06] eigen values are positive, you would be
[58:07] at a minimum because this means that in
[58:09] every direction you're already at a
[58:10] minimizer.
[58:12] So we're going to that this theoretical
[58:14] paper establishes a relationship between
[58:16] epsilon and alpha for like random
[58:18] Gaussian objectives. And without getting
[58:20] too detailed into the objectives, they
[58:23] kind of show that there's a tight
[58:24] correspondence between epsilon and alpha
[58:25] and they show that basically they have a
[58:27] monotonic relationship that like they
[58:29] concentrate around a monotonic
[58:30] relationship where decreasing epsilon
[58:32] decreases alpha and similarly increasing
[58:34] epsilon increases alpha.
[58:36] This tight relationship between both of
[58:38] the quantities has some pretty nice
[58:39] implications. So one thing is that
[58:41] critical points with high error, so if
[58:42] you have high epsilon, you must have a
[58:45] high alpha as a consequence. And if you
[58:47] have a high alpha, you have a high
[58:48] fraction of negative eigen values, which
[58:50] means that you are like definitely a
[58:52] saddle point. And in the extreme, if
[58:53] your epsilon was like extremely high,
[58:55] almost basically all your eigen values
[58:56] would be negative and you would be at
[58:58] like one of those
[58:59] of those peak things which seems like
[59:00] really depressing to be at.
[59:02] Um
[59:03] the second other direction of this tight
[59:05] correspondence between epsilon and alpha
[59:07] is that if you have index zero, which
[59:09] means that you have alpha equals zero
[59:11] and eigen values are all positive, then
[59:14] your epsilon must be lower as a result.
[59:16] So if like a local minima exist, like
[59:19] this kind of suggests a local minima
[59:20] probably don't even exist in the first
[59:21] place, but even if they did exist, if
[59:23] your alpha was very low, your alpha is
[59:25] zero for these local minima, it's like
[59:28] your your epsilon is also going to be
[59:30] extremely low when your alpha is low. So
[59:31] your error is going to be low in these
[59:32] regimes where you are you have very few
[59:35] negative eigen values.
[59:37] So
[59:38] just to do a brief intuition for what
[59:40] the theoretical argument looks like.
[59:43] So the intuition from there's some
[59:45] intuition that you can build from random
[59:47] matrix theory. So the first basic result
[59:50] that we can do is this is completely
[59:52] independent of deep learning or
[59:53] anything. If you take a random Gaussian
[59:54] matrix and you characterize its eigen
[59:56] values, there's this really beautiful
[59:57] principle called the Wigner semi-circle
[59:59] law, which basically states that the
[60:01] distribution of your eigen values
[60:03] follows this really nice semi-circle. So
[60:06] this is just like a like a very cute
[60:07] piece of math that the eigen values for
[60:09] a random Gaussian matrix are really
[60:11] well-behaved and this is like an
[60:12] experiment you can run at home and see
[60:13] like these types of like semi-circle
[60:15] laws.
[60:16] One kind of implication of this
[60:17] semi-circle law is that each eigen
[60:19] value, if it was distributed according
[60:21] to this the Wigner semi-circle law, the
[60:23] eigen value has a one-half probability
[60:25] of being positive and a one-half
[60:26] probability of being negative.
[60:29] Now Brandon Dean basically shows that
[60:31] the Hessian at critical points, so a
[60:33] critical point where the gradient is
[60:34] zero, you can analyze the Hessian and
[60:36] you can analyze the distribution of the
[60:38] eigen values at this Hessian. And they
[60:40] basically show that the distribution
[60:42] follows roughly the exact semi-circle
[60:44] law, but it's just shifted by some
[60:46] amount that depends on the error.
[60:47] So if you have basically a global
[60:50] minimum or you have like these points
[60:52] where the error is extremely low or very
[60:54] small, then this shifts this spectrum
[60:56] distribution. It retains the shape, but
[60:58] it's shifted towards the right. So if
[60:59] you randomly sample one of these eigen
[61:01] values, with high probability it's going
[61:03] to be positive.
[61:04] So this is basically what the
[61:07] [clears throat] picture shows for minima
[61:09] and it also shows the opposite
[61:10] direction, which is that if you have
[61:11] higher, it shifts the spectrum in the
[61:13] leftwards direction.
[61:15] And instead of the eigen values being
[61:16] like extremely positive, they're
[61:18] extremely likely to be negative. And
[61:19] almost all your eigen values are going
[61:21] to be negative if your error is like
[61:22] really high.
[61:23] So this has like a pretty simple
[61:25] implication that if you like this shows
[61:28] the tight correspondence between alpha
[61:29] and epsilon, which is that if your error
[61:31] is really low, then you're going to have
[61:32] a low chance of getting negative eigen
[61:34] values. If your error is really high,
[61:35] then you're going to have a high chance
[61:36] of getting negative eigen values.
[61:38] There's another really cool part of this
[61:40] model, which is that you can analyze
[61:41] this model across different dimensions.
[61:43] So if we start with one dimension, which
[61:44] is kind of the version that we have when
[61:46] we draw a loss landscape, what you'll
[61:48] find is that an exact saddle, sampling
[61:50] an exact saddle actually has like zero
[61:52] probability. None of the critical points
[61:54] are going to be
[61:55] like with high probability like none of
[61:57] this is like critical points are going
[61:59] to be saddle points and all of them are
[62:00] going to be minima.
[62:02] And this kind of this kind of maps to
[62:03] our intuition that when we draw a
[62:04] one-dimensional loss landscape, we
[62:06] mostly have minima.
[62:07] But on the other hand, if the number of
[62:09] parameters grows and they they basically
[62:11] show that as you increase the dimension,
[62:13] the relative
[62:14] like the relative ratio between number
[62:17] of saddle points and the number of local
[62:18] minima exponentially grows and the
[62:20] likelihood of a critical point being a
[62:21] saddle or a minima like it shifts
[62:23] towards being a saddle.
[62:25] >> What would it mean to be a saddle
[62:28] in one dimension because one eigen value
[62:29] is either positive or negative?
[62:31] >> Yes. So a saddle would look like
[62:34] it would look like
[62:36] this.
[62:39] >> I see. Okay, so you just zero eigen
[62:41] value.
[62:42] >> Yeah.
[62:48] Uh the objective itself is random.
[62:51] Like a we're sampling a random Gaussian
[62:53] objective.
[62:55] The so that's one sense in which like
[62:57] the objective is random and then there's
[62:59] like a distribution over eigen values.
[63:00] So if I randomly select one of the eigen
[63:02] values, like this is a distribution at a
[63:03] base.
[63:07] >> I'm not interpreting this in practice.
[63:09] Like for example, if you
[63:12] are you
[63:13] reading the
[63:14] possible loss landscape as
[63:17] random?
[63:18] >> Yeah. So
[63:19] this like intuition from like the
[63:20] randomness. But, we're not actually
[63:22] going to use this type of result when we
[63:24] look at practice. In practice, all we're
[63:25] going to do is we're just going to
[63:26] measure epsilon and alpha and see how
[63:27] they behave.
[63:29] So, I will show you this plot over here.
[63:31] So, in this plot, what you can do is you
[63:32] can just take one of these points and
[63:34] epsilon and alpha are not random
[63:35] quantities in this sense. You can just
[63:37] measure like for random models that you
[63:38] train, you can measure how many of the
[63:39] eigen values are negative and what the
[63:41] error of each of those models are. And
[63:43] what you'll find is this tight
[63:44] correspondence that's predicted by
[63:45] theory actually does hold somewhat
[63:46] empirically. And there is a correlation
[63:48] where as you decrease the number of
[63:50] eigen values, your error goes down as
[63:51] well.
[63:52] So, now that you have this
[63:53] correspondence, this basically suggests
[63:56] if you have if you're like at a saddle
[63:59] point, like if you have high error,
[64:00] you're probably going to be at a saddle
[64:01] point and you're not going to be at a
[64:02] local minima because if you had high
[64:04] error, then you can't have low alpha.
[64:07] And
[64:08] it also suggests that yeah, if you are
[64:10] at a local minima which has like low
[64:11] alpha, you probably have like very good
[64:13] error. You have probably have very good
[64:14] error.
[64:18] Cool. And to go further, there actually
[64:21] like maybe from a more like machine
[64:23] learning or CS perspective, there are
[64:24] many non-convex learning problems where
[64:26] you can actually show that no local
[64:28] minima exist like at all. So, for one
[64:31] paper, matrix completion has no spurious
[64:33] local minima. I think the title is very
[64:35] explanatory. Matrix completion is this
[64:37] like like non-convex learning problem
[64:39] which people were coming up with all
[64:41] sorts of algorithms for, but actually if
[64:42] you do gradient descent, you're
[64:43] guaranteed to converge to like if you
[64:45] are guaranteed to converge to a minima,
[64:47] then you would be guaranteed to converge
[64:48] to the global minima. So, this actually
[64:50] simplified a lot of the analysis for
[64:51] these types of like theoretical
[64:53] problems. And another example that you
[64:55] can do is you can have like a one layer
[64:56] MLP. And this older paper shows that in
[64:59] one layer MLP, you can prove that you
[65:01] won't actually get any local minima.
[65:03] You'll only have saddle points and a
[65:04] global minima, which is like another
[65:06] thing that kind of might defy your
[65:07] intuition about this. But, these are all
[65:09] again like toy pictures. There's
[65:12] obviously all sorts of like toy
[65:13] theoretical model or theoretical models
[65:15] you can cook up where the local minima
[65:16] do exist. Clearly, we can if we wanted
[65:18] to construct models that have local
[65:19] minima, but there's also very many
[65:20] natural models. So, for example, this
[65:22] paper is kind of showing the opposite
[65:23] picture where local minima do exist on
[65:25] the loss landscape.
[65:31] Um, so I think if you think about this
[65:33] previous part, now we don't have to
[65:35] worry about local minima that much
[65:36] because we either showed that they're
[65:37] very rare or if you get to one of these
[65:39] local minima, it has the same error as
[65:41] the global minima anyway. So, it's not
[65:42] that big of a deal. So, now the next
[65:44] thing that we have to be paranoid about
[65:46] are saddle points. And this is the thing
[65:47] that a lot of people developed like a
[65:48] lot of methods for that were worried
[65:50] about entering one of these saddle
[65:51] points and they wanted to escape these
[65:52] saddle points.
[65:54] Maybe the general theme of like some of
[65:56] these methods to escape saddle points is
[65:57] that if you like randomly perturb your
[65:59] parameters around the saddle point, then
[66:01] you'll just get off the saddle point and
[66:03] then you can continue training progress.
[66:05] So, this is like one theme of methods,
[66:06] but saddle points also slow down your
[66:08] training, so they're still not great.
[66:09] So, this is like a concern that people
[66:11] had about it and people designed a ton
[66:13] of like methods to escape saddle points.
[66:15] But uh there's this pretty interesting
[66:18] set of theoretical papers as well that
[66:19] basically show that gradient descent
[66:21] always converges to a local minima. Uh
[66:24] sorry, I think I said global here, but I
[66:26] I meant to say local.
[66:28] Basically, they can prove that gradient
[66:30] descent with like vanishing probability
[66:32] actually gets stuck at one of these
[66:33] saddles and will almost always will just
[66:35] enter a local minima. So, we don't know
[66:38] which local minima it'll enter, but it
[66:39] will guarantee that you enter at least
[66:40] one such like a one such local minima.
[66:43] And these theory papers have some like
[66:45] proofs about why this happens. And uh
[66:48] yeah, I yeah, I don't have that much
[66:49] more to say than uh
[66:51] these mental models are kind of why
[66:52] people believe that gradient descent
[66:54] doesn't get stuck at saddle points. But
[66:55] uh there are some more empirical
[66:57] analyses of how saddle points operate
[66:58] over the course of training. So,
[67:01] uh one common theoretical model to
[67:03] understand all of this optimization
[67:04] theory is like deep linear networks. So,
[67:06] instead of considering models which have
[67:08] activation functions which what what
[67:11] makes it like linear like what what
[67:13] makes a neural network like non-convex
[67:15] in the first place, you can answer you
[67:17] can ask questions for these deep linear
[67:19] networks which also have like pretty
[67:20] complicated optimization dynamics. And
[67:22] what people find is that over the course
[67:24] of training in these theoretical models,
[67:26] models like go from one saddle point to
[67:28] another. So they start in a saddle point
[67:30] and it might look like they have slow
[67:31] training around there, but then they
[67:32] move on to a next saddle point. And as
[67:34] you move from saddle point to saddle
[67:35] point, you increase the number of
[67:36] positive eigen values you have until you
[67:38] get to one of these like local minima
[67:39] where all the eigen values are positive.
[67:41] So this is just like another like
[67:42] cartoon of why how people think training
[67:44] might work. Uh these are the types of
[67:46] things that you want to design
[67:47] experiments for to test if you actually
[67:49] wanted to like understand whether this
[67:50] model is correct or not.
[67:52] And putting all of these mental models
[67:55] together, you can reason about the fact
[67:57] that first there are many more saddle
[67:59] points than local minima, and the local
[68:00] minima even if they exist would get
[68:02] really good loss. And finally gradient
[68:04] descent is guaranteed to converge to one
[68:05] of these local minima as governed by
[68:07] these theory papers. If you combine the
[68:09] fact that the minima are very like
[68:11] there's only global minima or close
[68:13] [clears throat] to global minima and
[68:14] gradient descent enters one of these
[68:15] minima, then you can just think that
[68:17] okay maybe gradient descent is going to
[68:18] enter where we want to and we don't have
[68:20] to reason about like critical points or
[68:21] saddle points or anything like that.
[68:24] Yeah.
[68:25] >> If this is the case, like
[68:27] where does training get started? Like
[68:29] eventually the training will start
[68:30] leveling out.
[68:32] >> Uh I guess uh
[68:34] I don't know. Have you observed that
[68:35] like for your runs you can like train
[68:36] for longer and you probably still see
[68:38] the loss improve. But there are other
[68:39] like issues that happen. So for example,
[68:42] you're limited by the number of
[68:42] parameters in your model.
[68:44] And the number of parameters in your
[68:45] model might also work make the loss
[68:47] landscape like worse. So this like might
[68:49] slow down training as well. Yeah.
[68:51] But uh maybe there is this uh like
[68:54] higher level belief which we're not on
[68:56] these slides or anything that if you
[68:57] kept making models bigger and then you
[68:59] also kept training them better with like
[69:01] a reasonable optimizer, you would
[69:03] basically be able to optimize like
[69:04] whatever function you cared about.
[69:08] [snorts]
[69:11] Or at least for natural functions which
[69:12] are like well-behaved in the ways that
[69:13] we're talking about.
[69:19] Any other questions?
[69:21] Yeah.
[69:29] >> Yeah, I think that's a reasonable belief
[69:31] that maybe the SGD like avoids these
[69:34] like saddle points.
[69:38] I guess the way to test this is if you
[69:39] did full batch gradient descent versus
[69:40] stochastic gradient descent, you can
[69:42] measure the index of these and check
[69:43] which one has more negative eigen values
[69:44] or something.
[69:46] Actually, wait.
[69:48] We might actually have this plot in our
[69:49] lecture.
[69:53] And so we have different batch sizes
[69:54] here. So the left is more stochastic and
[69:56] the right is less stochastic.
[69:59] I guess I can't really tell if there's
[70:00] more or less negative eigen values.
[70:03] Doesn't seem very conclusive.
[70:10] No.
[70:19] Any other questions?
[70:28] Okay, great. So just to summarize the
[70:29] mental models that we went over today,
[70:31] we went over we started with is a very
[70:33] empirical exploration of basins, and the
[70:35] basins mental models suggest that models
[70:37] if trained in certain training regimes
[70:38] would actually enter the same basin and
[70:40] you can average them for better better
[70:41] performance.
[70:42] You can always ensemble you can almost
[70:44] always ensemble them for better
[70:44] performance, but at least averaging
[70:46] allows you to get even the shared
[70:47] parameters, and this teaches you
[70:48] something about the loss landscape.
[70:50] We also went over this river valley
[70:52] mental model, which basically tells you
[70:54] how optimization proceeds primarily
[70:56] through like oscillation
[70:58] along these like valley walls rather
[71:00] than proceeding like in the same
[71:01] direction for all of training.
[71:04] And the two ways to handle this sort of
[71:06] like regime where you're bouncing around
[71:07] a lot and you need to bounce around a
[71:09] lot to make fast progress is you either
[71:10] need to anneal your learning rate at
[71:12] some point or you need to average the
[71:13] weights within a trajectory. So these
[71:15] are at least two theoretical ways to
[71:16] handle this.
[71:18] And finally our critical point analysis
[71:20] suggests that maybe we don't need to
[71:21] worry too much about local minima and
[71:23] saddle points and we can kind of just
[71:24] train as normal, but obviously this
[71:26] theory theory is like created as a just
[71:29] like a reaction to the fact that in
[71:30] practice people didn't really need to
[71:31] care about it. So you know
[71:33] I'm going to take that. Take with that
[71:35] what you will.
[71:36] Just as a precursor for next week. Next
[71:38] week we're going to be reasoning about
[71:39] the sharpness. So we're going to be
[71:40] reasoning about the maximum eigen value
[71:42] of the Hessian. So we're going to be
[71:45] talking about how the sharpness changes
[71:47] over the course of training, how it like
[71:48] increases or maybe even how it decreases
[71:50] and there's like some really like
[71:52] beautiful phenomena over here on how the
[71:53] sharpness evolves.
[71:55] But yeah cool. No other questions or
[72:00] >> For all language model setting do we
[72:03] usually see there's just one of like
[72:08] usually opposite of them?
[72:10] >> Yeah so it's usually not actually just
[72:12] like one direction because you have like
[72:15] the the number of parameters is like
[72:16] many. So this is something that maybe
[72:18] you'll do on the assignment too but if
[72:20] you looked at this decomposition of the
[72:22] eigen values into like we talked about
[72:24] this like dominant part which is where
[72:25] all the large eigen values are and then
[72:27] this like tail part which is where the
[72:28] eigen values are like much smaller. Like
[72:30] smaller eigen values intuitively
[72:31] correspond to flatter directions.
[72:33] So maybe those ones behave more river
[72:36] like and the other directions behave
[72:37] more valley like.
[72:39] But there's no like one to one clear
[72:41] mapping of like each thing goes is like
[72:43] a river or a valley. This is like the
[72:45] the softness of the mental model on like
[72:46] how it maps into like real training.
[72:50] Yeah.
[72:50] >> Remember there was a slide about I think
[72:52] it's called the disagreement
[72:54] [clears throat]
[72:55] talking about the EMA.
[72:56] >> Yeah sure.
[72:58] >> It's like how was I didn't quite catch
[73:00] like the the big application of like
[73:02] what's going on.
[73:03] >> Oh yeah sure. So you can take a
[73:05] pre-trained model
[73:06] which is these stars and you can fine
[73:08] tune them on some target task where your
[73:10] in distribution performance like
[73:11] improves. And the first weight averaging
[73:14] result which I guess you hadn't seen
[73:15] until this slide is that you can average
[73:17] a fine tuned model with its
[73:18] initialization and actually get better
[73:20] performance.
[73:22] Like this curve traces out like this
[73:24] even better performance and this is a
[73:25] surprising sense in which you can
[73:26] improve your in distribution performance
[73:28] just simply by averaging your model with
[73:30] its
[73:32] So this is like the first result.
[73:34] Uh the second result is that if you do
[73:35] this without standard fine-tuning, but
[73:37] with an EMA, you get better
[73:38] in-distribution and better
[73:39] out-of-distribution performance. So this
[73:41] blue point over here does better than
[73:43] this like uh lab bottom left over here
[73:44] which corresponds to standard
[73:45] fine-tuning.
[73:47] And so this has some predictive power of
[73:50] the EMA because the EMA is able to
[73:51] correctly like account for the fact that
[73:53] uh you like the EMA does improve
[73:55] performance, which is what the theory
[73:56] predicts.
[73:57] But the issue is that if you average the
[74:00] EMA with the original pre-trained model,
[74:02] you get even better models. So what that
[74:04] means is that the river valley landscape
[74:06] captures some part of the picture, which
[74:08] is that weight averaging is what's
[74:09] leaving some of the performance on the
[74:10] table, but it doesn't capture the full
[74:12] picture because you can get even better
[74:13] performance by averaging with the
[74:15] initialization. So there's still some
[74:17] like explanatory power in basins which
[74:18] is not fully captured by the river
[74:19] valley landscape.
[74:22] >> And then the proof is trace like by kind
[74:24] of just taking different like lambda.
[74:26] >> Yeah, different mixture weights. That's
[74:27] right.
[74:31] Yeah. Any other questions?
[74:38] Cool. Thanks.