Muon Orthogonalization Contracts #
Muon is more than momentum with a different name: after the momentum buffer is updated, the parameter direction is supposed to be an orthogonalized matrix direction. The runtime optimizer therefore takes an explicit orthogonalizer backend, while this file records the proof contract that such a backend should satisfy.
There are two useful levels:
ExactMatrixOrthogonalizersays the backend returns a matrix $Q$ with $Q^\mathsf{T}Q=I$.ApproxMatrixOrthogonalizer epssays the Gram residual $Q^\mathsf{T}Q-I$ is entrywise bounded by $\varepsilon$.
The theorems below connect those contracts to the executable Muon step: if the backend satisfies one of these contracts, the direction used in the parameter update is certified at the same level.
A matrix-shaped TorchLean tensor.
Instances For
The column Gram matrix $Q^\mathsf{T}Q$.
Instances For
Exact column orthogonality for a matrix-shaped update direction.
Instances For
A backend exactly orthogonalizes one specified momentum buffer.
Instances For
Residual matrix $Q^\mathsf{T}Q-I$, used for approximate orthogonalization certificates.
Instances For
Entrywise approximate column orthogonality.
For an exact backend use HasExactColumnGram. For Newton-Schulz or CUDA implementations, this is
the certificate shape we want the backend to establish or export: every entry of
$Q^\mathsf{T}Q-I$ is bounded by $\varepsilon$.
Instances For
A backend approximately orthogonalizes one specified momentum buffer.
Instances For
An exact matrix Muon orthogonalizer maps every momentum buffer to a direction whose columns have Gram matrix $I$.
Instances For
An approximate matrix Muon orthogonalizer maps every momentum buffer to a direction whose Gram residual is entrywise bounded by $\varepsilon$.
Instances For
Certified backend records #
Unconditionally certified exact Muon backend.
Use this when the orthogonalizer is known to return an exact $Q^\mathsf{T}Q=I$ direction for every buffer of a fixed matrix shape.
- orthogonalizer : Orthogonalizer α (Spec.Shape.dim m (Spec.Shape.dim n Spec.Shape.scalar))
Executable orthogonalizer used by Muon.
- certified : ExactMatrixOrthogonalizer self.orthogonalizer
The backend returns an exactly orthogonalized direction for every buffer.
Instances For
Unconditionally certified approximate Muon backend.
Use this when the orthogonalizer is known to return a direction whose Gram residual is bounded by $\varepsilon$ for every buffer of a fixed matrix shape.
- orthogonalizer : Orthogonalizer α (Spec.Shape.dim m (Spec.Shape.dim n Spec.Shape.scalar))
Executable orthogonalizer used by Muon.
- certified : ApproxMatrixOrthogonalizer eps self.orthogonalizer
The backend returns an approximately orthogonalized direction for every buffer.
Instances For
Checked exact Muon backend with a per-buffer success predicate.
This is the practical interface for algorithms whose correctness has preconditions on the matrix
being orthogonalized. The QR backend below is the first instance: its success predicate is positive
executable R pivots.
- orthogonalizer : Orthogonalizer α (Spec.Shape.dim m (Spec.Shape.dim n Spec.Shape.scalar))
Executable orthogonalizer used by Muon.
- Success : MatrixTensor α m n → Prop
Backend-specific success/certification condition for an input buffer.
- certified (buffer : MatrixTensor α m n) : self.Success buffer → ExactOrthogonalizesBuffer self.orthogonalizer buffer
Whenever
Success bufferholds, the backend exactly orthogonalizes that buffer.
Instances For
Checked approximate Muon backend with a per-buffer success predicate.
This is the intended proof shape for Newton-Schulz/CUDA-style backends: the kernel may be fast and
approximate, but the exported proof or checker must establish Success buffer, which then gives the
entrywise $Q^\mathsf{T}Q-I$ bound.
- orthogonalizer : Orthogonalizer α (Spec.Shape.dim m (Spec.Shape.dim n Spec.Shape.scalar))
Executable orthogonalizer used by Muon.
- Success : MatrixTensor α m n → Prop
Backend-specific success/certification condition for an input buffer.
- certified (buffer : MatrixTensor α m n) : self.Success buffer → ApproxOrthogonalizesBuffer eps self.orthogonalizer buffer
Whenever
Success bufferholds, the backend approximately orthogonalizes that buffer.