Hashimoto Ties LLM Weight Decay to Step Sizes, Not Overfitting
Stanford Online
In single-pass language model training, weight decay primarily regulates effective learning rates by countering normalization-induced parameter norm expansion rather than curbing model complexity.
The Noisy Quadratic Model (NQM) demonstrates that momentum provides negligible speedup at small batch sizes where gradient noise limits learning rates, yielding practical gains only once batch sizes approach the curvature stability limit. (40:00)
In transformer models with LayerNorm or RMSNorm, scale invariance causes gradient steps to drift parameter norms outward, which silently depresses the effective learning rate as eta over norm squared. (59:28)
In one-pass LLM pretraining, weight decay acts primarily as a thermostat for effective learning rates rather than a regularizer against overfitting; replaying the recorded effective learning rate schedule without weight decay fully matches performance. (65:16)
The Hyperball framework projects internal weights back onto a sphere with radius equal to initialization norms after each step, outperforming standard AdamW and Muon baselines while stabilizing hyperparameter transfer across scale. (70:31)
Detailed notes
## Background
This lecture was published on YouTube by Stanford Online on November 26, 2026, as part of the Stanford CS312: Deep Learning Alchemy course. Taught by Assistant Professor Tatsunori Hashimoto, the session explores optimizer anatomy—including learning rates, batch sizes, momentum, preconditioning, and AdamW—using the noisy quadratic model to analyze critical batch sizes and when momentum pays off. According to the page description, Hashimoto also examines how layer normalization triggers parameter norm growth, why weight decay primarily governs the effective learning rate in modern transformers, and how the Hyperball optimizer projects weights onto a fixed-radius sphere.
## TL;DR
Hashimoto investigates why simple stochastic gradient descent variants outshine classical convex optimization algorithms when training deep neural networks. Using the Noisy Quadratic Model (NQM), he proves that batch size exhibits a hard ceiling governed by curvature stability limits and demonstrates that momentum only accelerates progress at large batch sizes where noise is sufficiently dampened. Moving from quadratic theory to architectural realities, he explains how LayerNorm introduces scale invariance that drives weights outward along spherical tangents, silently shrinking the effective learning rate over time. To solve this norm lag, he reframes weight decay as an effective step size regulator and introduces Hyperball, which projects internal weights onto their initialization spheres to maintain clean hyperparameter transfer across model scales.
## Atmosphere & style
The lecture carries an engaging, grounded academic atmosphere where rigorous mathematical analysis meets pragmatic engineering lore. Hashimoto speaks with candid, conversational clarity, demystifying deep learning 'alchemy' by puncturing common misconceptions about convex optimization and classical regularization. His delivery feels like an insider look into the mechanics of training foundation models, balancing whiteboard equations with wry, practical observations about how simple implementation details silently dictate training dynamics.
## Bulletin
- [40:00](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=2400s) The Noisy Quadratic Model (NQM) demonstrates that momentum provides negligible speedup at small batch sizes where gradient noise limits learning rates, yielding practical gains only once batch sizes approach the curvature stability limit.
- [59:28](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=3568s) In transformer models with LayerNorm or RMSNorm, scale invariance causes gradient steps to drift parameter norms outward, which silently depresses the effective learning rate as eta over norm squared.
- [01:05:16](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=3916s) In one-pass LLM pretraining, weight decay acts primarily as a thermostat for effective learning rates rather than a regularizer against overfitting; replaying the recorded effective learning rate schedule without weight decay fully matches performance.
- [01:10:31](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=4231s) The Hyperball framework projects internal weights back onto a sphere with radius equal to initialization norms after each step, outperforming standard AdamW and Muon baselines while stabilizing hyperparameter transfer across scale.
## Key takeaways
- [00:05](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=5s) Deep learning relies on crude variants of mini-batch SGD rather than minimax optimal convex algorithms because neural networks present a specialized optimization setting co-designed with architecture.
- [06:09](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=369s) Preconditioning rescales ill-conditioned loss valleys to permit direct descent, but under stochastic noise it amplifies low-curvature error unless batch sizes are large enough to suppress noise.
- [25:49](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=1549s) The Noisy Quadratic Model decouples optimization into independent 1D subproblems when the Hessian curvature and gradient noise covariance share a common basis.
- [27:32](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=1652s) The critical batch size occurs when batch expansion allows learning rates to hit the theoretical quadratic stability threshold of 2 over the maximum Hessian eigenvalue, after which batching yields sharply diminishing returns.
- [30:40](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=1840s) Momentum dynamics split into underdamped oscillatory coordinates and overdamped smooth coordinates, with the slowest overdamped coordinate forming the rate-limiting bottleneck for multi-dimensional convergence.
- [43:02](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=2582s) Empirical LLM pretraining confirms NQM predictions: plain SGD and momentum optimizers perform almost identically at small batch sizes, and SGD at batch size 1 matches the original GPT-3 AdamW curve.
- [49:43](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=2983s) Real neural network optimization violates basic quadratic models at the 'edge of stability', where full-batch gradient descent exhibits sustained loss oscillations yet continues to make optimization progress.
- [55:00](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=3300s) Because normalization layers introduce scale invariance, gradients lack radial components and every tangent step pushes the weight norm outward away from the origin.
- [59:28](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=3568s) Parameter norm growth drives down effective step size (eta over ||theta||^2), causing actual effective learning rates to lag significantly behind the intended nominal schedule.
- [01:05:16](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=3916s) Dynamic weight decay algorithms like AdamC scale regularization inversely with the learning rate schedule to keep the theoretical equilibrium norm constant throughout training.
- [01:08:29](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=4109s) Direct spherical projection must exempt output projection heads, embedding layers, and normalization gains, as output logits directly calibrate prediction confidence.
- [01:15:42](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=4542s) Hyperball variants AdamH and MuonH establish broader functional learning rate plateaus, preventing parameter norm drift and improving loss across model scales.
- [01:17:25](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=4645s) Theoretical progress in deep learning requires diagnostics driven by architectural specifics, as abstract convex models miss crucial internal phenomena like scale invariance and weight drift.
## Detailed walkthrough
### [00:05](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=5s) Optimization, Hyperparameters, and the Deep Learning Paradox
Tatsunori Hashimoto opens the lecture by transitioning into what he calls "some more fun stuff": optimizers. He immediately adds a caveat: hyperparameters are inextricably tied to the topic. “You can never truly escape the hyperparameters, unfortunately,” Hashimoto remarks, framing the discussion around understanding the inner mechanics of both models and optimizers through the lens of hyperparameter dynamics. Optimization will occupy significant real estate in the course—four lectures and two assignments—because it sits squarely at the core of machine learning. Machine learning is fundamentally about feeding data into architectures, and the optimizer is the engine driving the loss down. Consequently, choices made in the optimizer dramatically impact both compute savings and the generalization behavior of the resulting models.
```mermaid
flowchart LR
accTitle: Evolution of Deep Learning Optimizers
accDescr: Progression from SGD to Adam to Muon showing compute efficiency gains.
SGD["Mini-batch SGD"] -->|"Adaptive scaling"| Adam["Adam / AdamW"]
Adam -->|"Orthogonalization"| Muon["Muon Optimizer"]
```
Hashimoto highlights the dramatic generational shifts in modern training efficiency—moving from basic Stochastic Gradient Descent (SGD) to Adam, and more recently from Adam to Muon. In compute-capped environments like training foundation models and large language models, even minor optimization gains translate into enormous real-world value. However, he contrasts the deep learning perspective with classical optimization theory. Optimization is an ancient, deeply theorized discipline, particularly in the realm of convex first-order methods. Courses like Stanford's convex optimization class cover minimax optimal algorithms and elegant tools such as mirror descent and Frank-Wolfe. Yet deep learning largely ignores that theoretical canon. Hashimoto emphasizes that practitioners instead rely on methods that might seem crude from a classical lens:
> “And really most of the field is just variations of mini batch stochastic gradient descent, which I think if you look at it from the lens of like convergence rates for optimization is like just kind of a terrible algorithm. Um, but it's not terrible for deep learning, right?”
He stresses that this divergence does not stem from ignorance among deep learning practitioners; rather, deep learning presents a very specialized, idiosyncratic subset of optimization problems where these specific practical techniques excel.
[03:09](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=189s) The Anatomy of SGD: Learning Rate and Batch Size
Stepping back, Hashimoto outlines the basic structure of first-order optimization algorithms. The baseline SGD update is conceptually minimal: parameters are updated iteratively by descending in the direction of the gradient. In stochastic optimization, the true gradient over an independent and identically distributed (i.i.d.) dataset is approximated by computing the gradient over a randomly drawn mini-batch. Despite its simple functional form, this formulation opens up critical architectural decisions: setting the learning rate schedule, handling noise introduced by mini-batching, choosing a preconditioner, and adding momentum.
Even on a toy quadratic loss, varying the learning rate and batch size produces wildly divergent trajectories. A learning rate set too high causes immediate divergence, whereas other settings yield vastly different rates and styles of convergence. Classical convex theory advises staying below a maximum stable learning rate and using decaying schedules to guarantee asymptotic convergence in noisy regimes. However, classical theory offers little concrete guidance on the exact tradeoffs between stochasticity, batch size, and computational expenditure when scaling deep neural networks under fixed compute budgets.
[06:09](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=369s) Preconditioning: Reshaping the Optimization Landscape
Hashimoto moves to preconditioning, a core tool in both classic optimization and deep learning. Instead of stepping directly along the raw gradient, the update vector is transformed by a positive semi-definite matrix $A$ (with bounded eigenvalues) before applying the step. Algorithmic preconditioning allows the optimizer to execute several key transformations:
- Adjust effective learning rates independently per parameter by scaling gradient coordinates up or down.
- Decorrelate parameters trapped in narrow, ill-conditioned valleys by effectively rotating and rescaling the landscape into a well-conditioned bowl.
- Adaptively estimate curvature on the fly by observing incoming gradients to dynamically shape the preconditioner.
```mermaid
flowchart TD
accTitle: Effect of Preconditioning on Gradients
accDescr: Comparing standard gradient descent trajectory in a steep valley to preconditioned descent.
subgraph Standard["Standard Gradient Descent"]
G1["Raw Gradient"] --> G2["Oscillates across steep valley walls"]
G2 --> G3["Slow progress along flat floor"]
end
subgraph Preconditioned["Preconditioned Descent (Matrix A)"]
P1["Gradient preconditioned by A"] --> P2["Rescales and decorrelates coordinates"]
P2 --> P3["Direct descent along true steepest path"]
end
```
In ill-conditioned quadratics, standard gradient descent zigzags back and forth across the steep valley walls rather than making direct progress along the floor. Multiplying by an appropriate preconditioner rescales the geometry, allowing the optimizer to descend straight down the valley. Hashimoto notes that because $A$ can be chosen from an enormous family of positive semi-definite matrices, preconditioning offers a massive design space that modern deep learning optimizers exploit heavily.
[08:08](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=488s) Momentum and Physical Intuition
Hashimoto introduces momentum, the third major lever in optimizer design. Drawing on the standard physical analogy of a heavy ball rolling down an uneven surface, he notes that momentum changes the fundamental dynamics of first-order steps. Rather than simply evaluating and accumulating individual gradient vectors at each discrete coordinate, momentum accelerates progress along directions of consistent descent, allowing the optimizer to build velocity and move faster than bare gradient steps would permit.
[08:26](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=506s) Momentum: Heavy Ball, Nesterov, and Damped Regimes
Tatsunori Hashimoto begins by explaining how momentum accelerates optimization by carrying over state across iterations. When updates move consistently in the same direction, that signal accumulates in the velocity term, driving the parameters faster and faster. While classical first-order optimization theory celebrates methods like Nesterov accelerated gradient for improving convergence rates on convex problems from $\mathcal{O}(1/t)$ to $\mathcal{O}(1/t^2)$, deep learning practitioners generally rely on Polyak heavy ball momentum instead:
> “You know, as with most things in deep learning, like you don't actually need to use Nesterov acceleration, you can just use heavy ball, which is this thing over here.”
Even in this simpler heavy ball formulation, momentum plays a massive role in empirical deep learning. Hashimoto emphasizes that momentum operates in two distinct qualitative regimes depending on the damping behavior:
- **Underdamped regime**: Occurs when momentum values are set very high, causing the optimization trajectory to oscillate back and forth across ravines or valleys in the loss landscape.
- **Overdamped regime**: Occurs when momentum is sufficiently small, preventing oscillations and allowing the optimizer to slide down the slope smoothly.
Understanding the boundary between these two regimes turns out to have crucial implications for the practical role of momentum when training deep networks.
---
[09:55](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=595s) Scope of the Optimization Design Space
Acknowledging the vastness of optimizer architectures and training dynamics, Hashimoto notes that two lectures cannot cover everything. Instead of an exhaustive taxonomy, the discussion focuses on specific, tractable questions that reveal fundamental optimization phenomena:
1. **Batch size interactions**: How mini-batch size couples with preconditioners and momentum terms. Hashimoto notes that toy theoretical frameworks—specifically the *noisy quadratic model* (NQM)—map remarkably cleanly onto these empirical interactions.
2. **Learning rates and parameter norms**: Hashimoto explains that learning rates in real neural networks are deceptively tricky because of their tight coupling with weight norms, a dynamic that surfaced in the course quiz.
3. **Advanced stability and preconditioning**: While subsequent lectures will delve into layer-wise learning rates, tailored initializations, and advanced preconditioning algorithms, the current focus remains on foundational hyperparameters.
---
[11:12](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=672s) Anatomy of AdamW and Decoupled Weight Decay
Hashimoto reviews the formulation of AdamW to contrast it with standard stochastic gradient descent (SGD). Standard SGD updates parameters directly along the current gradient:
$$\theta_{t+1} = \theta_t - \eta g_t$$
AdamW enhances this update through three distinct mechanisms:
```mermaid
flowchart LR
accTitle: Anatomy of AdamW Optimizer
accDescr: Diagram showing how stochastic gradients feed into momentum and second-moment preconditioning, combined with decoupled weight decay.
subgraph SGDPipeline["Gradient Accumulation"]
G["Gradient: g_t"] --> M["Momentum: m_t\n(Exp. Decaying Average)"]
G --> V["Preconditioner: v_t\n(Second Moments g_t^2)"]
end
subgraph UpdateStep["Parameter Update"]
M --> Ratio["m_t / (sqrt(v_t) + eps)"]
V --> Ratio
Ratio --> Step["theta_{t+1} Update"]
WD["Decoupled Weight Decay\n(Direct Step - eta * lambda * theta_t)"] --> Step
end
```
- **Momentum ($m_t$)**: Maintains an exponentially decaying moving average of past gradients to track directional persistence.
- **Preconditioning ($v_t$)**: Tracks the uncentered second moments ($g_t^2$) of the gradients. When gradients remain relatively constant across steps, $m_t$ and $\sqrt{v_t}$ roughly balance out, causing Adam to behave like sign SGD—stepping primarily based on the gradient's sign rather than its raw magnitude.
- **Decoupled weight decay ("W")**: Unlike classical L2 regularization, which adds $\frac{1}{2}\lambda \|\theta\|^2$ to the loss function and routes its derivative through the momentum and variance accumulators, AdamW applies weight decay directly to the parameters during the update step ($\theta_{t+1} = \theta_t - \eta \lambda \theta_t - \dots$). Hashimoto notes that keeping weight decay separate from the adaptive gradient machinery is critical to its behavior.
---
[13:39](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=819s) Deep Learning Optimization vs. Convex Optimization
Hashimoto contrasts the design philosophy of deep learning optimizers with traditional convex first-order optimization. In classical operations research, algorithms are designed to drive excess error ($\epsilon$) arbitrarily close to zero to guarantee globally optimal solutions (such as maximizing linear programming profits). In machine learning, however, irreducible statistical noise from data sampling means that chasing infinitesimal optimization error yields zero generalization benefit:
> “And so you're not looking for optimizers that will get you small excess error. You're looking for optimizers that will get you to this statistical indistinguishable regime as quickly as possible, right? And I sort of call this like loose or like, you know, noisy solutions very very quickly.”
SGD excels precisely because it navigates toward this statistically indistinguishable region rapidly, even if it cannot achieve high numerical precision.
Furthermore, deep learning optimizers are not required to converge on arbitrary convex or twice-differentiable functions—they only need to succeed on deep neural networks:
> “The second thing, and this is a major theme of today's lecture, is that deep learning optimizers do not need to work for everything, right? Like they do not need to work for the class of like, you know, twice differentiable convex functions. They only need to work for deep neural networks.”
Because neural network architectures and optimizers co-evolve, practitioners can modify the architecture to aid the optimizer or tailor the optimizer to architectural quirks. For instance, the **Hyperball** optimizer explicitly exploits the scale invariance introduced by layer normalization in modern transformers.
Finally, Hashimoto touches on the theoretical limits of adaptive optimizers. The original Adam paper contained a known flaw in its convergence proof; in fact, for any fixed $\beta_2 < 1$, adversarial convex counterexamples exist where Adam fails to converge. The failure mode occurs when tiny gradients cause the second-moment accumulator to shrink, blowing up the effective step size and kicking the parameters out of the optimum—a behavior directly mirroring sign SGD. Yet in real deep learning settings, these theoretical non-convergence counterexamples rarely hinder practical performance.
[17:15](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=1035s) Convexity vs. Deep Learning Priorities
```mermaid
flowchart LR
accTitle: Co-evolution of Architectures and Optimizers
accDescr: Cycle between architectural features that simplify optimization and custom optimizer designs that exploit network structures.
subgraph Arch["Architectural Design"]
A["Residual Connections & LayerNorm"]
B["Loss Surface Regularization"]
end
subgraph Opt["Optimizer Adaptation"]
C["Preconditioning & Block Hessians"]
D["Spherical Steps / Scale Invariance"]
end
A --> B
B -->|"simplifies optimization for"| C
C --> D
D -->|"motivates next-gen"| A
```
Addressing degenerate edge cases in optimization theory, Tatsunori Hashimoto points out that standard proofs rely on gradients diminishing toward zero at the minimum of a quadratic bowl. In contrast, an algorithm like SignSGD continues to oscillate at the bottom because its step sizes never naturally shrink based on gradient magnitude. Addressing a student comment regarding hyperparameter selection—where fixing parameters before observing the problem differs fundamentally from tuning hyperparameters to a known objective class—Hashimoto argues that in practice, practitioners select momentum terms ($\beta$) and learning rates relying on prior knowledge of problem curvature, exactly as one uses a Lipschitz constant:
> “I just sort of use this not as like a complaint, but more of like a difference in priorities, right? Like I don't think the priority in Adam was like ah yes it converges on every convex you know problem instance. It was more that, well, this is a good optimizer for deep neural networks.”
He emphasizes that language models are essentially never trained to first-order stationarity ($\nabla f(x) = 0$), making traditional convex asymptotic convergence proofs unreflective of actual deep learning concerns. Instead, deep learning evolves via a cyclical co-design process:
- **Architectural simplifications**: Innovations such as residual connections and LayerNorm flatten the loss landscape and make complex networks amenable to simple first-order methods.
- **Tailored optimizers**: Optimizers adapt directly to internal network properties, leveraging the scale invariance of parameters via spherical updates or exploiting the block-diagonal structure of the Hessian for structured preconditioning.
Hashimoto warns that optimization cannot be treated as a pure mathematical search for an universally optimal algorithm: “It's not that the math is not useful, it's that it's sometimes useful, right? So it's like even more complicated. It's like you can sometimes use math, but you have to know which math to use.” Practitioners must focus on macroscopic training dynamics—observing how loss curve trajectories transform when changing learning rates or batch sizes—before drilling down into the microscopic mechanics of parameter updates (such as $\mu\text{P}$ parameterizations).
[21:03](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=1263s) The Noisy Quadratic Model (NQM) and Critical Batch Size
Hashimoto introduces Part 1 of the lecture: deriving actionable heuristics from convex systems through the Noisy Quadratic Model (NQM), foundational work by Guodong Zhang, Roger Grosse, and collaborators. Instead of analyzing an idealized model with theoretical tools like Polyak averaging (which yields optimal convex rates that do not match neural network training reality), the goal is to evaluate vanilla, un-averaged SGD under stochastic noise. A standard quadratic formulation allows exact analytical solutions for optimization trajectories, enabling researchers to compute optimal batch sizes, momentum coefficients, and preconditioning dynamics.
The NQM successfully captures macro-level phenomena observed in empirical training benchmarks like CIFAR-10:
- **Noise-dominated small-batch regime**: At very small batch sizes, variance across samples dominates the local curvature. Here, learning rates scale strictly linearly with batch size without destabilizing training.
- **Momentum extension**: Incorporating momentum extends this linear scaling regime further, allowing stable scaling at larger batch sizes.
- **Diminishing returns and critical batch size**: Beyond a certain threshold—the critical batch size—the relationship between batch size and iteration speed breaks down; increasing batch size yields sharply diminishing returns in steps-to-convergence. The NQM derives dashed-line theoretical bounds for this threshold that match empirical deep learning data.
Mathematically, rather than tracking an arbitrary quadratic defined by an unstructured Hessian matrix $H$, the NQM simplifies the objective by diagonalizing $H$:
> “So when I say something like noisy quadratic model, probably, you know, the middle equation right here is like your first instinct, right? It's just like an arbitrary quadratic with a quadratic term $H$. But then we're going to do something really simple. We're just going to, you know, diagonalize this guy and put ourselves into this coordinate system that's already diagonalized.”
By rotating the system into the coordinate frame aligned with its principal axes, the analysis decouples into 1D independent quadratic subproblems along each eigenvector.
[025:49] Decoupled Coordinates in the Noisy Quadratic Model
To make the noisy quadratic model (NQM) mathematically tractable, Hashimoto introduces a crucial simplifying assumption: simultaneous diagonalizability. The quadratic objective has curvature represented by the matrix $H$ with eigenvalues/scales $h_i$, while the Gaussian gradient noise has covariance $C$. Hashimoto assumes that $C$ is axis-aligned with $H$, meaning both share the exact same eigenvectors. This rotation into a shared coordinate system eliminates all cross-talk across dimensions. Gradient descent can then be analyzed completely independently, coordinate by coordinate, for each coordinate $i \in \{1, \dots, d\}$.
```mermaid
flowchart LR
accTitle: "Simultaneous Diagonalization in NQM"
accDescr: "Input objective and noise are rotated into a shared eigenbasis, allowing coordinate-wise independent updates."
subgraph Coupled["Coupled Space"]
Q["Quadratic Curvature H"]
N["Noise Covariance C"]
end
subgraph Decoupled["Shared Eigenbasis"]
Coord1["Coordinate 1: h_1, c_1"]
Coord2["Coordinate 2: h_2, c_2"]
CoordD["Coordinate d: h_d, c_d"]
end
Q & N -->|"Simultaneous Diagonalization"| Decoupled
Coord1 --> S1["Independent GD Step"]
Coord2 --> S2["Independent GD Step"]
CoordD --> SD["Independent GD Step"]
```
Under this model, the role of mini-batching is straightforward: drawing an independent and identically distributed (IID) batch of size $B$ and averaging the gradients reduces the variance directly by a factor of $B$. As Hashimoto summarizes:
> “If we have this condition, life is really really simple because this means that you know both the noise and sort of the quadratic lives in the shared coordinate system.”
- Coordinate-wise independence allows analyzing gradient descent as $d$ separate 1D optimization problems.
- Averaging an IID batch of size $B$ divides the noise variance by exactly $B$.
- The framework sets up the baseline to evaluate plain SGD versus momentum SGD under noisy updates.
---
[027:32] Steady-State Loss and Critical Batch Size
Because the coordinates decouple completely, a 2D example can be visualized as two isolated problems: one steep coordinate and one flat coordinate. When running gradient descent with a fixed learning rate and a fixed batch size under constant noise, the optimization does not converge to the exact minimum. Instead, it enters a stationary distribution—analogous to Langevin dynamics—where the expected risk settles into a steady-state loss. This steady-state value is governed by a fundamental trade-off: decreasing the step size or increasing the batch size lowers the steady-state floor, but at the expense of convergence speed.
In classical convex optimization, one would employ intricate learning rate schedules to balance convergence rate against asymptotic error simultaneously. In deep learning practice, however, practitioners primarily tune coarse-grained knobs—a fixed learning rate and batch size—and accept suffering a non-zero steady-state loss. This mechanism directly explains the emergence of a critical batch size. While increasing $B$ reduces variance and permits using a larger learning rate, the learning rate cannot be scaled indefinitely; it is strictly bounded by the quadratic stability threshold of $2 / h_{\max}$, where $h_{\max}$ represents the sharpest curvature direction. Once the step size hits this stability wall, additional batching yields strongly diminishing returns because learning rate boosts are exhausted.
> “At this point additional batches don't help you at all because I mean you're going to get a little bit of reduction in the noise but you're not getting these learning rate boosts anymore right you've sort of hit the wall here.”
- Expected risk decomposes into a transient convergence term and an asymptotic steady-state loss term.
- Steady-state fluctuations behave like the stationary Gaussian distribution of a Langevin process at the bottom of the quadratic bowl.
- The theoretical maximum stable learning rate for a quadratic is $2 / h$, where $h$ is the maximum eigenvalue of the Hessian.
- Exceeding $2 / h$ causes the iterates to blow up catastrophically, creating a hard limit on batch-size scaling benefits.
---
[030:40] Momentum Regimes: Overdamped vs. Underdamped Dynamics
Hashimoto next incorporates momentum into the noisy quadratic framework. Rather than stepping directly in the direction of the stochastic gradient, momentum updates along an accumulated momentum buffer $M$, which aggregates both directional signal and noise over successive iterations. Analyzing expected risk under momentum yields a bound featuring two root terms, $R_1$ and $R_2$, which arise as roots of a quadratic characteristic equation governing the underlying second-order oscillatory system.
```mermaid
flowchart TD
accTitle: "Momentum Regimes in Optimization"
accDescr: "Momentum dynamics split into overdamped and underdamped regimes across different curvature directions."
A["Momentum SGD System"] --> B{"Regime"}
B -->|"High damping / low curvature"| C["Overdamped Regime"]
B -->|"Low damping / high curvature"| D["Underdamped Regime"]
C --> E["Smooth contour following; slowest converging direction"]
D --> F["Wild oscillations like a ball swirling in a bowl"]
E --> G["Rate-limiting factor for overall convergence"]
```
These dynamics bifurcate into two distinct physical regimes:
1. **The Underdamped Regime:** The parameters oscillate back and forth across the ravine, resembling a ball thrown into a bowl with too much velocity, swirling repeatedly before settling to the bottom.
2. **The Overdamped Regime:** The parameters glide smoothly along the contours without oscillating, closely mirroring standard gradient descent.
When balancing convergence speed and steady-state error across a spectrum of curvatures, different coordinates exhibit different behaviors. Critically, the overdamped directions converge much more slowly than the underdamped ones. As a result, the overdamped regime acts as the bottleneck for overall convergence, making its specific behavior the primary determinant of whether momentum actually accelerates training.
> “Why am I telling you all this? Well, it turns out that, you know, if you follow this logic, you know, the only thing that really matters in some of these regimes is the overdamped regime, right? This is the rate limiting step, and so we need to study the overdamped regime quite carefully in order to understand the benefits of momentum SGD.”
- Momentum transforms the discrete gradient update into a second-order linear dynamical system whose characteristic roots dictate stability and oscillation.
- If all coordinates were underdamped, performance would be suboptimal; an optimal configuration forces at least one direction into the overdamped or critically damped regime.
- Because overdamped coordinates exhibit the slowest decay rates, they form the rate-limiting bottleneck for multi-dimensional convergence in the NQM.
[34:27](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=2067s) The Transition Between Overdamped and Underdamped Dynamics
Tatsunori Hashimoto examines the optimization behavior across different momentum damping regimes, focusing on the boundary between the overdamped and underdamped regions. In the extreme overdamped regime, as the momentum parameter approaches zero, momentum optimization behaves essentially like stochastic gradient descent (SGD) running with an adjusted effective learning rate:
> “So over here, basically in the over-damped regime, you're not getting much more than plain old SGD, right?”
As one moves away from the extreme overdamped territory toward the boundary separating the overdamped and underdamped states, convergence rates improve, diverging upward from what standard SGD can achieve. Once the system crosses over into the underdamped regime, however, the convergence rate begins to fall off sharply. Hashimoto points out that when the dynamics become underdamped, the coordinates begin to oscillate around the minimum of the quadratic. That oscillation wastes optimization steps rather than bringing the parameter closer to zero. Therefore, if every coordinate sits in the underdamped regime, decreasing $\beta$ shifts the coordinates leftward on the phase diagram back toward the boundary, directly speeding up convergence.
```mermaid
flowchart LR
accTitle: Damping Regimes and Convergence Behavior
accDescr: Three regimes of momentum dynamics transitioning from overdamped through the optimal boundary to underdamped.
subgraph DampingRegimes["Momentum Damping Regimes"]
direction LR
A["Extreme Overdamped<br/>(beta near 0)"] -->|"Increase beta"| B["Optimal Boundary<br/>(Peak Convergence)"]
B -->|"Increase beta further"| C["Underdamped Regime<br/>(Oscillatory)"]
end
subgraph Dynamics["Observed Behavior"]
direction LR
D["Behaves like plain SGD<br/>at effective learning rate"]
E["Gains over SGD;<br/>fastest rate of descent"]
F["Oscillations waste steps;<br/>convergence slows down"]
end
A -.-> D
B -.-> E
C -.-> F
```
Hashimoto highlights two primary takeaways from this dynamic:
- In the heavily overdamped regime, momentum provides virtually no benefit over standard SGD.
- Significant convergence gains over SGD occur in the transition zone near the boundary between overdamped and underdamped behavior.
- Although SGD can theoretically match momentum via learning rate scaling under certain conditions, SGD faces a hard stability ceiling, which creates a window where momentum can deliver substantial speedups if that boundary prevents SGD from increasing its step size further.
---
[36:19](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=2179s) Audience Q&A: Stability Ceilings and Multi-Coordinate Tradeoffs
Opening the floor to questions, Hashimoto addresses whether these phase-diagram dynamics accurately capture language models. He clarifies that while he would not expect the exact phase diagram boundaries to map directly onto complex language models, the qualitative predictions generated by the Noisy Quadratic Model (NQM) hold remarkably well even at large scale.
A student asks why one cannot simply increase the SGD learning rate instead of relying on momentum. Hashimoto explains that convex quadratics impose a strict stability threshold:
> “There's a maximum learning rate that's achievable which is 2 over H, right?”
Exceeding $2/H$ (where $H$ represents the curvature or Hessian eigenvalue) causes the optimizer to bounce wildly back and forth across the valley and diverge. Momentum provides a way to realize effective learning rates beyond this boundary without triggering numerical instability.
Another student asks why the overdamped regime acts as the rate-limiting bottleneck across multiple coordinates. Hashimoto explains that because $\beta$ is a single scalar applied uniformly across all coordinates, tuning it forces an unavoidable tradeoff:
- If all coordinates are underdamped, one can globally decrease $\beta$ to improve the convergence rate of every single coordinate simultaneously.
- As $\beta$ continues to decrease, the highest-curvature directions will eventually strike the boundary and cross into the overdamped regime, where further decreases in $\beta$ slow them down.
- Consequently, the slowest-converging coordinate—the rate-limiting direction that dictates the ultimate loss reduction—will end up situated right at that boundary.
When asked why separate per-coordinate $\beta$ values cannot be assigned, Hashimoto points out that doing so requires preconditioning: knowing the exact curvature along each direction beforehand. The purpose of analyzing the NQM is deliberately to evaluate how a simple, handicapped optimizer navigates an unknown curvature landscape, rather than using algorithms like Newton's method that trivialize quadratic objectives.
---
[40:00](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=2400s) Batch Size Dictates When Momentum Helps
Hashimoto summarizes the mathematical takeaways of the NQM analysis by contrasting how batch size affects the usefulness of momentum. The irreducible error of the gradient estimate is determined by the batch size: in the small batch regime, this error is very high. To keep the steady-state irreducible error from exploding, the optimizer must use a very small learning rate. Because the base learning rate is kept small, momentum’s tendency to amplify effective step sizes offers no advantage and can actively trigger divergence.
Conversely, in the large batch regime, irreducible noise is minimal, allowing the base step size to be pushed right up to the maximum curvature limit. Here, momentum allows the optimizer to break past that SGD barrier, unlocking much larger effective step sizes and speeding up convergence:
> “So, you know, a concrete prediction that you might get from NQM is that in small batch cases, momentum, even though it's very natural, is not a very helpful idea.”
Hashimoto shows empirical data from the original NQM paper evaluating a language modeling task trained on roughly 1 billion tokens. The plot tracks the number of optimization steps required to hit a predefined target entropy as batch size varies:
- At small batch sizes, the curve for SGD (light green line) and the curve for Heavy Ball momentum (dark green line) lie almost on top of each other along the step-to-target tradeoff curve.
- As the batch size grows, the curves diverge substantially, with momentum and Adam achieving target entropy in far fewer steps than SGD.
- The same behavior is mirrored when comparing Heavy Ball to Adam: in noise-heavy regimes, sophisticated optimizers yield minimal gain over basic SGD, whereas denoised gradients at high batch sizes allow advanced algorithms to thrive, a pattern Hashimoto notes is visible on datasets like CIFAR-10 as well.
[43:02](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=2582s) Momentum at Small vs. Large Batch Sizes and GPT-3 at Batch Size 1
Examining empirical curves comparing optimizers across batch sizes, all algorithms agree tightly at the small batch end. Ignoring K-FAC for the moment, the algorithms shown in blue and green track each other almost identically. They only begin diverging once the batch size grows sufficiently large. At that point, a clear separation emerges: the algorithms equipped with momentum (plotted in darker shades) perform significantly better, matching the exact theoretical narrative derived from the noisy quadratic model (NQM).
```mermaid
flowchart LR
accTitle: Batch Size Regime and Optimizer Separation
accDescr: Diagram illustrating how optimizers perform identically at small batch sizes and diverge only at large batch sizes.
subgraph SmallBatch["Small Batch Regime (e.g., B = 1)"]
direction TB
SB1["Noise dominates"] --> SB2["SGD ≈ AdamW ≈ Momentum methods"]
end
subgraph LargeBatch["Large Batch Regime (B >> 1)"]
direction TB
LB1["Noise reduced by batching"] --> LB2["Momentum and preconditioning pull ahead"]
end
SmallBatch -->|"Increase batch size"| LargeBatch
```
Recent large-scale studies provide striking corroboration for this insight. A notable paper examining transformer training with very small batch sizes—specifically work associated with Andrew Gordon Wilson and Micah Goldblum—demonstrated that plain SGD at a batch size of 1 is remarkably competitive with sophisticated optimizers. While “no one is crazy enough to to want to do this normally, but if you have to, actually SGD is not terrible,” Tatsunori Hashimoto points out. Advanced optimizers certainly improve convergence rates in specific senses, but their true function is pushing the usable, parallelizable batch size far beyond what earlier methods could tolerate. When replicating the original GPT-3 training setup, the researchers found that SGD at batch size 1 closely matched the AdamW training trajectory:
> “Like I think, you know, no one is crazy enough to to want to do this normally, but if you have to, actually SGD is not terrible, right?” — Tatsunori Hashimoto
This reveals that at batch size 1, omitting complex bells and whistles incurs surprisingly little penalty, defying the common intuition that advanced optimizers are vastly superior across every operational regime.
- **GPT-3 replication findings**: Training curves using simple SGD at batch size 1 roughly matched the baseline AdamW curve reported in the original GPT-3 paper.
- **Hardware and systems tradeoffs**: A student raises the benefits of batch size 1, prompting Hashimoto to note that while batch size 1 has generalization advantages in data-constrained settings, it is computationally awful from a systems and hardware perspective because large batch sizes are required to parallelize effectively across accelerators (topics treated extensively in CS 336: Language Modeling from Scratch).
---
[45:41](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=2741s) Preconditioning Trade-offs in the Noisy Quadratic Model
The noisy quadratic model also offers a clear lens for analyzing preconditioning. In preconditioned gradient descent, the noisy gradient within the brackets is multiplied by a preconditioning matrix $P$ before stepping. Rather than modeling the full complexity of Adam directly, preconditioning can be analyzed by setting $P$ proportional to a power of the true Hessian, $H^p$.
```mermaid
flowchart TD
accTitle: Preconditioning Noise-Curvature Tradeoff
accDescr: Tradeoff between convergence rate and steady-state error as preconditioning power increases.
P["Preconditioner P = H^p"]
P -->|"Increase p toward 1"| CR["Convergence Rate strictly improves"]
P -->|"Increase p toward 1"| SS["Noise blown up along low-curvature dimensions"]
SS --> ERR["Steady-state error gets worse"]
CR --> BAL["Requires large batch size B to suppress noise"]
```
Because $H^{-1}$ represents the ideal, optimal preconditioner—the equivalent of running gradient descent on an isotropic unit Gaussian—the exponent $p \in [0, 1]$ parameterizes the strength and quality of preconditioning. Setting $p = 0$ corresponds to unconditioned descent, whereas $p = 1$ yields perfect preconditioning:
> “So stronger preconditioning makes steady state worse in this case. Whereas this first term, which is the convergence rate, strictly improves as we improve the quality of the preconditioner, as we make the preconditioning stronger, right?” — Tatsunori Hashimoto
In the noiseless convex setting, aggressive preconditioning accelerates convergence unequivocally. In the noisy setting, however, stretching a skinny, low-curvature dimension to make the quadratic spherical amplifies gradient noise along that exact dimension. Stronger preconditioning worsens the steady-state error while improving the initial convergence rate. When the batch size $B$ is small, steady-state noise dominates, preventing the use of strong preconditioning without destroying late-stage error. Only when large batch sizes suppress the gradient noise term can training harvest the convergence speedups of aggressive preconditioning.
- **Preconditioning parameterization**: $P = H^p$, where $p=0$ indicates no preconditioning and $p=1$ indicates full, perfect Hessian preconditioning.
- **Empirical validation**: Comparing Adam (blue curves) against momentum/SGD baselines (green curves) illustrates that preconditioning gains materialize strictly in large-batch regimes; all methods lie on the same diagonal convergence line at small batch sizes until reaching individual batch size ceilings.
- **Utility in scaling laws**: The NQM formulation has been successfully incorporated into modern scaling laws to account for changing batch sizes during parameter scaling.
---
[49:43](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=2983s) The Limits of the Quadratic Mental Model
Despite its success in building intuition, the noisy quadratic model has definitive boundaries that practitioners must respect. It serves as effective “mental math” for reasoning about how hyperparameters interact with batch sizes and noise, but deep learning optimization landscapes regularly display behaviors absent from quadratic theory.
```mermaid
flowchart LR
accTitle: Quadratic Model vs Deep Learning Reality
accDescr: Contrast between smooth convergence in quadratics and the jagged edge of stability in deep networks.
subgraph Quadratic["Quadratic Model (No Momentum)"]
Q1["Step size within limit"] --> Q2["Smooth, monotonic convergence"]
Q3["Step size too large"] --> Q4["Immediate explosive divergence"]
end
subgraph DeepLearning["Deep Learning Reality (Edge of Stability)"]
D1["Cranked learning rate"] --> D2["Jagged, oscillatory loss"]
D2 --> D3["Rapid, stable net convergence"]
end
```
In standard quadratic optimization without momentum, increasing the learning rate either produces smooth convergence or causes catastrophic, oscillatory divergence. In real neural networks, however, running full-batch gradient descent at high learning rates often produces a highly jagged, oscillating loss curve that nevertheless converges rapidly. This phenomenon—the edge of stability—cannot be explained within a static quadratic model:
> “Don't assume that um deep learning optimization landscapes are like noisy quadratics, right? That's not a fully accurate uh model.” — Tatsunori Hashimoto
The noisy quadratic model should therefore be treated as a valuable rule of thumb for understanding trade-offs in noise, preconditioning, and momentum, rather than a literal depiction of non-convex neural network loss surfaces.
- **Failure mode of the quadratic intuition**: In deep networks, full-batch gradient descent can exhibit severe, sustained loss oscillations while continuing to make steady overall optimization progress.
- **Next topic preview**: The lecture transitions from the limits of quadratic models to parameter norms, layer normalization, weight decay dynamics, and spherical projection methods such as Hyperball.
[51:50](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=3110s) Noise, Batch Size Limits, and Learning Rate Schedules in the NQM
A student asks whether injecting artificial noise could allow pushing optimization to larger batch sizes, referencing Hashimoto's previous model where preconditioning eventually lets optimization bounce across the parabola and wondering if noise might regularize this effect. Tatsunori Hashimoto rejects this idea, explaining that noise strictly hurts performance by raising the steady-state loss term without improving expected convergence rates. He emphasizes that the causality runs in reverse: increasing the batch size reduces effective noise, unlocking more aggressive optimization.
When the student notes that earlier discussions showed saturation at a certain batch size, Hashimoto clarifies the distinction between learning rate limits and batch size scaling. Learning rate has an upper bound set by the maximum curvature, past which stability collapses. Batch size, however, exhibits a softer transition: once the learning rate can no longer be increased, expanding the batch yields strongly diminishing returns. Adding noise does not help because this transition wall is governed by stability and the underlying quadratic curvature, not by noise. Another student observes that training error splits into convergence and steady-state components, suggesting one could train fast early on and reduce the steady-state loss late by dropping the learning rate. Hashimoto confirms this is the precise justification for learning rate schedules and notes it mirrors classical convex optimization results like Polyak averaging.
> “After you hit this point where the learning rates can't be increased anymore, then batch sizes have very strong diminishing returns.” — Tatsunori Hashimoto
- **Artificial noise:** Does not move the batch size stability boundary; it merely degrades final performance by strictly increasing steady-state error.
- **Batch size ceiling:** Diminishing returns occur once the batch size is large enough to support the maximum stable learning rate permitted by the curvature.
- **Learning rate schedules:** Theory predicts annealing the learning rate late in training suppresses steady-state error after fast early convergence.
---
[55:00](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=3300s) Scale Invariance and Weight Norm Growth from Layer Norm
Hashimoto transitions to the second part of the lecture, connecting back to a class quiz where students observed parameter norms steadily growing when training without weight decay. He sets out to explain both the causal mechanism behind norm growth and why it matters for modern frontier optimization algorithms. The root cause lies in the scale invariance introduced by normalization layers such as LayerNorm and RMSNorm, which project activations onto the unit ball before applying learned gains. Because normalization layers are used ubiquitously throughout modern architectures—such as pre-norm or QK-norm—scaling a linear weight tensor up or down has no effect on the layer's output. Consequently, the loss is invariant to the parameter norm.
Because the loss does not change radially, gradients on a scale-invariant parameter lie purely tangent to the sphere defined by the current weight vector. Taking a gradient step along this tangent inevitably pushes the weight vector outward into a higher-norm sphere. When weight decay is present, it acts as a restoring force pulling the weights back toward the origin, establishing a dynamic equilibrium where tangent outward drift balances inward decay. Hashimoto illustrates this using an animation of a toy objective pointing "north" without any norm penalty. Trajectories with identical weight decay converge to the exact same equilibrium norm regardless of whether they initialized with high or low norms, whereas a run without weight decay (orange curve) suffers unbounded norm growth as oscillations push the weights steadily outward. While transformers contain non-scale-invariant components like the output head, their scale-invariant internal layers naturally exhibit this drift unless stabilized by weight decay.
```mermaid
flowchart LR
accTitle: Balance of forces on scale-invariant weights
accDescr: Tangent gradient steps increase parameter norms while weight decay pulls them inward toward an equilibrium radius.
subgraph Forces["Parameter Update Forces"]
direction TB
G["Tangent Gradient Step<br/>(Drives norm outward)"]
W["Weight Decay<br/>(Pulls norm inward)"]
end
subgraph State["Weight Norm Dynamics"]
direction TB
E["Equilibrium Norm<br/>f(Learning Rate, Weight Decay)"]
U["Unbounded Growth<br/>(Zero Weight Decay)"]
end
G -->|"Balanced with"| W
W -->|"Reaches steady state"| E
G -->|"No decay present"| U
```
> “If I move along this tangent line, I'm obviously leaving the sphere, right? So I get norm that is slightly greater than the sphere.” — Tatsunori Hashimoto
- **Root cause of norm drift:** Scale-invariant operations (like RMSNorm) eliminate radial gradient components; tangent update steps strictly increase the Euclidean norm of the weight matrix.
- **Counteracting force:** Weight decay provides an inward pull toward the origin, establishing an equilibrium norm determined jointly by the learning rate and weight decay coefficient.
- **Architecture nuances:** While internal transformer blocks with pre-norm or QK-norm are largely scale invariant, components such as the final output unembedding head are not.
---
[59:28](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=3568s) Norm Growth Shrinks the Effective Step Size
Having explained *why* the norm expands, Hashimoto addresses the practical impact: if the loss function is mathematically invariant to the weight norm, does the drift actually matter? He explains that growing norms drastically destabilize training dynamics by diminishing the effective step size of the optimizer. Citing work by Roger Grosse and collaborators, Hashimoto points out that for scale-invariant layers, the effective learning rate or step size is proportional to the nominal learning rate divided by the squared parameter norm:
As the parameter norm $\|\theta\|$ blows up, the effective step size continuously shrinks, causing optimization to slow to a crawl and breaking the user's direct control over the effective schedule.
> “And what's going to happen is that bigger norms is going to then lead to smaller gradients or smaller effective step sizes. And this is going to sort of mess with your training dynamics in ways that are very unpleasant.” — Tatsunori Hashimoto
- **Effective learning rate formula:** Scales inversely with the square of the parameter norm ($\eta / \|\theta\|^2$).
- **Optimizer side effects:** Uncontrolled norm growth silently decays the true step size over training time, masking the intended learning rate schedule and degrading training speed.
[01:00:18](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=3618s) Norm Drift and the Loss of Learning Rate Control
When parameter norms grow, the angular update sizes become progressively smaller, shrinking the model's effective step size. From a pure loss perspective in an idealized scale-invariant toy problem, the absolute parameter norm does not matter. However, it matters immensely for optimization because drifting norms quietly alter update magnitudes under the hood. As established in earlier assignments, carefully tuning the learning rate is paramount; when parameter norms drift without oversight, the optimizer essentially robs the practitioner of direct control over that schedule. Tatsunori Hashimoto emphasizes that practitioners should not accept arbitrary norm growth, warning: “My norm growth is not fully controlled by me and yet it's somehow controlling my effective step size, right?”
Returning to the toy model under a realistic learning rate schedule, Hashimoto contrasts the nominal hyperparameter target against what the network actually experiences. If the learning rate remained fixed at any given moment, the system would seek a specific equilibrium norm, represented by a theoretical dashed target line. In practice, however, the actual trajectory lags behind this moving equilibrium. Because the accumulated norms remain higher than desired throughout this lag, the actual norm-modulated steps—the effective learning rates—end up substantially lower than the nominal schedule specified by the user. This persistent mismatch motivates both dynamic weight decay strategies and alternative optimization algorithms designed to exert strict, deliberate control over the effective step size.
```mermaid
flowchart TD
accTitle: Parameter Norm Drift and Effective Learning Rate
accDescr: Diagram showing how parameter updates increase norm, which shrinks angular updates and suppresses the effective learning rate.
- When the learning rate schedule changes over time, the theoretical norm equilibrium shifts dynamically rather than staying constant.
- Because parameter adjustments take time to track shifting targets, parameter norms lag behind equilibrium, depressing effective learning rates during critical training phases.
---
[01:02:28](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=3748s) Scale Invariance in Transformers: LayerNorm, QK-Norm, and the Output Head
A student asks how the time-invariant structure of weight decay interacts with changing learning rates, leading Hashimoto to point out that when running at a fixed learning rate $\eta$, the norm settles into an equilibrium proportional to $(\frac{\eta}{2\lambda g^2})^{1/4}$. Another student asks whether real transformer architectures exhibit true invariance to parameter norms. Hashimoto clarifies that while transformers are not strictly scale-invariant across every single layer, they sit extremely close to full scale invariance due to modern architectural conventions. Pre-LayerNorm ensures that the scale of the residual stream has virtually no bearing on downstream activations, and normalized query and key projections (QK-norm) render attention weights invariant to parameter scaling.
The primary exception to scale invariance is the final unnormalized linear output head. Because this projection feeds straight into the softmax layer, its magnitude directly dictates the logits and sets prediction confidence. Hashimoto explains: “The output head linear, right, goes straight into the softmax, and that represents confidence, right? And we do actually want to be able to control confidence, so that's not layer norm.” As a consequence of widespread normalization layers throughout the rest of the model, standard $L_2$ Euclidean distance is not the natural metric for understanding internal representation shifts; deep networks predominantly operate through angular changes rather than raw metric distance. When asked why the optimal learning rate scales inversely with the squared norm rather than linearly, Hashimoto points out that pulling out the two angular components from the Hessian-like curvature expression naturally factors out two powers of the norm.
- Pre-LayerNorm normalizes inputs before attention and feedforward blocks, insulating intermediate activations from residual stream norm inflation.
- QK-norm normalizes query and key vectors, making attention matrices invariant to the scaling of query/key projection weights.
- The final linear classification head is deliberately kept unnormalized so the network can scale its output logits to express calibrated prediction confidence.
- Transformer parameter space is geometrically better understood through angular distances on a sphere rather than standard Euclidean displacement.
---
[01:05:16](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=3916s) Dynamic Weight Decay with AdamC and Historical Evidence
To resolve the issue of shifting equilibria, Aaron Defazio introduced the AdamC optimizer, which treats weight decay as a dynamic quantity rather than a static hyperparameter. In AdamC, weight decay is scaled inversely with the learning rate schedule by multiplying a base weight decay by the ratio of the peak learning rate to the current learning rate:
By coupling $\lambda_t$ to the learning rate $\eta_t$, the time-varying components cancel out in the equilibrium formula, pinning the gradient-to-weight ratio and freezing the theoretical equilibrium norm at a static constant across the entire training run.
Hashimoto underscores that investigating parameter norm dynamics is a long-standing foundation of deep learning science, remarking: “I think reasoning about parameter norm growth in training dynamics is like not, you know, a very not a very like exciting thing to talk about if you're thinking about like you know, the the abilities of AI or something. But you know, like this is actually a really important sort of component of deep learning phenomena.” Work dating back to Van Laarhoven in 2017 established the predictable mathematical linkage between learning rates, weight decay, and parameter norms. More recently, D'Angelo et al. studied weight decay in one-pass language model pretraining—a setting where overfitting is absent and classical $L_2$ regularization is unnecessary. They proved that weight decay functions primarily as an effective learning rate controller: when recording the effective learning rate trajectory of a run using standard weight decay, one can completely disable weight decay (setting it to zero) on a second run, manually replicate that recorded effective learning rate schedule, and achieve virtually identical loss curves.
- In AdamC, scaling weight decay inversely with the learning rate schedule stabilizes the theoretical parameter norm equilibrium at a fixed target throughout training.
- Historical analyses demonstrate that weight decay accomplishes multiple distinct roles simultaneously, with parameter norm regulation being among the most critical.
- Empirical experiments by D'Angelo et al. in single-pass LLM pretraining verify that setting weight decay to zero and directly copying the effective learning rate trajectory from a decayed run fully reproduces the original training performance.
[01:08:29](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=4109s) Roger Grosse's Remark and the Subtlety of Transformer Norm Invariance
Tatsunori Hashimoto recaps that weight decay acts predominantly as an effective learning rate controller, which fundamentally changes model behavior during optimization. Leveraging this insight, he explores how optimizers can be improved by directly manipulating parameter norms. Throughout the lecture series, Hashimoto draws on Roger Grosse's work on neural network training dynamics, recommending Grosse's lectures to the class. He highlights a prescient slide where Grosse made an offhand observation:
> “Well, you know, we know that the norm's pretty important. Has anyone tried just projecting all of these weights to unit norm all the time? Well, then we just perfectly control the learning rate, so that seems good.”
Although projecting weights to a unit ball after every step sounds inherently silly at first glance, Hashimoto points out that when executed carefully, it works remarkably well. However, applying normalization across an entire transformer architecture requires handling critical subtleties, because transformers are not completely scale invariant:
- **Output Head**: The norm of the unembedding or output layer directly encodes prediction confidence (softmax logits). Normalizing these weights destroys logit calibration.
- **Normalization Parameters ($\gamma$)**: Normalizing layer norm or RMSNorm scaling parameters ($\gamma$) robs the architecture of its ability to regulate the output scale of internal layers.
- **Embeddings**: In token and word embeddings, geometric norms often represent token frequency or categorical significance; constraining them alters representation capacity.
- **Internal Weights**: Pure scale invariance lives within the internal matrices—specifically attention projections ($W_Q, W_K, W_V, W_O$) and feedforward MLP blocks—that are bounded by normalization layers.
---
[01:10:31](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=4231s) The Hyperball Optimization Framework
To exploit scale invariance cleanly, Hashimoto introduces Hyperball, an optimization strategy gaining significant traction across industrial AI research labs. Rather than projecting blindly to the unit sphere, Hyperball sets a target radius $r$ equal to the Frobenius norm of the weights at initialization ($\|W_0\|_F$). Drawing on earlier discussions of initialization scaling, Hashimoto reminds the class that initial matrices are already scaled precisely to maintain forward signal propagation and backward gradient stability.
```mermaid
flowchart LR
accTitle: Hyperball Step Workflow
accDescr: Base optimizer generates an update, which is normalized onto a unit ball, added to weights, and then projected back onto the initialization Frobenius radius.
subgraph Update["Update Processing"]
A["Base Optimizer<br/>(e.g., AdamW, Muon)"] -->|"Emits step $U_t$"| B["Direction Normalization<br/>$U_t / \|U_t\|$"]
end
subgraph Projection["Parameter Update & Projection"]
B -->|"Step onto weights"| C["Update Weights<br/>$W_{t+1/2} = W_t - \eta \hat{U}_t$"]
C -->|"Project back"| D["Project to Radius<br/>$\|W_{t+1}\|_F = r = \|W_0\|_F$"]
end
```
Hashimoto situates Hyperball among related geometric and manifold optimization approaches:
- **Weight Normalization (Salimans & Kingma, 2016)**: Disentangling directional vectors from scalar magnitudes via explicit reparameterization.
- **Column-wise Unit Norm Constraints**: Constraining matrices column-by-column rather than across the global Frobenius ball (a substantially tighter constraint).
- **Manifold Gradient Descent (Jeremy Bernstein)**: Enforcing matrix manifold invariants during optimization, such as preserving orthogonality ($W^\top W = I$).
- **Independent Discoveries**: Because the underlying dynamics are so impactful, multiple independent teams formulated spherical projection schemes around the same time, though Grosse anticipated the concept years earlier.
---
[01:13:08](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=4388s) Empirical Results and Scaling Behavior
Empirical evaluations confirm that spherical projections deliver clear advantages over standard baselines. Variants like AdamH and MuonH (the Hyperball counterparts to AdamW and Muon) show consistent, statistically significant reductions in validation loss across scale. Hashimoto emphasizes to students who completed Assignment 1 that even seemingly minuscule margins in pretraining cross-entropy represent tangible performance gains.
```
Weight Norm over Steps Loss Convergence
Norm ^ Loss ^
| / Standard Optimizer (drifts) | \ Standard (AdamW / Muon)
| / | \
r |--===================== Hyperball | \== AdamH / MuonH (consistently lower)
+---------------------------> Steps +---------------------------> Steps
```
When a student asks about a peculiar artifact in the curves—specifically, *“Is there a reason Adam restarts decreasing again after step 30 or something?”*—Hashimoto answers without hesitation:
> “Learning rate schedule. Yeah. Whenever whenever you see like some strange learning curve behavior, it's it's usually learning rate schedule.”
---
[01:14:05](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=4445s) Hyperparameter Transfer and External Replication
Beyond raw validation improvements, Hashimoto highlights that maintaining weight norms at a constant radius aids hyperparameter transfer across model scales. In standard training, expanding model width and depth shifts the dynamics into a higher-dimensional sphere, causing weights to drift at unpredictable rates. Because weight growth depresses the effective learning rate ($\eta_{\text{eff}} \approx \eta / \|W\|^2$), optimal learning rates change between small and large runs. Hyperball reduces this drift, yielding a broader and more forgiving plateau of functional learning rates across scale.
Recent replication work from researchers at EPFL underscores the generality of these findings:
- Evaluated optimal learning rate sweeps and demonstrated that Muon and Adam constrained to spherical geometries reliably outperform their unconstrained baselines.
- Proposed alternate strategies that jointly tune magnitude and direction parameters, confirming that regulating weight scale dynamics stabilizes hyperparameter transfer.
In closing this topic, Hashimoto reflects on why tracking seemingly obscure diagnostic curves is essential for deep learning practitioners:
> “And of course hyperball I think is a is a super deep learning specific optimization trick, right? Like you can't apply this to an arbitrary convex optimization problem.”
By dissecting the precise non-convex interactions between optimizer updates and transformer architectural scale invariance, researchers can move beyond generic convex optimization principles and engineer bespoke algorithms suited to modern deep learning dynamics.
[01:16:33](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=4593s) Re-evaluating Weight Decay and Effective Learning Rate
Tatsunori Hashimoto explains that the relationship between models and optimizers runs both ways: model architectures can inspire specialized optimization techniques, and novel optimizers can inform what architectural choices or model constraints are beneficial. Bringing together the themes of the second half of the lecture, he highlights a fundamental misconception about regularization in modern deep learning practice. In traditional statistical learning, weight decay is taught as a tool for restricting model capacity to prevent overfitting. However, in contemporary large language model pretraining—which operates almost exclusively in the one-pass, streaming data regime—this standard interpretation breaks down completely.
Instead, weight decay acts primarily as a thermostat for the effective learning rate by counterbalancing the outward drift of parameter norms caused by layer normalization. As parameter norms balloon, the effective step size contracts proportionally to the square of the norm, inadvertently throttling optimization. Hashimoto warns practitioners against letting this drift happen unchecked, noting that manipulating weight decay often functions as a proxy for manipulating the learning rate itself. Algorithmic interventions—whether by scaling weight decay in lockstep with the learning rate schedule (as in AdamC) or directly constraining weights to a fixed manifold (as in Hyperball)—restore tight control over the effective step size, yielding measurable improvements in both training stability and loss.
As Hashimoto summarizes: “In the one-pass setting, what weight decay is primarily doing is controlling the effective learning rate of your optimization process.”
- In one-pass training settings, weight decay does not control classical model complexity.
- Tuning weight decay can produce effects functionally interchangeable with tuning the learning rate schedule.
- Algorithmic control over norm drift prevents unwanted decay in the effective learning rate, directly boosting optimizer performance and cross-scale predictability.
---
[01:17:25](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=4645s) The Interplay of Theory, Empirics, and Deep Learning Science
Reflecting on the entire lecture, Hashimoto underscores the messy, hybrid nature of progress in deep learning optimization. The field cannot rely purely on mathematical abstraction, nor can it operate as blind trial-and-error empiricism. The first part of the lecture leaned heavily on theoretical abstractions like the noisy quadratic model (NQM), which yield clean, powerful intuitions about critical batch sizes and momentum dynamics, but ultimately operate within a limited, idealized scope. The second part shifted to an empirical, diagnostic approach—analyzing raw weight-norm trajectories across training runs to deduce why scale-invariant architectures exhibit effective step-size decay.
Borrowing an observation from Roger Gross’s lecture notes, Hashimoto reflects on why deep learning science is so uniquely demanding. The difficulty does not stem from neural networks being fundamentally mysterious or inscrutable black boxes, but rather from how difficult it is for researchers to identify which subtle physical phenomena inside the network actually dictate performance and deserve formal modeling. Something as seemingly mundane or cosmetic as weight norm drift can easily be dismissed as an arbitrary implementation artifact, yet it turns out to govern effective learning rates across billions of parameters. To build meaningful algorithms or prove relevant theorems, theorists and algorithm designers must possess sharp empirical instincts for what is genuinely taking place inside the network during training.
As Hashimoto puts it when describing the core challenge of the discipline: “Deep learning science is just very challenging, not because like, you know, deep learning is inscrutable per se, but because it's just really difficult to know what the right phenomenon and the right model is, right?”
```mermaid
flowchart TD
accTitle: The Cycle of Deep Learning Science
accDescr: Diagram illustrating the feedback loop between theoretical models, empirical observation of network phenomena, and algorithm design.
subgraph Theory ["Theoretical Abstraction"]
NQM["Noisy Quadratic Model & Curvature"]
end
- High-level theory like the noisy quadratic model provides valuable foundational intuition about batch sizing and momentum, but fails to capture scale invariance or norm drift.
- Empirical observations of internal network metrics (such as layer-by-layer Frobenius norms) are essential for diagnosing where theoretical assumptions diverge from practice.
- Successful deep learning research requires a tight feedback loop where empirical findings dictate which phenomena are worth formalizing into new optimization algorithms and architectural constraints.
## Notable quotes
> [01:16:33](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=4593s) In the one-pass setting, what weight decay is primarily doing is controlling the effective learning rate of your optimization process. — Tatsunori Hashimoto
> [13:39](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=819s) deep learning optimizers do not need to work for everything, right? Like they do not need to work for the class of like, you know, twice differentiable convex functions. They only need to work for deep neural networks. — Tatsunori Hashimoto
> [51:50](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=3110s) After you hit this point where the learning rates can't be increased anymore, then batch sizes have very strong diminishing returns. — Tatsunori Hashimoto
> [01:17:25](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=4645s) Deep learning science is just very challenging, not because like, you know, deep learning is inscrutable per se, but because it's just really difficult to know what the right phenomenon and the right model is, right? — Tatsunori Hashimoto
> [49:43](https://www.youtube.com/watch?v=wdjnAOrS7f8&t=2983s) Don't assume that um deep learning optimization landscapes are like noisy quadratics, right? That's not a fully accurate uh model. — Tatsunori Hashimoto
## Mentioned
Tatsunori Hashimoto, Roger Grosse, Andrew Gordon Wilson, Micah Goldblum, Jeremy Bernstein, Tim Salimans, Diederik Kingma, Van Laarhoven, D'Angelo et al., Guodong Zhang, SGD, Adam, AdamW, AdamC, AdamH, Muon, MuonH, Hyperball, SignSGD, Noisy Quadratic Model (NQM), LayerNorm, RMSNorm, GPT-3, K-FAC, Stanford University, EPFL, CS 336: Language Modeling from Scratch
## Video description
Browse Stanford's online courses in deep learning: https://stanford.io/4zhLWFN
Why does mini-batch SGD, a weak algorithm by convex optimization standards, work so well for deep learning? In this Stanford CS312: Deep Learning Alchemy lecture, Assistant Professor Tatsunori Hashimoto breaks down the anatomy of an optimizer: learning rate, batch size, preconditioning, momentum, and AdamW. He uses the noisy quadratic model to explain critical batch size and when momentum pays off, then turns to norms and weight decay, showing how layer norm makes weight norms grow and why weight decay mainly controls the effective learning rate. He closes with Hyperball, which projects weights onto a fixed-radius sphere.
Key questions answered in this lecture:
Q: What is the noisy quadratic model in deep learning optimization?
A: A diagonalized quadratic loss with gradient noise whose covariance is aligned with the curvature, so each coordinate can be analyzed separately and batching divides the noise variance by the batch size. Hashimoto uses it to analyze plain SGD, momentum and preconditioning, trading convergence rate against steady-state loss.
Q: Why does increasing batch size stop speeding up training?
A: Larger batches reduce noise and allow bigger learning rates, but the learning rate cannot exceed the stability limit of 2 over the largest curvature. Past that point, extra batches give strongly diminishing returns, which is the critical batch size.
Q: Does momentum help SGD at small batch sizes?
A: The NQM predicts momentum adds little at small batch sizes, where noise forces small learning rates, and helps mainly at large batch sizes. Experiments agree, and SGD at batch size 1 roughly matched the AdamW training curve for GPT-3 style training.
Q: Why do weight norms grow in transformers and why does it matter?
A: Layer norms make the loss nearly scale invariant, so gradients lie tangent to the sphere and each step pushes the norm outward until weight decay balances it. Bigger norms shrink the effective step size (learning rate over norm squared), so you lose control of your learning rate.
Q: What does weight decay do in LLM pretraining?
A: In one-pass training, Hashimoto argues weight decay mainly controls the effective learning rate, not model complexity, and tuning it can act like tuning the learning rate. AdamC makes weight decay scale with the learning rate schedule to keep the norm equilibrium constant.
Q: What is the Hyperball optimizer?
A: Take a base update such as AdamW or Muon, normalize it, step, then project the weights back onto a ball whose radius is the Frobenius norm at initialization, leaving embeddings, norm gains and the output head unprojected. AdamH and MuonH were consistently better at scale and gave easier hyperparameter transfer.
Chapters:
0:00 Why optimization matters in deep learning
3:09 Anatomy of SGD: LR, batch, preconditioning
8:06 Momentum: heavy ball and Nesterov
11:12 AdamW recap and decoupled weight decay
13:39 Deep learning vs convex optimizers
22:03 The noisy quadratic model (NQM)
27:32 Steady-state loss and critical batch size
30:40 Momentum: overdamped vs underdamped
41:33 Momentum helps only at large batch sizes
45:41 Preconditioning tradeoffs in the NQM
49:43 Limits of the quadratic mental model
55:00 Why parameter norms grow: layer norm
59:28 Norm growth and effective learning rate
1:08:42 Hyperball: projecting weights to a sphere
About the speaker:
Tatsunori Hashimoto is an Assistant Professor of Computer Science at Stanford University and a faculty affiliate of the Stanford Institute for Human-Centered Artificial Intelligence (HAI). His research uses tools from statistics to make machine learning systems more robust and reliable, especially for language. He also teaches CS336: Language Modeling from Scratch. He was a postdoc at Stanford with John Duchi and Percy Liang, earned his PhD at MIT, and studied statistics and math at Harvard.
Readings:
- Zhang et al. (2019), Which Algorithmic Choices Matter at Which Batch Sizes?: https://arxiv.org/abs/1907.04164
- Weight decay blog: https://whenwen.github.io/wd_blog/public/weight-decay-part-2.html
- Hyperball: https://arxiv.org/abs/2606.16899
Course website: https://deep-learning-alchemy.github.io/
Watch the full CS312 playlist: https://www.youtube.com/playlist?list=PLXRTcAYPI4AU
Recorded October 1, 2026, in CS312: Deep Learning Alchemy, a Stanford University course taught by Tatsunori Hashimoto and Suhas Kotha.
Tatsunori Hashimoto argues that modern deep learning optimization fundamentally diverges from classical convex theory, as practitioners prioritize rapid navigation to statistically indistinguishable loss regions over infinitesimal error minimization. Through analytical frameworks like the Noisy Quadratic Model and empirical analyses of architectural scale invariance, the lecture demonstrates how batch size, momentum, preconditioning, and weight decay interact to govern effective learning rates.
Convex Optimization Assumptions vs. Deep Learning Reality (13:39)
Classical optimization theory centers on driving excess optimization error arbitrarily close to zero, often relying on asymptotic guarantees like Polyak averaging or Nesterov acceleration. In contrast, Hashimoto explains that machine learning training operates under irreducible data-sampling noise, meaning chasing exact numerical stationarity (where the gradient equals zero) delivers no generalization benefit. Language models are virtually never trained to first-order stationarity, and optimizers do not need to work across all twice-differentiable convex objectives.
Instead, neural network architectures and optimizers co-evolve. Practitioners frequently introduce architectural features such as normalization layers to assist optimizers, or tailor optimizers to architectural quirks. Algorithms like SignSGD or Adam do not shrink step sizes naturally based on gradient magnitude at the bottom of a quadratic bowl, yet they succeed because deep learning prioritizes reaching acceptable, noisy parameter spaces rapidly rather than achieving exact stationarity.
The Noisy Quadratic Model and Critical Batch Size (21:03)
To derive actionable heuristics for real training setups, Hashimoto examines the Noisy Quadratic Model (NQM) developed by Guodong Zhang, Roger Grosse, and collaborators. By assuming the quadratic Hessian and noise covariance share an eigenbasis (simultaneous diagonalizability), the model decomposes optimization into independent one-dimensional coordinates. In this system, stochastic optimization settles into a stationary distribution where decreasing the step size or expanding batch size lowers the steady-state error floor at the expense of convergence speed.
This framework explains the emergence of a critical batch size. At small batch sizes, gradient noise dominates, and the learning rate scales linearly with batch size. As batch size expands, variance diminishes until the learning rate hits the classical quadratic stability threshold of 2 over the maximum curvature ($2/h_{\max}$). Beyond this critical threshold, increasing the batch size yields sharply diminishing returns. Hashimoto notes that momentum and aggressive preconditioning offer minimal benefits in noise-dominated small-batch regimes, but become critical at large batch sizes by accelerating convergence once variance is sufficiently suppressed.
Momentum Dynamics Across Curvature Bottlenecks
Analyzing momentum within the NQM framework reveals a characteristic second-order dynamic split into two regimes: an underdamped regime, where parameters oscillate across steep ravines like a ball swirling in a bowl, and an overdamped regime, where parameters slide smoothly without oscillating. Because a single momentum scalar is applied uniformly across coordinates of varying curvature, tuning momentum forces a trade-off among different dimensions.
If all coordinates sit in the underdamped regime, reducing the momentum parameter speeds up convergence by curbing wasted oscillations. However, as momentum decreases, the highest-curvature directions hit the boundary and enter the overdamped regime, where progress slows. Consequently, the slowest-converging, overdamped direction becomes the rate-limiting bottleneck for the network's overall loss reduction. While momentum allows practitioners to bypass basic SGD stability ceilings without triggering divergence, its advantage appears only when batch sizes are large enough to keep irreducible noise from destabilizing the expanded effective step size.
Scale Invariance and Weight Norm Drift (55:00)
Turning to empirical training dynamics, Hashimoto explores why parameter norms continuously grow in networks using normalization layers like LayerNorm and RMSNorm. Because these layers render internal operations invariant to parameter scale, radial gradients vanish, and updates occur strictly tangent to the parameter sphere. These tangential steps naturally push the parameter vector outward into higher-norm spheres, systematically eroding direct control over the training run.
This outward drift has severe practical consequences: work cited from Roger Grosse and collaborators shows that for scale-invariant layers, the effective step size scales inversely with the squared parameter norm ($\|\theta\|^2$). As norms balloon, effective learning rates silently decay, slowing optimization to a crawl. In one-pass language model pretraining—where overfitting is absent—weight decay does not act as classical L2 capacity regularization. Instead, it serves as a restoring force balancing outward tangent steps, functioning primarily as a thermostat that stabilizes the effective learning rate.
Controlling Effective Step Sizes with Spherical Projections
To overcome the shifting equilibria caused by norm growth, alternative optimizers explicitly regulate parameter magnitudes. Dynamic schemes like Aaron Defazio’s AdamC scale weight decay inversely with the learning rate schedule to pin the equilibrium norm across the entire training run. Taking this principle further, the Hyperball framework projects internal weight matrices directly back onto a hypersphere defined by their initialization Frobenius radius after every update step.
Because transformers are not globally scale-invariant, Hashimoto emphasizes that spherical projections must be applied selectively. While internal attention and feedforward weights can be constrained, output heads (which encode prediction confidence into softmax logits), normalization gain parameters, and token embeddings cannot be projected without degrading model capacity. When applied to appropriate layers, spherical projection methods like AdamH and MuonH yield statistically significant improvements in validation loss and broaden the plateau of stable learning rates across model scales.
Hashimoto concludes that advancing deep learning requires bridging mathematical theory with empirical network diagnostics. While models like the NQM clarify interactions between noise, batch sizes, and momentum, they fail to capture non-convex phenomena like the edge of stability. The central challenge of deep learning science lies not in overcoming an inscrutable black box, but in identifying which subtle internal dynamics—such as weight norm growth—actually dictate performance and warrant formal modeling.
Source quotes
[76:33] Tatsunori Hashimoto: In the one-pass setting, what weight decay is primarily doing is controlling the effective learning rate of your optimization process.
[13:39] Tatsunori Hashimoto: deep learning optimizers do not need to work for everything, right? Like they do not need to work for the class of like, you know, twice differentiable convex functions. They only need to work for deep neural networks.
[51:50] Tatsunori Hashimoto: After you hit this point where the learning rates can't be increased anymore, then batch sizes have very strong diminishing returns.
[77:25] Tatsunori Hashimoto: Deep learning science is just very challenging, not because like, you know, deep learning is inscrutable per se, but because it's just really difficult to know what the right phenomenon and the right model is, right?
[49:43] Tatsunori Hashimoto: Don't assume that um deep learning optimization landscapes are like noisy quadratics, right? That's not a fully accurate uh model.
Original transcript
[0:05] Okay. Uh we will get started. Um now we
[0:08] get to talk about some more fun stuff.
[0:10] Um optimizers.
[0:12] But actually we're also going to talk
[0:13] about hyperparameters. You can never
[0:14] truly escape the hyperparameters,
[0:16] unfortunately. So uh we will start
[0:18] talking about some much more interesting
[0:20] and nuanced
[0:22] uh internals of models and optimizer uh
[0:25] behavior. Um but really we're going to
[0:27] do it partially in the context of
[0:29] hyperparameters.
[0:31] Okay. So we're going to be spending uh
[0:33] decent amount of time on optimizations.
[0:35] I think four lectures and two
[0:37] assignments. Um and the reason why we're
[0:39] going to do so is because optimization
[0:41] is is just really central to you know
[0:43] machine learning. Machine learning is
[0:44] about putting data into models and then
[0:46] training these models. The optimizer is
[0:48] what makes the loss go down, right? So
[0:50] um the optimization you know is
[0:53] essentially an enormous uh influence on
[0:55] both the compute savings that we get and
[0:57] also as we'll see later the
[0:59] generalization properties of these
[1:01] models. And so understanding
[1:02] optimization and optimization dynamics
[1:04] is kind of the first step or a critical
[1:06] step in understanding deep learning uh
[1:08] as a whole.
[1:10] And you know we've seen you know really
[1:12] significant improvements going from you
[1:14] know SGD to Adam and then from Adam to
[1:17] Muon. Each one of these gains you know
[1:19] has resulted in very significant
[1:20] improvements in um uh compute efficiency
[1:25] of training large-scale models. Um
[1:26] especially language models and other
[1:28] kinds of foundation models where you're
[1:30] you know essentially very very compute
[1:31] capped. And so having a slightly more
[1:33] efficient optimizer would be very very
[1:35] valuable.
[1:37] Of course um optimization is is not
[1:40] something that's specific to machine
[1:41] learning, right? Optimization is you
[1:44] know a very old very well-studied field.
[1:47] Um in machine learning because of
[1:49] various you know aspects of machine
[1:51] learning we almost always end up doing
[1:53] first-order optimization, right? We look
[1:55] at the gradients and we use the
[1:56] gradients in certain clever ways to
[1:58] build an optimizer.
[2:00] So too has, you know, a very deep and
[2:02] like, you know, well understood field of
[2:05] study in convex optimization, right?
[2:07] This is the set of like first order
[2:08] optimization algorithms. Um, you know,
[2:11] if you're interested in this, you know,
[2:12] you've got convex here, which is a
[2:14] lovely course. You know, John has really
[2:16] nice lecture notes on like what's the
[2:17] best achievable algorithms, like minimax
[2:19] optimal algorithms for certain kinds of
[2:23] optimization settings. And there's like
[2:24] lots of really beautiful mathematical
[2:26] methods, right? Mirror descent, Frank
[2:28] Wolfe, all these kinds of things.
[2:30] And then we're going to ignore this
[2:31] entire literature, right? Because it
[2:33] turns out that you can do much much
[2:35] better if you're willing to do
[2:37] kind of very practical but very ugly
[2:39] ugly things, right? And really most of
[2:41] the field is just variations of mini
[2:43] batch stochastic gradient descent, which
[2:45] I think if you look at it from the lens
[2:46] of like convergence rates for
[2:48] optimization is like just kind of a
[2:49] terrible algorithm.
[2:51] Um, but it's not terrible for deep
[2:52] learning, right? And let let's kind of
[2:54] separate things, you know, like it's not
[2:55] like the deep learning people don't
[2:56] really understand how to do
[2:57] optimization. It's really that this is a
[2:59] very specialized, you know, narrow
[3:01] subset of optimization problems. And it
[3:03] turns out that the the specific things
[3:05] that we do here turns out to be very
[3:08] good idea.
[3:09] Okay.
[3:10] And so I'm going to give a very very
[3:12] very rough intro to optimization, at
[3:15] least from the deep learning lens. I'm
[3:17] sure all of you have taken machine
[3:18] learning and many of you will have taken
[3:20] convex.
[3:21] And so this is like not particularly,
[3:24] you know,
[3:25] deep or anything like that. But I'll
[3:27] I'll give you sort of my view of like
[3:28] what are the important variations, what
[3:29] are we going to talk about. It's going
[3:30] to inform,
[3:32] you know, why and how I'm going to
[3:33] structure the rest of the lecture here.
[3:36] Um, really the basic SGD update that we
[3:38] have is extremely simple. It's like
[3:40] really the prototype of a first order
[3:41] optimization algorithm, right? We're
[3:43] just going to have our parameters and
[3:45] we're going to update it by descending
[3:46] in the gradient direction. Yes, this is
[3:48] stochastic gradient descent.
[3:50] Really the only thing is just, you know,
[3:51] their gradients are noisy in some way
[3:53] usually because of the sampling
[3:54] structure. We have a big data set that's
[3:56] independent and identically distributed.
[3:58] And what we're going to do is we're
[3:59] going to sample some random collection
[4:00] of those guys and then take the gradient
[4:02] with respect to that.
[4:03] Cool. But then it's going to turn out
[4:05] that there's lots of important
[4:06] variations for us to think about, like
[4:08] how do we think about this learning rate
[4:09] thing? How do we think about the noise
[4:11] structure coming from this mini batch
[4:13] structure? Um and then you've got lots
[4:15] of advanced choices, like what is a
[4:16] preconditioner? Like what do we use? Or
[4:19] momentum? Like is that good? How do we
[4:21] use it? And you know, they're going to
[4:22] result in very different behaviors. I'll
[4:23] go through, you know, different subsets,
[4:25] but like depending on various choices
[4:26] that you might have here, you know,
[4:28] you're going to end up with very
[4:29] different optimization trajectories even
[4:31] on something as simple as a as a
[4:32] quadratic optimization problem, right?
[4:34] Um
[4:35] so today's lecture is going to be
[4:37] focused on some subset of these choices
[4:39] and trying to have a good mental model
[4:42] uh for, you know, what's happening in
[4:43] deep learning and why we sort of do
[4:45] certain things in deep learning
[4:47] optimization.
[4:49] Okay. Um so the first thing that we are
[4:51] going to think about and something that
[4:53] you've already played with and so you
[4:54] have hopefully some familiarity is
[4:56] thinking about learning rates and batch
[4:58] sizes. Um normally if you're thinking
[5:00] about classic convex optimization, you
[5:02] know, you're going to be told something
[5:03] like well, you know, there's a maximum
[5:05] stable learning rate and you want to
[5:06] pick certain kinds of learning rate
[5:08] schedules in order to converge in
[5:09] stochastic settings. Um but it's not
[5:11] like there's very specific prescriptions
[5:13] for what this needs to be. Um and then
[5:15] batch size, like what's the right
[5:17] tradeoff between stochasticity um and
[5:20] sort of the the compute that we're going
[5:21] to expend um in computing gradients for
[5:24] this batch, right? Um and of course
[5:25] we're going to scale things up and down,
[5:27] so these are all going to interact
[5:28] somehow with the scale of our model and
[5:30] our compute budget and all of these
[5:31] things. Um and if you look at kind of,
[5:33] you know, the um optimization
[5:36] trajectories here, you know, you can get
[5:37] some like pretty wildly different
[5:39] behaviors. Like this purple or sorry,
[5:40] this orange thing that just straight up
[5:42] diverges is like, you know, learning
[5:44] rate too big, but everything else is
[5:46] going to converge in sort of different
[5:47] ways. And you can think about like,
[5:49] okay, like which one of these is
[5:50] actually the right choice if we're
[5:51] optimizing a deep neural network and not
[5:53] like a random quadratic uh as we have
[5:55] here.
[5:57] So this is the most basic thing and
[5:58] maybe some of you are like I already
[5:59] know uh how all of this is done, um but
[6:02] there are actually going to be some
[6:03] really interesting ways of thinking
[6:05] about learning rate uh and batching.
[6:07] Okay.
[6:09] Another thing that we can do, and this
[6:10] is just very important, you know, both
[6:12] for classic optimization theory and for,
[6:15] you know, the theory of deep learning
[6:17] optimization is preconditioning, right?
[6:19] We don't have to descend along the
[6:20] gradient as it is literally. Um we can
[6:22] precondition it using a matrix A, that's
[6:24] the red letters over there. Um and that
[6:26] can sort of change the coordinates, so
[6:28] to speak, in which we're descending. Um
[6:31] and so, you know, practically if we're
[6:33] thinking very algorithmically what this
[6:34] A let me do, you know, you can now have
[6:36] learning rates, so to speak, that are
[6:38] faster or slower per parameter by
[6:39] scaling the gradients upward down. You
[6:41] can decorrelate the parameters, like if
[6:43] two parameters are in like this very
[6:45] narrow valley, you can kind of rotate
[6:47] the Gaussian and scale them so that
[6:49] you're kind of going down a really nice
[6:50] quadratic, not a really skinny one.
[6:52] Um and maybe most importantly for the
[6:54] purpose of kind of a lot of these deep
[6:57] learning optimizers is that you can
[6:58] learn them on the go. Um you know, as
[7:00] you're kind of descending down, you can
[7:02] kind of look at your gradients and say,
[7:03] okay, like does it look like I'm in a
[7:05] certain kind of a
[7:06] a quadratic quadratic? Um how should I
[7:09] be shaping my preconditioner in order to
[7:11] be able to descend um quickly? And you
[7:14] can kind of see that this would have a
[7:15] huge impact in practice. Like a normal
[7:17] gradient descent on this, you know, kind
[7:19] of narrow quadratic is going to bounce
[7:22] back and forth on one of this one of
[7:24] these directions, the narrower of the
[7:25] two directions. Um whereas if you
[7:27] precondition this thing by sort of
[7:29] scaling the quadratic, you know, now
[7:30] we're going to see some really nice uh
[7:33] sort of straight descent along sort of
[7:35] the steepest direction of this actual
[7:36] quadratic uh shape, right? I mean, this
[7:39] is really an idealized case, but you can
[7:40] kind of see that if you're in these kind
[7:42] of narrow valleys, preconditioning can
[7:44] really really help you uh converge. And
[7:46] it does have a huge impact in practice.
[7:48] Um we'll once again see how to think
[7:51] about preconditioning in the context uh
[7:53] of uh deep neural networks. And And A
[7:56] can be pretty arbitrary as long as
[7:57] you're um positive semi-definite and
[7:59] you've got sort of bounded eigen values,
[8:01] right? Which means it we have a huge
[8:02] design space of how we're going to
[8:04] precondition uh gradient descent.
[8:07] Okay.
[8:08] Um and then finally, you know, we've got
[8:11] momentum. And momentum is kind of the
[8:13] analogy here, of course, is something
[8:15] like a heavy ball rolling down a hill.
[8:16] You've probably seen this already in
[8:18] like machine learning 101.
[8:20] But really the thing that happens here
[8:22] is that you can now accelerate faster
[8:24] than just adding up your gradients
[8:26] because you carry over state, right?
[8:28] Like if you're moving in the same
[8:29] direction, that sort of accumulates in
[8:30] the second term and you go faster and
[8:32] faster and faster.
[8:34] And you know, this both in terms of
[8:36] practical convergence is very helpful.
[8:38] But if you're looking at the theory of
[8:39] first order optimization and you, you
[8:41] know, think about things like Nesterov
[8:43] acceleration, you can get like striking
[8:45] improvements in convergence rate, right?
[8:47] You can actually go from like 1 over t
[8:49] to 1 over t squared, you know, it's a
[8:50] really beautiful result.
[8:52] You know, as with most things in deep
[8:53] learning, like you don't actually need
[8:54] to use Nesterov acceleration, you can
[8:56] just use heavy ball, which is this thing
[8:57] over here.
[8:59] But you know, this does have a huge
[9:00] impact in practice, right? We do want to
[9:01] think about momentum and how to make
[9:03] good use of it.
[9:05] Importantly, and this will come up,
[9:07] you know, in a few slides down in the
[9:08] lecture,
[9:10] in momentum you can kind of think about
[9:11] two different phases. You can have
[9:14] underdamped phase in which you're kind
[9:15] of oscillating back and forth where your
[9:17] momentum values are very high. If you
[9:19] make your momentum small enough, it
[9:21] actually won't oscillate. It'll kind of
[9:22] go down this sort of
[9:24] hill sort of more smoothly. And those
[9:26] two phases actually have pretty
[9:27] important implications for how we think
[9:29] a little bit about, you know, the role
[9:31] of momentum in deep learning
[9:33] optimization.
[9:35] Okay. So those are kind of the
[9:36] components. Actually, if anyone has
[9:37] questions, feel free to ask about them
[9:39] before I move on.
[9:42] But we're going to sort of think about
[9:43] some of these like components in very
[9:45] specific concrete questions that I'm
[9:47] going to instantiate
[9:49] over the next, you know, two sections of
[9:51] this this lecture.
[9:55] Okay.
[9:56] So you know, I the this design space of
[9:59] optimizers is too big and like the set
[10:02] of, you know, all training dynamics
[10:03] things is too rich for me to cover
[10:05] in just, you know, two lectures here.
[10:09] But what I'm going to do is um, I'm
[10:12] going to cover a few of these useful and
[10:14] tractable questions to sort of motivate
[10:16] us to study important phenomena.
[10:18] Um, so first I'm going to look at the
[10:21] batch size. You've already looked at the
[10:23] batch size, but it turns out that you
[10:25] know, the batch size have these really
[10:26] interesting interactions with these
[10:28] other optimizer components. It interacts
[10:30] with the preconditioner, it interacts
[10:32] with the momentum terms, and the ways in
[10:34] which this interact actually turn out to
[10:36] be um, really cool in that some very
[10:39] simple theoretical or toy models of
[10:41] optimization um, called the noisy
[10:43] quadratic model um, map on very cleanly
[10:47] to sort of these intuitions. And then
[10:49] we're going to talk about um, just kind
[10:51] of like the learning rate. This is even
[10:53] more simple, but actually it turns out
[10:55] even the notion of a learning rate in a
[10:57] real deep neural network training run is
[10:59] actually it's more complex than you
[11:01] think. And so we're going to talk about
[11:03] you know, the interaction between
[11:04] learning rates and norms. You saw this
[11:06] in the quiz um, on and all this stuff.
[11:08] Um, in the next lecture um, I'm going to
[11:11] talk about you know, some different
[11:12] stuff. I'm going to talk about things
[11:13] like you know, varying learning rates
[11:15] and initializations per layer to make
[11:17] things more stable or you know, like
[11:19] sort of more advanced ideas and how to
[11:21] precondition uh,
[11:22] our optimizers. But you know, we'll
[11:24] leave that for later. We'll start with
[11:25] the basics, which is much more
[11:27] hyperparameters.
[11:28] Um,
[11:30] I was debating whether or not I could
[11:31] just skip you know, defining Adam, but I
[11:33] figured that it would be good just to
[11:34] put it up here um, so that you have it
[11:37] fresh in your mind because I'm going to
[11:38] talk about Adam a little bit um, in the
[11:41] lecture. Although really a lot of the
[11:43] ideas are abstracted out. So the basic
[11:44] SGD is at the top right. Everyone knows
[11:46] what that is. Um, in Adam W um, adds a
[11:49] few different components. It adds a
[11:51] momentum term um, through this M of T
[11:54] object and it adds a preconditioning
[11:56] term through this V of T object. Um, and
[11:59] what is it doing? Well, the M of T is
[12:00] really tracking an exponentially
[12:02] decaying average of the past uh,
[12:05] gradients plus a sort of cumulative
[12:07] history. Um, and then V of T is tracking
[12:10] kind of the second moments, like the
[12:11] squared terms of these gradients, right?
[12:13] GT squared.
[12:15] Then you're kind of dividing. Um and so
[12:17] one of the intuitions that you can have
[12:18] about uh Adam W, and this is not, you
[12:20] know, important to the lecture, but
[12:22] general sort of, you know, ways of
[12:24] thinking about it is that if you're sort
[12:26] of unchanging, if the gradients are all
[12:28] constant, these things are kind of going
[12:30] to cancel out. Actually, there should be
[12:31] a square root. Um these things should
[12:34] actually cancel out so that you end up
[12:35] with kind of a sign SGD behavior. Um so
[12:37] you're just going to descend on the sign
[12:40] of the gradient rather than on the
[12:41] magnitude of the gradient. And we'll see
[12:43] how that relates to some of these other
[12:45] ideas about sort of like norm
[12:46] constrained optimization. And finally,
[12:48] the W part of Adam W um comes from uh
[12:52] essentially this what's called decoupled
[12:53] weight decay. It's the second term where
[12:55] you're adding weight decay as part of
[12:57] the update rather than rolling it into
[12:59] the objective where you would take
[13:00] derivatives against it and this, you
[13:02] know, weight decay term would, you know,
[13:04] normally filter through all of this sort
[13:05] of momentum machinery, but in Adam W you
[13:08] just kind of don't do that and you add
[13:09] weight decay much more directly. Once
[13:11] again, we'll talk about why this kind of
[13:13] more specific update form is maybe an
[13:15] interesting and important object to to
[13:18] be dealing with.
[13:19] Okay, so this is Adam W. Um probably the
[13:23] most popular optimizer still even with
[13:25] things like Muon around. Um so it's
[13:27] useful to understand the mechanics of
[13:29] what this thing is actually doing.
[13:32] So now I've sort of shown you, you know,
[13:35] SGD or, you know, you could even put up
[13:37] like Adagrad or Nesterov acceleration.
[13:39] Um and that's like classic convex first
[13:41] order optimizer. And then, you know, we
[13:43] had uh Adam on the bottom. Um so there's
[13:46] I think big important conceptual
[13:47] differences between deep learning
[13:49] optimizers and sort of more traditional
[13:52] uh
[13:53] algorithms derived in first order uh
[13:55] optimization. Um and, you know, it's not
[13:59] that all um sort of convex optimization
[14:01] based optimizers like don't follow
[14:04] these, but there are sort of differences
[14:06] in the way I think people uh
[14:08] think and try to get algorithms. So the
[14:10] first one is that in a lot of these like
[14:13] just general machine learning problems,
[14:15] you don't really want really exact
[14:17] solutions. I think the history of like
[14:18] operations research and things is, you
[14:20] know, you have this epsilon, which is,
[14:21] you know, your tolerance to which you've
[14:23] optimized your your optimization
[14:25] problem, and you want to send epsilon to
[14:27] really really small. Like you want to
[14:28] make sure that you're like, you know,
[14:29] getting the the maximum profits in your
[14:32] like linear allocation problem or
[14:33] whatever, right? You don't want to leave
[14:35] any profits on the table. But um you
[14:37] know, in machine learning, basically you
[14:39] have an irreducible error, right? You're
[14:41] sampling this data and you're training
[14:42] this model. So you have this uncertainty
[14:44] about what the the best predictor is, no
[14:46] matter how good your optimizer is,
[14:48] right? And so you're not looking for
[14:50] optimizers that will get you small
[14:52] excess error. You're looking for
[14:53] optimizers that will get you to this
[14:55] statistical indistinguishable regime as
[14:57] quickly as possible, right? And I sort
[14:59] of call this like loose or like, you
[15:01] know, noisy solutions very very quickly.
[15:03] SGD is very good at this, right? Like it
[15:04] won't get you to these tiny epsilons
[15:06] very good very well, but it will get you
[15:08] to a reasonable solution very very fast.
[15:11] Um the second thing, and this is a major
[15:13] theme of today's lecture, is that deep
[15:15] learning optimizers do not need to work
[15:17] for everything, right? Like they do not
[15:18] need to work for the the class of like,
[15:20] you know, twice differentiable convex
[15:22] functions. They only need to work for
[15:23] deep neural networks. And this is like
[15:26] an important point because you can
[15:27] actually also change the network, right?
[15:29] So you can like co-evolve both the
[15:31] architecture and the optimizer together,
[15:34] right? If the optimizer is not working
[15:35] well, you can change the architecture,
[15:37] and if the architecture is not working
[15:38] well, you can also change the optimizer.
[15:40] This co-evolution has happened over many
[15:42] years. And so, you know, a lot of these
[15:45] um deep learning optimization tricks
[15:47] that that we'll talk about are also
[15:48] exploiting specific aspects of deep
[15:51] neural networks and training dynamics
[15:53] and all of these things. Um and so uh
[15:56] something I'll mention at the the near
[15:58] the end of this lecture here called
[15:59] Hyperball is really like kind of really
[16:01] going to the extreme. It exploits the
[16:03] fact that, you know, transformers have
[16:05] these layer norms, and the layer norms
[16:07] have very particular structure, and so
[16:08] we can design our optimization to
[16:10] exploit that structure.
[16:13] Okay.
[16:14] Um
[16:15] so, you know, I think one the
[16:17] differences here um is
[16:20] like
[16:21] the optimizers that we use in deep
[16:22] learning like don't have a lot of the
[16:25] the properties or in some ways they do,
[16:27] but the ways in which we use them are
[16:29] not in the in the ways that where we try
[16:30] to make them converge. So, um it turned
[16:33] out that the original um Adam paper had
[16:35] a convergence bug, a convergence proof
[16:37] bug. It's actually not that material um
[16:40] in the sense that uh if you crank the
[16:43] beta two parameter sufficiently, I think
[16:45] high um you can get every Adam to
[16:48] converge on every convex instance. Um
[16:50] but you can actually show that for like
[16:52] every beta value that there exists some
[16:54] like convex function on which this thing
[16:56] does not converge. Really the failure
[16:58] case is that you can get it to fall into
[17:00] a cycle where your gradients are very
[17:03] close to zero that blows up the second
[17:05] um moment term and then sort of that
[17:08] pushes uh the um optimizer out of the
[17:11] bottom. Like, you know, the sine SGD
[17:13] analogy is actually not too wrong here
[17:15] in that normally you converge on
[17:16] quadratics because the gradients get
[17:18] small as you get to the bottom, but if
[17:20] you're doing sine SGD you're always just
[17:21] going to oscillate on the bottom, right?
[17:22] So you can kind of imagine lots of
[17:24] degeneracies of this form. Um but once
[17:26] again, I mean I don't think it really
[17:28] mattered that you know the Adam
[17:30] convergence proof was wrong. Um you know
[17:32] in LLM I don't think I've ever seen an
[17:34] LLM trained to first order stationarity.
[17:36] Like this is just not a thing that we
[17:37] really care about very much. Yes.
[17:39] >> You know to to the point that you
[17:40] mentioned, like choosing your betas
[17:43] after you fix the problem is
[17:44] fundamentally very different from
[17:46] choosing the problem after you fix the
[17:47] parameters.
[17:49] >> Sure, yeah, but like you know you have a
[17:50] problem class. You can pick a beta
[17:52] subject to like your knowledge about the
[17:53] curvature of the problem or something.
[17:55] So like I do think like you know in some
[17:57] abstract sense like it's fine that you
[17:59] continue or like there exists some betas
[18:00] that will let you converge. It's no
[18:02] different than like you know picking
[18:04] your learning rate knowing that you have
[18:05] some Lipschitz you know smoothness. So I
[18:07] do think this is all fine. I just sort
[18:09] of use this not as like a complaint, but
[18:12] more of like a difference in priorities,
[18:14] right? Like I don't think the priority
[18:16] in Adam was like ah yes it converges on
[18:18] every convex you know problem instance.
[18:20] It was more that, well, this is a good
[18:22] optimizer for deep neural networks.
[18:26] And so yeah, I think one of the things
[18:29] that we will end up seeing in quite a
[18:30] bit is, you know, we have architectures
[18:32] that are easy to optimize, right? And
[18:34] what does it mean to be easy to
[18:35] optimize? They're easy to optimize using
[18:38] first-order methods that that we often
[18:39] use. And so things like the residual
[18:41] connection or layer norm or all of these
[18:43] things,
[18:44] you know, essentially make the the life
[18:46] easier for the optimizer. And then, you
[18:49] know, on the flip side now, you know,
[18:50] once we have these architectures set,
[18:53] now we're going to design our optimizers
[18:55] to accelerate training, you know, we
[18:56] might exploit, you know, essentially
[18:58] scale invariance of certain parameters
[19:00] and so do updates on the sphere. We
[19:02] might notice that certain kinds of like
[19:04] Hessians of the objective have block
[19:06] structure, right? And so we might be
[19:07] able to pre-condition in certain ways
[19:10] and get further acceleration.
[19:12] And so these are sort of ongoing cycles
[19:14] that you see. And this is why I think
[19:16] you you kind of get this very different
[19:18] evolution for deep learning optimizers
[19:21] compared to
[19:22] more general purpose, let's call them,
[19:24] optimizers.
[19:27] Okay.
[19:28] So I think optimization is just very
[19:32] complicated because of this. It's not as
[19:34] simple as like, oh, like what's the
[19:35] fastest converging optimizer? Like what
[19:38] is the mathematical framework under
[19:40] which we can derive the best optimizer?
[19:42] This is just not really, you know, the
[19:45] way I would think about this.
[19:47] You know, in this classic framework,
[19:48] like things like Adam are are not
[19:50] obviously good ideas. But also I think
[19:52] the thing that makes this actually
[19:53] complicated is that it's not that the
[19:55] math is not useful, it's that it's
[19:57] sometimes useful, right? So it's like
[19:59] even more complicated. It's like you you
[20:00] can sometimes use math, but you have to
[20:02] know which math to use. And it's like,
[20:03] well, but which math should we be using?
[20:06] That's the intuition part that hopefully
[20:07] you get partially out of this class,
[20:08] right?
[20:10] So then as part of this, you know, I
[20:13] think an important thing for you all to
[20:14] do is to understand the macroscopic
[20:16] behavior, not like the bottom-up
[20:18] behavior of like, oh, this optimizer
[20:19] takes these steps. You kind of want to
[20:21] understand like, okay, when I change the
[20:23] grade, what is happening to the
[20:24] optimizer, right? Like how does the loss
[20:26] curve change, shapes change? What does
[20:28] that mean about the macroscopic behavior
[20:30] is happening with these optimization?
[20:32] And this is the kind of perspective that
[20:34] we'll take in the lecture as well. And
[20:36] once we have this view, then we can go
[20:38] backwards to to kind of the like the
[20:39] micro level and say okay, we know these
[20:41] top-down behaviors are true. Now what is
[20:44] actually happening mechanically in the
[20:46] the optimization updates, right? So
[20:49] we'll answer some of these questions as
[20:50] we go through the lecture, not all of
[20:51] them. Like for example, this bottom one
[20:53] is really about like mu p, which I don't
[20:55] talk about yet,
[20:57] but you'll see some of these themes
[20:58] throughout this lecture today.
[21:01] Cool. Okay.
[21:03] So part one, we can think of as like
[21:05] convex intuitions as their limits. We're
[21:07] going to take the simplest possible
[21:08] convex system,
[21:10] add some noise to it, and then we're
[21:12] just going to analyze it as if it was
[21:14] the real world. But we're not going to
[21:15] go about it in terms of the classic kind
[21:17] of convergence analyses. We're going to
[21:19] do so
[21:20] in this like very kind of handicapped
[21:22] way that turns out to give us the right
[21:24] set of answers.
[21:26] And this is the noisy quadratic model.
[21:27] That's our first part. And then the
[21:28] second part is going to be we're going
[21:30] to drill down on that quiz question that
[21:32] we gave you about parameter norms and
[21:33] them growing and how they interact with
[21:35] weight decay. And then that will lead us
[21:38] to a particular class of optimizers. And
[21:40] this will be kind of
[21:41] almost a case study of how, you know,
[21:43] understanding the internals and the
[21:45] training dynamics of a neural network
[21:47] can lead you to to interesting new
[21:49] algorithms.
[21:50] Cool. Okay, any questions so far? I can
[21:52] pause for one moment and then I'll just
[21:54] get started on part one if there's no
[21:55] questions.
[22:00] Okay.
[22:01] [snorts]
[22:04] So what we're going to start with is the
[22:06] the noisy quadratic model. And this is
[22:08] kind of like, you know, you start with
[22:10] the simplest possible systems. Like what
[22:12] is what is the simplest possible sort of
[22:14] toy model of the world that we could use
[22:16] in optimization? It's the quadratic,
[22:18] right? The quadratic is really quite
[22:20] nice.
[22:21] You know, we can solve for many of the
[22:23] quantities exactly. Like you can solve
[22:25] for the optimization dynamics on a
[22:27] quadratic for SGD like almost exactly.
[22:30] Um, because of this, you can sort of
[22:32] back out things like, what is the
[22:33] optimal batch going to be? Like how do I
[22:35] set my batch size or momentum or any of
[22:37] these other parameters? Like all of
[22:39] these are very tractable in the
[22:40] quadratic world. So that's great. That
[22:42] can give us, you know, precise
[22:43] predictions.
[22:45] Um, and quadratics have been very useful
[22:47] in just general convex optimization.
[22:49] This is how we think about things like
[22:51] preconditioning, right? And so I think
[22:53] it's very natural to take something as
[22:55] simple as a quadratic and then say, all
[22:57] right, can we take the quadratic and
[23:00] then use that as a way to get intuition
[23:02] about training dynamics in real neural
[23:05] networks? Um, and I'm going to be
[23:06] working off of, you know, this paper by
[23:09] Roger and Grosse and others um, that has
[23:11] really kind of stood the test of time. A
[23:13] lot of people uh, sort of training
[23:15] models like think about, you know, the
[23:16] noisy quadratic model in terms of like
[23:18] rough rules of thumb and intuition about
[23:20] how things behave.
[23:22] Of course, you know, one caveat is going
[23:23] to be that, you know, we're not going to
[23:26] like actually try to solve this problem.
[23:27] Like if we try to solve this as like a,
[23:29] you know, theorist, what we're going to
[23:30] say is something like, oh yes, you know,
[23:32] what you need is a very specific kind of
[23:34] optimizer with Polyak averaging and then
[23:36] we'll get these rates. Turns out that's
[23:37] not what you want to do. You don't want
[23:39] to solve this problem exactly. We want
[23:41] to take vanilla SGD and analyze its
[23:43] behavior on this uh,
[23:45] problem.
[23:47] Okay. So why should we sort of think
[23:49] about NQM? Well, it turns out the NQM
[23:52] makes some very basic predictions that
[23:54] are fairly accurate um, and has sort of
[23:57] implications. Um, so we know that, you
[24:00] know, in some critically low batch sizes
[24:03] where like, you know, the batch size is
[24:04] really teeny tiny, um, you're noise
[24:06] limited, right? The noise of each of the
[24:08] gradient examples that you get is
[24:10] dominating kind of the curvature that
[24:12] you're taking. So in small step size um,
[24:15] small batch size regimes on the left
[24:16] here, you expect actually linear
[24:18] relationships between increasing batch
[24:21] size and learning rate, right? And that
[24:22] is what we see even in practice in
[24:24] something like CIFAR, right? And then at
[24:26] a At a point this relationship just kind
[24:27] of to diverge.
[24:29] Of course, what one thing to know is
[24:31] that, you know, this relationship
[24:32] continues for a little bit longer if you
[24:34] have momentum. So that's an interesting
[24:36] empirical observation. I wonder if we
[24:37] can replicate it in the NQM.
[24:40] Another thing that, you know, people
[24:41] talk about a lot is this idea of a
[24:43] critical batch size, once again, where,
[24:45] you know, the the relationship between
[24:47] batch and uh
[24:49] sort of the number of steps that you
[24:50] take sort of starts to diverge. This is
[24:52] like diminishing returns of increased
[24:54] batches, right? And we can sort of model
[24:56] this almost exactly in the NQM, and you
[24:58] know, you can get these sort of like
[24:59] linear dashed line predictions, and
[25:01] they're like pretty accurate, right? Um
[25:03] and so you can see that maybe some of
[25:04] the questions that we're very interested
[25:06] in, like you know, what should my batch
[25:07] size be or like, you know, how do
[25:09] algorithms interact with batch size,
[25:11] maybe they can kind of be solved out in
[25:13] this NQM, and these intuitions can can
[25:16] inform us of how to do optimization,
[25:18] right? Um
[25:20] So what is the NQM? It is kind of what
[25:22] you think, except even simpler than
[25:23] maybe what you think. Um so when I say
[25:26] something like noisy quadratic model,
[25:27] probably, you know, the middle equation
[25:29] right here is like your first instinct,
[25:31] right? It's just like an arbitrary
[25:32] quadratic with um uh
[25:35] you know, a quadratic term h. Um but
[25:37] then we're going to do something really
[25:38] simple. We're just going to, you know,
[25:39] diagonalize this guy and put put
[25:41] ourselves into this coordinate system
[25:43] that's already diagonalized. So it's
[25:45] kind of like, you know, rotating your
[25:46] quadratic. Now you only need to care
[25:48] about the major axes of your quadratic,
[25:49] right? And the scales here are little h
[25:51] of i.
[25:52] Um and now what we're going to do is
[25:54] we're going to take this quadratic and
[25:55] then our gradients, of course, are going
[25:57] to be, you know, just add the linear
[25:59] function here. Um and then I'm going to
[26:00] add some noise. And I'm going to make a
[26:02] very important uh simplifying assumption
[26:04] here, which is that the noise C is going
[26:06] to be kind of axis aligned with the
[26:09] quadratic, right? So the quadratic h has
[26:11] some eigenvectors, right? Those define
[26:13] the directions that we're going to sort
[26:14] of rotate the quadratic. Um the noise C
[26:17] for the Gaussian, that's also elliptical
[26:19] and also has, you know, major and minor
[26:21] axes to that ellipse. So the
[26:23] eigenvectors associated with C we're
[26:25] going to assume line up with the same
[26:26] eigenvalues or say eigenvectors as h.
[26:30] So that's, you know, simultaneous
[26:31] diagonalizability.
[26:32] If we have this condition, life is
[26:34] really really simple because this means
[26:36] that you know both the noise and sort of
[26:38] the quadratic lives in the shared
[26:40] coordinate system. They're all
[26:41] decomposable and so gradient descent you
[26:44] can kind of actually analyze coordinate
[26:46] by coordinate, right? So each coordinate
[26:47] lives independently and the gradient
[26:49] descent you analyze one coordinate at a
[26:51] time this little I from 1 to B.
[26:54] Great. And what does batching do? Of
[26:56] course batching is very important,
[26:57] right? This is the core kind of variable
[26:59] that we're going to analyze in the NQM
[27:01] and so batching is just going to reduce
[27:03] variance by B, right? We assume we have
[27:04] an IID collection of of things. We
[27:06] average them of course it's going to
[27:08] divide the variance by B.
[27:10] So this is kind of the NQM world and
[27:12] then given this you know we're going to
[27:14] do gradient descent by following this
[27:15] noisy gradient and we're going to ask
[27:17] okay what happens when we you know do
[27:19] naive SGD, what happens when we do
[27:21] momentum SGD and we'll do some analyses
[27:24] of these kinds of things.
[27:25] Everything good so far?
[27:28] Good. Excellent.
[27:32] Yes, okay.
[27:34] So to give some example here, right?
[27:37] The dynamics of this thing are
[27:38] completely separable and so the two
[27:40] coordinates you know let's say I have a
[27:42] steep coordinate which is this one and I
[27:43] have a flat coordinate which is the
[27:45] x-axis here. I rotated the you know
[27:48] quadratic already so that it's axis
[27:49] aligned. These two are just going to
[27:51] operate as two different optimization
[27:53] problems. They're independent, right?
[27:54] They don't couple at all because the
[27:55] noise
[27:57] and the the quadratic both
[27:58] simultaneously diagonalize.
[28:00] And what's going to happen is because
[28:03] what I'm going to do is I'm going to
[28:04] have a fixed batch size and a fixed step
[28:06] size in my gradient descent and I have a
[28:08] fixed amount of noise
[28:10] I'm going to actually eventually just
[28:12] converge to a steady state, right? This
[28:13] is the expected risk over here and the
[28:16] expected risk for both of these you know
[28:18] two directions is converging to a steady
[28:20] state where the steady state is kind of
[28:22] this you know
[28:25] these particles like kind of
[28:27] mixing and entering their stationary
[28:29] distribution at the bottom here, right?
[28:31] And this is
[28:32] uh you know if you if you're familiar
[28:33] with this stuff um exactly Langevin
[28:35] dynamics right and the stationary
[28:36] distributions a Gaussian and you're
[28:38] going to get some sort of you know
[28:39] steady state loss uh that's defined by
[28:42] this quantity over here right and we can
[28:44] see that we can manipulate the steady
[28:46] state losses by either changing the
[28:48] learning rate or changing the batch size
[28:50] right those of those quantities are
[28:52] going to allow us to exchange
[28:54] essentially the convergence rate on the
[28:56] left over here um in exchange for uh
[28:59] steady state losses.
[29:01] Um once again if you were actually doing
[29:02] convex optimization and trying to solve
[29:04] this problem right like you would have
[29:06] do something much more sophisticated you
[29:07] would try to like have the right kind of
[29:09] learning rate schedules and really try
[29:10] to minimize both quantities at once.
[29:12] That's not necessarily what we're going
[29:13] to do we're only going to manipulate the
[29:15] coarse grain quantities which is
[29:16] learning rate which is fixed and batch
[29:19] and then just balance these two terms
[29:20] right we're just going to suffer this
[29:21] steady state loss and we're just going
[29:23] to call it a day.
[29:24] Okay.
[29:27] Now um
[29:28] what NQM suggests is that as we increase
[29:31] batch size um what's going to happen is
[29:34] that sort of the amount of steps that we
[29:37] need to hit a target loss is going to
[29:39] sort of you know improve to a certain
[29:41] point and then at a certain point it's
[29:44] going to stop improving further right
[29:46] and why does that happen well um what's
[29:48] going to happen is that at some point
[29:51] right um you know as we increase the
[29:53] batch size the learning rate can grow
[29:55] and grow and grow right we're reducing
[29:56] the noise so that means we can take
[29:58] bigger and bigger steps.
[29:59] But even if we were completely noiseless
[30:01] there's a limit to the size of the steps
[30:03] that we can take on a quadratic right
[30:04] there's a stability limit which is two
[30:06] over h where h is kind of the narrowest
[30:08] direction of the quadratic right um and
[30:11] this is the maximum stable learning rate
[30:12] if we exceed this this whole thing is
[30:14] just going to completely blow up on us
[30:15] so we [clears throat] can't go to the
[30:16] right of this this wall over here right
[30:18] this is the maximum allowable learning
[30:20] rate. At this point additional batches
[30:22] don't help you at all because I mean
[30:24] you're going to get a little bit of
[30:25] reduction in the noise but you're not
[30:26] getting these learning rate boosts
[30:28] anymore right you've sort of hit the
[30:29] wall here.
[30:30] Um and so this sort of recapitulates you
[30:32] know somewhat nicely kind of these like
[30:34] critical batch size dynamics based on
[30:36] these kind of like noise to curvature
[30:38] tradeoffs um is what you might call. So
[30:41] this is like the most basic starting
[30:42] point. Um this is not, you know,
[30:44] particularly surprising, but it's just
[30:45] kind of validating that this, you know,
[30:47] captures some of these ideas.
[30:49] Um
[30:50] so now we're going to move on to what I
[30:51] think are interesting and
[30:53] counterintuitive observations that work
[30:55] out in practice.
[30:57] Um so first let's study momentum. What's
[30:59] happening in momentum SGD? So I've
[31:01] written out a simple formal
[31:03] momentum-based SGD on this slide over
[31:05] here.
[31:06] What's happening um I think I I put up
[31:08] momentum SGD in our earlier lecture as
[31:11] well, right? But instead of updating by
[31:13] the gradients directly, what I'm doing
[31:15] here is I'm updating by M, you know, my
[31:17] momentum terms, and my momentum terms
[31:19] sort of accumulate over my steps. And
[31:21] then, you know, as I accumulate I'm also
[31:23] accumulating noise because each of my
[31:25] gradients also has some noise, right?
[31:27] Um
[31:28] in the sort of the NQM paper you can
[31:30] sort of do some math here and you can
[31:32] derive an upper bound for the expected
[31:34] risk, right? Of, you know, as you sort
[31:36] of run for longer and longer, what is
[31:38] the risk that you get?
[31:40] The key thing here
[31:41] is that once again we have a steady
[31:42] state risk, and the steady state risk
[31:44] can be controlled by your learning rate
[31:46] and your batch size, right? If I make a
[31:48] small learning rate or if I increase my
[31:49] batch size I can send this term to zero.
[31:52] And then I have this first term which is
[31:53] the convergence rate of a momentum SGD.
[31:57] Um and it turns out, you know, R1 and
[31:58] R2, these two quantities, they're
[32:00] solutions to a quadratic. And the the
[32:02] reason why these are solutions to the
[32:03] quadratic is because momentum SGD is is
[32:06] kind of like an oscillatory system.
[32:08] You're solving for kind of the uh poles
[32:10] of that. And so
[32:13] um in order to understand what is
[32:15] happening here um I want to sort of
[32:17] separate two regimes of momentum first
[32:19] and I'll walk through kind of the
[32:21] phenomena that actually happens. Um so
[32:23] as I hinted at at the beginning or or
[32:25] earlier uh when I was showing you
[32:27] momentum, there are two regimes to
[32:29] momentum. There's a overdamped regime,
[32:32] and in the overdamped regime this looks
[32:33] a little like gradient descent, right?
[32:35] Like it's sort of smoothly following the
[32:37] contours of my quadratic.
[32:39] Um, there's also an underdamped regime,
[32:41] and in the underdamped regime, it's kind
[32:43] of like you've thrown the ball into sort
[32:45] of this like, you know, bowl too fast
[32:47] and sort of oscillating a little wildly,
[32:49] and then eventually, you know, it will
[32:51] go to the bottom of this bowl, right?
[32:52] I'm sure you've played with all of these
[32:53] kind of like throw the ball into bowls
[32:55] kind of things uh when you were kids.
[32:57] Um, and it's kind of exactly like this.
[32:59] Um,
[33:01] and what's going to happen is that it's
[33:03] going to turn out to be the case that if
[33:04] you want your, you know, um uh
[33:07] uh momentum SGD to be sort of optimal in
[33:10] in the sense of balancing steady state
[33:12] and sort of convergence rate, you need
[33:13] at least one of your dimensions to be
[33:15] overdamped. If they're all underdamped,
[33:17] you know, you would actually be a build
[33:18] a better off by making one of your
[33:20] coordinates actually exactly in between
[33:22] over and underdamped. We'll see that in
[33:23] a moment, I think.
[33:25] Yes. Um, and importantly, you know,
[33:28] you're going to be limited by high
[33:30] curvature directions, right? You're
[33:31] going to have many directions in your
[33:32] quadratic. Some of them will be behaving
[33:34] like they're underdamped, some of them
[33:36] will be behaving like they're
[33:37] overdamped, and it turns out that the
[33:38] overdamped direction is the slowest
[33:40] converging direction.
[33:42] Why am I telling you all this? Well, it
[33:44] turns out that, you know, if you follow
[33:45] this logic, you know, the only thing
[33:47] that really matters in some of these
[33:49] regimes is the overdamped regime, right?
[33:51] This is the rate limiting step, and so
[33:52] we need to study the overdamped regime
[33:54] quite carefully in order to understand
[33:56] the benefits of momentum SGD.
[33:59] Okay.
[34:00] Um, so this might all be a little bit
[34:01] counterintuitive. Um, and so I cooked up
[34:05] a little animation uh to try to explain
[34:07] these two regimes and their impact um on
[34:10] convergence rates. Um, and so one of the
[34:13] things that I think is very interesting,
[34:14] and this is a prediction uh of the noisy
[34:17] quadratic model. You can look at the
[34:18] derivations in the paper if you like.
[34:20] I'm not going to go through the the
[34:21] actual mathematical derivations here.
[34:23] Um, that is that in the overdamped
[34:25] regime, especially the the sort of more
[34:27] extreme overdamped regime as you
[34:28] approach beta equals zero, um there's
[34:31] this very interesting effect where you
[34:33] can actually run SGD but with a faster
[34:36] learning rate, what you might call an
[34:37] effective learning rate. And momentum
[34:40] and sort of
[34:42] uh optimization trajectories coincide,
[34:44] right? So over here, basically in the
[34:46] over-damped regime, you're not getting
[34:48] much more than plain old SGD, right? Um
[34:52] but as we approach sort of this region
[34:54] between over and under-damped, right? We
[34:56] get improvements in convergence rates
[34:58] and we sort of diverge or improved upon
[35:01] what's achievable by SGD.
[35:04] Now what happens in the under-damped
[35:05] regime? Now convergence rates are
[35:07] falling for momentum. This is what I
[35:09] meant by saying if all of your
[35:10] coordinates are under-damped, well you
[35:12] kind of want to make them over-damped in
[35:14] order to improve convergence rate. I can
[35:16] move to the left of this plot here um to
[35:19] actually improve my convergence. So
[35:20] what's happening in the actual
[35:21] optimization, this is a single
[35:22] quadratic, you know I'm trying to get to
[35:23] zero, right? Is that there's a point
[35:25] here where this is converging a little
[35:27] faster, but once you get oscillatory,
[35:29] this oscillation is wasting time, right?
[35:31] You're not actually converging um any
[35:32] faster. So hopefully this gives you a
[35:34] bit of intuition about momentum dynamics
[35:37] and what's happening. Like the two key
[35:38] facts maybe to remember.
[35:40] First, if you're really over-damped,
[35:42] right? In this regime you're no better
[35:44] than SGD and the second thing is that
[35:46] the gains can happen kind of in this
[35:48] regime.
[35:49] Oh and there's one more uh fact that
[35:51] I've already mentioned that I want to
[35:52] reiterate again, which is that you know
[35:54] there's an upper limit to SGD's learning
[35:56] rate, right? I I did say that there is a
[35:58] correspondence between SGD and momentum
[36:01] in that you can rescale the learning
[36:03] rate, but one really important thing is
[36:05] that SGD does have an upper limit to its
[36:07] learning rate. In this case it's much
[36:08] higher, but imagine this boundary was
[36:10] lower here, you know you would get
[36:12] significant improvements for momentum
[36:14] because the SGD learning rate wouldn't
[36:16] be able to be pushed past a certain
[36:17] point.
[36:19] Okay. Um so that's all the the kind of
[36:22] you know basic phenomena for momentum.
[36:24] Um this might have been a little much so
[36:25] I can pause here, take some questions in
[36:27] case anyone has them uh before I kind of
[36:30] move on uh past here. So this is a basic
[36:32] explanation for why momentum might not
[36:35] help if you're the same as SGD or it
[36:36] might help if your uh SGD learning rate
[36:39] can't be pushed any higher.
[36:43] Yes.
[36:43] >> How long do you think these dynamics
[36:45] like [clears throat] uh
[36:52] >> Yeah. So,
[36:54] there are very concrete predictions that
[36:56] I will get to in a couple of slides that
[36:59] this model makes that match language
[37:01] models very well even at very large
[37:03] scales.
[37:04] You know, would I bet that these kinds
[37:05] of like phase diagram things like line
[37:07] up in language models? Much less so,
[37:09] right?
[37:10] Yes.
[37:11] >> Why could we not just like push the
[37:13] learning rate for SGD up because that
[37:14] seems like the best scenario?
[37:16] >> Right. So, so in this plot, of course,
[37:17] you know, SGD is doing quite well by
[37:19] just pushing the learning rate up.
[37:21] But there's a stability limit. Like at
[37:23] some point,
[37:24] you know, think of a quadratic, you're
[37:26] just going to bounce wildly back and
[37:27] forth and diverge off, right, of the
[37:29] quadratic. There's a
[37:30] maximum learning rate that's achievable
[37:32] which is 2 over H, right?
[37:35] And so this is like a hard bound for
[37:37] like all of these algorithms and once
[37:38] you exceed that, you're going to blow
[37:40] up.
[37:41] And so one way of thinking about
[37:42] momentum is, you know, with SGD, there's
[37:45] a max learning rate that you can hit and
[37:47] momentum can give you effective learning
[37:49] rates beyond that that do not diverge,
[37:51] right?
[37:53] Cool.
[37:54] Yes.
[37:55] >> Well, the delta here looks like pretty
[37:56] small on the right side.
[37:58] >> Here? Yeah. Or or on the right?
[37:59] >> I mean like on the left. Yeah, yeah.
[38:01] >> Yeah, I mean this is small, but imagine
[38:02] the upper limit of SGD was much lower in
[38:04] the over damped regime, then you would
[38:06] get significant gains. Like blue would
[38:07] would taper off here and orange could go
[38:09] higher, right?
[38:11] Cuz here I'm only sweeping momentum. I'm
[38:13] not sweeping learning rate for the
[38:15] orange.
[38:17] Yes.
[38:17] >> What is over damped the rate rate
[38:19] limiting regime?
[38:21] >> Over damped Okay, so so the rate
[38:22] limiting regime is that if you have
[38:24] multiple coordinates, right, you're
[38:26] going to change your beta which is
[38:28] global, right? Beta is the same across
[38:29] every coordinate.
[38:31] If I'm all under damped, I I could
[38:33] decrease beta and every coordinate would
[38:34] uniformly improve, right? And so I would
[38:36] decrease beta, decrease beta, decrease
[38:38] beta until at some point, right, I'm
[38:40] going to hit this boundary. And from
[38:42] here, now I'm going to keep decreasing
[38:45] beta which is going to for my high
[38:47] curvature direction, start to decrease
[38:49] the convergence rate,
[38:50] um and so hurt me, right? And so I need
[38:52] to converge on all the coordinates. And
[38:54] so, you know, this is going to be kind
[38:56] of the the point for at least one of the
[38:57] two. That's not precise because, you
[38:59] know, all of these losses do add, but in
[39:01] some sense if you want to get to low
[39:03] losses, like the slowest converging one
[39:05] will be the one that's exactly at this
[39:06] boundary, right? It's sub optimal for
[39:09] all of the coordinates to be here
[39:10] because you can always decrease the beta
[39:11] to improve the convergence.
[39:14] Yeah.
[39:15] >> Why can't you make the betas like
[39:16] separate for each term?
[39:17] >> That would be like kind of like
[39:19] preconditioning, right? And then so if
[39:20] you knew the curvature of the
[39:21] directions, then yeah, you would you
[39:22] would do all sorts of more clever stuff.
[39:24] But here if a priori you just didn't
[39:26] know what the structure of the problem
[39:27] was, then you're committed to this.
[39:29] Um I think one of the things about the
[39:31] NQM is the algorithm is like
[39:33] intentionally very handicapped, right?
[39:35] Like there there are lots of things we
[39:36] can do to just solve this problem. Like
[39:38] if you run Newton's method, it's going
[39:40] to like solve, you know, a quadratic,
[39:41] right? Uh but the point here is to say
[39:43] like we're going to analyze a simple
[39:44] algorithm on this thing, and it turns
[39:46] out that combination is the gives us
[39:48] good intuition.
[39:48] >> Yeah, I don't know if you're going over
[39:49] this, but NQM also has predictions for
[39:51] when you do have the per coordinate how
[39:53] that should be like you have the pre
[39:54] condition.
[39:54] >> Pre condition Yeah yeah I'll go over pre
[39:55] condition. Yes yes yes good good good.
[39:57] Excellent.
[39:58] Um
[40:00] Right. Okay. Um so it turns out, right,
[40:03] that, you know, the the way that this
[40:05] will kind of work is like, you know, I
[40:06] have my steep side and I have my sort of
[40:09] slow side. Um and the convergence rate
[40:11] is going to be dominated by kind of the
[40:14] the over damped regime. And the over
[40:16] damped regime in this case is the flat
[40:17] regime. And, you know, I can always, at
[40:19] least in this case, you know, design my
[40:21] SGD with the same learning rate. So, you
[40:24] know, momentum isn't adding anything at
[40:25] least in this case, right? There are
[40:27] other cases where momentum does add
[40:29] quite a bit.
[40:31] And this is kind of where the analysis
[40:32] lands. Um you know, if you're interested
[40:34] in like kind of working out the
[40:35] specifics of the math, you know, I would
[40:37] encourage you to look at it. The math is
[40:38] not terribly complicated. It's all like
[40:40] taking limits of of things and looking
[40:42] at, you know, leading order terms. Um
[40:44] but really the the takeaway of this
[40:46] analysis kind of boils down to the
[40:48] following. If you're in the small batch
[40:50] case, right? My batch size is small.
[40:52] Now, my irreducible error is very hot,
[40:54] right? In order to push the irreducible
[40:56] error down, I need to pick a small
[40:59] learning rate, right? Um and if I need
[41:01] to have a small learning rate, right? If
[41:03] if, you know, my ability to to pick
[41:05] large learning rates is limited, um
[41:07] then, you know, having large effective
[41:08] step sizes for for momentum can be
[41:10] actively counterproductive. It can also,
[41:12] you know, force some of these problems
[41:13] to to diverge.
[41:15] In the large batch cases, um where, you
[41:17] know, we have very low irreducible
[41:19] error, now, you know, I have the option
[41:21] of taking very large step sizes up to my
[41:23] curvature maximum, um and then so now
[41:26] large momentum can allow me to like, you
[41:28] know, even get past that point and then
[41:30] start to exploit the benefits of these
[41:31] very large effective step sizes, right?
[41:34] So, you know, a concrete prediction that
[41:35] you might get from NQM is that in small
[41:38] batch cases, momentum, even though it's
[41:40] very natural, is not a very helpful
[41:42] idea. Once you get to these very large
[41:44] batch regimes, you start to see big
[41:47] gains.
[41:48] And this turns out to be true. So, this
[41:49] is from the original NQM paper. Um and
[41:52] what you find, this is a language
[41:54] modeling uh task. Uh I think this is
[41:56] actually like 1 billion tokens, if I
[41:58] remember right. Um and, you know, this
[42:01] is uh this is a slightly different
[42:03] visualization than maybe you're used to.
[42:05] You hit you set a target entropy and
[42:07] you're looking for the number of steps
[42:08] that you take until you hit that target,
[42:10] right? But this is um
[42:12] fairly intuitive once you sort of think
[42:14] about it a little bit.
[42:15] But what we find with this is SGD, which
[42:17] is this light green line, right? Is on
[42:20] this sort of dashed line that we see
[42:21] here of this batch size to steps to
[42:24] target tradeoff. Um and at the very
[42:26] beginning, add a heavy ball, which is
[42:27] this dark green line, doesn't really
[42:29] change this tradeoff very much, right?
[42:31] The curves do diverge as we increase
[42:33] batch size, but the smaller the batch,
[42:35] the closer the Q is, right? Um and then
[42:38] similarly for for heavy ball to atom,
[42:40] like, you know, the differences are
[42:42] smaller in the small batch regime.
[42:44] Um one way of mentally thinking about
[42:46] this is maybe, you know, in the very
[42:48] noise-limited regime where all the
[42:50] gradients are super noisy, the
[42:51] optimizer, there's just not as much that
[42:53] you can do, right? It's only once you
[42:55] start de-noising these gradients can you
[42:56] do much more sophisticated things with
[42:58] them. Similarly, here it's much clearer
[43:00] I think on the CIFAR-10 example, right?
[43:02] Um, all the algorithms like agree very
[43:04] closely. Uh, ignore K-FAC for the moment
[43:06] here. Um, all like the the algorithms in
[43:09] blue and green agree almost exactly and
[43:11] they only start diverging once their
[43:13] batch size gets sufficiently big and
[43:15] then we see the separation where the
[43:16] algorithms with momentum, which are
[43:18] darker, you know, start to get much
[43:19] better, right? So,
[43:21] hopefully you kind of see exactly the
[43:23] story that I gave. Um, and I think
[43:26] there's been lots of interesting more
[43:27] recent larger scale corroboration. There
[43:29] is this nice paper on training
[43:31] transformers with very small batch
[43:33] sizes. Um, and you know, even, you know,
[43:36] SGD, which I think honestly is a is an
[43:38] algorithm you really do not want to be
[43:40] training with, um, at batch size one is
[43:43] kind of competitive with much more
[43:45] sophisticated optimizers. Like I think,
[43:47] you know, no one is crazy enough to to
[43:49] want to do this normally, but if you
[43:50] have to, actually SGD is not terrible,
[43:52] right? Um, you know, all these
[43:54] sophisticated optimizers, one way of
[43:56] looking at what optimizers are doing is
[43:58] of course they improve convergence rates
[44:00] in some sense, but also they like really
[44:02] push the usable batch size much further
[44:05] out than their predecessors, right? And
[44:06] this is very useful if you're, you know,
[44:08] interested in systems questions of like
[44:10] how large can I parallelize? You want
[44:11] big batches so you can parallelize
[44:13] across many accelerators.
[44:15] And if you look at kind of the training
[44:16] curves, one thing that's kind of
[44:18] striking is for GPT-3 training, you
[44:21] know, these authors replicated the
[44:23] original kind of AdamW settings, uh, you
[44:26] know, in the GPT-3 paper and they sort
[44:28] of match the training curve, um, using
[44:31] SGD with batch size one, right? Um,
[44:34] which which is honestly a little bit
[44:35] crazy, but it shows that, you know, if
[44:37] you're in the batch size one regime,
[44:39] you're not paying a huge cost to not
[44:42] have a lot of these bells and whistles.
[44:43] Like it is possible to converge at a
[44:45] reasonable rate, um, which I think is a
[44:47] very counter-intuitive result. You kind
[44:49] of think that these like advanced
[44:50] optimizers are just better in every
[44:52] regime by a lot, um, but there are kind
[44:55] of predictions that you get from NQM
[44:57] that tell you like maybe, maybe not,
[44:58] maybe less so.
[44:59] Okay. So that was the momentum part. Um,
[45:02] we'll move on to preconditioning. If
[45:03] anyone has final momentum questions, I
[45:05] can answer them before moving on.
[45:08] Oh, yeah.
[45:08] >> So in this line on first, right?
[45:11] Seems like
[45:14] >> Yeah.
[45:15] It's Well, batch equals one has this
[45:17] added advantage, which we're not going
[45:19] to talk about yet, that it generalizes
[45:21] much better. So if you're like in data
[45:22] constrained regimes like batch size
[45:24] ones, great. Like you want to train with
[45:25] batch size one all the time. But batch
[45:27] size one is horrible from a systems
[45:29] perspective. And systems is very
[45:30] important. Um, we're not going to go
[45:31] into systems at all. That's much more um
[45:34] CS 336 language models from scratch
[45:36] stuff, but you know, very important. You
[45:38] want big batch sizes.
[45:41] Okay, cool.
[45:43] So um the other thing that the noisy
[45:45] quadratic model can tell us is
[45:47] preconditioning, right? I told you
[45:48] earlier that quadratics are cool because
[45:51] that's kind of where all this convex
[45:52] intuition about preconditioning comes
[45:54] from. So let's do exactly that. So
[45:56] preconditioned uh descent here looks
[45:58] like this, right? We got our noisy
[46:00] gradient, which is inside the brackets.
[46:02] I'm going to hit it with my
[46:03] preconditioner P and then I'm going to
[46:04] take my optics, right? Um, and as long
[46:06] as P is like reasonably sane, this thing
[46:08] will converge in basically the same way.
[46:11] Now, what should I pick as my
[46:13] preconditioner? Well, the right thing to
[46:15] do or like, you know, the better thing
[46:16] to do would be like model Adam or
[46:18] something, but that's a little too
[46:19] complicated. So I will just look at P
[46:21] equals the true Hessian uh
[46:24] to a power of P, right? Um, and to
[46:26] remind you of, you know, what the right
[46:28] preconditioner is, H itself is the
[46:30] optimal preconditioner, right? So if we
[46:32] plugged in the actual quadratic and we
[46:33] inverse that, we're going to get the
[46:35] optimal preconditioner. It's like doing
[46:37] gradient descent on a unit Gaussian.
[46:39] This was going to work really, really
[46:40] well. So P is controlling how good the
[46:42] preconditioner is. Is If P is zero, no
[46:45] preconditioning. If P is one, this is
[46:47] perfect preconditioning. And now we can
[46:49] reason about how does the quality of the
[46:50] preconditioner um affect convergence
[46:52] rates, right? Um, and so one thing
[46:56] that's kind of interesting is that, you
[46:57] know, when we precondition, in the
[46:59] noiseless case, this is optimal, right?
[47:01] Like we're going to converge really,
[47:02] really fast. But in the noisy case, the
[47:04] preconditioner does do something. Like
[47:06] if H is, let's say, really skinny,
[47:08] right? And I, you know, blow up the
[47:10] skinny dimension in order to make it a
[47:12] sort of spherical quadratic. What's
[47:14] happening there? Well, I've blown up the
[47:16] noise as well, right? So once again, we
[47:18] see this tradeoff between the steady
[47:20] state in which, you know,
[47:22] the higher P makes the steady state
[47:24] worse. So stronger preconditioning makes
[47:27] steady state worse in this case.
[47:29] Whereas this first term, which is the
[47:31] convergence rate, strictly improves as
[47:33] we improve the quality of the
[47:34] preconditioner, as we make the
[47:36] preconditioning stronger, right?
[47:38] So, you know, we see a very similar
[47:40] tradeoff to before in the momentum case
[47:42] where we have tradeoffs between two
[47:44] terms and sort of this preconditioning
[47:46] power P is once again trading off
[47:49] between the two. And so we might imagine
[47:51] very, very similar outcomes
[47:53] as before, which would be exactly right,
[47:56] right? So actually, let me stay on this
[47:58] slide for one a little bit longer.
[48:00] You know, once again, what the effect
[48:01] that we're going to get is is if the
[48:03] batch size is small, right? This is the
[48:05] dominant term. I cannot crank up my
[48:07] preconditioner without making the steady
[48:09] state term really big. If B is really
[48:11] big, now this is small, I can make my
[48:13] preconditioner large and I can reap the
[48:15] benefits of the convergence rate
[48:16] improvements, right?
[48:18] And this is, you know, I'm going to, you
[48:19] know, repaste the same figures, right?
[48:21] But this is what we see. Now let's focus
[48:24] on so the preconditioning effects. The
[48:26] preconditioning effects here are kind of
[48:28] Adam, which is in the blue lines, versus
[48:30] kind of the green lines over here.
[48:32] And once again, we see that, you know,
[48:33] the gains from this are much more of a
[48:35] larger batch effect. You know, this this
[48:37] ideal line and the the dashed diagonal
[48:39] line, like all the methods are kind of
[48:40] on it until eventually they diverge
[48:43] because they kind of exceed the batch
[48:44] size that they can support.
[48:49] And also, I guess going back to the
[48:51] sorry
[48:52] Andrew Gordon Wilson paper or Michael
[48:54] Goldbloom paper,
[48:55] you know, we see
[48:57] basically get same effect as well. The
[48:58] SGD and Adam W are combining both
[49:00] momentum and preconditioning and these
[49:02] effects kind of go away at batch size
[49:03] one.
[49:05] Cool. So NQM has been kind of this
[49:07] really simple but also very useful place
[49:11] to think about these trade-offs, right?
[49:12] Batch size controls noise, noise
[49:14] controls steady state error, and we
[49:16] trade off steady state error for
[49:18] convergence rates, right? And things
[49:19] that sort of affect steady state error
[49:22] are things that are useful primarily
[49:25] Sorry, things that sort of increase
[49:27] steady state error can only really be
[49:29] used once your batch sizes are large.
[49:32] NQM has been used for many things. It's
[49:34] been used for like improving scaling law
[49:36] predictions where you incorporate batch
[49:37] size into the scaling law axis and it
[49:39] can give you more accurate predictions
[49:41] if you're like messing with the batch
[49:42] size while you're scaling.
[49:44] And so, you know, this has been a kind
[49:45] of
[49:46] surprisingly effective model despite
[49:48] just like the incredible simplicity of
[49:50] being a quadratic.
[49:51] Now you might say, okay, this is
[49:53] you know, let's spend the rest of the
[49:54] class studying quadratics.
[49:56] But I will caution you, especially for
[49:58] next lecture,
[50:00] where you know, I'm going to talk about
[50:02] kind of the limit or sorry, not next
[50:04] lecture, next set of optimization
[50:06] lectures where there are going to be
[50:09] limits to this convex mental model. And
[50:11] there are phenomena that I think are
[50:12] really cool and really important
[50:15] but are not at all predicted by
[50:17] quadratic behavior. So one example of
[50:19] this
[50:20] I've already showed you this plot before
[50:21] but I want you to sort of internalize it
[50:22] again is this you know observation that
[50:25] you know as you crank up the learning
[50:26] rate Sorry, crank up and as you go
[50:28] upwards here, your convergence rate
[50:30] improves but somehow your losses become
[50:33] very jagged even with full batch
[50:35] gradient descent, right?
[50:37] With quadratics you don't really expect
[50:38] this. This is without momentum. With
[50:40] quadratics without momentum you don't
[50:41] expect this. You either converge nicely
[50:44] or you like immediately blow up, right?
[50:45] Or you blow up through oscillations. You
[50:47] don't get this weird thing where you get
[50:48] these like strong oscillations but
[50:49] somehow you're converging very quickly,
[50:51] right? And these are kind of interesting
[50:52] mysterious phenomena that we will see is
[50:55] like not purely a quadratic phenomenon
[50:57] but also a very important deep learning
[50:59] one. So you You you want to be on toes.
[51:01] Don't assume that um deep learning
[51:04] optimization landscapes are like noisy
[51:06] quadratics, right? That's not a fully
[51:08] accurate uh model.
[51:10] So NQN. NQN is great. I think you all
[51:12] should, you know, roughly internalize
[51:14] the implications of this thing because
[51:15] it's very simple. It's convenient. It
[51:17] It's kind of like mental math for trying
[51:19] to work out various limits and various
[51:21] dependencies between hyperparameters.
[51:24] And it's given lots of great rough
[51:25] intuitions to people for how to, you
[51:27] know, think about momentum or
[51:28] preconditioning. Um and so knowing when
[51:31] to trust this is very important.
[51:32] Um and if you can do this, then you'll
[51:34] have great rules of thumb and great ways
[51:36] of intuition um for how these
[51:39] hyperparameters kind of affect
[51:40] optimization dynamics.
[51:44] Cool. Okay, that was the first part. Now
[51:46] we're going to talk about uh norms and
[51:48] hyperbola and all these other fun and
[51:50] interesting things in your assignment.
[51:52] Um
[51:53] so any questions about uh NQN before I
[51:55] move on? Yeah.
[51:57] >> Is it ever good to add an artificial
[51:59] noise to let you push to larger batch
[52:02] sizes? Because from the model that you
[52:03] said, the problem is basically that the
[52:06] at some point the preconditioning gets
[52:08] you to the state where you're able to
[52:09] hop from one side of the parabola
[52:10] together.
[52:11] Noise regularizes this?
[52:13] >> So
[52:15] um I don't think you would ever add
[52:17] additional noise because noise
[52:20] only ever hurts you. Um you can think of
[52:22] noise as like
[52:24] effectively increasing, always strictly
[52:26] increasing the steady state term and it
[52:29] doesn't really affect the the expected
[52:31] convergence rate of the algorithm. Um
[52:34] so I don't think there's cases where you
[52:36] would add noise to increase batch. I
[52:37] think it's more the causality is
[52:39] reversed. Like if you increase batch,
[52:40] then you have lower effective noise and
[52:42] you can do all sorts of things.
[52:44] >> I thought that you were talking earlier
[52:46] about like saturating to a certain batch
[52:48] size and beyond that point like you
[52:51] operate at that learning rate.
[52:53] >> It's not that you can't operate well.
[52:54] For batch size, so learning rate, right,
[52:56] has an upper limit which is kind of the
[52:58] curvature limit. So beyond that limit
[53:00] for learning rate, kind of all bets are
[53:01] off.
[53:02] But for batch sizes, it's not that
[53:04] there's a hard limit. The batch size
[53:05] dependence is much softer, and it looks
[53:08] like
[53:10] let me find that.
[53:12] This one over here, right? The batch
[53:14] size dependence is much more like this
[53:16] where at some point batch size just
[53:18] doesn't give you the same payoff
[53:20] anymore.
[53:21] After you hit this point where the
[53:22] learning rates can't be increased
[53:24] anymore, then batch sizes have very
[53:26] strong diminishing returns. So this is
[53:28] kind of the batch size problem. So
[53:29] adding noise doesn't help you with this
[53:31] because the the limits here, the
[53:33] transition point isn't coming from
[53:34] noise, it's coming from stability,
[53:36] right? So adding noise would would make
[53:38] your results worse, but it wouldn't move
[53:40] this wall. This is a function of your
[53:41] quadratics.
[53:43] Great.
[53:45] >> There's one more question.
[53:46] >> One more question, yes.
[53:48] >> You say you have two parts of the error.
[53:49] One is like the convergence from the
[53:51] steady state, but the actual training
[53:53] like the steady state you can have a lot
[53:55] of ways like
[53:57] you always regularize like you always
[53:59] make it
[54:01] you can always finalize it at the end,
[54:03] right? So in the end like only the first
[54:05] part matters the most in actual
[54:07] training, and then you can do like for
[54:09] example just lower the learning rate.
[54:11] >> That's actually the intuition for why
[54:13] like learning rate schedules exist. You
[54:15] can have faster convergence at the start
[54:16] of training, and then by the end of
[54:17] training since you want to lower the
[54:18] steady state risk you can bring the
[54:20] learning rate down. Then it makes a
[54:21] prediction you should have a learning
[54:22] rate schedule.
[54:23] >> That's right. That's right. Yeah, and
[54:24] then we'll we'll cover this more in the
[54:27] next set of results. So you know,
[54:29] currently this set of assignments and
[54:31] lectures is like this thing, these
[54:32] things, and then also mu P and and mu on
[54:34] and preconditioning, but the ones after
[54:36] that are going to be about
[54:38] curvature and stability and also like
[54:41] this oscillation and number of value
[54:42] landscape stuff, and there you'll see
[54:44] exactly this effect that you anneal the
[54:45] learning rate down, and then your loss
[54:47] drops because you can reduce your steady
[54:48] state error.
[54:49] But the theory also predicts this too
[54:51] like Polyak averaging and convergence
[54:52] results for for convex optimization do
[54:54] exactly this. So it's it's more of like
[54:56] a deep learning variation of the same
[54:58] same set of ideas.
[55:01] Okay.
[55:02] So now the second part.
[55:04] I think one of the things that's kind of
[55:05] fun or nice about the quiz is that now
[55:08] you all had like skin in the game and so
[55:09] you have like, you know, actual thoughts
[55:11] about this. You're like, okay, like I I
[55:13] looked at this graph, you know, I
[55:15] internalized it and I kind of know what
[55:17] this is about, right? And you might be
[55:19] wondering like why do we care about this
[55:20] norm thing, right? Like why is it so
[55:22] important that we predict whether this
[55:23] thing goes up or down, right? Um and so
[55:26] from this plot we do know that if we
[55:28] don't do anything, like if we don't
[55:29] weight decay, [clears throat] norms tend
[55:30] to go and go up and they grow over time,
[55:32] right? Um and so let's kind of like
[55:34] first dig into this phenomenon of norm
[55:37] growth and then it's going to kind of
[55:39] come back. This phenomenon will come
[55:40] back and interact with optimization in
[55:42] ways that are actually very interesting
[55:44] and then have implications for uh kind
[55:46] of like frontier or like state of the
[55:48] art training algorithms uh for models,
[55:50] which is really cool interaction, right?
[55:51] So we're going to start with our quiz
[55:52] and we're going to end up with kind of
[55:53] the newest uh optimization algorithm
[55:56] changes that we have today.
[55:58] Okay, so we'll start with why and then
[55:59] I'll answer who cares afterwards.
[56:02] Okay, so why does the norm grow? Um the
[56:06] most important sort of, you know, causal
[56:09] mechanism that you can think of is the
[56:11] norm invariance of the transformer to to
[56:14] many things. Um remember that, you know,
[56:16] we have layer norms throughout the
[56:18] transformer um and to stabilize training
[56:21] of large transformers, you know, we have
[56:22] decided to add layer norms in lots of
[56:25] places. We have the QK norm, we have pre
[56:26] norm. Do we have post norm? We don't
[56:28] have post norm. Yeah, but other people
[56:30] also have a post norm right after,
[56:31] right? There's norms everywhere. Um and
[56:33] I jokingly say in, you know, language
[56:35] models from scratch like, you know, just
[56:37] add norms everywhere. They're great,
[56:38] they don't hurt you, right? Um and what
[56:40] do norms do? Um well, what norms do is
[56:43] that, you know, this is the layer norm
[56:44] operation or RMS norm to be more
[56:46] specific operation, you know, you
[56:48] basically project something to the unit
[56:50] ball and then you decide uh based on a
[56:52] learned parameter how much to scale it
[56:54] up, right?
[56:55] Now, you know, you immediately should
[56:57] notice uh that, you know, if we scale,
[57:01] you know, my parameter A up or down.
[57:02] Let's say I'm going to norm I'm linear,
[57:05] right? And if I scale this parameter up
[57:06] or down, my norm is going to kill that
[57:08] scalar, right? So this is a nearly scale
[57:10] invariant operations. I can scale my
[57:12] parameters up or down, and my outputs do
[57:14] not change. And because my outputs don't
[57:16] change, my losses don't change, right?
[57:18] So in other words, the loss does not
[57:20] care about the norm of my parameters.
[57:23] Um and if you think about what this
[57:24] means, this has like sort of immediate
[57:26] interesting implications about the
[57:28] behavior of of, you know, parameters.
[57:30] Well,
[57:32] where are the gradients? If I have
[57:33] something that's scale invariant, well,
[57:35] what's going to happen is that my, you
[57:36] know, if my weights are somewhere on the
[57:38] sphere, my gradients are going to lie
[57:40] tangent to the sphere, right? And if I
[57:42] move along this tangent line, I'm
[57:44] obviously leaving the sphere, right? So
[57:46] I get norm that is slightly greater than
[57:48] the sphere. Um and then if I have weight
[57:50] decay, that's going to pull me back a
[57:52] little bit. So there's this kind of two
[57:53] forces that are fighting each other,
[57:54] right? I'm going to move tangent, which
[57:56] is going to drift me off the sphere, and
[57:58] then I have weight decay which pulls me
[58:00] back into the sphere. And the two
[58:01] forces, once they balance out, will give
[58:03] you some sort of potential, you know,
[58:05] equilibrium weight norm that you end up
[58:06] with, right? So that's kind of
[58:08] mechanically we can work out what might
[58:10] happen if we have a scale invariant loss
[58:12] and we apply um SGD onto this thing. So
[58:15] let's
[58:16] see what happens. Uh so this is a little
[58:19] animation. Um there are two
[58:20] trajectories. Dark blue starts out with
[58:22] high norm, light blue starts out with
[58:24] low norm. They have the same weight
[58:26] decay.
[58:27] They converge to the same equilibrium
[58:28] point. Orange on the other hand has no
[58:30] weight decay, and we see that in this
[58:32] objective. Oh, sorry. To explain the
[58:33] objective, it's, you know, basically get
[58:35] as close as you can to this, you know,
[58:37] this uh sort of north pointing direction
[58:40] with no sort of penalty for the norm
[58:42] itself, right? Um and so we see that
[58:44] what's happening is that, you know, as I
[58:46] sort of predicted, the norm grows
[58:48] because of these oscillations. They're
[58:49] moving tangent, and then the weight
[58:50] decay is the thing that sort of brings
[58:52] it back to its equilibrium point. Um you
[58:54] can of course calculate what the
[58:55] equilibrium point is if you want. Um and
[58:57] it's a function of both the learning
[58:58] rate uh and your weight decay.
[59:01] So this is kind of hopefully now fully
[59:02] mechanically explains uh what you were
[59:04] seeing in the quiz, right? If we don't
[59:06] have weight decay, we're basically
[59:07] getting this orange curve over here. Um
[59:09] of course the transformer is not fully
[59:11] scale invariant. There are layers that
[59:13] are scale-invariant. The output, for
[59:14] example, is not scale-invariant, right?
[59:16] But we can see that for the
[59:17] scale-invariant components, you're going
[59:19] to get this norm growth, right? And the
[59:20] weight decay is the the one thing that
[59:22] will bring this guy back.
[59:25] Cool.
[59:27] Um and so now that was the why, like
[59:30] what's happening with the norm growth.
[59:32] Um you know, the other thing that we can
[59:34] do is to then ask like what does this do
[59:37] to the model, right? Like we do know
[59:38] that the norm grows, but maybe because
[59:41] the loss doesn't care about, you know,
[59:43] norm growth, maybe we just leave it be,
[59:44] right? It's fine. It's an invariance.
[59:46] Who cares?
[59:47] Um but what's going to happen is that
[59:49] bigger norms is going to then lead to
[59:52] smaller gradients or smaller effective
[59:54] step sizes. And this is going to sort of
[59:56] mess with your training dynamics in ways
[59:58] that are very unpleasant. There's
[59:59] another paper
[60:00] uh by by Roger and Grosse and others um
[60:03] where they sort of calculate out for
[60:04] some simple model, you know, what is the
[60:06] effective step size. And the effective
[60:07] step size, you know, turns out to be,
[60:10] you know, the learning rate divided by
[60:11] sort of the the parameter norm uh
[60:13] square. Um and so this means that the
[60:16] larger your parameter norm, the smaller
[60:18] your effective step sizes, right? Um and
[60:21] so or at least when you look at sort of
[60:23] the angular updates of the of the
[60:25] parameters, you know, you have smaller
[60:27] uh step sizes.
[60:28] And so, you know, this is kind of the
[60:30] reason why we care that the norm drifts.
[60:32] Of course, from the loss perspective, we
[60:34] do not care about the norm because it's
[60:35] fully scale-invariant or at least my toy
[60:37] problem is scale-invariant. But what why
[60:39] we do care is because, you know, the
[60:42] update sizes are drifting. And we know
[60:44] from assignment one that it's very
[60:45] important to tune your learning rate,
[60:47] right? And if I want to tune my learning
[60:48] rate, this is kind of robbing me control
[60:51] over my learning rate, right? My norm
[60:52] growth is not fully controlled by me and
[60:54] yet it's somehow controlling my
[60:56] effective step size, right? So if you
[60:57] were reasoning through it in this way,
[60:58] you would then see or you would maybe
[61:00] think that wait, maybe we don't want
[61:02] norms to grow uncontrollably or without
[61:04] our our input. We want to control
[61:06] exactly what is happening here.
[61:09] COOL. SO LET'S JUST GO BACK TO the toy
[61:11] example and now we can also look at, you
[61:13] you going to happen if I change my
[61:14] learning rate to like a realistic
[61:16] looking schedule, right? So that's the
[61:17] top one, that's the learning rate
[61:18] schedule. Um, the equilibrium target,
[61:21] right? If I stayed at a particular
[61:22] learning rate would be kind of this
[61:24] dashed line. Um, and what happens,
[61:26] right? Is that, you know, the
[61:28] equilibrium target that we want to be
[61:29] at, this is kind of the affected
[61:31] learning rates are different from sort
[61:33] of the nominal learning rates that we
[61:34] want. So we want to be on this dashed
[61:36] line. This is the learning rate that I
[61:37] sort of put into my hyperparameter. Um,
[61:39] but actually the learning rates we're
[61:40] getting are these kind of blue curves
[61:42] over here, right? These blue curves are
[61:44] basically the kind of norm modulated
[61:46] steps that I'm taking. And so as the you
[61:49] know, um, these these two trajectories,
[61:52] they lag behind the equilibrium, you
[61:54] know, you see that their learning rates
[61:55] are lower than they should be because
[61:56] their norms are higher than we would
[61:57] want them to be, right?
[61:59] Um,
[62:00] so this is all very bad because it means
[62:02] we are starting to lose control over the
[62:03] learning rate, right? And we would
[62:05] ideally like to have very precise
[62:06] control over the learning rate. Um, and
[62:08] so this motivates a whole class of
[62:09] algorithms and also, you know, the use
[62:12] of weight decay in various ways in order
[62:14] to try to implicitly control or more
[62:16] precisely control the behavior of the
[62:18] system through uh, the effective um,
[62:20] learning rate.
[62:22] Okay. Um,
[62:24] any questions so far?
[62:27] >> Oh, good.
[62:28] >> Oh, so how does this relate to like in
[62:30] the weight decay term you have all of
[62:31] this like burning rate, I think which is
[62:33] time invariant, right? But you have this
[62:35] annuity structure and then multiplied by
[62:37] that sort of the weight decay like that
[62:40] is a parameter.
[62:41] >> Yes.
[62:41] >> I'm curious how it plays into this like
[62:43] the circle
[62:45] >> Yeah, that's right. So so the
[62:46] equilibrium is changing, right? So so if
[62:48] I ran out at a fixed learning rate I
[62:50] would hit eta over two lambda g squared
[62:52] to the the quarter power here, right? At
[62:53] least for this problem. Um,
[62:56] but since the learning rate is changing
[62:57] my equilibrium is possibly shifting
[62:58] while this is changing or this is this
[63:00] is being fixed. Um, in the next slide
[63:02] we'll talk about actually keeping the
[63:03] weight decay dynamic um, to try to to
[63:07] mess with this a little bit. But um, for
[63:09] now you know, we're not going to think
[63:10] about that at all.
[63:11] Uh, yes.
[63:12] >> In the architectures we have is the loss
[63:14] like invariant to the norm of the
[63:16] parameter?
[63:16] >> No. So
[63:17] >> um
[63:18] there are layers that are more invariant
[63:20] than others. So like um we have layer
[63:22] norm
[63:24] >> You must pre-layer norm for everything
[63:25] and even for the final head too.
[63:27] >> You have the pre-layer norm for the
[63:28] final head, but the final layer is not
[63:30] not norm invariant. Yeah. So so we have
[63:32] um layer norms in many places. And
[63:35] because of this, for example, this layer
[63:36] norm makes it invariant. The the size of
[63:38] the residual stream does not matter at
[63:40] all, right? Because of this layer norm,
[63:41] you know, makes sure that every X,
[63:43] right, is sort of unit. Um same with the
[63:46] Q K norms. Because we norm the Q K sort
[63:48] of query query and key vectors, those
[63:51] are norm invariant. Of course, um the
[63:53] one thing that is really not norm
[63:55] invariant is the output head. The output
[63:57] head linear, right, goes straight into
[63:59] the softmax, and that represents
[64:00] confidence, right? And we do actually
[64:02] want to be able to control confidence,
[64:03] so that's not layer norm.
[64:04] Um so it's not fully uh scale invariant,
[64:08] but in the spectrum of like fully scale
[64:10] invariant to not scale invariant, it is
[64:12] very close to scale invariant because of
[64:13] all these layer norms we've been
[64:14] injected everywhere.
[64:16] Yeah. And the other other thing that
[64:17] I'll I'll mention related to this is
[64:20] because of all these facts, you know, it
[64:22] is quite um intuition for how models
[64:25] like kind of behave is like they're not
[64:27] really thinking about L 2 metric as like
[64:28] their natural notion of like distance.
[64:30] Often everything is very angular, right?
[64:32] Because of all these layer norms.
[64:34] Yes.
[64:35] >> Is there simple intuition for why
[64:38] like optimal learning rate is scaled by
[64:39] norm squared by norm?
[64:41] >> Optimal learning rate is scaled by
[64:43] Sorry. Uh what do you mean by that?
[64:46] >> The uh second Goodfellow paper.
[64:49] >> Uh second Goodfellow Oh yeah yeah. Um
[64:52] Wait. Where where was that? Oh right
[64:54] right here. Yes.
[64:56] >> Why does it scale by norm squared? I
[64:57] would expect if you just linearly
[64:58] project out.
[65:00] >> It it it pulls out of here, right? Like
[65:03] basically you've got two angular
[65:04] components, and you've got two norms
[65:06] that then pull out of the
[65:08] Because we're we we're looking at sort
[65:10] of the angular components of of this
[65:11] like kind of Hessian like term.
[65:13] [snorts]
[65:15] Okay.
[65:16] All right. Um so
[65:19] now
[65:20] this was a a question about like okay,
[65:22] like you know, we keep the the weight
[65:24] decay fixed, but like why do we have to
[65:26] keep the weight decay fixed?
[65:28] Aaron Defazio had this this fun paper.
[65:30] This one was the origin of Adam C,
[65:34] where he said okay, like weight decay is
[65:36] actually primarily going to be used to
[65:38] control the effective learning rate. And
[65:40] the way we're going to do that is now
[65:41] we're just going to treat weight decay
[65:42] itself as a you know, thing that changes
[65:45] over time, and we're going to set this
[65:46] thing
[65:47] via this formula, where the formula is a
[65:49] ratio of the max learning rate to the
[65:51] current learning rate times a multiplier
[65:54] for like the base weight decay, right?
[65:56] And this now basically means that we can
[65:58] sort of control the gradient to weight
[66:01] ratios at a very specific constant,
[66:03] right? And also, you know, looking at
[66:04] the previous sort of
[66:08] animations, right? If we
[66:10] take the ratio of these two guys, if we
[66:12] control lambda T to be a function of
[66:14] theta or linear function of theta, we've
[66:15] now canceled out all the dynamic
[66:17] components. The equilibrium should be
[66:18] static now, right? And so this allows
[66:20] learning rate schedules to sort of
[66:22] control
[66:23] the norm sort of to a constant target.
[66:26] And in many cases, you know, at least in
[66:28] in Defazio's paper, they show gains. I'm
[66:30] not going to go into too much detail
[66:31] here because I have an alternative that
[66:33] I want to talk about instead in terms of
[66:35] sort of
[66:36] norm control.
[66:38] Okay.
[66:39] You know, I want to add that the the
[66:40] evidence for this view goes for quite a
[66:43] long time.
[66:44] I think reasoning about parameter norm
[66:46] growth in training dynamics is like not,
[66:49] you know, a very
[66:52] not a very like exciting thing to talk
[66:54] about if you're thinking about like you
[66:55] know, the the abilities of AI or
[66:57] something. But you know, like this is
[66:59] actually a really important
[67:01] sort of component of deep learning
[67:03] phenomena. Goes back to at least 2017.
[67:06] Van der Hoven had sort of this
[67:08] characterization of how like learning
[67:10] rate and regularization and sort of
[67:12] parameter norm are all like very
[67:14] predictably linked together.
[67:16] And then the paper I talked about had
[67:18] like three different things that weight
[67:20] decay does at once, of which norm
[67:23] control is one of them. There's two
[67:24] others that we won't talk about yet.
[67:26] And then for more recent work,
[67:28] D'Angelo at all
[67:30] sort of had sort of a study of like
[67:32] what's happening with weight decay in
[67:34] one pass language model training regimes
[67:36] where you don't need regularization.
[67:38] They come to basically a similar
[67:39] conclusion.
[67:41] Maybe kind of interestingly,
[67:44] they have this experiment where they can
[67:45] show that, you know, you can make
[67:48] certain weight you can remove weight
[67:51] decays to zero if you set the effective
[67:54] learning rates to what the weight decay
[67:56] would imply, right? So as we change
[67:57] weight decay, we have these norms that
[67:59] change over the training trajectory. And
[68:01] so there's an effective learning rate
[68:02] associated with those. We can sort of
[68:03] record that from a single sort of
[68:05] initial run and then copy it over to a
[68:08] run that doesn't have any weight decay.
[68:09] Just sort of copying the effective
[68:11] learning rate over. And if you do that,
[68:13] sort of the colored lines are basically
[68:15] one of them is with weight decay,
[68:17] another one is without weight decay, but
[68:18] sort of copying the effective learning
[68:20] rates over. And you see that the colored
[68:22] lines sort of line up with each other,
[68:24] sort of allowing these models to like
[68:25] imitate a run
[68:27] with weight decay as long as you sort of
[68:29] match the effective learning rate. So
[68:31] this is a nice piece of evidence
[68:33] that weight decay as the effective
[68:34] learning rate control is actually doing
[68:36] quite a bit to change the behavior of
[68:38] the model.
[68:40] Cool.
[68:42] So now, you know,
[68:44] let's think about what this means. Like
[68:45] we now have this
[68:47] interesting phenomenon, this weight
[68:48] decay learning rate component.
[68:50] And we know that it's important to
[68:52] optimization. And so maybe we want to
[68:54] improve our optimizers using this
[68:55] knowledge.
[68:57] And you know, we throughout this lecture
[68:58] you've sort of seen Roger Grosse's
[69:01] papers and he really knows his training
[69:03] dynamics well and he has a beautiful set
[69:04] of lectures. You should all if you're
[69:05] interested in this stuff, go look at it.
[69:07] And in one of his slides, you know, he
[69:09] has this offhand remark that I think is
[69:11] like really ahead of its time. He's
[69:12] like, well, you know, we know that the
[69:13] norm's pretty important. Has anyone
[69:15] tried just projecting all of these
[69:17] weights to unit norm all the time? Well,
[69:19] then we just perfectly control the
[69:20] learning rate, so that seems good.
[69:23] No one does it, but I expect it to be
[69:25] pretty good. Of course, this sounds very
[69:27] silly. It's like, what do you mean?
[69:28] You're going to project your weights to
[69:29] the unit ball every time? Um, but if you
[69:31] do this well, it turns out to actually
[69:34] be a quite good idea. Um,
[69:37] so there's a subtlety. Just as I was
[69:39] saying before, that the whole
[69:40] transformer is not like fully uh norm
[69:43] invariant, um you know, it it turns out
[69:45] that we do not want to make the
[69:47] transformer fully norm invariant, right?
[69:48] Like, you know, the output norm, right?
[69:50] That encodes confidence. I do not want
[69:52] to, you know, norm that guy. Um, if you
[69:54] look at the norm, it has parameters,
[69:56] right? The gamma parameters. Um, do I
[69:58] norm the norm? The answer is no, right?
[69:59] If I norm the norm, then like I have no
[70:01] control over the output scale of any of
[70:03] my layers. That's very bad. Um, and also
[70:06] the embedding, you know, usually encodes
[70:08] certain kinds of features as sort of the
[70:11] norm. Like, if you if you've done word
[70:12] embeddings, like the frequency of the
[70:14] word is often encoded in the norm. So
[70:15] maybe we don't want to uh norm the
[70:18] embedding either. So, you know, we're
[70:20] just going to normalize all the internal
[70:21] weights, things like the MLPs and the
[70:23] attention weights and all these weights
[70:25] that are, you know, tightly controlled
[70:26] by layer norms like the before and
[70:27] after, or you know, at least after.
[70:31] Um, and this leads to a very simple
[70:32] optimization algorithm. Um, and you
[70:34] know,
[70:35] over there. Um, but you know, I'm not
[70:37] just putting this here because on it.
[70:39] Um, you know, hyperball is kind of this
[70:41] um sort of new set of optimization
[70:44] tricks, let's call it, that's been
[70:45] developed. Um, and it's a thing that a
[70:48] lot of the the labs are using now, or at
[70:50] least they have been using before even
[70:51] the publication. Um, and it's actually
[70:54] very very effective. So the idea is very
[70:55] simple. You compute your base optimizer
[70:57] update. This can be any optimizer, but
[70:59] let's say it's AdamW, right? So AdamW
[71:01] emits sort of what the next update
[71:02] should look like. That's U of T. Um, and
[71:04] then I'm just going to normalize the
[71:06] direction first, right? So I project the
[71:08] this update into a unit ball. And then
[71:11] I'm going to take a sort of step on my
[71:13] weights using that sort of unit ball
[71:15] normalized update, and then I'm going to
[71:17] project that, you know, parameter back.
[71:19] So both the gradients or you know, the
[71:20] update and uh the parameters are
[71:23] constantly being projected back to the
[71:25] ball. Um, Um, we're not going to project
[71:27] it always back to the unit ball, we're
[71:29] going to project it back to a radius r
[71:30] ball, which we define usually as the uh
[71:34] sort of Frobenius norm of the
[71:35] initialization. So this is the the
[71:37] radius of the initial matrix that we
[71:39] get.
[71:40] And of course you you remember from um
[71:43] the previous uh
[71:44] talk that like the the initialization,
[71:46] right, has the right scale to sort of
[71:48] propagate signal back and forth. So this
[71:49] is a good sort of radius to be setting
[71:52] uh all of our matrices, right? Okay, so
[71:54] great. Hopefully this is like I mean
[71:56] this is a very simple algorithm.
[71:57] Hopefully this is uh quite clear.
[72:00] Um,
[72:01] there's tons of related ideas that have
[72:03] been successful. Um, you know,
[72:06] uh this is probably the oldest paper of
[72:08] the series. You know, people have done
[72:09] things like separate out the direction
[72:11] and the magnitude of weights and like
[72:13] reparameterize neural networks. Um,
[72:15] there was a paper that was sort of um
[72:18] popular a little bit before um of
[72:20] actually basically rethinking the
[72:21] architecture to basically project all
[72:23] the weights uh column-wise onto unit
[72:26] norm. This is a much stronger constraint
[72:28] than constraining the weights onto the
[72:29] ball. Um,
[72:32] there is uh other kinds of ideas of
[72:34] projections. Um, Jeremy Bernstein, who's
[72:36] at I think still at Thinking Machines,
[72:38] um is you know had a nice blog on
[72:41] basically gradient descent where you
[72:43] sort of
[72:44] either project or you stay on a
[72:45] particular manifold, like w transpose w
[72:48] is equal to i, right? So there's a
[72:49] different class of constraints than
[72:51] spherical, but you know these ideas are
[72:52] also effective. Um, and then finally
[72:54] like this is the idea that's
[72:55] sufficiently effective that it it's been
[72:57] discovered sort of by multiple people
[72:59] all at kind of a very similar uh time
[73:02] range. Um, and of course you know Roger
[73:04] Gross was was ahead of it by several
[73:06] years.
[73:07] Um,
[73:08] so does it work? Um, the answer is yes.
[73:10] Um, you know you can scale this guy up
[73:12] and mu on h and adam h, which are the
[73:14] hyperbolic equivalents, are sort of
[73:16] consistently better at scale, right? The
[73:17] darker colored lines are consistently
[73:19] better. Um, and because you've gone
[73:21] through assignment one, you do know that
[73:22] teeny tiny differences in loss are
[73:23] actually pretty substantial. Um, these
[73:25] are probably statistically significant
[73:27] differences. And importantly, when we
[73:29] look at the norm of the weights, they
[73:30] don't grow uncontrollably like they do
[73:32] under scale invariance, right? Under
[73:34] hyperball, they're of course projected
[73:36] down to exactly the initialization,
[73:38] because that's a hard constraint that we
[73:40] enforce. Um and then sort of, you know,
[73:42] if you actually look at sort of training
[73:43] steps versus loss, um you know, you you
[73:46] see uh very nice convergence um all the
[73:48] way to the end. Yes.
[73:50] >> Is there a reason Adam restarts
[73:52] decreasing again after step 30 or
[73:54] something?
[73:54] >> Uh learning rate schedule.
[73:58] Yeah. Whenever whenever you see like
[73:59] some strange learning curve behavior,
[74:01] it's it's usually learning rate
[74:02] schedule.
[74:04] Okay.
[74:05] Um maybe interestingly, and we will, you
[74:07] know, ask you to do this in your
[74:08] assignments, so you will find out how
[74:09] true this result is, at least in our toy
[74:11] system, um is that controlling the uh
[74:15] sort of norm of the weights allows for
[74:17] easier hyperparameter transfer. Like one
[74:19] of the things that happens is as you
[74:20] sort of increase the size of your model,
[74:22] the norm of the weights are sort of
[74:23] drifting, and the ways in which they
[74:25] drift are sort of different. You're on a
[74:26] higher dimensional hyperball, um and so
[74:28] things are sort of drifting more, and so
[74:30] the learning rate also changes. The
[74:31] optimal learning rate changes because
[74:33] the effective learning rate is, you
[74:35] know, not under your control. Um on the
[74:37] other hand, if you project the unit
[74:38] norms, you can get, you know, some
[74:39] better hyperparameter transfer. Still
[74:41] not perfect. You can't use the same
[74:42] hyperparameters kind of forever for
[74:44] every setting, um but it is certainly a
[74:46] lot more robust and maybe slightly more
[74:48] forgiving in terms of setting the
[74:50] hyperparameters, which is quite nice.
[74:55] And then finally, um you know, I think
[74:57] the nice thing about the the speed of uh
[75:00] modern language modeling research is
[75:02] that people are, you know, at least for
[75:04] popular ideas, replicating each other
[75:06] all the time. Um and so um some folks at
[75:08] EPFL had this paper where basically they
[75:12] um
[75:13] had their own method, but they also
[75:14] replicated a lot of the core results.
[75:15] Like you can see on the left here um
[75:18] that the best learning rate across the
[75:19] sweep, right, this triangle point over
[75:21] here, um for both uh muon on the sphere,
[75:24] which is sort of this dark red versus
[75:26] the the uh orange, or the dark blue
[75:28] versus the dashed blue, um hyperball
[75:31] gives significant gains uh in uh sort
[75:34] pre-training. And they also sort of have
[75:36] nice replication. This is their method
[75:38] which is slightly different. They they
[75:39] both tune the magnitude and direction,
[75:41] so it's not, you know, norm invariant,
[75:43] but very similar idea gives nice
[75:45] hyperparameter transfer.
[75:47] So you can go, you know, read this paper
[75:48] if you're interested in this this line
[75:50] of thing. And also the original
[75:51] hyperball paper. But this is I think,
[75:53] you know, an illustrative example of why
[75:56] I think it's pretty interesting to study
[75:58] sort of some of these niche things,
[75:59] right? At first when you're, you know,
[76:01] being tested on this, you're like, why
[76:03] are you testing me on the shape of my my
[76:05] norm curve?
[76:06] It turns out to have, you know, maybe
[76:08] more interesting implications than you
[76:10] initially
[76:12] realized. And so this is kind of a lot
[76:14] of the interesting stuff where the the
[76:16] model behaviors and the optimizers are
[76:18] now interacting. And of course hyperball
[76:21] I think is a is a super deep learning
[76:22] specific optimization trick, right? Like
[76:24] you can't apply this to an arbitrary
[76:26] convex optimization problem.
[76:28] But by figuring out, you know, what's
[76:29] happening in our optimization dynamics,
[76:31] we can then come up with cool new sort
[76:33] of optimization tricks and then vice
[76:34] versa, right? These optimizers can also
[76:36] inform,
[76:37] you know, what kinds of architecture and
[76:39] model constraints are potentially a good
[76:41] idea.
[76:42] Cool. Okay. So to put it all together,
[76:46] right?
[76:47] First of all, weight decay doesn't
[76:48] control, you know, model complexity as
[76:51] you might initially think, especially in
[76:52] the one-pass setting, right? In the
[76:54] one-pass setting, what weight decay is
[76:55] primarily doing is controlling the
[76:57] effective learning rate of your
[76:59] optimization process. And we know that
[77:02] learning rate's really important, so
[77:03] don't let your effective learning rate
[77:04] drift.
[77:05] Tuning your weight decay turns out to
[77:07] have impact similar to in some cases
[77:09] tuning your learning rate, right? So you
[77:10] can exchange one for the other and you
[77:12] want to have tight control over what's
[77:14] happening to your learning rate.
[77:15] And then finally there's algorithmic
[77:17] ways of ensuring this control which
[77:19] turns out to give you significant gains
[77:21] or stability or any of these other
[77:22] things.
[77:25] Okay. So to put it all together,
[77:26] hopefully you appreciate how kind of
[77:28] complicated all of this is and how messy
[77:30] it is. There's like empirical stuff and
[77:32] there's like sometimes some math and
[77:33] they all kind of interact in various
[77:34] ways. In our first part, right? Um you
[77:37] know, we we thought about theory
[77:38] intuitions and QM and all these things
[77:40] and they, you know, give you give us
[77:41] great intuition, but they also have
[77:43] limited scope, right? In the second
[77:44] part, you we kind of went for more of an
[77:47] empirical approach where we looked at
[77:48] these sort of like norm curves and they
[77:50] reason about what is actually happening.
[77:52] Um and you know, uh I kind of want to
[77:54] close with sort of, you know, copying
[77:56] Roger Gross's lecture notes. I wrote
[77:57] something similar and I was like, ah
[77:58] well I might as well, you know, just
[77:59] give citation to the original person
[78:01] here, um which is really that, you know,
[78:03] deep learning science is just very
[78:05] challenging, not because like, you know,
[78:07] deep learning is inscrutable per se, but
[78:10] because it's just really difficult to
[78:11] know what the right phenomenon and the
[78:13] right model is, right? Like a priori,
[78:15] you know, norm drift might look like a
[78:17] arbitrary whatever kind of thing, but it
[78:19] turns out to have a very important
[78:20] implication and that's why, you know, if
[78:23] your algorithm developers or whatever,
[78:24] you still need a very good sense of like
[78:26] what is happening in the network, right?
[78:28] You need good empirical intuition and
[78:30] empirical things going on in order to be
[78:32] a good theorist or a good algorithm
[78:33] developer. Um
[78:35] thanks.