Phases of Muoncompanion
Section SA · Setup: model, momentum, regularized SignSVD, normalization
Proved in Lean
Proposition SA.1 (Residual and gradient moments)
In Definition SA.1, \(\Sigmain\) and \(\Sigmaout\) are symmetric and positive semidefinite, and the following hold.
  1. (i)
    For deterministic \(\Delta\in\R^{\Nout\times\Nin}\) the residual \(d\defeq\Xout^\T\Delta\Xin\) is centered, and
    \begin{equation}\tag{SA.4} \EE d^2=\Var(d)=\Tr\big(\Sigmaout\Delta\Sigmain\Delta^\T\big)=\norm{\Delta}_\Sigma^2, \qquad \cR(W)=\tfrac12\norm{W-\Wstar}_\Sigma^2 . \end{equation}
  2. (ii)
    For deterministic \(\Delta\) and a batch of \(B\) independent copies, the gradient
    \[ G^\circ\defeq\frac1B\sum_ad_a^\circ\,\Xout^{(a)}\tensor\Xin^{(a)} \]
    satisfies
    \begin{equation}\tag{SA.5} G^\circ=\frac1B\,Y\vec D^\circ X^\T,\qquad \EE G^\circ=\Sigmaout\Delta\Sigmain . \end{equation}
  3. (iii)
    For the state \(\Dt\) at step \(t\) with \(\EE\norm{\Dt}_\F^2<\infty\) and the fresh batch of step \(t\), the residuals and the gradient of (SA.3) satisfy
    \begin{equation}\tag{SA.6} \EE_t\,d_a^\circ=0,\qquad \EE_t\,(d_a^\circ)^2=2\cR(t),\qquad \EE_t\,\Gt^\circ=\Sigmaout\Dt\Sigmain . \end{equation}
Proof.
The covariances are symmetric, and \(v^\T\Sigmain v=\EE[(v^\T\Xin)^2]\ge0\) for every \(v\in\R^{\Nin}\); the same holds for \(\Sigmaout\).
Mixed fourth-order moments factorize by independence: for coordinates \(i,k\le\Nout\) and \(j,l\le\Nin\),
\begin{equation}\tag{SA.7} \EE\big[(\Xout)_i(\Xout)_k(\Xin)_j(\Xin)_l\big]=(\Sigmaout)_{ik}(\Sigmain)_{jl}. \end{equation}
The second moment of the residual is the trace. Expanding
\[ d^2=\sum_{i,k\le\Nout}\sum_{j,l\le\Nin}\Delta_{ij}\Delta_{kl}\,(\Xout)_i(\Xout)_k(\Xin)_j(\Xin)_l \]
and taking expectations term by term with (SA.7) gives
\[ \EE d^2=\sum_{i,j,k,l}\Delta_{ij}\Delta_{kl}(\Sigmaout)_{ik}(\Sigmain)_{jl}=\Tr\big(\Sigmaout\Delta\Sigmain\Delta^\T\big), \]
the last equality by expanding the trace as \(\sum_{i,k,j,l}(\Sigmaout)_{ik}\Delta_{kl}(\Sigmain)_{lj}\Delta_{ij}\) and using the symmetry of \(\Sigmain\). The residual is centered because \(\EE[(\Xout)_i(\Xin)_j]=\EE(\Xout)_i\,\EE(\Xin)_j=0\) by independence, and hence \(\Var(d)=\EE d^2\). The formula for \(\cR\) is (SA.1) with \(\Delta=W-\Wstar\). This proves (i).
The matrix form of the gradient is finite algebra. Matrix multiplication gives \((Y\vec D^\circ X^\T)_{ij}=\sum_ad_a^\circ(\Xout^{(a)})_i(\Xin^{(a)})_j\), which is \(B\) times the \((i,j)\) entry of \(G^\circ\). For one sample, the entry \(d\,(\Xout)_i(\Xin)_j=\sum_{k,l}\Delta_{kl}(\Xout)_k(\Xout)_i(\Xin)_l(\Xin)_j\) has expectation \(\sum_{k,l}(\Sigmaout)_{ik}\Delta_{kl}(\Sigmain)_{lj}=(\Sigmaout\Delta\Sigmain)_{ij}\) by (SA.7); identical distribution of the samples gives \(\EE G^\circ\). This proves (ii).
Part (iii) follows from (i) and (ii) because the batch of step \(t\) is independent of the past: conditionally on \(\cF_t\) the state \(\Dt\) is fixed and the batch has its unconditional law, so the fixed-state identities of (i) and (ii) at \(\Delta=\Dt\) are the three conditional expectations.

Uses

Used by

Lean

Proved in Lean
Muon.Setup.prop_app_setup_moments_i source
theorem prop_app_setup_moments_i {m n : ℕ} {C : Covariances m n} {ν : Measure (Vec m × Vec n)}
    (hν : IsFeatureLaw C ν) (Δ : Mat m n) :
    C.Sout.PosSemidef ∧ C.Sin.PosSemidef ∧
    (∫ x, resid Δ x ∂ν = 0) ∧ (∫ x, (resid Δ x) ^ 2 ∂ν = pairSigma C Δ Δ) ∧
    variance (fun x => resid Δ x) ν = pairSigma C Δ Δ ∧
    (∀ Wstar W : Mat m n, popRisk ν Wstar W = riskSigma C (W - Wstar)) := by
Muon.Setup.prop_app_setup_moments_ii source
theorem prop_app_setup_moments_ii {m n : ℕ} {Ω : Type*} [MeasurableSpace Ω]
    (P : Measure Ω)
    [IsProbabilityMeasure P] {C : Covariances m n} {ν : Measure (Vec m × Vec n)}
    (hν : IsFeatureLaw C ν) {B : ℕ} (hB : 0 < B) (Δ : Mat m n) (x : Fin B → Ω → Vec m × Vec n)
    (hx : IIDBatch P ν x) :
    (∀ b : Batch m n B, grad Δ b = ((B : ℝ))⁻¹ •
      ((Matrix.of fun (i : Fin m) (a : Fin B) => (b a).1 i) *
        Matrix.diagonal (fun a => resid Δ (b a)) *
        (Matrix.of fun (j : Fin n) (a : Fin B) => (b a).2 j)ᵀ)) ∧
    mean P (fun ω => grad Δ (fun a => x a ω)) = C.Sout * Δ * C.Sin := by
Muon.Setup.prop_app_setup_moments_iii source
theorem prop_app_setup_moments_iii {m n : ℕ} {Ω : Type*} [MeasurableSpace Ω]
    {P : Measure Ω}
    [IsProbabilityMeasure P] {C : Covariances m n} {ν : Measure (Vec m × Vec n)}
    [IsProbabilityMeasure ν] (hν : IsFeatureLaw C ν) {B : ℕ} (hB : 0 < B) (M : ModelLaw P ν B)
    (Wstar : Mat m n) (W : ℕ → Ω → Mat m n)
    (hW : ∀ t, Measurable[M.ℱ t] (W t))
    (t : ℕ) (hWL2 : ∀ i j, MemLp (fun ω => W t ω i j) 2 P) (a : Fin B) :
    (condExp (M.ℱ t) P (fun ω => resid (W t ω - Wstar) (M.x t ω a)) =ᵐ[P] 0) ∧
    (condExp (M.ℱ t) P (fun ω => (resid (W t ω - Wstar) (M.x t ω a)) ^ 2) =ᵐ[P]
      fun ω => 2 * popRisk ν Wstar (W t ω)) ∧
    ∀ (i : Fin m) (k : Fin n),
      (condExp (M.ℱ t) P (fun ω => grad (W t ω - Wstar) (M.x t ω) i k) =ᵐ[P]
        fun ω => (C.Sout * (W t ω - Wstar) * C.Sin) i k) := by