TorchLean API

NN.MLTheory.Optimization.Muon.QR

QR Muon Backend #

The real-valued QR orthogonalizer, its positive-pivot condition, and the exact certificates it supplies to Muon updates.

QR/Gram-Schmidt orthogonalizer: return the Q factor of the fresh matrix buffer.

Instances For

    The success condition for TorchLean's executable QR orthogonalizer.

    Instances For
      theorem Optim.Muon.get2_addSpec_real {m n : } (A B : MatrixTensor m n) (i : Fin m) (j : Fin n) :

      Entry rule for matrix-shaped tensor addition over $\mathbb{R}$.

      theorem Optim.Muon.get2_scaleSpec_real {m n : } (A : MatrixTensor m n) (c : ) (i : Fin m) (j : Fin n) :

      Entry rule for matrix-shaped tensor scaling over $\mathbb{R}$.

      theorem Optim.Muon.get2_subSpec_real {m n : } (A B : MatrixTensor m n) (i : Fin m) (j : Fin n) :

      Entry rule for matrix-shaped tensor subtraction over $\mathbb{R}$.

      Right multiplication by the identity matrix leaves a real matrix unchanged.

      Three scaled copies of the same real matrix combine into one scaled copy using the sum of the coefficients.

      If three scaled copies of a matrix are added and the coefficients sum to one, the result is the original matrix.

      Scaling an exact-column-orthogonal real matrix by a scalar whose square is one preserves exact column Gram.

      Scaling an exact-column-orthogonal real matrix gives an approximate Gram certificate whenever $|k^2-1|$ is bounded by the requested tolerance.

      If $Q^\mathsf{T}Q=I$, then one column-oriented Newton-Schulz step returns $(a+b+c)Q$.

      theorem Optim.Muon.newtonSchulzFixedPoint_of_exact_column_gram_of_coeff_sum_one {m n : } (coeffs : NewtonSchulzCoeffs ) (Q : MatrixTensor m n) (hgram : HasExactColumnGram Q) (hsum : coeffs.a + coeffs.b + coeffs.c = 1) :

      For real coefficients whose sum is one, an exact-column-orthogonal matrix is a fixed point of one column-oriented Newton-Schulz step.

      theorem Optim.Muon.newtonSchulzStep_hasExactColumnGram_of_exact_column_gram_of_sum_square_one {m n : } (coeffs : NewtonSchulzCoeffs ) (Q : MatrixTensor m n) (hgram : HasExactColumnGram Q) (hsquare : (coeffs.a + coeffs.b + coeffs.c) * (coeffs.a + coeffs.b + coeffs.c) = 1) :

      If $Q^\mathsf{T}Q=I$ and $(a+b+c)^2=1$, then one column-oriented Newton-Schulz step still has exact column Gram.

      theorem Optim.Muon.newtonSchulzStep_hasApproxColumnGram_of_exact_column_gram_of_sum_square_error {m n : } (coeffs : NewtonSchulzCoeffs ) (Q : MatrixTensor m n) (eps : ) (hgram : HasExactColumnGram Q) (herr : MathFunctions.abs ((coeffs.a + coeffs.b + coeffs.c) * (coeffs.a + coeffs.b + coeffs.c) - 1) eps) (heps : 0 eps) :

      If $Q^\mathsf{T}Q=I$ and $|(a+b+c)^2-1|\leq\varepsilon$, then one column-oriented Newton-Schulz step has entrywise Gram residual bounded by $\varepsilon$.

      theorem Optim.Muon.newtonSchulzFixedPointCheckedExact_success_of_coeff_sum_one {m n : } (coeffs : NewtonSchulzCoeffs ) (steps : ) (buffer : MatrixTensor m n) (hgram : HasExactColumnGram buffer) (hsum : coeffs.a + coeffs.b + coeffs.c = 1) :

      If the Newton-Schulz coefficients sum to one, exact column Gram is enough to satisfy the exact fixed-point backend's success predicate.

      theorem Optim.Muon.update_has_exact_certified_step_newtonSchulz_exact_gram_checked {m n : } (coeffs : NewtonSchulzCoeffs ) (steps : ) (lr momentum : ) (buf params grads : MatrixTensor m n) (hgram : HasExactColumnGram (update { lr := lr, momentum := momentum, buf := buf, orthogonalizer := newtonSchulzOrthogonalizer coeffs steps } params grads).1.buf) (hsum : coeffs.a + coeffs.b + coeffs.c = 1) :
      ∃ (direction : MatrixTensor m n), ExactCertifiedStep { lr := lr, momentum := momentum, buf := buf, orthogonalizer := newtonSchulzOrthogonalizer coeffs steps } params grads direction

      For real coefficients with $a+b+c=1$, exact column Gram of the fresh momentum buffer is enough to certify a Newton-Schulz Muon update exactly.

      theorem Optim.Muon.update_newtonSchulz_exact_gram_direction_has_exact_column_gram_checked {m n : } (coeffs : NewtonSchulzCoeffs ) (steps : ) (lr momentum : ) (buf params grads : MatrixTensor m n) (hgram : HasExactColumnGram (update { lr := lr, momentum := momentum, buf := buf, orthogonalizer := newtonSchulzOrthogonalizer coeffs steps } params grads).1.buf) (hsum : coeffs.a + coeffs.b + coeffs.c = 1) :
      HasExactColumnGram ((newtonSchulzOrthogonalizer coeffs steps).apply (update { lr := lr, momentum := momentum, buf := buf, orthogonalizer := newtonSchulzOrthogonalizer coeffs steps } params grads).1.buf)

      For real coefficients with $a+b+c=1$, exact column Gram of the fresh momentum buffer gives $Q^\mathsf{T}Q=I$ for the actual Newton-Schulz update direction.

      theorem Optim.Muon.init_has_exact_certified_step_newtonSchulz_exact_gram_checked {m n : } (coeffs : NewtonSchulzCoeffs ) (steps : ) (lr momentum : ) (params grads : MatrixTensor m n) (hgram : HasExactColumnGram (update (init lr momentum (newtonSchulzOrthogonalizer coeffs steps) params) params grads).1.buf) (hsum : coeffs.a + coeffs.b + coeffs.c = 1) :
      ∃ (direction : MatrixTensor m n), ExactCertifiedStep (init lr momentum (newtonSchulzOrthogonalizer coeffs steps) params) params grads direction

      Initialized version: exact column Gram of the first fresh momentum buffer and $a+b+c=1$ certify the first Newton-Schulz Muon step exactly.

      The QR orthogonalizer satisfies the exact Muon direction contract whenever the executable QR pivots of the input buffer are positive.

      QR packaged as a checked exact Muon backend.

      Instances For
        theorem Optim.Muon.update_has_exact_certified_step_qr {m n : } (lr momentum : ) (buf params grads : MatrixTensor m n) (hpivots : HasPositiveQRPivots (update { lr := lr, momentum := momentum, buf := buf, orthogonalizer := qrOrthogonalizer } params grads).1.buf) :
        ∃ (direction : MatrixTensor m n), ExactCertifiedStep { lr := lr, momentum := momentum, buf := buf, orthogonalizer := qrOrthogonalizer } params grads direction

        Concrete QR-backed Muon step theorem: if the fresh momentum buffer has positive QR pivots, the executable Muon update has a certified exact step.

        theorem Optim.Muon.update_qr_direction_has_exact_column_gram {m n : } (lr momentum : ) (buf params grads : MatrixTensor m n) (hpivots : HasPositiveQRPivots (update { lr := lr, momentum := momentum, buf := buf, orthogonalizer := qrOrthogonalizer } params grads).1.buf) :
        HasExactColumnGram (qrOrthogonalizer.apply (update { lr := lr, momentum := momentum, buf := buf, orthogonalizer := qrOrthogonalizer } params grads).1.buf)

        Concrete QR-backed direction theorem: if the fresh momentum buffer has positive QR pivots, the actual direction used by the Muon update has column Gram $I$.

        theorem Optim.Muon.init_has_exact_certified_step_qr {m n : } (lr momentum : ) (params grads : MatrixTensor m n) (hpivots : HasPositiveQRPivots (update (init lr momentum qrOrthogonalizer params) params grads).1.buf) :
        ∃ (direction : MatrixTensor m n), ExactCertifiedStep (init lr momentum qrOrthogonalizer params) params grads direction

        Initialized QR-backed Muon step theorem: if the first fresh momentum buffer has positive QR pivots, the first initialized Muon update has a certified exact step.

        theorem Optim.Muon.init_qr_direction_has_exact_column_gram {m n : } (lr momentum : ) (params grads : MatrixTensor m n) (hpivots : HasPositiveQRPivots (update (init lr momentum qrOrthogonalizer params) params grads).1.buf) :
        HasExactColumnGram (qrOrthogonalizer.apply (update (init lr momentum qrOrthogonalizer params) params grads).1.buf)

        Initialized QR-backed direction theorem: if the first fresh momentum buffer has positive QR pivots, the first initialized Muon update direction has column Gram $I$.