TorchLean API

NN.MLTheory.Optimization.Muon.NewtonSchulz

Newton-Schulz Muon Backends #

Polynomial orthogonalizers, residual checks, and fixed-point conditions used by Muon.

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 used below. 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.leftGram {α : Type} [Context α] {m n : } (X : MatrixTensor α m n) :

    Left Gram matrix $XX^\mathsf{T}$, useful for row-oriented rectangular Newton-Schulz updates.

    Instances For
      def Optim.Muon.rightGram {α : Type} [Context α] {m n : } (X : MatrixTensor α m n) :

      Right/column Gram matrix $X^\mathsf{T}X$, matching TorchLean's column-orthogonality certificate.

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

        One row-oriented Newton-Schulz polynomial step using $XX^\mathsf{T}$.

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

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

          Instances For
            def Optim.Muon.newtonSchulzLeftIter {α : Type} [Context α] {m n : } (coeffs : NewtonSchulzCoeffs α) :
            MatrixTensor α m nMatrixTensor α m n

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

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

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

              Instances For

                Row-oriented Newton-Schulz-shaped orthogonalizer backend.

                Instances For

                  Column-oriented Newton-Schulz-shaped orthogonalizer backend.

                  Instances For
                    def Optim.Muon.ResidualApproxSuccess {α : Type} [Context α] {m n : } (eps : α) (orthogonalizer : Orthogonalizer α (Spec.Shape.dim m (Spec.Shape.dim n Spec.Shape.scalar))) (buffer : MatrixTensor α m n) :

                    Residual-check success predicate for approximate Muon backends.

                    This is the lightest sound checker boundary: after a backend returns a direction, prove or check that the direction's Gram residual is bounded by $\varepsilon$.

                    Instances For

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

                      Instances For
                        def Optim.Muon.newtonSchulzResidualCheckedOrthogonalizer {α : Type} [Context α] {m n : } (coeffs : NewtonSchulzCoeffs α) (steps : ) (eps : α) :

                        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} [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} [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} [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.

                            theorem Optim.Muon.newtonSchulzFixedPoint_exactOrthogonalizesBuffer {α : Type} [Context α] {m n : } (coeffs : NewtonSchulzCoeffs α) (steps : ) (buffer : MatrixTensor α m n) (hgram : HasExactColumnGram buffer) (hfixed : NewtonSchulzFixedPoint coeffs buffer) :

                            If a buffer already has exact column Gram and is fixed by one Newton-Schulz step, then the finite-iteration Newton-Schulz backend exactly orthogonalizes that buffer.

                            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