9.5 Adam and AdamW
In Section 9.3, plain minibatch SGD required a learning rate of on TinyLM to reach a loss of about nats/byte. Adam with , a learning rate more than a hundred times smaller, reaches nats/byte in the same steps, as we will measure below. Why does an optimizer with a hundredfold smaller nominal learning rate train faster, and why is it the universal default for Transformers?
Momentum (Section 9.4) averages gradients over time but still applies a single scalar step size to every parameter. Yet in deep networks, and especially in Transformers, gradient magnitudes vary by orders of magnitude across embeddings, attention projections, MLP layers, and normalization parameters. Adam (Adaptive Moment Estimation, Kingma and Ba (2015)) combines momentum with a per-coordinate root-mean-square (RMS) gradient preconditioner developed through AdaGrad (Duchi et al., 2011) and RMSProp (Tieleman and Hinton, 2012). Dividing each coordinate's update by its own historical gradient scale makes the learning rate a direct step length in parameter space rather than a multiplier on raw gradients.
That same per-coordinate division, however, breaks standard regularization: adding to the loss rescales each weight's decay rate by the inverse of its gradient scale. Loshchilov and Hutter (2019) resolved this by decoupling weight decay from the adaptive preconditioner, creating AdamW. In this section, we trace the progression from AdaGrad and RMSProp to Adam, measure coordinate gradient scales and compare Adam against SGD with momentum on TinyLM, derive AdamW and its weight-decay timescale and equilibrium norm, and detail which parameter groups must be exempt from weight decay.
import copy
import random9.5.1 Per-Coordinate Adaptive Learning Rates#
9.5.1.1 AdaGrad and RMSProp#
In models with sparse or heterogeneous features (such as token embeddings where common tokens appear in every minibatch and rare tokens appear only occasionally), a single global learning rate cannot serve all coordinates. AdaGrad (Duchi et al., 2011) accumulates the running sum of squared gradients elementwise and scales each coordinate's step inversely by :
where and prevents division by zero. On an axis-aligned valley, scaling each coordinate by its own gradient magnitude automatically cancels the directional curvature difference, acting as a gradient-only approximation to the diagonal preconditioner of Section 9.1.5 (Section 23.5.1).
def adagrad_2d(x1, x2, s1, s2, f_grad, eta=2.0, eps=1e-6):
g1, g2 = f_grad(x1, x2)
s1, s2 = s1 + g1 ** 2, s2 + g2 ** 2
x1 -= eta / math.sqrt(s1 + eps) * g1
x2 -= eta / math.sqrt(s2 + eps) * g2
return x1, x2, s1, s2
d2l.show_trace_2d(d2l.f_valley, d2l.train_2d(adagrad_2d, d2l.valley_grad))step 20, x1: -0.002295, x2: -0.000000
Because accumulates squared gradients monotonically without bound, AdaGrad's effective step size decays as under persistent stochastic gradients, eventually halting progress on non-convex deep networks. RMSProp (Tieleman and Hinton, 2012) replaces the cumulative sum with an exponential moving average (EMA) of squared gradients over a window of steps:
(Note: following standard optimization notation, here denotes the second-moment squared-gradient average rather than the velocity vector of Section 9.4.) By forgetting ancient gradients, RMSProp maintains a non-vanishing step size even from a moderate learning rate :
def rmsprop_2d(x1, x2, v1, v2, f_grad, eta=0.4, beta2=0.9, eps=1e-6):
g1, g2 = f_grad(x1, x2)
v1 = beta2 * v1 + (1 - beta2) * g1 ** 2
v2 = beta2 * v2 + (1 - beta2) * g2 ** 2
x1 -= eta / math.sqrt(v1 + eps) * g1
x2 -= eta / math.sqrt(v2 + eps) * g2
return x1, x2, v1, v2
d2l.show_trace_2d(d2l.f_valley, d2l.train_2d(rmsprop_2d, d2l.valley_grad))step 20, x1: -0.010599, x2: 0.000000
Notice two properties of (9.5.2):
- Early step amplification without bias correction: Because , the first step has , causing an oversized initial jump of magnitude at (and at ).
- Normalized step length: Whenever a coordinate's gradient has roughly steady magnitude, and the update has magnitude regardless of how small becomes. Near a minimum, a constant-rate adaptive method therefore oscillates within an neighborhood until is decayed by a schedule (Section 9.7).
9.5.1.2 Adam and Bias Correction#
Adam (Kingma and Ba, 2015) combines an EMA of the first moment (momentum, ) with an EMA of the uncentered second moment (), and applies exact bias correction to both estimators. Unrolling from shows that the weights sum to rather than . Dividing by and yields unbiased moment estimators and :
The parameter update divides the bias-corrected first moment by the coordinate RMS scale :
Standard defaults are , (or in large language model training (Brown et al., 2020)), and . At , and , so the initial step is exactly .
More generally, rescaling any coordinate of the objective by a positive constant multiplies both and by , leaving their ratio invariant (for ). Thus, under Adam, specifies a direct coordinate step length in parameter space: a coordinate with consistent gradient sign moves by per step, whereas a coordinate dominated by zero-mean noise moves by .
def adam_2d(x1, x2, s1, s2, f_grad, eta=0.4, beta1=0.9, beta2=0.999,
eps=1e-8):
def update(x, g, state): # state: (m, v, t), 0 before the first step
m, v, t = state if state else (0, 0, 0)
m, v = beta1 * m + (1 - beta1) * g, beta2 * v + (1 - beta2) * g ** 2
m_hat, v_hat = m / (1 - beta1 ** (t + 1)), v / (1 - beta2 ** (t + 1))
return x - eta * m_hat / (math.sqrt(v_hat) + eps), (m, v, t + 1)
g1, g2 = f_grad(x1, x2)
(x1, s1), (x2, s2) = update(x1, g1, s1), update(x2, g2, s2)
return x1, x2, s1, s2
path = d2l.train_2d(adam_2d, d2l.valley_grad, steps=200, beta2=0.999)
d2l.show_trace_2d(d2l.f_valley, path)step 200, x1: 0.000022, x2: 0.000042
Implementing Adam from scratch requires maintaining the step counter and the two buffers for each parameter tensor:
class Adam(torch.optim.Optimizer):
"""Adam from scratch: steps scaled by two debiased moving averages."""
def __init__(self, params, lr=1e-3, betas=(0.9, 0.999), eps=1e-8):
super().__init__(params, dict(lr=lr, betas=betas, eps=eps))
@torch.no_grad()
def step(self):
for group in self.param_groups:
(beta1, beta2), lr, eps = group['betas'], group['lr'], group['eps']
for p in group['params']:
if p.grad is None: # A parameter that received no gradient
continue
state = self.state[p]
if not state: # First step: t = 0 and m = v = 0
state.update(t=0, m=torch.zeros_like(p),
v=torch.zeros_like(p))
state['t'] += 1
t, m, v = state['t'], state['m'], state['v']
m.mul_(beta1).add_(p.grad, alpha=1 - beta1)
v.mul_(beta2).add_(p.grad ** 2, alpha=1 - beta2)
m_hat, v_hat = m / (1 - beta1 ** t), v / (1 - beta2 ** t)
p.sub_(lr * m_hat / (v_hat.sqrt() + eps))9.5.2 Adam on a Language Model#
9.5.2.1 Gradient Scales and Comparison with SGD on TinyLM#
Why is per-coordinate scaling so critical for Transformers? To measure gradient scales across TinyLM (Section 9.3.1), we first load the WikiText103 dataset (, window length ):
data = d2l.WikiText103(batch_size=64, num_steps=64)Next we define gradients(model, data) to compute the root-mean-square (RMS) gradient of each parameter tensor over minibatches, snapshot(model) to clone parameter values, and an initial TinyLM instance with Adam ():
def gradients(model, data, num_batches=10):
"""RMS over num_batches minibatches of each parameter's gradient."""
device = d2l.try_gpu()
sq = {name: 0 for name, _ in model.named_parameters()}
for _, (X, Y) in zip(range(num_batches), data.train_dataloader()):
model.zero_grad()
loss = F.cross_entropy(model(X.to(device)).flatten(0, 1),
Y.to(device).flatten())
loss.backward()
for name, p in model.named_parameters():
sq[name] += p.grad ** 2 / num_batches
return {name: v.sqrt() for name, v in sq.items()}
def snapshot(model):
return {name: p.detach().clone() for name, p in model.named_parameters()}
model = d2l.TinyLM(len(data.vocab)).to(d2l.try_gpu())
optimizer = torch.optim.Adam(model.parameters(), lr=3e-3)Grouping tensors into the functional parameter kinds via rms_by_kind, we compare their RMS gradient magnitudes at step and step alongside the normalized Adam step length :
KINDS = ['token_emb', 'pos_emb', 'qkv', 'proj', 'mlp', 'head']
def rms_by_kind(tensors):
"""RMS of the entries of each kind of parameter, from {name: tensor}."""
sums, counts = {}, {}
for name, t in tensors.items():
kind = (('LayerNorm' if 'norm' in name else 'biases')
if len(t.shape) == 1 else
next(k for k in KINDS if k in name))
sums[kind] = sums.get(kind, 0) + float((t ** 2).sum())
counts[kind] = counts.get(kind, 0) + math.prod(t.shape)
return {kind: math.sqrt(sums[kind] / counts[kind]) for kind in sums}
grad_init = rms_by_kind(gradients(model, data))
d2l.train_steps(model, data, optimizer, num_steps=500)
grad_500 = rms_by_kind(gradients(model, data))
before = snapshot(model)
d2l.train_steps(model, data, optimizer, num_steps=1)
after = snapshot(model)
step = rms_by_kind({name: (before[name] - after[name]) / 3e-3
for name in before})
print(f'{"":<11}{"RMS gradient at step 0":>24}{"at step 500":>13}'
f'{"Adam step / lr":>16}')
for kind in KINDS + ['LayerNorm', 'biases']:
print(f'{kind:<11}{grad_init[kind]:>24.1e}{grad_500[kind]:>13.1e}'
f'{step[kind]:>16.2f}')
ratio = lambda column: max(column.values()) / min(column.values())
print(f'{"max / min":<11}{ratio(grad_init):>24.0f}{ratio(grad_500):>13.0f}'
f'{ratio(step):>16.1f}') RMS gradient at step 0 at step 500 Adam step / lr
token_emb 2.0e-04 9.2e-05 0.21
pos_emb 1.8e-04 1.6e-04 0.27
qkv 8.2e-04 3.8e-04 0.23
proj 1.4e-03 5.7e-04 0.21
mlp 1.0e-03 2.6e-04 0.24
head 4.5e-03 1.3e-03 0.12
LayerNorm 4.8e-03 1.3e-03 0.18
biases 7.0e-03 6.2e-04 0.15
max / min 39 15 2.2
Raw gradient magnitudes span a range at initialization (from on token embeddings to on biases) and a range at step . Under SGD, a single scalar learning rate moves the groups with the largest gradients (biases, LayerNorm, the output head) faster than the embeddings; under Adam, the normalized step size across all eight parameter groups lies within a narrow band (, close to the pure-noise ratio ).
Because gradient scales in TinyLM lie around and Adam's EMA includes , Adam at produces parameter steps comparable in magnitude to SGD with momentum at . To compare both optimizers across shared seeds, we first set up the model and optimizer closures make_lm, make_sgd, and make_adam:
make_lm = lambda: d2l.TinyLM(len(data.vocab))
make_sgd = lambda model, lr: torch.optim.SGD(model.parameters(), lr,
momentum=0.9)
make_adam = lambda model, lr: torch.optim.Adam(model.parameters(), lr)
seeds = [random.getrandbits(31) for _ in range(3)]We then sweep SGD with momentum across and Adam across from identical initial weights per seed:
def sweep(make_optimizer, lrs):
"""Loss curves of one run per learning rate and seed, printing the final
losses; the runs of one seed start from the same initialization."""
runs = [d2l.lr_sweep(make_lm, make_optimizer, data, lrs, seed,
verbose=False)[0] for seed in seeds]
for lr in lrs:
print(f' lr {lr:<7g}', *(f'{d2l.final_loss(run[lr]):6.3f}'
for run in runs))
return {lr: [run[lr] for run in runs] for lr in lrs}
print('final loss of three runs, SGD with momentum')
sgd_lm = sweep(make_sgd, [0.1, 0.3, 0.5, 1.0])
print('Adam')
adam_lm = sweep(make_adam, [3e-4, 1e-3, 3e-3, 1e-2, 3e-2])final loss of three runs, SGD with momentum
lr 0.1 1.835 1.857 1.867
lr 0.3 1.644 1.900 1.694
lr 0.5 inf inf 1.754
lr 1 inf inf inf
Adam
lr 0.0003 1.930 1.913 1.932
lr 0.001 1.655 1.662 1.660
lr 0.003 1.587 1.591 1.587
lr 0.01 1.642 1.644 1.649
lr 0.03 2.847 2.781 2.794
Summarizing each optimizer at its best learning rate (best_rate), we compare the usable learning-rate range (within nats of the optimum), steps to reach nats, maximum single-step loss spikes, and smoothed loss trajectories:
def best_rate(curves):
"""The lr with the lowest mean final loss, and each lr's mean."""
mean = {lr: sum(map(d2l.final_loss, runs)) / len(runs)
for lr, runs in curves.items()}
return min(mean, key=mean.get), mean
print(f'{"":6}{"best lr":>8}{"final loss":>17} {"within 0.15 nats":<18}'
f'{"steps to 1.8":<16}largest one-step rise')
for name, curves in [('SGD', sgd_lm), ('Adam', adam_lm)]:
best, mean = best_rate(curves)
runs = curves[best]
finals = [d2l.final_loss(run) for run in runs]
usable = [f'{lr:g}' for lr in curves if mean[lr] <= mean[best] + 0.15]
steps = ' '.join(str(d2l.steps_to_reach(run, 1.8)) for run in runs)
rises = ' '.join(f'{max(b - a for a, b in zip(run, run[1:])):.2f}'
for run in runs)
print(f'{name:<6}{best:>8g}{min(finals):>8.3f} to {max(finals):.3f} '
f'{" ".join(usable):<18}{steps:<16}{rises}')
best_sgd, best_adam = best_rate(sgd_lm)[0], best_rate(adam_lm)[0]
d2l.plot(list(range(0, 2000, 25)),
[d2l.smooth(sgd_lm[best_sgd][0]),
d2l.smooth(adam_lm[best_adam][0])],
'step', 'training loss',
legend=[f'SGD + momentum, lr {best_sgd:g}',
f'Adam, lr {best_adam:g}']) best lr final loss within 0.15 nats steps to 1.8 largest one-step rise
SGD 0.3 1.644 to 1.900 0.1 0.3 1100 None 1250 0.16 1.72 0.39
Adam 0.003 1.587 to 1.591 0.001 0.003 0.01 725 725 700 0.17 0.20 0.16
On TinyLM, Adam reaches a target loss of nats in nearly half the steps of SGD with momentum ( vs. ), finishes at a lower final loss, operates across a usable learning-rate window ( to ), and remains finite even at because its normalized update length is bounded by . SGD's best rate, , sits one grid step below divergence: its worst one-step loss spikes are several times Adam's, and at most runs diverge to inf. On larger Transformers with subword vocabularies, this gap widens further due to block-level Hessian heterogeneity (Zhang et al., 2024) and heavy-tailed token frequencies (Kunstner et al., 2023; Kunstner et al., 2024).
In this run, one spike sets an SGD seed back so far that it never reaches .
9.5.2.2 Role of and Limits of the Second-Moment Estimate#
In (9.5.4), caps the maximum effective coordinate learning rate at ; in the limit , Adam reduces to SGD with momentum at step size . Conversely, when is too small, a short-memory second-moment estimate can weight frequent small gradients more heavily than occasional large opposing gradients—a phenomenon used by Reddi et al. (2018) to construct a synthetic periodic convex counterexample () on which small- Adam fails to converge (Section 23.5.2.2; Exercise 4). In practice, keeping prevents this pathology without requiring monotonic running maxima (AMSGrad).
9.5.3 Decoupled Weight Decay (AdamW)#
9.5.3.1 Coupled Regularization vs. Decoupled Weight Decay#
Under plain SGD (Section 2.7), adding an penalty to the objective adds to the gradient, which is mathematically identical to shrinking the weights by before each step:
When the penalized gradient is fed into Adam, however, the penalty term is divided by the coordinate preconditioner :
Under coupled regularization, weights with small loss gradients are decayed up to more aggressively than weights with large gradients—or, when dominates the loss gradient, Adam normalizes the penalty by its own magnitude and drives the weight toward zero at speed per step until .
Loshchilov and Hutter (2019) introduced AdamW, which decouples weight decay from the adaptive gradient step:
where and are computed solely from the data loss gradient .
class AdamW(torch.optim.Adam):
"""Adam with decoupled weight decay: shrink the weights, then step."""
def __init__(self, params, lr=1e-3, weight_decay=0.01):
super().__init__(params, lr) # Adam's own weight_decay stays 0
self.weight_decay = weight_decay
@torch.no_grad()
def step(self):
for group in self.param_groups:
for p in group['params']:
if p.grad is not None:
p.mul_(1 - group['lr'] * self.weight_decay)
super().step()To compare no decay, coupled Adam + l2, and decoupled AdamW on TinyLM, we first define matrix_rms to measure the entrywise RMS of the 2D non-embedding weight matrices and train_tracked to record both the step losses and the matrix RMS every steps:
def matrix_rms(model):
"""RMS of the entries of the weight matrices, embeddings excluded."""
W = torch.cat([p.detach().flatten() for name, p in model.named_parameters()
if p.ndim == 2 and 'emb' not in name])
return float(W.square().mean().sqrt())
def train_tracked(make_optimizer, data, seed, num_steps, every=250):
"""Train TinyLM from seed with make_optimizer(params); return the losses,
the matrix RMS at the start and every `every` steps, and the model."""
torch.manual_seed(seed)
model = d2l.TinyLM(len(data.vocab))
optimizer = make_optimizer(model.parameters())
losses, rms = [], [matrix_rms(model)]
for _ in range(num_steps // every):
losses += d2l.train_steps(model, data, optimizer, every)
rms.append(matrix_rms(model))
return losses, rms, modelRunning all three configurations for steps at and from a shared seed shows the dramatic difference between coupled penalty and decoupled weight decay:
seed = random.getrandbits(31)
curves = {}
for name, make_optimizer in [
('no decay', lambda params: torch.optim.Adam(params, 3e-3)),
('Adam + ℓ2', lambda params: torch.optim.Adam(params, 3e-3,
weight_decay=0.1)),
('AdamW', lambda params: torch.optim.AdamW(params, 3e-3,
weight_decay=0.1))]:
curves[name], rms, _ = train_tracked(make_optimizer, data, seed, 1000)
print(f'{name:<10} final loss {d2l.final_loss(curves[name]):.3f}, RMS of '
f'the weight matrices {rms[0]:.4f} -> {rms[-1]:.4f}')
d2l.plot(list(range(0, 1000, 25)), [d2l.smooth(c) for c in curves.values()],
'step', 'training loss', legend=list(curves))no decay final loss 1.740, RMS of the weight matrices 0.0447 -> 0.1078
Adam + ℓ2 final loss 3.151, RMS of the weight matrices 0.0447 -> 0.0028
AdamW final loss 1.736, RMS of the weight matrices 0.0447 -> 0.0969
Coupled Adam + l2 at collapses the hidden weight matrices from an initial RMS of down to , destroying the network's representation and stalling at the unigram byte-frequency entropy ( nats/byte). Decoupled AdamW trains cleanly alongside the unregularized baseline while bounding weight growth.
9.5.3.2 The Timescale of Decay and Equilibrium Norm#
Writing for Adam's normalized update direction and unrolling (9.5.7) over steps yields
Thus, AdamW expresses the parameters as an exponentially weighted moving average of past updates with decay factor and characteristic decay timescale
steps (Wang and Aitchison, 2025). At and , the decay timescale is steps. Over a -step run, weight decay acts across timescales.
Over runs longer than , the initial weights decay away and each coordinate reaches a stochastic equilibrium norm where per-step shrinkage balances the injection of normalized updates (with of unit mean square ). By the exact same variance recursion as the SGD noise ball (Section 9.2) with in place of curvature:
Stabilizing the root-mean-square weight magnitude at stabilizes the relative angular update rate of normalized weight matrices at (rotational equilibrium, Kosson et al. (2024)), preventing the uncontrolled random-walk growth of unregularized weights that would otherwise decay the effective angular step size as over long pretraining runs (D'Angelo et al., 2024). When sweeping , holding the per-step shrinkage (and thus the timescale ) fixed decouples the learning-rate search from the decay timescale (Loshchilov and Hutter, 2019; Wang and Aitchison, 2025; Bergsma et al., 2025).
9.5.3.3 Parameters Exempt from Weight Decay and Optimizer State Memory#
Standard Transformer recipes apply decoupled weight decay to the weight matrices and exempt biases and normalization parameters. OLMo 2 additionally exempts the embedding tables, and we adopt that choice here. Decay is then applied only to 2D internal projection matrices ( of TinyLM), while two parameter groups are exempted ():
- 1D biases and LayerNorm/RMSNorm gain and shift vectors: Normalization scales start near and directly control feature variance; decaying them toward zero distorts layer activations rather than regulating angular update speed.
- Token and positional embedding tables (the OLMo 2 exemption): Token embedding rows receive gradients only when their token appears in a minibatch, whereas decoupled decay shrinks every row on every step, collapsing rare token representations and inflating downstream LayerNorm gradients (OLMo et al., 2025).
model = d2l.TinyLM(len(data.vocab))
decay = [p for name, p in model.named_parameters()
if p.ndim == 2 and 'emb' not in name]
no_decay = [p for name, p in model.named_parameters()
if p.ndim != 2 or 'emb' in name]
optimizer = torch.optim.AdamW([
{'params': decay, 'weight_decay': 0.1},
{'params': no_decay, 'weight_decay': 0.0}], lr=3e-3)
n_decay = sum(p.numel() for p in decay)
n = n_decay + sum(p.numel() for p in no_decay)
print(f'decayed: {n_decay} of {n} parameters')decayed: 425984 of 470784 parameters
9.5.3.4 Optimizer State Memory#
Finally, maintaining the two per-parameter buffers doubles the static parameter memory footprint. In 32-bit floating point ( bytes per scalar), each trainable parameter requires bytes of device memory: bytes for the parameter , bytes for the gradient , and bytes for the AdamW state (Section 13.4). For a -parameter model, the optimizer state alone consumes before storing any activations. Freezing parameters (leaving them out of the optimizer) or quantizing/factoring directly eliminates or compresses this -byte-per-parameter overhead.
While AdamW normalizes each weight entry independently, 2D weight matrices act as linear operators on activation vectors. Section 9.6 asks whether we can do even better by normalizing the update of each 2D weight matrix as a whole operator rather than entry by entry.
9.5.4 Summary#
AdaGrad scales each coordinate inversely by the root of its cumulative squared gradients, RMSProp replaces that unbounded sum with a leaky exponential moving average , and Adam adds first-moment momentum together with bias corrections and . Dividing by makes Adam invariant to diagonal rescaling of the gradient, turning into a direct coordinate step length in parameter space and equalizing update magnitudes across Transformer parameter groups whose raw gradients differ by . AdamW decouples weight decay from the adaptive preconditioner, establishing a uniform decay timescale , an equilibrium weight RMS proportional to , and a steady relative angular step proportional to . Standard recipes decay only 2D weight matrices while exempting 1D biases and normalization parameters (and, following OLMo 2, embedding tables), with accounting for of the bytes per trainable parameter in float32.
9.5.5 Exercises#
-
[code] Coordinate rotation vs. diagonal scale invariance.
- Verify with
adam_2dond2l.f_valleythat Adam is invariant to rescaling the objective by (for ) and to changing from to . - Rotate the valley by via . Run
adagrad_2d,rmsprop_2d, andadam_2dat for steps on the unrotated and rotated valleys (and with ), and explain why rotating the eigenbasis away from the coordinate axes restores ill-conditioning for diagonal preconditioners.
- Verify with
-
[code] Constant-rate limit cycles and AMSGrad. ●
- Show that if a 1D coordinate alternates as on under Adam, its amplitude is independent of .
- Run
adam_2donf_valleyfor steps and explain why the iterate approaches within of the origin while remembers the initial gradients, then gets ejected once decays below the momentum stability threshold. Verify that replacing with (AMSGrad) prevents the ejection.
-
[extended] Frequent and rare tokens and per-group learning rates.
- Following Kunstner et al. (2024), partition the byte values of
WikiText103into frequent () and rare () tokens, and compare validation loss on each group under tuned SGD with momentum, Adam, and sign descent with momentum (). - Assign separate learning rates to the three parameter groups of
TinyLM(embeddings, 2D matrices, 1D vectors) under SGD with momentum, and measure how much of the SGD–Adam gap is closed by group-level versus coordinate-level scaling.
- Following Kunstner et al. (2024), partition the byte values of
-
[code] Adversarial periodic gradients and second-moment repairs. On the 3-periodic sequence () and otherwise on (Reddi et al., 2018), run Adam with and compare it against AMSGrad and Yogi (Zaheer et al., 2018).
-
Two limits of AdamW and rotational equilibrium.
- For , derive the deterministic equilibrium when is constant, the zero-mean noise equilibrium when is i.i.d. with , and the mixed equilibrium when .
- Simulate in with (Kosson et al., 2024) to verify that the equilibrium RMS matches and the per-step rotation angle matches .
-
[code] Joint search and parameter-group exemptions. ●
- Train
TinyLMon overlapping windows ofd2l.TimeMachinefor steps across a grid of and , comparing parametrization by versus per-step shrinkage . - Compare validation perplexity on
WikiText103at when decaying all parameters versus decaying only 2D weight matrices (Section 9.5.3.3), and identify whether exempting embeddings or 1D vectors accounts for most of the gain.
- Train