TorchLean API

NN.API.Optim

Optimizers #

Optimizer configuration records and runtime optimizer constructors.

The default trainer config exposes self-contained core update rules for SGD, momentum SGD, AdaGrad, RMSProp, Adam, AdamW, and Adadelta. Runtime-only extension points live here too:

def TorchLean.optim.Optimizer.validateFor {α : Type} [Runtime.FromFloat α] (optimizer : Optimizer) (scalarName : String := "the runtime scalar") :

Check the supplied configuration and its representation in the selected runtime scalar.

Float32 and IEEE32 reject overflow, positive stabilizers rounded to zero, and averaging coefficients rounded to one. Float retains binary64 domains. Custom scalar instances may supply Runtime.FromFloat.roundForValidation; its default retains the input-domain checks. scalarName labels conversion errors when an execution boundary selects a specific format.

Instances For

    Optimizer algorithms accepted by model-training commands.

    Instances For

      Parse an optimizer name used by --optim.

      Instances For

        Name written to logs and summaries.

        Instances For

          Configure the selected algorithm with its command-line learning rate and defaults.

          Instances For
            def TorchLean.optim.muon.optimizer {α : Type} [Storage α] [Context α] (lr momentum : α) (orthogonalizer : {s : Shape} → Orthogonalizer α s := fun {s : Shape} => Optim.Muon.identityOrthogonalizer) {paramShapes : List Shape} :

            Runtime Muon-style optimizer for module-level training.

            Muon is public at the runtime layer because a meaningful Muon run needs an orthogonalization backend. The default identity backend supports proofs and fallback behavior; production Muon should pass a matrix-shaped orthogonalizer.

            Instances For
              def TorchLean.optim.galore.sgd {α : Type} [Storage α] [Context α] (lr : α) (projector : {s : Shape} → Projector α s s := fun {s : Shape} => Optim.GaLore.identityProjector) {paramShapes : List Shape} :

              Projected-SGD runtime constructor for GaLore-style gradient projection.

              This is a projection strategy wrapped around an SGD update. Full GaLore also needs a policy that constructs and refreshes low-rank projectors for matrix parameters; this constructor exposes the verified update boundary once a same-shape projector is supplied.

              Instances For