Phases of Muoncompanion
Section SA · Setup: model, momentum, regularized SignSVD, normalization
Proved in Lean
Lemma SA.4 (Gaussian covariance of a batch)
Let \(A\in\R^{\Nout\times\Nin}\) be deterministic with \(\norm A_\F=1\), let \(z\sim\mathcal N(0,\Id_{\Nout})\) and \(w\sim\mathcal N(0,\Id_{\Nin})\) be independent, and let \(X\defeq(z^\T Aw)\,z\tensor w\). Then \(\EE X=A\), and its covariance tensor \(\mathcal C_{ij,kl}\defeq\Cov(X_{ij},X_{kl})\) is
\begin{equation}\tag{SA.27} \mathcal C_{ij,kl}=\delta_{ik}\delta_{jl}+2(AA^\T)_{ik}\delta_{jl}+2\delta_{ik}(A^\T A)_{jl}+A_{ij}A_{kl}+2A_{il}A_{kj}. \end{equation}
Consequently, in the frozen-state model with \(A=\Ahat\), the batches \(G_{t+1-j}\) are independent and identically distributed,
\begin{equation}\tag{SA.28} \begin{gathered} \EE\Gt=\Sigmaout^{1/2}\Ahat\Sigmain^{1/2},\\ \Cov\big((\Gt)_{ij},(\Gt)_{kl}\big)=\frac1B\sum_{p,q,r,s}(\Sigmaout^{1/2})_{ip}(\Sigmain^{1/2})_{jq}\,\mathcal C_{pq,rs}\,(\Sigmaout^{1/2})_{kr}(\Sigmain^{1/2})_{ls}, \end{gathered} \end{equation}
and the single-batch Frobenius variance is
\begin{equation}\tag{SA.29} \begin{aligned} \mathsf V_B&\defeq\EE\norm{\Gt-\EE\Gt}_\F^2\\ &=\frac1B\Big\{\Tr\Sigmaout\Tr\Sigmain+2\Tr(\Sigmaout\Ahat\Ahat^\T)\Tr\Sigmain+2\Tr\Sigmaout\Tr(\Sigmain\Ahat^\T\Ahat)+3\norm{\EE\Gt}_\F^2\Big\}. \end{aligned} \end{equation}
Proof.
The mean is computed by independence of \(z\) and \(w\) and the second moments of standard normals:
\[ \EE X_{ij}=\sum_{p,q}A_{pq}\,\EE[z_iz_p]\,\EE[w_jw_q]=A_{ij}. \]
The second moment is a sum over nine Wick pairings. Expanding the product,
\[ \EE[X_{ij}X_{kl}]=\sum_{p,q,r,s}A_{pq}A_{rs}\,\EE[z_iz_kz_pz_r]\,\EE[w_jw_lw_qw_s], \]
and the fourth moments of independent standard normal coordinates are
\begin{equation}\tag{SA.30} \EE[z_iz_kz_pz_r]=\delta_{ik}\delta_{pr}+\delta_{ip}\delta_{kr}+\delta_{ir}\delta_{kp}, \end{equation}
and likewise for \(w\); this identity holds because an index appearing an odd number of times gives zero, two distinct pairs give \(1\), and four equal indices give \(\EE g^4=3\), which is the number of pairings. The product of the two three-term identities has nine terms. The term pairing \((i,k)\) with \((j,l)\) contributes \(\delta_{ik}\delta_{jl}\sum_{p,q}A_{pq}^2=\delta_{ik}\delta_{jl}\). The two terms pairing \((i,k)\) in \(z\) with a crossed pairing in \(w\) contribute
\[ \delta_{ik}\sum_pA_{pj}A_{pl}+\delta_{ik}\sum_pA_{pl}A_{pj}=2\delta_{ik}(A^\T A)_{jl}, \]
and symmetrically the two terms with \((j,l)\) paired in \(w\) and a crossed pairing in \(z\) contribute \(2(AA^\T)_{ik}\delta_{jl}\). The four terms with crossed pairings in both families contribute \(A_{ij}A_{kl}+A_{il}A_{kj}+A_{kj}A_{il}+A_{kl}A_{ij}=2A_{ij}A_{kl}+2A_{il}A_{kj}\). Subtracting the product of the means \(A_{ij}A_{kl}\) gives (SA.27).
The batch statements follow from independence of the samples. The batch \(\Gt\) is the average over \(a\) of the independent, identically distributed matrices \(\Sigmaout^{1/2}X_a\Sigmain^{1/2}\), where \(X_a\) is built from \((z_a,w_a)\) and \(A=\Ahat\). Its mean is \(\Sigmaout^{1/2}\Ahat\Sigmain^{1/2}\), and its covariance is \(1/B\) times the covariance of one transformed sample, which is (SA.28) by the bilinearity of the covariance. Different batches use disjoint sets of samples and are therefore independent.
The Frobenius variance is a contraction of the tensor. For one sample,
\[ \EE\norm{\Sigmaout^{1/2}(X-A)\Sigmain^{1/2}}_\F^2=\EE\Tr\big(\Sigmaout(X-A)\Sigmain(X-A)^\T\big) =\sum_{i,j,k,l}(\Sigmaout)_{ik}(\Sigmain)_{jl}\,\mathcal C_{ij,kl}, \]
using the symmetry \(\mathcal C_{ij,kl}=\mathcal C_{kl,ij}\) and of the covariances. The five terms of (SA.27) contract to
\[ \begin{gathered} \Tr\Sigmaout\Tr\Sigmain,\qquad 2\Tr(\Sigmaout AA^\T)\Tr\Sigmain,\qquad 2\Tr\Sigmaout\Tr(\Sigmain A^\T A),\\ \Tr(\Sigmaout A\Sigmain A^\T),\qquad 2\Tr(\Sigmaout A\Sigmain A^\T), \end{gathered} \]
where the last two use \(\sum_{i,j,k,l}(\Sigmaout)_{ik}(\Sigmain)_{jl}A_{ij}A_{kl}=\sum_{i,k}(\Sigmaout)_{ik}(A\Sigmain A^\T)_{ik}\) and the same value for \(A_{il}A_{kj}\) after exchanging the roles of \(j\) and \(l\). Since \(\Tr(\Sigmaout A\Sigmain A^\T)=\norm{\Sigmaout^{1/2}A\Sigmain^{1/2}}_\F^2=\norm{\EE\Gt}_\F^2\) and \(\mathsf V_B\) is \(1/B\) times the one-sample variance, (SA.29) follows.

Used by

Lean

Proved in Lean
Muon.Setup.sampleX source
def sampleX {m n : ℕ} (A : Mat m n) (z : Vec m) (w : Vec n) : Mat m n :=
Muon.Setup.sampleTensor source
def sampleTensor {m n : ℕ} (A : Mat m n) : Fin m → Fin n → Fin m → Fin n → ℝ :=
Muon.Setup.lem_app_setup_gaussian_moments_i source
theorem lem_app_setup_gaussian_moments_i [IsProbabilityMeasure P] {Z : Ω → Vec m} {W : Ω → Vec n}
    (hZW : P.map (fun ω => (Z ω, W ω)) = (Muon.Foundations.stdGaussianPi m).prod
      (Muon.Foundations.stdGaussianPi n))
    (A : Mat m n) (hA : fro A = 1) :
    mean P (fun ω => sampleX A (Z ω) (W ω)) = A := by
Muon.Setup.lem_app_setup_gaussian_moments_ii source
theorem lem_app_setup_gaussian_moments_ii [IsProbabilityMeasure P] {Z : Ω → Vec m}
    {W : Ω → Vec n}
    (hZW : P.map (fun ω => (Z ω, W ω)) = (Muon.Foundations.stdGaussianPi m).prod
      (Muon.Foundations.stdGaussianPi n))
    (A : Mat m n) (hA : fro A = 1) :
    covT P (fun ω => sampleX A (Z ω) (W ω)) = sampleTensor A := by
Muon.Setup.lem_app_setup_gaussian_moments_iii source
theorem lem_app_setup_gaussian_moments_iii (F : FrozenParams m n B) (S : FrozenSamples P m n B) :
    iIndepFun (fun s : ℤ => frozenBatchG F S s) P ∧
      ∀ s s' : ℤ, P.map (frozenBatchG F S s) = P.map (frozenBatchG F S s') := by
Muon.Setup.lem_app_setup_gaussian_moments_iv source
theorem lem_app_setup_gaussian_moments_iv (F : FrozenParams m n B) (S : FrozenSamples P m n B)
    (s : ℤ) :
    mean P (frozenBatchG F S s) = rOut F.C * F.A * rIn F.C ∧
      ∀ (i : Fin m) (j : Fin n) (k : Fin m) (l : Fin n),
        covT P (frozenBatchG F S s) i j k l =
          (1 / (B : ℝ)) * ∑ p : Fin m, ∑ q : Fin n, ∑ r : Fin m, ∑ u : Fin n,
            rOut F.C i p * rIn F.C j q * sampleTensor F.A p q r u *
              rOut F.C k r * rIn F.C l u := by
Muon.Setup.lem_app_setup_gaussian_moments_v source
theorem lem_app_setup_gaussian_moments_v (F : FrozenParams m n B) (S : FrozenSamples P m n B) :
    frozenVB S F = (1 / (B : ℝ)) *
      (Matrix.trace F.C.Sout * Matrix.trace F.C.Sin
        + 2 * Matrix.trace (F.C.Sout * (F.A * Matrix.transpose F.A)) * Matrix.trace F.C.Sin
        + 2 * Matrix.trace F.C.Sout * Matrix.trace (F.C.Sin * (Matrix.transpose F.A * F.A))
        + 3 * (fro (mean P (frozenBatchG F S 0))) ^ 2) := by