TorchLean API

NN.MLTheory.Optimization.Muon.NewtonSchulz

Newton-Schulz Muon Backends #

The column-oriented Newton-Schulz polynomial orthogonalizer, its residual-checked packaging, and the fixed-point condition under which it is an exact backend. Real-valued facts about the polynomial step at an exactly column-orthogonal matrix live in NN.MLTheory.Optimization.Muon.QR, next to the entrywise matrix API they need.

Coefficients for the odd Newton-Schulz polynomial used by Muon-style orthogonalization.

The column-oriented shape is $X\mapsto aX+bX(X^\mathsf{T}X)+cX(X^\mathsf{T}X)^2$, matching the $Q^\mathsf{T}Q$ certificate HasExactColumnGram. TorchLean keeps the coefficients explicit so experiments and backend-specific proofs can choose the polynomial they actually use.

  • a : α

    Linear coefficient.

  • b : α

    Cubic coefficient.

  • c : α

    Quintic coefficient.

Instances For
    def Optim.Muon.newtonSchulzStep {α : Type} [TorchLean.Storage α] [Context α] {m n : ℕ} (coeffs : NewtonSchulzCoeffs α) (X : MatrixTensor α m n) :

    One column-oriented Newton-Schulz polynomial step using the column Gram matrix $X^\mathsf{T}X$.

    Instances For
      def Optim.Muon.newtonSchulzIter {α : Type} [TorchLean.Storage α] [Context α] {m n : ℕ} (coeffs : NewtonSchulzCoeffs α) :
      ℕ → MatrixTensor α m n → MatrixTensor α m n

      Iterate the column-oriented Newton-Schulz polynomial step a fixed number of times.

      Instances For

        Column-oriented Newton-Schulz-shaped orthogonalizer backend.

        Instances For

          Turn any orthogonalizer into a checked approximate backend by using the Gram-residual bound itself as the success predicate.

          Instances For

            Newton-Schulz packaged as a checked approximate backend.

            The backend is the explicit Newton-Schulz tensor program, and the success predicate is the post-check that its returned direction satisfies the requested Gram-residual bound.

            Instances For
              def Optim.Muon.NewtonSchulzFixedPoint {α : Type} [TorchLean.Storage α] [Context α] {m n : ℕ} (coeffs : NewtonSchulzCoeffs α) (buffer : MatrixTensor α m n) :

              A buffer is a fixed point of one column-oriented Newton-Schulz step.

              This is a deliberately local condition. It does not assert convergence from arbitrary inputs; it records the exact algebraic fact needed when a backend has already reached a stable direction.

              Instances For
                theorem Optim.Muon.newtonSchulzIter_fixed_of_step_fixed {α : Type} [TorchLean.Storage α] [Context α] {m n : ℕ} (coeffs : NewtonSchulzCoeffs α) (steps : ℕ) (buffer : MatrixTensor α m n) (hfixed : NewtonSchulzFixedPoint coeffs buffer) :
                newtonSchulzIter coeffs steps buffer = buffer

                If one Newton-Schulz step fixes a buffer, then any finite number of Newton-Schulz iterations fixes the same buffer.

                theorem Optim.Muon.newtonSchulzOrthogonalizer_fixed_apply {α : Type} [TorchLean.Storage α] [Context α] {m n : ℕ} (coeffs : NewtonSchulzCoeffs α) (steps : ℕ) (buffer : MatrixTensor α m n) (hfixed : NewtonSchulzFixedPoint coeffs buffer) :
                (newtonSchulzOrthogonalizer coeffs steps).apply buffer = buffer

                A Newton-Schulz fixed point is returned unchanged by the corresponding orthogonalizer.

                An exact-column-orthogonal buffer that is fixed by one Newton-Schulz step is exactly orthogonalized by every finite Newton-Schulz iteration.

                Newton-Schulz packaged as a checked exact backend for already-stable directions.

                The success predicate says that the input buffer already has exact column Gram and is a fixed point of one Newton-Schulz step. Under that explicit condition, every finite Newton-Schulz iteration returns the same exact-column-orthogonal direction.

                Instances For