TorchLean API

NN.MLTheory.Optimization.Muon.QR

QR Muon Backend and Real-Valued Certificates #

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

The entrywise matrix API (matrix_ext, get2_mat_mul_spec) is stated over ℝ, so this module also holds the real-valued facts about columnGram and about one Newton-Schulz step at an exactly column-orthogonal matrix, which the generic NN.MLTheory.Optimization.Muon.NewtonSchulz module cannot prove.

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

Instances For

    Positive pivots of the real-valued QR specification; no native QR claim is made.

    Instances For

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

      Column Gram entries #

      theorem Optim.Muon.get2_columnGram {m n : ℕ} (Q : MatrixTensor ℝ m n) (i j : Fin n) :
      Spec.get2 (columnGram Q) i j = ∑ r : Fin m, Spec.get2 Q r i * Spec.get2 Q r j

      Entries of the column Gram matrix are inner products of columns.

      Scaling a matrix by k scales every column Gram entry by k * k.

      Scaling exactly column-orthogonal matrices #

      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.

      Newton-Schulz at an exactly column-orthogonal matrix #

      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 : ℝ) (momentumBuffer parameters gradients : MatrixTensor ℝ m n) (hgram : HasExactColumnGram (update { lr := lr, momentum := momentum, momentumBuffer := momentumBuffer, orthogonalizer := newtonSchulzOrthogonalizer coeffs steps } parameters gradients).optimizerState.momentumBuffer) (hsum : coeffs.a + coeffs.b + coeffs.c = 1) :
      ∃ (direction : MatrixTensor ℝ m n), ExactCertifiedStep { lr := lr, momentum := momentum, momentumBuffer := momentumBuffer, orthogonalizer := newtonSchulzOrthogonalizer coeffs steps } parameters gradients 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 : ℝ) (momentumBuffer parameters gradients : MatrixTensor ℝ m n) (hgram : HasExactColumnGram (update { lr := lr, momentum := momentum, momentumBuffer := momentumBuffer, orthogonalizer := newtonSchulzOrthogonalizer coeffs steps } parameters gradients).optimizerState.momentumBuffer) (hsum : coeffs.a + coeffs.b + coeffs.c = 1) :
      HasExactColumnGram ((newtonSchulzOrthogonalizer coeffs steps).apply (update { lr := lr, momentum := momentum, momentumBuffer := momentumBuffer, orthogonalizer := newtonSchulzOrthogonalizer coeffs steps } parameters gradients).optimizerState.momentumBuffer)

      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.

      QR certificates #

      The QR orthogonalizer satisfies the exact Muon direction contract whenever the 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 : ℝ) (momentumBuffer parameters gradients : MatrixTensor ℝ m n) (hpivots : HasPositiveQRPivots (update { lr := lr, momentum := momentum, momentumBuffer := momentumBuffer, orthogonalizer := qrOrthogonalizer } parameters gradients).optimizerState.momentumBuffer) :
        ∃ (direction : MatrixTensor ℝ m n), ExactCertifiedStep { lr := lr, momentum := momentum, momentumBuffer := momentumBuffer, orthogonalizer := qrOrthogonalizer } parameters gradients 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 : ℝ) (momentumBuffer parameters gradients : MatrixTensor ℝ m n) (hpivots : HasPositiveQRPivots (update { lr := lr, momentum := momentum, momentumBuffer := momentumBuffer, orthogonalizer := qrOrthogonalizer } parameters gradients).optimizerState.momentumBuffer) :
        HasExactColumnGram (qrOrthogonalizer.apply (update { lr := lr, momentum := momentum, momentumBuffer := momentumBuffer, orthogonalizer := qrOrthogonalizer } parameters gradients).optimizerState.momentumBuffer)

        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$.