Rounded Optimizer Steps for NF #
Instances of RuntimeApprox.Optimizer.NumericalStepContract for the NF rounded-real model.
Exact and rounded updates both use the public optimizer equations, with shared elementwise error
transformers. The real-valued error traces are noncomputable; these contracts do not verify native
buffer management or LibTorch execution.
The first contracts cover SGD and momentum SGD. They already compose with the generic
NumericalStepContract.run_approx theorem over arbitrary finite gradient streams and arbitrary
tensor ranks. Adaptive optimizers build on the positive-division and square-root rules and are kept
in this module so all optimizer numerical contracts share one public home.
The Adam recurrence follows Kingma and Ba, Adam: A Method for Stochastic Optimization, ICLR 2015 (https://arxiv.org/abs/1412.6980). The decoupled decay term follows Loshchilov and Hutter, Decoupled Weight Decay Regularization, ICLR 2019 (https://arxiv.org/abs/1711.05101).
SGD #
Error in the runtime learning-rate scalar stored by SGD.
Instances For
Exact/runtime relation for SGD state.
Instances For
Parameter error after one SGD update, expressed using the rounded-real tensors.
Instances For
Numerical refinement contract for TorchLean's plain SGD update.
Instances For
One actual TorchLean SGD parameter update refines its exact-real counterpart.
This is the parameter component of sgdContract.updateApprox; the learning rate is carried over
unchanged, so the contract's state component is just hstate.
Momentum SGD #
Exact/runtime relation for momentum SGD state.
Instances For
State and parameter bounds for one momentum-SGD update.
Instances For
Numerical refinement contract for momentum SGD with arbitrary-rank parameter tensors.
Instances For
One public momentum-SGD update refines its exact-real counterpart.
This named corollary exposes the useful one-step statement without duplicating its proof; the
generic momentumSGDContract.updateApprox field remains the source used for finite runs and
graph-level composition.
AdamW #
Error budgets relating exact and rounded AdamW state.
- lr : ℝ
Error in the stored learning rate.
- beta1 : ℝ
Error in the first-moment decay coefficient.
- beta2 : ℝ
Error in the second-moment decay coefficient.
- epsilon : ℝ
Error in the denominator stabilizer.
- weightDecay : ℝ
Error in the decoupled weight-decay coefficient.
- firstMoment : ℝ
Infinity-norm error in the first-moment tensor.
- secondMoment : ℝ
Infinity-norm error in the second-moment tensor.
Instances For
Exact/runtime relation for the persistent AdamW state.
Instances For
Errors for scalar expressions derived inside one AdamW step.
They are kept separate from persistent state errors because subtraction, powers, reciprocal, and
the product lr * weightDecay each round in the runtime scalar model.
- oneMinusBeta1 : ℝ
Error in the rounded scalar expression
1 - beta1. - oneMinusBeta2 : ℝ
Error in the rounded scalar expression
1 - beta2. - firstMomentBiasInverse : ℝ
Error in the reciprocal first-moment bias correction.
- secondMomentBiasInverse : ℝ
Error in the reciprocal second-moment bias correction.
- decayScale : ℝ
Error in the rounded product
lr * weightDecay.
Instances For
Composed errors for the intermediate tensors in one AdamW step.
- squaredGradient : ℝ
Error after squaring the gradient.
- firstMoment : ℝ
Error after updating the first moment.
- secondMoment : ℝ
Error after updating the second moment.
- correctedFirstMoment : ℝ
Error after first-moment bias correction.
- correctedSecondMoment : ℝ
Error after second-moment bias correction.
- standardDeviation : ℝ
Error after square root of the corrected second moment.
- denominator : ℝ
Error after adding epsilon to the square-root denominator.
- normalizedMoment : ℝ
Error in the first moment divided by the epsilon-shifted RMS.
- adaptiveUpdate : ℝ
Error in the Adam update before subtraction from parameters.
- decayUpdate : ℝ
Error in the decoupled weight-decay update.
- decayedParameters : ℝ
Error after applying decoupled weight decay.
- parameterError : ℝ
Final parameter error after the full AdamW step.
Instances For
AdamW's one-step error trace from rounded-real tensors and scalar subexpression budgets. Each tensor contributes one infinity-norm bound, regardless of rank. This trace does not compute the scalar budgets or prove the domain premises supplied by the caller.
Instances For
One AdamW update is numerically sound with an epsilon-controlled denominator margin.
The derived-scalar hypotheses account for rounding in 1-β, bias correction, and decoupled decay.
η bounds the exact denominator, not the second moment. At a zero-gradient initial step, epsilon
supplies this margin. The square-root bound admits zero inputs, and the denominator-error margin
accounts for rounding in both the square root and epsilon before justifying division.
AdamW contract instance #
Numerical assumptions and positivity margin for one AdamW update.
- derivedErrors : AdamWDerivedErrors
Bounds for rounded scalar subexpressions used by bias correction and decay.
- minimumDenominator : ℝ
Positive lower bound on
sqrt(max v̂ 0) + epsilon; epsilon supplies it whenv̂ = 0.
Instances For
Complete validity predicate for one AdamW contract application.
Instances For
State and parameter error object produced by one AdamW contract step.
Instances For
AdamW instance of the generic numerical optimizer contract.
Its assumptions are proof data, not a second execution framework.
NumericalStepContract.run_approx therefore composes AdamW over finite runs exactly as it does SGD
and momentum SGD.