Optimization

Optimization is the process of updating model parameters to improve an objective. In machine learning, the optimized objective is usually a proxy for the real task.

Gradient descent updates parameters in the direction that locally reduces the objective:

Here is the learning rate.

The objective can be viewed as a Loss landscape:

Optimization follows local information from gradients, while evaluation decides whether that local progress supports the intended generalization claim.

Core Ideas

  • Loss defines the training signal.
  • Gradients indicate local directions for parameter updates.
  • Learning rate controls update size.
  • Batches estimate the objective from subsets of data.
  • Optimizer state can change the update beyond raw gradients.
  • Curvature and scale affect how stable a step size is.
  • Second-order methods or diagnostics use curvature information directly or approximately.
  • Constraints may be enforced exactly, approximated by penalties, or handled by projection/decoding.

Update View

A generic first-order optimizer can be written as:

For plain gradient descent, is empty. For Adam and AdamW, contains moment estimates.

Optimization Protocol

ComponentWhat To Record
optimized objectivefull loss, auxiliary losses, regularization, constraints, and weights
update unitmicro-batch, accumulated batch, optimizer step, epoch, sample, token, graph, or trajectory
gradient estimatebatch sampling rule, masking rule, distributed averaging, and valid element denominator
optimizer statemomentum, adaptive moments, weight decay, gradient scaler, and scheduler state
learning-rate schedulewarmup, decay, restart, step boundary, and resume behavior
stability controlsclipping, normalization, mixed precision, loss scaling, skip-step logic
selection rulecheckpoint, early stopping metric, validation split, seed policy, and search budget

The practical update is rarely just raw gradient descent. A useful abstraction is:

where is the processed gradient after masking, averaging, clipping, scaling, or preconditioning, and represents optimizer-specific scaling such as adaptive moments or approximate curvature.

Constraints and Penalties

Some optimization problems include a feasible set:

Others use a soft penalty:

These are not the same claim. A constraint says the solution must remain valid; a penalty only changes the objective. See Constrained optimization.

This distinction matters for constrained decoding, KL-regularized policies, molecular geometry, valid graphs, and resource-constrained model selection.

Curvature View

First-order methods use gradients. Second-order methods also use curvature:

The Hessian is usually too large to materialize for deep models, but Hessian-vector products, diagonal approximations, and curvature diagnostics still help explain unstable training and learning-rate sensitivity.

Training Signal vs Claim

Optimization only proves that the training procedure reduced the chosen objective under a protocol. It does not automatically prove generalization, calibration, ranking quality, sampling quality, or biological utility.

ObservationWhat It SupportsWhat It Does Not Prove
train loss decreasesoptimizer follows a useful training signalvalidation/test improvement
validation loss improvesselected objective helps held-out validation distributiondeployment or OOD claim
metric improves but loss worsenssurrogate loss and metric may be misalignedthat the loss is wrong without protocol audit
unstable lossstep size, gradient scale, precision, data order, or objective issuearchitecture failure by itself
best checkpoint late/earlyselection rule mattersfinal test can be repeatedly inspected

Paper Reading Checklist

ClaimRequired Evidence
better optimizersame objective, schedule budget, batch size, step count, and tuning budget
faster convergencewall-clock, optimizer steps, samples/tokens, hardware, and precision all reported
better stabilitygradient norm, loss scale, NaN/overflow handling, seed variation, and failure rate
better final qualityuntouched final test after validation-only model selection
better scalingcompute, memory, communication, and data pipeline bottlenecks separated

Watch For

  • Lower training loss does not guarantee better generalization.
  • Optimization instability can look like model failure.
  • Hyperparameters can dominate small experiments.
  • Broken gradients can look like a bad optimizer.
  • A scheduler stepped at the wrong boundary can silently change the experiment.
  • Gradient accumulation changes the effective batch only if loss scaling and synchronization boundaries are correct.
  • Mixed precision can silently skip optimizer steps or change numerical behavior.
  • Comparing optimizers without equal tuning budget is usually not a clean optimizer claim.
  • A hard constraint, a soft regularizer, and a post-hoc filter support different claims.