6.6 Optimization Mechanics and Fair Experiments
A loss is a measurement; an optimizer turns its derivatives into a trajectory. Before tuning a trillion-parameter run, be able to explain one parameter update and verify that batching preserves the intended objective.
From Likelihood to an Update
For logits , class probability is . The loss for correct class is , whose logit derivative is . The chain rule maps that derivative through the network to , the gradient of the batch objective at update . Gradient descent uses , with learning rate .
For the diagnostic quadratic , the gradient at is . One SGD step with gives ; with it gives . Along the high-curvature direction, convergence requires . A small gradient in one coordinate does not make the same step size stable in another. This is a local teaching example, not a convergence guarantee for a neural network.
What AdamW Remembers
Adam keeps exponential averages of the gradient and its elementwise square. With , decay coefficients , and update index [1]:
AdamW applies decay coefficient separately from the adaptive update; stabilizes the denominator [2]:
At the first step, bias correction gives and . Ignoring and decay, each nonzero coordinate moves approximately , not proportionally to its raw gradient magnitude. This is why “same learning rate” does not mean “same update” across optimizers.
Adding to the loss instead puts into Adam’s moments and preconditioner. It is therefore different from AdamW. In plain SGD the two forms coincide under matching coefficients. Record which parameters receive decay; excluding biases and normalization parameters is a policy to test, not a mathematical necessity.
Token Weighting Must Survive Parallelism
Let rank have summed valid-token loss , token count , and let be the number of ranks. The desired objective is with . If the distributed reducer averages gradients, each rank must backpropagate to recover that objective. A reducer that sums needs a different factor.
For two ranks, take and . Averaging local means gives , while the token mean is . The gradient generally changes too. Across accumulated microbatches, use the valid count over the entire update window; do not average unequal microbatch means. Unscale mixed-precision gradients first, aggregate the complete update, then clip the global norm once. Clipping each microbatch is a different algorithm.
For fixed-length dense batches, effective input tokens per update are local batch × data-parallel ranks × accumulation steps × sequence length. Prompt masking and padding reduce the supervised-token count. Track both. Increasing batch size changes gradient noise and updates per token; linear learning-rate scaling is a hypothesis, not a universal law.
Design an Optimizer Experiment
Use the 7.5 lab as the executable contract: input manifest and integer tokenizer, masked next-token objective, FP32 CPU memory budget, AdamW settings, token-normalized metrics, abort checks, complete local checkpoint, held-out evaluation, and reproducibility gate. It uses no reference model. The schedule multiplies a ten-update warmup envelope by a cosine envelope indexed against the final planned budget. At fixed batch size, steps map to tokens; if batch size changes, preserve the intended token-indexed schedule explicitly.
Change one hypothesis at a time, but tune each competing optimizer on development data with an equal search budget. Match initialization, data stream, target-token budget, and evaluation points; also report wall time and optimizer overhead. Log gradient and parameter-update norms separately. Select the recipe on validation data, then evaluate the locked choice on untouched test clusters. Reusing the lab’s test set for repeated recipe selection turns it into development data.
Research snapshot, as of 2026-11-17. Li et al. report that the Muon–AdamW ordering after fine-tuning can reverse as pretraining data budget grows [3]. Arefin et al. report delayed effects of temporary Muon weight decay: an intervention can look worse when removed and better at the final budget [4]. These are bounded experimental findings, not a universal optimizer ranking. They motivate measuring the final downstream objective and full learning trajectory, rather than selecting from early pretraining loss alone.
Quizzes
Quiz 1: Why does restoring only weights fail to reproduce an AdamW run?
The next update depends on first and second moments, step-dependent bias correction, learning-rate schedule, RNG state, and the next data batch. Equal weights do not imply equal next updates.
Quiz 2: With an averaging reducer, why is the local loss multiplied by world size?
The reducer divides the sum of local gradients by R. Backpropagating R times the local loss sum divided by the global token count cancels that division and yields the global token-mean gradient.
Quiz 3: An optimizer reaches lower loss after 20% of training. What is still missing?
The final-budget comparison, downstream adaptation and retention results, equal tuning budgets, run-to-run variation, and actual compute cost. Early ordering need not persist.
References
- Kingma & Ba. Adam: A Method for Stochastic Optimization. Paper.
- Loshchilov & Hutter. Decoupled Weight Decay Regularization. Paper.
- Li et al. (2026). Pretraining Data Scale Reverses the Muon-AdamW Fine-Tuning Gap. v2.
- Arefin et al. (2026). Delayed Effects of Temporary Weight Decay in Muon Pretraining. v1.