Momentum buffer 2026-11-05
A momentum buffer stores an accumulated history of gradients for an optimization algorithm. In one common convention, a parameter vector , supplied gradient , learning rate and constant coefficient obey the recurrence relation
The buffer belongs to the optimizer state: it remembers earlier inputs even when the current parameters are unchanged. This is the undampened momentum convention used by PyTorch stochastic gradient descent with weight decay and the Nesterov accelerated gradient method disabled; its documented first buffer is the first gradient, agreeing with this recurrence from . Other conventions absorb the learning rate into the stored buffer, so a buffer value needs its update convention to be interpreted.[ref]
Repeated substitution gives the exponentially weighted gradient history
To verify this identity, substitute its expression for into : multiplication by raises every old exponent by one, and the added is precisely the new exponent-zero term. The formula holds at because its sum is empty, completing the mathematical induction.
For an original scalar example with and a constant supplied gradient , the geometric series yields . At , and the limit is 10. The buffer is an unnormalized sum: multiplying it by changes its scale, and would require a corresponding learning rate adjustment to preserve these parameter updates.
The same memory explains why momentum can temporarily oppose the current gradient. If , and the new scalar gradient is , then . With a positive learning rate, the parameter still decreases, although the present negative gradient alone would call for an increase. Persistence can carry motion through rapidly alternating gradients, but this example also shows why the rule need not decrease the objective function at every step.
Optimization algorithm 2026-11-05
An optimization algorithm is a procedure for finding or approximating an optimum of an objective function subject to specified optimization constraints. Its output must be assessed through feasibility, objective quality and a justified stopping rule, rather than only the number of iterations performed.
For , gradient descent with fixed step gives . It converges to the minimizer for , oscillates without decay at when , and diverges for . This elementary example shows why an update formula needs a step-size condition. For a nonconvex objective, a small gradient can certify approximate stationarity without certifying a global minimum.
Optimization checkpoint 2026-11-05
An optimization checkpoint is a saved description of an ongoing optimization algorithm from which its optimizer updates can resume. It combines the current parameters with the relevant optimizer state. The practical criterion is optimizer restart equivalence: after restoring the saved information and supplying the same subsequent inputs, the chosen update rule should produce the same subsequent states.
For a deterministic scalar example, minimize the quadratic function with gradient , learning rate and momentum buffer recurrence , followed by . Start with . After one step the saved pair is . Restoring both gives and . Restoring only and initializing a new momentum buffer to zero gives and . Equal saved parameters can therefore lead to unequal continuations. These numbers are an original calculation for the declared recurrence.
In PyTorch, a general training checkpoint commonly serializes separate model and optimizer dictionaries, together with the training position. The model dictionary contains learned parameters and registered model buffers; the optimizer dictionary contains its own changing state and group settings.[ref] Restoring the optimizer state-to-parameter association also matters: the optimizer loader pairs stored identifiers with parameters in group order, without independently establishing that they denote the same mathematical parameters.[ref]
The required checkpoint boundary depends on the computation being resumed. A changing learning rate schedule, the next position in the training data, and the state of a pseudorandom number generator can influence future updates. Matching them is part of computational reproducibility; a saved parameter vector alone does not specify the whole training process.