Documentation

LeanMlir.Proofs.Nets.ViT.ViTParamGrad

ViT-Tiny — every parameter gradient node IS the loss's derivative in that parameter #

vit_net_tiedGB says each of the 200 parameter gradient nodes denotes its layer's parameter Jacobian contracted with the cotangent the emitted backward chain threads to it, the chain's top being the smoothed-loss cotangent. vit_net_lossGrad composes that with the chain: for any loss L of the logits whose gradient at the net's output is g, the loss of the WHOLE net vitNetB with that one parameter varied is differentiable in it and every node is its gradient (HasGradAt). vitNetB is the tie's forward, batched, at its stochastic-depth sites sd; at none it is batchMap N of the canonical vitForwardKV at the twelve blocks (vitNetB_eq_vitForwardKV). vit_net_lossGrad_smoothedCE discharges hL for the label-smoothed loss the artifacts ship (smoothedBatchLossDiv, whose gradient is the softmaxDiv cotangent the render emits).

How. ConvNeXt's shape (ConvNeXtParamGrad.lean): no ViT op couples examples, so the work is per example and lifted once.

Two nodes carry the batch sum inside den, as their text does: the classifier bias (biasGradB) and the CLS token.

Hypotheses. 0 < ε (the LayerNorms' VJPs); no smoothness hypothesis (GELU has no kink). For the smoothed loss, every example's target sums to one and 0 < nC. Stated at ViT-Tiny's literal dims, as the tie is.

Stochastic depth. As in the tie: sd is the render's drop flag, none the drop-free chain, some the *drop* artifacts'. Per example a site is siteScale on the out-projection's or fc2's output (vitHM, vitPostO, vitPostL2/F1/F2), so the loss read after each op runs through it, and the cotangents the bundle states are the tie's at the same sites.

Precision. As in the tie: every per-token dense weight node is rowDenseWeightGradBAt bf16 id … and the patch-embed weight node patchEmbedWeightGradBAt (bf16 && bf16ConvW) id … (StableHLO.PrecisionSwitch), so bf16 := true is the kind the vitin_*bf16 artifacts emit, read over ℝ at the identity rounding (Bf16Erasure), and bf16 := false the f32 artifacts'. The bias, LayerNorm, CLS, position and classifier nodes carry no flag because no render switches them.

noncomputable def Proofs.ViTTieGB.attnCore {Np1 heads d : ℕ} (Q K V : Mat Np1 (heads * d)) :
Mat Np1 (heads * d)

The multi-head attention core as the render spells it: per head, slice → scaled Q·Kᵀ → row softmax → ·V → pad, summed over heads (blkSaves' att).

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    theorem Proofs.ViTTieGB.attnCore_eq_colSlabQ {Np1 heads d : ℕ} (K V : Mat Np1 (heads * d)) :
    (fun (Q : Mat Np1 (heads * d)) => attnCore Q K V) = colSlabApplyH fun (hh : Fin heads) (Q' : Mat Np1 d) => sdpa Np1 d Q' (headSliceMat Np1 heads d hh K) (headSliceMat Np1 heads d hh V)

    The core in Q is a per-slab map: each head's attention on its own Q slab (sum_headPadMat_apply).

    theorem Proofs.ViTTieGB.attnCore_eq_colSlabK {Np1 heads d : ℕ} (Q V : Mat Np1 (heads * d)) :
    (fun (K : Mat Np1 (heads * d)) => attnCore Q K V) = colSlabApplyH fun (hh : Fin heads) (K' : Mat Np1 d) => sdpa Np1 d (headSliceMat Np1 heads d hh Q) K' (headSliceMat Np1 heads d hh V)

    …in K.

    theorem Proofs.ViTTieGB.attnCore_eq_colSlabV {Np1 heads d : ℕ} (Q K : Mat Np1 (heads * d)) :
    (fun (V : Mat Np1 (heads * d)) => attnCore Q K V) = colSlabApplyH fun (hh : Fin heads) (V' : Mat Np1 d) => sdpa Np1 d (headSliceMat Np1 heads d hh Q) (headSliceMat Np1 heads d hh K) V'

    …in V.

    noncomputable def Proofs.ViTTieGB.attnCoreQHasVJPMat {Np1 heads d : ℕ} (K V : Mat Np1 (heads * d)) :
    HasVJPMat fun (Q : Mat Np1 (heads * d)) => attnCore Q K V

    The attention core's VJP in Q, K, V fixed: per head, the certified sdpaBackQ.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      noncomputable def Proofs.ViTTieGB.attnCoreKHasVJPMat {Np1 heads d : ℕ} (Q V : Mat Np1 (heads * d)) :
      HasVJPMat fun (K : Mat Np1 (heads * d)) => attnCore Q K V

      …in K: per head, sdpaBackK.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        noncomputable def Proofs.ViTTieGB.attnCoreVHasVJPMat {Np1 heads d : ℕ} (Q K : Mat Np1 (heads * d)) :
        HasVJPMat fun (V : Mat Np1 (heads * d)) => attnCore Q K V

        …in V: per head, sdpaBackV.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          theorem Proofs.ViTTieGB.attnCoreQ_flat_differentiable {Np1 heads d : ℕ} (K V : Mat Np1 (heads * d)) :
          Differentiable ℝ fun (v : Vec (Np1 * (heads * d))) => (attnCore (Mat.unflatten v) K V).flatten

          The core is differentiable in Q, flattened.

          theorem Proofs.ViTTieGB.attnCoreK_flat_differentiable {Np1 heads d : ℕ} (Q V : Mat Np1 (heads * d)) :
          Differentiable ℝ fun (v : Vec (Np1 * (heads * d))) => (attnCore Q (Mat.unflatten v) V).flatten

          …in K.

          theorem Proofs.ViTTieGB.attnCoreV_flat_differentiable {Np1 heads d : ℕ} (Q K : Mat Np1 (heads * d)) :
          Differentiable ℝ fun (v : Vec (Np1 * (heads * d))) => (attnCore Q K (Mat.unflatten v)).flatten

          …in V.

          theorem Proofs.ViTTieGB.attnCoreQ_backward {Np1 heads d : ℕ} (Q K V : Mat Np1 (heads * d)) (dA : Vec (Np1 * (heads * d))) :

          The core's Q backward IS the tie's coreQFlat — the per-head sdpaBackQ on each slab, concatenated; rfl once the saved Q is unflattened.

          theorem Proofs.ViTTieGB.attnCoreK_backward {Np1 heads d : ℕ} (Q K V : Mat Np1 (heads * d)) (dA : Vec (Np1 * (heads * d))) :

          …K: coreKFlat.

          theorem Proofs.ViTTieGB.attnCoreV_backward {Np1 heads d : ℕ} (Q K V : Mat Np1 (heads * d)) (dA : Vec (Np1 * (heads * d))) :

          …V: coreVFlat.

          theorem Proofs.ViTTieGB.vitMlpSite_hasGradAt {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (hε : 0 < ε) (p : BlockParamsV (heads * d) mlpDim) (sM : Option ℝ) (H : Mat Np1 (heads * d)) (dy : Vec (Np1 * (heads * d))) :
          HasGradAt (fun (v : Vec (Np1 * (heads * d))) => linLoss dy (vitMlpSiteF gf sM ε p v)) H.flatten (vitCotHVD gf ε p.γ2 p.Wfc1 p.Wfc2 sM H.flatten (Mat.flatten fun (r : Fin Np1) => dense p.Wfc1 p.bfc1 (layerNormVec (heads * d) ε p.γ2 p.β2 (H r))) dy)

          The MLP sublayer's input gradient at its site is vitCotHVD, at any saved sublayer input H: the raw skip plus the MLP branch's certified backward of sM ⊙ dy (vitMlpBr_back).

          The block's forward, per example, as named Mats — blkSaves' let chain verbatim, the attention site in h.

          noncomputable def Proofs.ViTTieGB.vitLn1M {Np1 heads d mlpDim : ℕ} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (y : Vec (Np1 * (heads * d))) :
          Mat Np1 (heads * d)

          LN₁'s output.

          Equations
          Instances For
            noncomputable def Proofs.ViTTieGB.vitQM {Np1 heads d mlpDim : ℕ} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (y : Vec (Np1 * (heads * d))) :
            Mat Np1 (heads * d)

            The Q projection.

            Equations
            Instances For
              noncomputable def Proofs.ViTTieGB.vitKM {Np1 heads d mlpDim : ℕ} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (y : Vec (Np1 * (heads * d))) :
              Mat Np1 (heads * d)

              The K projection.

              Equations
              Instances For
                noncomputable def Proofs.ViTTieGB.vitVM {Np1 heads d mlpDim : ℕ} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (y : Vec (Np1 * (heads * d))) :
                Mat Np1 (heads * d)

                The V projection.

                Equations
                Instances For
                  noncomputable def Proofs.ViTTieGB.vitAttM {Np1 heads d mlpDim : ℕ} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (y : Vec (Np1 * (heads * d))) :
                  Mat Np1 (heads * d)

                  The attention core's output (the out-projection's input).

                  Equations
                  Instances For
                    noncomputable def Proofs.ViTTieGB.vitOM {Np1 heads d mlpDim : ℕ} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (y : Vec (Np1 * (heads * d))) :
                    Mat Np1 (heads * d)

                    The out-projection's output.

                    Equations
                    Instances For
                      noncomputable def Proofs.ViTTieGB.vitHM {Np1 heads d mlpDim : ℕ} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA : Option ℝ) (y : Vec (Np1 * (heads * d))) :
                      Mat Np1 (heads * d)

                      The attention sublayer's output h, the out-projection through the attention site.

                      Equations
                      Instances For
                        noncomputable def Proofs.ViTTieGB.vitLn2M {Np1 heads d mlpDim : ℕ} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA : Option ℝ) (y : Vec (Np1 * (heads * d))) :
                        Mat Np1 (heads * d)

                        LN₂'s output.

                        Equations
                        Instances For
                          noncomputable def Proofs.ViTTieGB.vitM1M {Np1 heads d mlpDim : ℕ} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA : Option ℝ) (y : Vec (Np1 * (heads * d))) :
                          Mat Np1 mlpDim

                          fc1's output (pre-GELU).

                          Equations
                          Instances For
                            noncomputable def Proofs.ViTTieGB.vitWoF {Np1 heads d mlpDim : ℕ} (p : BlockParamsV (heads * d) mlpDim) :
                            Vec (Np1 * (heads * d)) → Vec (Np1 * (heads * d))

                            The out-projection, flat.

                            Equations
                            Instances For
                              noncomputable def Proofs.ViTTieGB.vitPostO {Np1 heads d mlpDim : ℕ} (gf : GeluForm) (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (y : Vec (Np1 * (heads * d))) :
                              Vec (Np1 * (heads * d)) → Vec (Np1 * (heads * d))

                              The block after the out-projection: the attention site and residual, then the MLP sublayer at its site.

                              Equations
                              Instances For
                                theorem Proofs.ViTTieGB.vitHM_flat {Np1 heads d mlpDim : ℕ} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA : Option ℝ) (y : Vec (Np1 * (heads * d))) :
                                (fun (i : Fin (Np1 * (heads * d))) => y i + dropScalarOpt sA (vitOM ε p y).flatten i) = (vitHM ε p sA y).flatten

                                The attention residual's flat sum is h, flattened.

                                theorem Proofs.ViTTieGB.vitPostO_hasGradAt {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (hε : 0 < ε) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (y dy : Vec (Np1 * (heads * d))) :
                                HasGradAt (fun (u : Vec (Np1 * (heads * d))) => linLoss dy (vitPostO gf ε p sA sM y u)) (vitOM ε p y).flatten (dropScalarOpt sA (cH gf ε p.γ1 p.β1 p.γ2 p.β2 p.Wq p.Wk p.Wv p.Wo p.bq p.bk p.bv p.bo p.Wfc1 p.bfc1 p.Wfc2 sA sM y dy))

                                The out-projection's output cotangent is sA ⊙ cH — the loss after the out-projection; the site's backward is the site (dropScalarOptHasVJP).

                                theorem Proofs.ViTTieGB.vitPostAtt_hasGradAt {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (hε : 0 < ε) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (y dy : Vec (Np1 * (heads * d))) :
                                HasGradAt (fun (a : Vec (Np1 * (heads * d))) => linLoss dy (vitPostO gf ε p sA sM y (vitWoF p a))) (vitAttM ε p y).flatten (cAtt gf ε p.γ1 p.β1 p.γ2 p.β2 p.Wq p.Wk p.Wv p.Wo p.bq p.bk p.bv p.bo p.Wfc1 p.bfc1 p.Wfc2 sA sM y dy)

                                The block after the attention core: out-projection, then vitPostO.

                                noncomputable def Proofs.ViTTieGB.vitPostQ {Np1 heads d mlpDim : ℕ} (gf : GeluForm) (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (y : Vec (Np1 * (heads * d))) :
                                Vec (Np1 * (heads * d)) → Vec (Np1 * (heads * d))

                                The block after the Q projection.

                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For
                                  noncomputable def Proofs.ViTTieGB.vitPostK {Np1 heads d mlpDim : ℕ} (gf : GeluForm) (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (y : Vec (Np1 * (heads * d))) :
                                  Vec (Np1 * (heads * d)) → Vec (Np1 * (heads * d))

                                  The block after the K projection.

                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  Instances For
                                    noncomputable def Proofs.ViTTieGB.vitPostV {Np1 heads d mlpDim : ℕ} (gf : GeluForm) (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (y : Vec (Np1 * (heads * d))) :
                                    Vec (Np1 * (heads * d)) → Vec (Np1 * (heads * d))

                                    The block after the V projection.

                                    Equations
                                    • One or more equations did not get rendered due to their size.
                                    Instances For
                                      theorem Proofs.ViTTieGB.vitPostQ_hasGradAt {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (hε : 0 < ε) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (y dy : Vec (Np1 * (heads * d))) :
                                      HasGradAt (fun (u : Vec (Np1 * (heads * d))) => linLoss dy (vitPostQ gf ε p sA sM y u)) (vitQM ε p y).flatten (cQ gf ε p.γ1 p.β1 p.γ2 p.β2 p.Wq p.Wk p.Wv p.Wo p.bq p.bk p.bv p.bo p.Wfc1 p.bfc1 p.Wfc2 sA sM y dy)

                                      The Q projection's output cotangent is cQ: cAtt pulled back through the core in Q.

                                      theorem Proofs.ViTTieGB.vitPostK_hasGradAt {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (hε : 0 < ε) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (y dy : Vec (Np1 * (heads * d))) :
                                      HasGradAt (fun (u : Vec (Np1 * (heads * d))) => linLoss dy (vitPostK gf ε p sA sM y u)) (vitKM ε p y).flatten (cK gf ε p.γ1 p.β1 p.γ2 p.β2 p.Wq p.Wk p.Wv p.Wo p.bq p.bk p.bv p.bo p.Wfc1 p.bfc1 p.Wfc2 sA sM y dy)

                                      The K projection's output cotangent is cK.

                                      theorem Proofs.ViTTieGB.vitPostV_hasGradAt {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (hε : 0 < ε) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (y dy : Vec (Np1 * (heads * d))) :
                                      HasGradAt (fun (u : Vec (Np1 * (heads * d))) => linLoss dy (vitPostV gf ε p sA sM y u)) (vitVM ε p y).flatten (cV gf ε p.γ1 p.β1 p.γ2 p.β2 p.Wq p.Wk p.Wv p.Wo p.bq p.bk p.bv p.bo p.Wfc1 p.bfc1 p.Wfc2 sA sM y dy)

                                      The V projection's output cotangent is cV.

                                      noncomputable def Proofs.ViTTieGB.vitPostL1 {Np1 heads d mlpDim : ℕ} (gf : GeluForm) (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (y : Vec (Np1 * (heads * d))) :
                                      Vec (Np1 * (heads * d)) → Vec (Np1 * (heads * d))

                                      The block after LN₁: the multi-head attention layer, then vitPostO.

                                      Equations
                                      Instances For
                                        theorem Proofs.ViTTieGB.vitPostL1_hasGradAt {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (hε : 0 < ε) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (y dy : Vec (Np1 * (heads * d))) :
                                        HasGradAt (fun (u : Vec (Np1 * (heads * d))) => linLoss dy (vitPostL1 gf ε p sA sM y u)) (vitLn1M ε p y).flatten (cLn1 gf ε p.γ1 p.β1 p.γ2 p.β2 p.Wq p.Wk p.Wv p.Wo p.bq p.bk p.bv p.bo p.Wfc1 p.bfc1 p.Wfc2 sA sM y dy)

                                        LN₁'s output cotangent is cLn1: sA ⊙ cH pulled back through the certified attention layer (mhsaBackFlat_eq_mhsa_vjp), whose three paths are the Q/K/V fan-in.

                                        noncomputable def Proofs.ViTTieGB.vitPostL2 {Np1 heads d mlpDim : ℕ} (gf : GeluForm) (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (y : Vec (Np1 * (heads * d))) :
                                        Vec (Np1 * (heads * d)) → Vec (Np1 * (heads * d))

                                        The block after LN₂: the MLP body through the MLP site, then the residual.

                                        Equations
                                        • One or more equations did not get rendered due to their size.
                                        Instances For
                                          theorem Proofs.ViTTieGB.hasGradAt_constAdd_site {n : ℕ} (c : Vec n) (sM : Option ℝ) (u dy : Vec n) :
                                          HasGradAt (fun (u' : Vec n) => linLoss dy fun (i : Fin n) => c i + dropScalarOpt sM u' i) u (dropScalarOpt sM dy)

                                          The loss read after a branch's last op, through its site: u ↦ ⟨c + sM ⊙ u, dy⟩ has gradient sM ⊙ dy (the site's backward is the site).

                                          theorem Proofs.ViTTieGB.vitPostL2_hasGradAt {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (y dy : Vec (Np1 * (heads * d))) :
                                          HasGradAt (fun (u : Vec (Np1 * (heads * d))) => linLoss dy (vitPostL2 gf ε p sA sM y u)) (vitLn2M ε p sA y).flatten (cLn2 gf ε p.γ1 p.β1 p.γ2 p.β2 p.Wq p.Wk p.Wv p.Wo p.bq p.bk p.bv p.bo p.Wfc1 p.bfc1 p.Wfc2 sA sM y dy)

                                          LN₂'s output cotangent is cLn2: the MLP body's certified backward (transformerMlp_back_flat_eq_perRowFlatPR) at sM ⊙ dy.

                                          noncomputable def Proofs.ViTTieGB.vitPostF1 {Np1 heads d mlpDim : ℕ} (gf : GeluForm) (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (y : Vec (Np1 * (heads * d))) :
                                          Vec (Np1 * mlpDim) → Vec (Np1 * (heads * d))

                                          The block after fc1: GELU, fc2, the MLP site, then the residual.

                                          Equations
                                          • One or more equations did not get rendered due to their size.
                                          Instances For
                                            theorem Proofs.ViTTieGB.vitPostF1_hasGradAt {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (y dy : Vec (Np1 * (heads * d))) :
                                            HasGradAt (fun (u : Vec (Np1 * mlpDim)) => linLoss dy (vitPostF1 gf ε p sA sM y u)) (vitM1M ε p sA y).flatten (cM1 gf ε p.γ1 p.β1 p.γ2 p.β2 p.Wq p.Wk p.Wv p.Wo p.bq p.bk p.bv p.bo p.Wfc1 p.bfc1 p.Wfc2 sA sM y dy)

                                            fc1's output cotangent is cM1: through fc2 and the GELU, at sM ⊙ dy.

                                            noncomputable def Proofs.ViTTieGB.vitPostF2 {Np1 heads d mlpDim : ℕ} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (y : Vec (Np1 * (heads * d))) :
                                            Vec (Np1 * (heads * d)) → Vec (Np1 * (heads * d))

                                            The block after fc2: the MLP site, then the residual.

                                            Equations
                                            Instances For
                                              theorem Proofs.ViTTieGB.vitPostF2_hasGradAt {Np1 heads d mlpDim : ℕ} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (y dy u : Vec (Np1 * (heads * d))) :
                                              HasGradAt (fun (u' : Vec (Np1 * (heads * d))) => linLoss dy (vitPostF2 ε p sA sM y u')) u (dropScalarOpt sM dy)

                                              fc2's output cotangent is sM ⊙ dy.

                                              The block forward, read after each node #

                                              theorem Proofs.ViTTieGB.vit_fwd_eq_postO {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (y : Vec (Np1 * (heads * d))) :
                                              BlockParamsV.fwdOD gf p ε sA sM y = vitPostO gf ε p sA sM y (vitOM ε p y).flatten

                                              The block forward is vitPostO at the out-projection's output.

                                              theorem Proofs.ViTTieGB.vit_fwd_eq_postF2 {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (y : Vec (Np1 * (heads * d))) :
                                              BlockParamsV.fwdOD gf p ε sA sM y = vitPostF2 ε p sA sM y (Mat.flatten fun (r : Fin Np1) => dense p.Wfc2 p.bfc2 (gf.map mlpDim (vitM1M ε p sA y r)))

                                              The block forward is vitPostF2 at fc2's output (rfl).

                                              theorem Proofs.ViTTieGB.vit_fwd_γ1 {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (θ : Vec (heads * d)) (y : Vec (Np1 * (heads * d))) :
                                              BlockParamsV.fwdOD gf { γ1 := θ, β1 := p.β1, Wq := p.Wq, Wk := p.Wk, Wv := p.Wv, Wo := p.Wo, bq := p.bq, bk := p.bk, bv := p.bv, bo := p.bo, γ2 := p.γ2, β2 := p.β2, Wfc1 := p.Wfc1, bfc1 := p.bfc1, Wfc2 := p.Wfc2, bfc2 := p.bfc2 } ε sA sM y = vitPostL1 gf ε p sA sM y (Mat.flatten fun (r : Fin Np1) => layerNormVec (heads * d) ε θ p.β1 (Mat.unflatten y r))

                                              The block with γ1 varied is vitPostL1 after LN₁ at that γ1. The fifteen lemmas below say the same for each other parameter: the node's op at the varied parameter, between the block's prefix and the rest of the block (vitPost*).

                                              theorem Proofs.ViTTieGB.vit_fwd_β1 {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (θ : Vec (heads * d)) (y : Vec (Np1 * (heads * d))) :
                                              BlockParamsV.fwdOD gf { γ1 := p.γ1, β1 := θ, Wq := p.Wq, Wk := p.Wk, Wv := p.Wv, Wo := p.Wo, bq := p.bq, bk := p.bk, bv := p.bv, bo := p.bo, γ2 := p.γ2, β2 := p.β2, Wfc1 := p.Wfc1, bfc1 := p.bfc1, Wfc2 := p.Wfc2, bfc2 := p.bfc2 } ε sA sM y = vitPostL1 gf ε p sA sM y (Mat.flatten fun (r : Fin Np1) => layerNormVec (heads * d) ε p.γ1 θ (Mat.unflatten y r))
                                              theorem Proofs.ViTTieGB.vit_fwd_Wq {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (W : Mat (heads * d) (heads * d)) (y : Vec (Np1 * (heads * d))) :
                                              BlockParamsV.fwdOD gf { γ1 := p.γ1, β1 := p.β1, Wq := W, Wk := p.Wk, Wv := p.Wv, Wo := p.Wo, bq := p.bq, bk := p.bk, bv := p.bv, bo := p.bo, γ2 := p.γ2, β2 := p.β2, Wfc1 := p.Wfc1, bfc1 := p.bfc1, Wfc2 := p.Wfc2, bfc2 := p.bfc2 } ε sA sM y = vitPostQ gf ε p sA sM y (Mat.flatten fun (r : Fin Np1) => dense W p.bq (Mat.unflatten (vitLn1M ε p y).flatten r))
                                              theorem Proofs.ViTTieGB.vit_fwd_bq {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (θ : Vec (heads * d)) (y : Vec (Np1 * (heads * d))) :
                                              BlockParamsV.fwdOD gf { γ1 := p.γ1, β1 := p.β1, Wq := p.Wq, Wk := p.Wk, Wv := p.Wv, Wo := p.Wo, bq := θ, bk := p.bk, bv := p.bv, bo := p.bo, γ2 := p.γ2, β2 := p.β2, Wfc1 := p.Wfc1, bfc1 := p.bfc1, Wfc2 := p.Wfc2, bfc2 := p.bfc2 } ε sA sM y = vitPostQ gf ε p sA sM y (Mat.flatten fun (r : Fin Np1) => dense p.Wq θ (Mat.unflatten (vitLn1M ε p y).flatten r))
                                              theorem Proofs.ViTTieGB.vit_fwd_Wk {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (W : Mat (heads * d) (heads * d)) (y : Vec (Np1 * (heads * d))) :
                                              BlockParamsV.fwdOD gf { γ1 := p.γ1, β1 := p.β1, Wq := p.Wq, Wk := W, Wv := p.Wv, Wo := p.Wo, bq := p.bq, bk := p.bk, bv := p.bv, bo := p.bo, γ2 := p.γ2, β2 := p.β2, Wfc1 := p.Wfc1, bfc1 := p.bfc1, Wfc2 := p.Wfc2, bfc2 := p.bfc2 } ε sA sM y = vitPostK gf ε p sA sM y (Mat.flatten fun (r : Fin Np1) => dense W p.bk (Mat.unflatten (vitLn1M ε p y).flatten r))
                                              theorem Proofs.ViTTieGB.vit_fwd_bk {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (θ : Vec (heads * d)) (y : Vec (Np1 * (heads * d))) :
                                              BlockParamsV.fwdOD gf { γ1 := p.γ1, β1 := p.β1, Wq := p.Wq, Wk := p.Wk, Wv := p.Wv, Wo := p.Wo, bq := p.bq, bk := θ, bv := p.bv, bo := p.bo, γ2 := p.γ2, β2 := p.β2, Wfc1 := p.Wfc1, bfc1 := p.bfc1, Wfc2 := p.Wfc2, bfc2 := p.bfc2 } ε sA sM y = vitPostK gf ε p sA sM y (Mat.flatten fun (r : Fin Np1) => dense p.Wk θ (Mat.unflatten (vitLn1M ε p y).flatten r))
                                              theorem Proofs.ViTTieGB.vit_fwd_Wv {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (W : Mat (heads * d) (heads * d)) (y : Vec (Np1 * (heads * d))) :
                                              BlockParamsV.fwdOD gf { γ1 := p.γ1, β1 := p.β1, Wq := p.Wq, Wk := p.Wk, Wv := W, Wo := p.Wo, bq := p.bq, bk := p.bk, bv := p.bv, bo := p.bo, γ2 := p.γ2, β2 := p.β2, Wfc1 := p.Wfc1, bfc1 := p.bfc1, Wfc2 := p.Wfc2, bfc2 := p.bfc2 } ε sA sM y = vitPostV gf ε p sA sM y (Mat.flatten fun (r : Fin Np1) => dense W p.bv (Mat.unflatten (vitLn1M ε p y).flatten r))
                                              theorem Proofs.ViTTieGB.vit_fwd_bv {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (θ : Vec (heads * d)) (y : Vec (Np1 * (heads * d))) :
                                              BlockParamsV.fwdOD gf { γ1 := p.γ1, β1 := p.β1, Wq := p.Wq, Wk := p.Wk, Wv := p.Wv, Wo := p.Wo, bq := p.bq, bk := p.bk, bv := θ, bo := p.bo, γ2 := p.γ2, β2 := p.β2, Wfc1 := p.Wfc1, bfc1 := p.bfc1, Wfc2 := p.Wfc2, bfc2 := p.bfc2 } ε sA sM y = vitPostV gf ε p sA sM y (Mat.flatten fun (r : Fin Np1) => dense p.Wv θ (Mat.unflatten (vitLn1M ε p y).flatten r))
                                              theorem Proofs.ViTTieGB.vit_fwd_Wo {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (W : Mat (heads * d) (heads * d)) (y : Vec (Np1 * (heads * d))) :
                                              BlockParamsV.fwdOD gf { γ1 := p.γ1, β1 := p.β1, Wq := p.Wq, Wk := p.Wk, Wv := p.Wv, Wo := W, bq := p.bq, bk := p.bk, bv := p.bv, bo := p.bo, γ2 := p.γ2, β2 := p.β2, Wfc1 := p.Wfc1, bfc1 := p.bfc1, Wfc2 := p.Wfc2, bfc2 := p.bfc2 } ε sA sM y = vitPostO gf ε p sA sM y (Mat.flatten fun (r : Fin Np1) => dense W p.bo (Mat.unflatten (vitAttM ε p y).flatten r))
                                              theorem Proofs.ViTTieGB.vit_fwd_bo {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (θ : Vec (heads * d)) (y : Vec (Np1 * (heads * d))) :
                                              BlockParamsV.fwdOD gf { γ1 := p.γ1, β1 := p.β1, Wq := p.Wq, Wk := p.Wk, Wv := p.Wv, Wo := p.Wo, bq := p.bq, bk := p.bk, bv := p.bv, bo := θ, γ2 := p.γ2, β2 := p.β2, Wfc1 := p.Wfc1, bfc1 := p.bfc1, Wfc2 := p.Wfc2, bfc2 := p.bfc2 } ε sA sM y = vitPostO gf ε p sA sM y (Mat.flatten fun (r : Fin Np1) => dense p.Wo θ (Mat.unflatten (vitAttM ε p y).flatten r))
                                              theorem Proofs.ViTTieGB.vit_fwd_γ2 {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (θ : Vec (heads * d)) (y : Vec (Np1 * (heads * d))) :
                                              BlockParamsV.fwdOD gf { γ1 := p.γ1, β1 := p.β1, Wq := p.Wq, Wk := p.Wk, Wv := p.Wv, Wo := p.Wo, bq := p.bq, bk := p.bk, bv := p.bv, bo := p.bo, γ2 := θ, β2 := p.β2, Wfc1 := p.Wfc1, bfc1 := p.bfc1, Wfc2 := p.Wfc2, bfc2 := p.bfc2 } ε sA sM y = vitPostL2 gf ε p sA sM y (Mat.flatten fun (r : Fin Np1) => layerNormVec (heads * d) ε θ p.β2 (Mat.unflatten (vitHM ε p sA y).flatten r))
                                              theorem Proofs.ViTTieGB.vit_fwd_β2 {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (θ : Vec (heads * d)) (y : Vec (Np1 * (heads * d))) :
                                              BlockParamsV.fwdOD gf { γ1 := p.γ1, β1 := p.β1, Wq := p.Wq, Wk := p.Wk, Wv := p.Wv, Wo := p.Wo, bq := p.bq, bk := p.bk, bv := p.bv, bo := p.bo, γ2 := p.γ2, β2 := θ, Wfc1 := p.Wfc1, bfc1 := p.bfc1, Wfc2 := p.Wfc2, bfc2 := p.bfc2 } ε sA sM y = vitPostL2 gf ε p sA sM y (Mat.flatten fun (r : Fin Np1) => layerNormVec (heads * d) ε p.γ2 θ (Mat.unflatten (vitHM ε p sA y).flatten r))
                                              theorem Proofs.ViTTieGB.vit_fwd_Wfc1 {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (W : Mat (heads * d) mlpDim) (y : Vec (Np1 * (heads * d))) :
                                              BlockParamsV.fwdOD gf { γ1 := p.γ1, β1 := p.β1, Wq := p.Wq, Wk := p.Wk, Wv := p.Wv, Wo := p.Wo, bq := p.bq, bk := p.bk, bv := p.bv, bo := p.bo, γ2 := p.γ2, β2 := p.β2, Wfc1 := W, bfc1 := p.bfc1, Wfc2 := p.Wfc2, bfc2 := p.bfc2 } ε sA sM y = vitPostF1 gf ε p sA sM y (Mat.flatten fun (r : Fin Np1) => dense W p.bfc1 (Mat.unflatten (vitLn2M ε p sA y).flatten r))
                                              theorem Proofs.ViTTieGB.vit_fwd_bfc1 {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (θ : Vec mlpDim) (y : Vec (Np1 * (heads * d))) :
                                              BlockParamsV.fwdOD gf { γ1 := p.γ1, β1 := p.β1, Wq := p.Wq, Wk := p.Wk, Wv := p.Wv, Wo := p.Wo, bq := p.bq, bk := p.bk, bv := p.bv, bo := p.bo, γ2 := p.γ2, β2 := p.β2, Wfc1 := p.Wfc1, bfc1 := θ, Wfc2 := p.Wfc2, bfc2 := p.bfc2 } ε sA sM y = vitPostF1 gf ε p sA sM y (Mat.flatten fun (r : Fin Np1) => dense p.Wfc1 θ (Mat.unflatten (vitLn2M ε p sA y).flatten r))
                                              theorem Proofs.ViTTieGB.vit_fwd_Wfc2 {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (W : Mat mlpDim (heads * d)) (y : Vec (Np1 * (heads * d))) :
                                              BlockParamsV.fwdOD gf { γ1 := p.γ1, β1 := p.β1, Wq := p.Wq, Wk := p.Wk, Wv := p.Wv, Wo := p.Wo, bq := p.bq, bk := p.bk, bv := p.bv, bo := p.bo, γ2 := p.γ2, β2 := p.β2, Wfc1 := p.Wfc1, bfc1 := p.bfc1, Wfc2 := W, bfc2 := p.bfc2 } ε sA sM y = vitPostF2 ε p sA sM y (Mat.flatten fun (r : Fin Np1) => dense W p.bfc2 (Mat.unflatten (Mat.flatten fun (r' : Fin Np1) => gf.map mlpDim (vitM1M ε p sA y r')) r))
                                              theorem Proofs.ViTTieGB.vit_fwd_bfc2 {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (θ : Vec (heads * d)) (y : Vec (Np1 * (heads * d))) :
                                              BlockParamsV.fwdOD gf { γ1 := p.γ1, β1 := p.β1, Wq := p.Wq, Wk := p.Wk, Wv := p.Wv, Wo := p.Wo, bq := p.bq, bk := p.bk, bv := p.bv, bo := p.bo, γ2 := p.γ2, β2 := p.β2, Wfc1 := p.Wfc1, bfc1 := p.bfc1, Wfc2 := p.Wfc2, bfc2 := θ } ε sA sM y = vitPostF2 ε p sA sM y (Mat.flatten fun (r : Fin Np1) => dense p.Wfc2 θ (Mat.unflatten (Mat.flatten fun (r' : Fin Np1) => gf.map mlpDim (vitM1M ε p sA y r')) r))

                                              Differentiability #

                                              theorem Proofs.ViTTieGB.vitPostO_differentiable {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (hε : 0 < ε) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (y : Vec (Np1 * (heads * d))) :
                                              Differentiable ℝ (vitPostO gf ε p sA sM y)

                                              Each vitPost* is differentiable (0 < ε where the MLP sublayer's LN₂ is inside).

                                              theorem Proofs.ViTTieGB.vitWoF_differentiable {Np1 heads d mlpDim : ℕ} (p : BlockParamsV (heads * d) mlpDim) :
                                              theorem Proofs.ViTTieGB.vitPostL1_differentiable {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (hε : 0 < ε) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (y : Vec (Np1 * (heads * d))) :
                                              Differentiable ℝ (vitPostL1 gf ε p sA sM y)
                                              theorem Proofs.ViTTieGB.vitPostQ_differentiable {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (hε : 0 < ε) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (y : Vec (Np1 * (heads * d))) :
                                              Differentiable ℝ (vitPostQ gf ε p sA sM y)
                                              theorem Proofs.ViTTieGB.vitPostK_differentiable {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (hε : 0 < ε) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (y : Vec (Np1 * (heads * d))) :
                                              Differentiable ℝ (vitPostK gf ε p sA sM y)
                                              theorem Proofs.ViTTieGB.vitPostV_differentiable {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (hε : 0 < ε) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (y : Vec (Np1 * (heads * d))) :
                                              Differentiable ℝ (vitPostV gf ε p sA sM y)
                                              theorem Proofs.ViTTieGB.vitPostL2_differentiable {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (y : Vec (Np1 * (heads * d))) :
                                              Differentiable ℝ (vitPostL2 gf ε p sA sM y)
                                              theorem Proofs.ViTTieGB.vitPostF1_differentiable {Np1 heads d mlpDim : ℕ} {gf : GeluForm} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (y : Vec (Np1 * (heads * d))) :
                                              Differentiable ℝ (vitPostF1 gf ε p sA sM y)
                                              theorem Proofs.ViTTieGB.vitPostF2_differentiable {Np1 heads d mlpDim : ℕ} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option ℝ) (y : Vec (Np1 * (heads * d))) :
                                              def Proofs.ViTTieGB.vitBlockLossTiedGB (gf : GeluForm) (N : ℕ) {Np1 heads d mlpDim : ℕ} (xN epsStr cotN : String) (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) (bf16 : Bool) (sA sM : Option (Vec N)) (xin : Vec (N * (Np1 * (heads * d)))) (Φ : BlockParamsV (heads * d) mlpDim → Vec 1) (dyOut : Vec (N * (Np1 * (heads * d)))) :

                                              ViT block, every parameter node a loss derivative — the sixteen nodes vitBlockTiedGB ties, at the tie's batched activations and cotangents, Φ the loss at the block's output as a function of the block's record.

                                              Equations
                                              • One or more equations did not get rendered due to their size.
                                              Instances For
                                                theorem Proofs.ViTTieGB.vit_block_lossTiedGB {gf : GeluForm} (N : ℕ) {Np1 heads d mlpDim : ℕ} (xN epsStr cotN : String) (ε : ℝ) (hε : 0 < ε) (p : BlockParamsV (heads * d) mlpDim) (bf16 : Bool) (sA sM : Option (Vec N)) (xin : Vec (N * (Np1 * (heads * d)))) {Lb : Vec (N * (Np1 * (heads * d))) → Vec 1} {dyOut : Vec (N * (Np1 * (heads * d)))} (hLb : HasGradAt Lb (StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf p ε (exampleSite sA n) (exampleSite sM n)) xin) dyOut) {Φ : BlockParamsV (heads * d) mlpDim → Vec 1} (hΦ : ∀ (p' : BlockParamsV (heads * d) mlpDim), Φ p' = Lb (StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf p' ε (exampleSite sA n) (exampleSite sM n)) xin)) :
                                                vitBlockLossTiedGB gf N xN epsStr cotN ε p bf16 sA sM xin Φ dyOut
                                                noncomputable def Proofs.ViTTieGB.vitHeadO {nC : ℕ} (ε : ℝ) (γF βF : Vec 192) (Wcls : Mat 192 nC) (bcls : Vec nC) :
                                                Vec (197 * 192) → Vec nC

                                                The head per example: the final vector LN on every token, then the CLS-slice classifier — vitHeadHasVJP's map.

                                                Equations
                                                • One or more equations did not get rendered due to their size.
                                                Instances For
                                                  def Proofs.ViTTieGB.vitHeadLossTiedGB (N : ℕ) {nC : ℕ} (xN aN epsStr cotN : String) (ε : ℝ) (γF βF : Vec 192) (Wcls : Mat 192 nC) (bcls : Vec nC) (b12out : Vec (N * (197 * 192))) (Φ : Vec 192 → Vec 192 → Mat 192 nC → Vec nC → Vec 1) (g : Vec (N * nC)) :

                                                  Head, every parameter node a loss derivative — the final LN's two nodes (vitFinalLNTiedGB) and the classifier's two (vitHeadTiedGB).

                                                  Equations
                                                  • One or more equations did not get rendered due to their size.
                                                  Instances For
                                                    theorem Proofs.ViTTieGB.vit_head_lossTiedGB (N : ℕ) {nC : ℕ} (xN aN epsStr cotN : String) (ε : ℝ) (γF βF : Vec 192) (Wcls : Mat 192 nC) (bcls : Vec nC) (b12out : Vec (N * (197 * 192))) {L : Vec (N * nC) → Vec 1} {g : Vec (N * nC)} (hL : HasGradAt L (StableHLO.batchMap N (vitHeadO ε γF βF Wcls bcls) b12out) g) {Φ : Vec 192 → Vec 192 → Mat 192 nC → Vec nC → Vec 1} (hΦ : ∀ (a b : Vec 192) (W : Mat 192 nC) (bb : Vec nC), Φ a b W bb = L (StableHLO.batchMap N (vitHeadO ε a b W bb) b12out)) :
                                                    vitHeadLossTiedGB N xN aN epsStr cotN ε γF βF Wcls bcls b12out Φ g
                                                    theorem Proofs.ViTTieGB.patchEmbedFlat_weight_differentiable (bc cls : Vec 192) (pos : Mat 197 192) (x : Vec (3 * 224 * 224)) :
                                                    Differentiable ℝ fun (θ : Vec (192 * 3 * 16 * 16)) => patchEmbedFlat 3 224 224 16 196 192 (Kernel4.unflatten θ) bc cls pos x

                                                    The patch embedding is differentiable in its conv weight.

                                                    theorem Proofs.ViTTieGB.patchEmbedFlat_bias_differentiable (Wc : Kernel4 192 3 16 16) (cls : Vec 192) (pos : Mat 197 192) (x : Vec (3 * 224 * 224)) :
                                                    Differentiable ℝ fun (θ : Vec 192) => patchEmbedFlat 3 224 224 16 196 192 Wc θ cls pos x

                                                    …in its conv bias.

                                                    theorem Proofs.ViTTieGB.patchEmbedFlat_cls_differentiable (Wc : Kernel4 192 3 16 16) (bc : Vec 192) (pos : Mat 197 192) (x : Vec (3 * 224 * 224)) :
                                                    Differentiable ℝ fun (θ : Vec 192) => patchEmbedFlat 3 224 224 16 196 192 Wc bc θ pos x

                                                    …in the CLS token.

                                                    theorem Proofs.ViTTieGB.patchEmbedFlat_pos_differentiable (Wc : Kernel4 192 3 16 16) (bc cls : Vec 192) (x : Vec (3 * 224 * 224)) :
                                                    Differentiable ℝ fun (θ : Vec (197 * 192)) => patchEmbedFlat 3 224 224 16 196 192 Wc bc cls (Mat.unflatten θ) x

                                                    …in the position embedding.

                                                    def Proofs.ViTTieGB.vitEmbedLossTiedGB (N : ℕ) (xN cotN : String) (Wc : Kernel4 192 3 16 16) (bc cls : Vec 192) (pos : Mat 197 192) (bf16 : Bool) (img : Vec (N * (3 * 224 * 224))) (Φ : Kernel4 192 3 16 16 → Vec 192 → Vec 192 → Mat 197 192 → Vec 1) (dyEmbed : Vec (N * (197 * 192))) :

                                                    Patch embedding, every parameter node a loss derivative — the four nodes vitEmbedTiedGB ties (the CLS token's with the batch sum inside den).

                                                    Equations
                                                    • One or more equations did not get rendered due to their size.
                                                    Instances For
                                                      theorem Proofs.ViTTieGB.vit_embed_lossTiedGB (N : ℕ) (xN cotN : String) (Wc : Kernel4 192 3 16 16) (bc cls : Vec 192) (pos : Mat 197 192) (bf16 : Bool) (img : Vec (N * (3 * 224 * 224))) {Lb : Vec (N * (197 * 192)) → Vec 1} {dyEmbed : Vec (N * (197 * 192))} (hLb : HasGradAt Lb (StableHLO.batchMap N (patchEmbedFlat 3 224 224 16 196 192 Wc bc cls pos) img) dyEmbed) {Φ : Kernel4 192 3 16 16 → Vec 192 → Vec 192 → Mat 197 192 → Vec 1} (hΦ : ∀ (W : Kernel4 192 3 16 16) (b c : Vec 192) (q : Mat 197 192), Φ W b c q = Lb (StableHLO.batchMap N (patchEmbedFlat 3 224 224 16 196 192 W b c q) img)) :
                                                      vitEmbedLossTiedGB N xN cotN Wc bc cls pos bf16 img Φ dyEmbed
                                                      theorem Proofs.ViTTieGB.vitBlkB_hasGradAt_comp {gf : GeluForm} (N : ℕ) {Np1 heads d mlpDim : ℕ} (ε : ℝ) (hε : 0 < ε) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option (Vec N)) (X : Vec (N * (Np1 * (heads * d)))) {G : Vec (N * (Np1 * (heads * d))) → Vec 1} {dY : Vec (N * (Np1 * (heads * d)))} (hG : HasGradAt G (StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf p ε (exampleSite sA n) (exampleSite sM n)) X) dY) :
                                                      HasGradAt (fun (y : Vec (N * (Np1 * (heads * d)))) => G (StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf p ε (exampleSite sA n) (exampleSite sM n)) y)) X (StableHLO.batchMapAuxIdx N (fun (n : Fin N) => BlockParamsV.cotInD gf p ε (exampleSite sA n) (exampleSite sM n)) X dY)

                                                      Pull the loss gradient back through a batched block's certified VJP at its sites: the cotangent is the tie's batchMapAuxIdx N (p.cotInD ε …) (vitBlockCotInB_eq_vjp).

                                                      theorem Proofs.ViTTieGB.vitHeadB_hasGradAt_comp (N : ℕ) {nC : ℕ} (ε : ℝ) (hε : 0 < ε) (γF βF : Vec 192) (Wcls : Mat 192 nC) (bcls : Vec nC) (X : Vec (N * (197 * 192))) {L : Vec (N * nC) → Vec 1} {g : Vec (N * nC)} (hL : HasGradAt L (StableHLO.batchMap N (vitHeadO ε γF βF Wcls bcls) X) g) :
                                                      HasGradAt (fun (y : Vec (N * (197 * 192))) => L (StableHLO.batchMap N (vitHeadO ε γF βF Wcls bcls) y)) X (StableHLO.batchMapAux N (vitCotTowerOutV 196 192 nC ε γF Wcls) X g)

                                                      …and through the batched head (vitCotTowerOutB_eq_vjp).

                                                      noncomputable def Proofs.ViTTieGB.vitNetB (gf : GeluForm) (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) :
                                                      Vec (N * nC)

                                                      ViT-Tiny, batched: the tie's forward, stage by stage — batchMap N of the patch embedding, batchMapIdx N of each block at its sites, then batchMap N of the head. At sd = none it is batchMap N of vitForwardKV at the twelve blocks (vitNetB_eq_vitForwardKV).

                                                      Equations
                                                      • One or more equations did not get rendered due to their size.
                                                      Instances For
                                                        noncomputable def Proofs.ViTTieGB.vitPreE (N : ℕ) {nC : ℕ} (w : ViTTie.ViTTieWeights nC) :
                                                        Vec (N * (3 * 224 * 224)) → Vec (N * (197 * 192))

                                                        The patch embedding's output — block b1's input (the tie's ib1).

                                                        Equations
                                                        Instances For
                                                          noncomputable def Proofs.ViTTieGB.vitPreB1 (gf : GeluForm) (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) :
                                                          Vec (N * (3 * 224 * 224)) → Vec (N * (197 * 192))

                                                          Block b1's output.

                                                          Equations
                                                          • One or more equations did not get rendered due to their size.
                                                          Instances For
                                                            noncomputable def Proofs.ViTTieGB.vitPreB2 (gf : GeluForm) (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) :
                                                            Vec (N * (3 * 224 * 224)) → Vec (N * (197 * 192))

                                                            Block b2's output.

                                                            Equations
                                                            • One or more equations did not get rendered due to their size.
                                                            Instances For
                                                              noncomputable def Proofs.ViTTieGB.vitPreB3 (gf : GeluForm) (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) :
                                                              Vec (N * (3 * 224 * 224)) → Vec (N * (197 * 192))

                                                              Block b3's output.

                                                              Equations
                                                              • One or more equations did not get rendered due to their size.
                                                              Instances For
                                                                noncomputable def Proofs.ViTTieGB.vitPreB4 (gf : GeluForm) (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) :
                                                                Vec (N * (3 * 224 * 224)) → Vec (N * (197 * 192))

                                                                Block b4's output.

                                                                Equations
                                                                • One or more equations did not get rendered due to their size.
                                                                Instances For
                                                                  noncomputable def Proofs.ViTTieGB.vitPreB5 (gf : GeluForm) (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) :
                                                                  Vec (N * (3 * 224 * 224)) → Vec (N * (197 * 192))

                                                                  Block b5's output.

                                                                  Equations
                                                                  • One or more equations did not get rendered due to their size.
                                                                  Instances For
                                                                    noncomputable def Proofs.ViTTieGB.vitPreB6 (gf : GeluForm) (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) :
                                                                    Vec (N * (3 * 224 * 224)) → Vec (N * (197 * 192))

                                                                    Block b6's output.

                                                                    Equations
                                                                    • One or more equations did not get rendered due to their size.
                                                                    Instances For
                                                                      noncomputable def Proofs.ViTTieGB.vitPreB7 (gf : GeluForm) (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) :
                                                                      Vec (N * (3 * 224 * 224)) → Vec (N * (197 * 192))

                                                                      Block b7's output.

                                                                      Equations
                                                                      • One or more equations did not get rendered due to their size.
                                                                      Instances For
                                                                        noncomputable def Proofs.ViTTieGB.vitPreB8 (gf : GeluForm) (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) :
                                                                        Vec (N * (3 * 224 * 224)) → Vec (N * (197 * 192))

                                                                        Block b8's output.

                                                                        Equations
                                                                        • One or more equations did not get rendered due to their size.
                                                                        Instances For
                                                                          noncomputable def Proofs.ViTTieGB.vitPreB9 (gf : GeluForm) (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) :
                                                                          Vec (N * (3 * 224 * 224)) → Vec (N * (197 * 192))

                                                                          Block b9's output.

                                                                          Equations
                                                                          • One or more equations did not get rendered due to their size.
                                                                          Instances For
                                                                            noncomputable def Proofs.ViTTieGB.vitPreB10 (gf : GeluForm) (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) :
                                                                            Vec (N * (3 * 224 * 224)) → Vec (N * (197 * 192))

                                                                            Block b10's output.

                                                                            Equations
                                                                            • One or more equations did not get rendered due to their size.
                                                                            Instances For
                                                                              noncomputable def Proofs.ViTTieGB.vitPreB11 (gf : GeluForm) (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) :
                                                                              Vec (N * (3 * 224 * 224)) → Vec (N * (197 * 192))

                                                                              Block b11's output.

                                                                              Equations
                                                                              • One or more equations did not get rendered due to their size.
                                                                              Instances For
                                                                                noncomputable def Proofs.ViTTieGB.vitPreB12 (gf : GeluForm) (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) :
                                                                                Vec (N * (3 * 224 * 224)) → Vec (N * (197 * 192))

                                                                                Block b12's output.

                                                                                Equations
                                                                                • One or more equations did not get rendered due to their size.
                                                                                Instances For
                                                                                  theorem Proofs.ViTTieGB.vitPreE_apply (N : ℕ) {nC : ℕ} (w : ViTTie.ViTTieWeights nC) (img : Vec (N * (3 * 224 * 224))) :
                                                                                  vitPreE N w img = StableHLO.batchMap N (patchEmbedFlat 3 224 224 16 196 192 w.Wc w.bc w.cls w.pos) img
                                                                                  theorem Proofs.ViTTieGB.vitPreB1_apply {gf : GeluForm} (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) :
                                                                                  vitPreB1 gf N ε w sd img = StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf w.b1 ε (exampleSite (vitSdA sd 0) n) (exampleSite (vitSdM sd 0) n)) (vitPreE N w img)
                                                                                  theorem Proofs.ViTTieGB.vitPreB2_apply {gf : GeluForm} (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) :
                                                                                  vitPreB2 gf N ε w sd img = StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf w.b2 ε (exampleSite (vitSdA sd 1) n) (exampleSite (vitSdM sd 1) n)) (vitPreB1 gf N ε w sd img)
                                                                                  theorem Proofs.ViTTieGB.vitPreB3_apply {gf : GeluForm} (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) :
                                                                                  vitPreB3 gf N ε w sd img = StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf w.b3 ε (exampleSite (vitSdA sd 2) n) (exampleSite (vitSdM sd 2) n)) (vitPreB2 gf N ε w sd img)
                                                                                  theorem Proofs.ViTTieGB.vitPreB4_apply {gf : GeluForm} (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) :
                                                                                  vitPreB4 gf N ε w sd img = StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf w.b4 ε (exampleSite (vitSdA sd 3) n) (exampleSite (vitSdM sd 3) n)) (vitPreB3 gf N ε w sd img)
                                                                                  theorem Proofs.ViTTieGB.vitPreB5_apply {gf : GeluForm} (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) :
                                                                                  vitPreB5 gf N ε w sd img = StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf w.b5 ε (exampleSite (vitSdA sd 4) n) (exampleSite (vitSdM sd 4) n)) (vitPreB4 gf N ε w sd img)
                                                                                  theorem Proofs.ViTTieGB.vitPreB6_apply {gf : GeluForm} (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) :
                                                                                  vitPreB6 gf N ε w sd img = StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf w.b6 ε (exampleSite (vitSdA sd 5) n) (exampleSite (vitSdM sd 5) n)) (vitPreB5 gf N ε w sd img)
                                                                                  theorem Proofs.ViTTieGB.vitPreB7_apply {gf : GeluForm} (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) :
                                                                                  vitPreB7 gf N ε w sd img = StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf w.b7 ε (exampleSite (vitSdA sd 6) n) (exampleSite (vitSdM sd 6) n)) (vitPreB6 gf N ε w sd img)
                                                                                  theorem Proofs.ViTTieGB.vitPreB8_apply {gf : GeluForm} (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) :
                                                                                  vitPreB8 gf N ε w sd img = StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf w.b8 ε (exampleSite (vitSdA sd 7) n) (exampleSite (vitSdM sd 7) n)) (vitPreB7 gf N ε w sd img)
                                                                                  theorem Proofs.ViTTieGB.vitPreB9_apply {gf : GeluForm} (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) :
                                                                                  vitPreB9 gf N ε w sd img = StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf w.b9 ε (exampleSite (vitSdA sd 8) n) (exampleSite (vitSdM sd 8) n)) (vitPreB8 gf N ε w sd img)
                                                                                  theorem Proofs.ViTTieGB.vitPreB10_apply {gf : GeluForm} (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) :
                                                                                  vitPreB10 gf N ε w sd img = StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf w.b10 ε (exampleSite (vitSdA sd 9) n) (exampleSite (vitSdM sd 9) n)) (vitPreB9 gf N ε w sd img)
                                                                                  theorem Proofs.ViTTieGB.vitPreB11_apply {gf : GeluForm} (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) :
                                                                                  vitPreB11 gf N ε w sd img = StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf w.b11 ε (exampleSite (vitSdA sd 10) n) (exampleSite (vitSdM sd 10) n)) (vitPreB10 gf N ε w sd img)
                                                                                  theorem Proofs.ViTTieGB.vitPreB12_apply {gf : GeluForm} (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) :
                                                                                  vitPreB12 gf N ε w sd img = StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf w.b12 ε (exampleSite (vitSdA sd 11) n) (exampleSite (vitSdM sd 11) n)) (vitPreB11 gf N ε w sd img)
                                                                                  noncomputable def Proofs.ViTTieGB.vitSufB12 (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) :
                                                                                  Vec (N * (197 * 192)) → Vec (N * nC)

                                                                                  The net after block b12 — the head.

                                                                                  Equations
                                                                                  Instances For
                                                                                    noncomputable def Proofs.ViTTieGB.vitSufB11 (gf : GeluForm) (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) :
                                                                                    Vec (N * (197 * 192)) → Vec (N * nC)

                                                                                    The net after block b11: block b12, then the rest.

                                                                                    Equations
                                                                                    • One or more equations did not get rendered due to their size.
                                                                                    Instances For
                                                                                      noncomputable def Proofs.ViTTieGB.vitSufB10 (gf : GeluForm) (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) :
                                                                                      Vec (N * (197 * 192)) → Vec (N * nC)

                                                                                      The net after block b10: block b11, then the rest.

                                                                                      Equations
                                                                                      • One or more equations did not get rendered due to their size.
                                                                                      Instances For
                                                                                        noncomputable def Proofs.ViTTieGB.vitSufB9 (gf : GeluForm) (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) :
                                                                                        Vec (N * (197 * 192)) → Vec (N * nC)

                                                                                        The net after block b9: block b10, then the rest.

                                                                                        Equations
                                                                                        • One or more equations did not get rendered due to their size.
                                                                                        Instances For
                                                                                          noncomputable def Proofs.ViTTieGB.vitSufB8 (gf : GeluForm) (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) :
                                                                                          Vec (N * (197 * 192)) → Vec (N * nC)

                                                                                          The net after block b8: block b9, then the rest.

                                                                                          Equations
                                                                                          • One or more equations did not get rendered due to their size.
                                                                                          Instances For
                                                                                            noncomputable def Proofs.ViTTieGB.vitSufB7 (gf : GeluForm) (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) :
                                                                                            Vec (N * (197 * 192)) → Vec (N * nC)

                                                                                            The net after block b7: block b8, then the rest.

                                                                                            Equations
                                                                                            • One or more equations did not get rendered due to their size.
                                                                                            Instances For
                                                                                              noncomputable def Proofs.ViTTieGB.vitSufB6 (gf : GeluForm) (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) :
                                                                                              Vec (N * (197 * 192)) → Vec (N * nC)

                                                                                              The net after block b6: block b7, then the rest.

                                                                                              Equations
                                                                                              • One or more equations did not get rendered due to their size.
                                                                                              Instances For
                                                                                                noncomputable def Proofs.ViTTieGB.vitSufB5 (gf : GeluForm) (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) :
                                                                                                Vec (N * (197 * 192)) → Vec (N * nC)

                                                                                                The net after block b5: block b6, then the rest.

                                                                                                Equations
                                                                                                • One or more equations did not get rendered due to their size.
                                                                                                Instances For
                                                                                                  noncomputable def Proofs.ViTTieGB.vitSufB4 (gf : GeluForm) (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) :
                                                                                                  Vec (N * (197 * 192)) → Vec (N * nC)

                                                                                                  The net after block b4: block b5, then the rest.

                                                                                                  Equations
                                                                                                  • One or more equations did not get rendered due to their size.
                                                                                                  Instances For
                                                                                                    noncomputable def Proofs.ViTTieGB.vitSufB3 (gf : GeluForm) (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) :
                                                                                                    Vec (N * (197 * 192)) → Vec (N * nC)

                                                                                                    The net after block b3: block b4, then the rest.

                                                                                                    Equations
                                                                                                    • One or more equations did not get rendered due to their size.
                                                                                                    Instances For
                                                                                                      noncomputable def Proofs.ViTTieGB.vitSufB2 (gf : GeluForm) (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) :
                                                                                                      Vec (N * (197 * 192)) → Vec (N * nC)

                                                                                                      The net after block b2: block b3, then the rest.

                                                                                                      Equations
                                                                                                      • One or more equations did not get rendered due to their size.
                                                                                                      Instances For
                                                                                                        noncomputable def Proofs.ViTTieGB.vitSufB1 (gf : GeluForm) (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) :
                                                                                                        Vec (N * (197 * 192)) → Vec (N * nC)

                                                                                                        The net after block b1: block b2, then the rest.

                                                                                                        Equations
                                                                                                        • One or more equations did not get rendered due to their size.
                                                                                                        Instances For
                                                                                                          noncomputable def Proofs.ViTTieGB.vitSufE (gf : GeluForm) (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) :
                                                                                                          Vec (N * (197 * 192)) → Vec (N * nC)

                                                                                                          The net after the patch embedding: block b1, then the rest.

                                                                                                          Equations
                                                                                                          • One or more equations did not get rendered due to their size.
                                                                                                          Instances For
                                                                                                            theorem Proofs.ViTTieGB.vit_factor_embed {gf : GeluForm} (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) (W : Kernel4 192 3 16 16) (b c : Vec 192) (q : Mat 197 192) :
                                                                                                            vitNetB gf N ε { Wc := W, bc := b, cls := c, pos := q, b1 := w.b1, b2 := w.b2, b3 := w.b3, b4 := w.b4, b5 := w.b5, b6 := w.b6, b7 := w.b7, b8 := w.b8, b9 := w.b9, b10 := w.b10, b11 := w.b11, b12 := w.b12, γF := w.γF, βF := w.βF, Wcls := w.Wcls, bcls := w.bcls } sd img = vitSufE gf N ε w sd (StableHLO.batchMap N (patchEmbedFlat 3 224 224 16 196 192 W b c q) img)

                                                                                                            The net with the patch embedding varied is the suffix after it at the varied embedding.

                                                                                                            theorem Proofs.ViTTieGB.vit_factor_b1 {gf : GeluForm} (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) (p : BlockParamsV 192 768) :
                                                                                                            vitNetB gf N ε { Wc := w.Wc, bc := w.bc, cls := w.cls, pos := w.pos, b1 := p, b2 := w.b2, b3 := w.b3, b4 := w.b4, b5 := w.b5, b6 := w.b6, b7 := w.b7, b8 := w.b8, b9 := w.b9, b10 := w.b10, b11 := w.b11, b12 := w.b12, γF := w.γF, βF := w.βF, Wcls := w.Wcls, bcls := w.bcls } sd img = vitSufB1 gf N ε w sd (StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf p ε (exampleSite (vitSdA sd 0) n) (exampleSite (vitSdM sd 0) n)) (vitPreE N w img))

                                                                                                            The net with block b1's weights varied is the suffix after it at the varied block.

                                                                                                            theorem Proofs.ViTTieGB.vit_factor_b2 {gf : GeluForm} (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) (p : BlockParamsV 192 768) :
                                                                                                            vitNetB gf N ε { Wc := w.Wc, bc := w.bc, cls := w.cls, pos := w.pos, b1 := w.b1, b2 := p, b3 := w.b3, b4 := w.b4, b5 := w.b5, b6 := w.b6, b7 := w.b7, b8 := w.b8, b9 := w.b9, b10 := w.b10, b11 := w.b11, b12 := w.b12, γF := w.γF, βF := w.βF, Wcls := w.Wcls, bcls := w.bcls } sd img = vitSufB2 gf N ε w sd (StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf p ε (exampleSite (vitSdA sd 1) n) (exampleSite (vitSdM sd 1) n)) (vitPreB1 gf N ε w sd img))

                                                                                                            The net with block b2's weights varied is the suffix after it at the varied block.

                                                                                                            theorem Proofs.ViTTieGB.vit_factor_b3 {gf : GeluForm} (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) (p : BlockParamsV 192 768) :
                                                                                                            vitNetB gf N ε { Wc := w.Wc, bc := w.bc, cls := w.cls, pos := w.pos, b1 := w.b1, b2 := w.b2, b3 := p, b4 := w.b4, b5 := w.b5, b6 := w.b6, b7 := w.b7, b8 := w.b8, b9 := w.b9, b10 := w.b10, b11 := w.b11, b12 := w.b12, γF := w.γF, βF := w.βF, Wcls := w.Wcls, bcls := w.bcls } sd img = vitSufB3 gf N ε w sd (StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf p ε (exampleSite (vitSdA sd 2) n) (exampleSite (vitSdM sd 2) n)) (vitPreB2 gf N ε w sd img))

                                                                                                            The net with block b3's weights varied is the suffix after it at the varied block.

                                                                                                            theorem Proofs.ViTTieGB.vit_factor_b4 {gf : GeluForm} (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) (p : BlockParamsV 192 768) :
                                                                                                            vitNetB gf N ε { Wc := w.Wc, bc := w.bc, cls := w.cls, pos := w.pos, b1 := w.b1, b2 := w.b2, b3 := w.b3, b4 := p, b5 := w.b5, b6 := w.b6, b7 := w.b7, b8 := w.b8, b9 := w.b9, b10 := w.b10, b11 := w.b11, b12 := w.b12, γF := w.γF, βF := w.βF, Wcls := w.Wcls, bcls := w.bcls } sd img = vitSufB4 gf N ε w sd (StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf p ε (exampleSite (vitSdA sd 3) n) (exampleSite (vitSdM sd 3) n)) (vitPreB3 gf N ε w sd img))

                                                                                                            The net with block b4's weights varied is the suffix after it at the varied block.

                                                                                                            theorem Proofs.ViTTieGB.vit_factor_b5 {gf : GeluForm} (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) (p : BlockParamsV 192 768) :
                                                                                                            vitNetB gf N ε { Wc := w.Wc, bc := w.bc, cls := w.cls, pos := w.pos, b1 := w.b1, b2 := w.b2, b3 := w.b3, b4 := w.b4, b5 := p, b6 := w.b6, b7 := w.b7, b8 := w.b8, b9 := w.b9, b10 := w.b10, b11 := w.b11, b12 := w.b12, γF := w.γF, βF := w.βF, Wcls := w.Wcls, bcls := w.bcls } sd img = vitSufB5 gf N ε w sd (StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf p ε (exampleSite (vitSdA sd 4) n) (exampleSite (vitSdM sd 4) n)) (vitPreB4 gf N ε w sd img))

                                                                                                            The net with block b5's weights varied is the suffix after it at the varied block.

                                                                                                            theorem Proofs.ViTTieGB.vit_factor_b6 {gf : GeluForm} (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) (p : BlockParamsV 192 768) :
                                                                                                            vitNetB gf N ε { Wc := w.Wc, bc := w.bc, cls := w.cls, pos := w.pos, b1 := w.b1, b2 := w.b2, b3 := w.b3, b4 := w.b4, b5 := w.b5, b6 := p, b7 := w.b7, b8 := w.b8, b9 := w.b9, b10 := w.b10, b11 := w.b11, b12 := w.b12, γF := w.γF, βF := w.βF, Wcls := w.Wcls, bcls := w.bcls } sd img = vitSufB6 gf N ε w sd (StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf p ε (exampleSite (vitSdA sd 5) n) (exampleSite (vitSdM sd 5) n)) (vitPreB5 gf N ε w sd img))

                                                                                                            The net with block b6's weights varied is the suffix after it at the varied block.

                                                                                                            theorem Proofs.ViTTieGB.vit_factor_b7 {gf : GeluForm} (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) (p : BlockParamsV 192 768) :
                                                                                                            vitNetB gf N ε { Wc := w.Wc, bc := w.bc, cls := w.cls, pos := w.pos, b1 := w.b1, b2 := w.b2, b3 := w.b3, b4 := w.b4, b5 := w.b5, b6 := w.b6, b7 := p, b8 := w.b8, b9 := w.b9, b10 := w.b10, b11 := w.b11, b12 := w.b12, γF := w.γF, βF := w.βF, Wcls := w.Wcls, bcls := w.bcls } sd img = vitSufB7 gf N ε w sd (StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf p ε (exampleSite (vitSdA sd 6) n) (exampleSite (vitSdM sd 6) n)) (vitPreB6 gf N ε w sd img))

                                                                                                            The net with block b7's weights varied is the suffix after it at the varied block.

                                                                                                            theorem Proofs.ViTTieGB.vit_factor_b8 {gf : GeluForm} (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) (p : BlockParamsV 192 768) :
                                                                                                            vitNetB gf N ε { Wc := w.Wc, bc := w.bc, cls := w.cls, pos := w.pos, b1 := w.b1, b2 := w.b2, b3 := w.b3, b4 := w.b4, b5 := w.b5, b6 := w.b6, b7 := w.b7, b8 := p, b9 := w.b9, b10 := w.b10, b11 := w.b11, b12 := w.b12, γF := w.γF, βF := w.βF, Wcls := w.Wcls, bcls := w.bcls } sd img = vitSufB8 gf N ε w sd (StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf p ε (exampleSite (vitSdA sd 7) n) (exampleSite (vitSdM sd 7) n)) (vitPreB7 gf N ε w sd img))

                                                                                                            The net with block b8's weights varied is the suffix after it at the varied block.

                                                                                                            theorem Proofs.ViTTieGB.vit_factor_b9 {gf : GeluForm} (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) (p : BlockParamsV 192 768) :
                                                                                                            vitNetB gf N ε { Wc := w.Wc, bc := w.bc, cls := w.cls, pos := w.pos, b1 := w.b1, b2 := w.b2, b3 := w.b3, b4 := w.b4, b5 := w.b5, b6 := w.b6, b7 := w.b7, b8 := w.b8, b9 := p, b10 := w.b10, b11 := w.b11, b12 := w.b12, γF := w.γF, βF := w.βF, Wcls := w.Wcls, bcls := w.bcls } sd img = vitSufB9 gf N ε w sd (StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf p ε (exampleSite (vitSdA sd 8) n) (exampleSite (vitSdM sd 8) n)) (vitPreB8 gf N ε w sd img))

                                                                                                            The net with block b9's weights varied is the suffix after it at the varied block.

                                                                                                            theorem Proofs.ViTTieGB.vit_factor_b10 {gf : GeluForm} (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) (p : BlockParamsV 192 768) :
                                                                                                            vitNetB gf N ε { Wc := w.Wc, bc := w.bc, cls := w.cls, pos := w.pos, b1 := w.b1, b2 := w.b2, b3 := w.b3, b4 := w.b4, b5 := w.b5, b6 := w.b6, b7 := w.b7, b8 := w.b8, b9 := w.b9, b10 := p, b11 := w.b11, b12 := w.b12, γF := w.γF, βF := w.βF, Wcls := w.Wcls, bcls := w.bcls } sd img = vitSufB10 gf N ε w sd (StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf p ε (exampleSite (vitSdA sd 9) n) (exampleSite (vitSdM sd 9) n)) (vitPreB9 gf N ε w sd img))

                                                                                                            The net with block b10's weights varied is the suffix after it at the varied block.

                                                                                                            theorem Proofs.ViTTieGB.vit_factor_b11 {gf : GeluForm} (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) (p : BlockParamsV 192 768) :
                                                                                                            vitNetB gf N ε { Wc := w.Wc, bc := w.bc, cls := w.cls, pos := w.pos, b1 := w.b1, b2 := w.b2, b3 := w.b3, b4 := w.b4, b5 := w.b5, b6 := w.b6, b7 := w.b7, b8 := w.b8, b9 := w.b9, b10 := w.b10, b11 := p, b12 := w.b12, γF := w.γF, βF := w.βF, Wcls := w.Wcls, bcls := w.bcls } sd img = vitSufB11 gf N ε w sd (StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf p ε (exampleSite (vitSdA sd 10) n) (exampleSite (vitSdM sd 10) n)) (vitPreB10 gf N ε w sd img))

                                                                                                            The net with block b11's weights varied is the suffix after it at the varied block.

                                                                                                            theorem Proofs.ViTTieGB.vit_factor_b12 {gf : GeluForm} (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) (p : BlockParamsV 192 768) :
                                                                                                            vitNetB gf N ε { Wc := w.Wc, bc := w.bc, cls := w.cls, pos := w.pos, b1 := w.b1, b2 := w.b2, b3 := w.b3, b4 := w.b4, b5 := w.b5, b6 := w.b6, b7 := w.b7, b8 := w.b8, b9 := w.b9, b10 := w.b10, b11 := w.b11, b12 := p, γF := w.γF, βF := w.βF, Wcls := w.Wcls, bcls := w.bcls } sd img = vitSufB12 N ε w (StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf p ε (exampleSite (vitSdA sd 11) n) (exampleSite (vitSdM sd 11) n)) (vitPreB11 gf N ε w sd img))

                                                                                                            The net with block b12's weights varied is the suffix after it at the varied block.

                                                                                                            theorem Proofs.ViTTieGB.vit_factor_head {gf : GeluForm} (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) (a b : Vec 192) (W : Mat 192 nC) (bb : Vec nC) :
                                                                                                            vitNetB gf N ε { Wc := w.Wc, bc := w.bc, cls := w.cls, pos := w.pos, b1 := w.b1, b2 := w.b2, b3 := w.b3, b4 := w.b4, b5 := w.b5, b6 := w.b6, b7 := w.b7, b8 := w.b8, b9 := w.b9, b10 := w.b10, b11 := w.b11, b12 := w.b12, γF := a, βF := b, Wcls := W, bcls := bb } sd img = StableHLO.batchMap N (vitHeadO ε a b W bb) (vitPreB12 gf N ε w sd img)

                                                                                                            The net with the head varied is the head at the varied parameters.

                                                                                                            theorem Proofs.ViTTieGB.vit_forward_eq_head {gf : GeluForm} (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) :
                                                                                                            vitNetB gf N ε w sd img = StableHLO.batchMap N (vitHeadO ε w.γF w.βF w.Wcls w.bcls) (vitPreB12 gf N ε w sd img)

                                                                                                            The net's output is the head at block b12's output.

                                                                                                            theorem Proofs.ViTTieGB.vit_logitsB_eq {gf : GeluForm} (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) :
                                                                                                            StableHLO.batchMap N (dense w.Wcls w.bcls) (StableHLO.batchMap N (StableHLO.clsSliceFlat 196 192) (StableHLO.batchMap N (fun (b : Vec ((196 + 1) * 192)) => Mat.flatten fun (r : Fin (196 + 1)) => layerNormVec 192 ε w.γF w.βF (Mat.unflatten b r)) (vitPreB12 gf N ε w sd img))) = vitNetB gf N ε w sd img

                                                                                                            The logits the tie's loss cotangent reads are vitNetB's. The tie spells the head as three batched ops (batchMap_comp).

                                                                                                            theorem Proofs.ViTTieGB.fwdO_eq_blockVFlat {gf : GeluForm} {Np1 heads d mlpDim : ℕ} (ε : ℝ) (p : BlockParamsV (heads * d) mlpDim) :
                                                                                                            BlockParamsV.fwdO gf p ε = blockVFlat gf Np1 heads d mlpDim ε p

                                                                                                            A block's forward is the depth-k fold's flat block: the spelled multi-head block (vitBlockFwdOMHV) is blockV (vitBlockSpelledMHV_eq).

                                                                                                            theorem Proofs.ViTTieGB.vitNetB_eq_vitForwardKV {gf : GeluForm} (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (img : Vec (N * (3 * 224 * 224))) :
                                                                                                            vitNetB gf N ε w none img = StableHLO.batchMap N (vitForwardKV gf 3 224 224 16 196 768 3 64 nC 12 w.Wc w.bc w.cls w.pos ε ![w.b1, w.b2, w.b3, w.b4, w.b5, w.b6, w.b7, w.b8, w.b9, w.b10, w.b11, w.b12] w.γF w.βF w.Wcls w.bcls) img

                                                                                                            Without stochastic depth vitNetB is the canonical ViT-Tiny forward, batched: vitForwardKV at the twelve blocks ![w.b1, …, w.b12], the forward whose graph vitFwdGraphKMHV_faithful ties to the render and whose VJP is vitForwardKVHasVJP, applied per example. Per example it unfolds the depth-12 fold block by block (fwdO_eq_blockVFlat); batchMap_comp splits the batched composite into the capstone's stage-by-stage chain.

                                                                                                            def Proofs.ViTTieGB.ViTNetLossTiedGB (gf : GeluForm) (xN aN epsStr cotN : String) (N : ℕ) {nC : ℕ} (ε : ℝ) (w : ViTTie.ViTTieWeights nC) (bf16 bf16ConvW : Bool) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) (L : Vec (N * nC) → Vec 1) (g : Vec (N * nC)) :

                                                                                                            Every ViT-Tiny parameter gradient node is the derivative of L in that parameter, for a loss L of the logits and g the cotangent the chain starts from: the 200 nodes vit_net_tiedGB ties, each at the cotangent the tie threads to it from g, stated against L of vitNetB with that one parameter varied.

                                                                                                            Equations
                                                                                                            • One or more equations did not get rendered due to their size.
                                                                                                            Instances For
                                                                                                              theorem Proofs.ViTTieGB.vit_net_lossGrad {gf : GeluForm} (xN aN epsStr cotN : String) (N : ℕ) {nC : ℕ} (ε : ℝ) (hε : 0 < ε) (w : ViTTie.ViTTieWeights nC) (bf16 bf16ConvW : Bool) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) {L : Vec (N * nC) → Vec 1} {g : Vec (N * nC)} (hL : HasGradAt L (vitNetB gf N ε w sd img) g) :
                                                                                                              ViTNetLossTiedGB gf xN aN epsStr cotN N ε w bf16 bf16ConvW sd img L g

                                                                                                              Every ViT-Tiny parameter gradient node is the derivative of the loss in that parameter. For any loss L of the logits with gradient g at the net's output, each of the 200 nodes vit_net_tiedGB ties — at the same cotangent — is ∂L/∂θ of the WHOLE net, vitNetB with that one parameter varied (a patch-embedding field, a block's record w.bk := p with one slot changed, or a head field).

                                                                                                              Hypothesis: 0 < ε, the LayerNorms' (the tie itself needs none). The loss enters only through hL; vit_net_lossGrad_smoothedCE discharges it for the loss the artifacts ship.

                                                                                                              theorem Proofs.ViTTieGB.vit_net_lossGrad_smoothedCE {gf : GeluForm} (xN aN epsStr cotN aStr negAK bStr logN ohN : String) (N : ℕ) {nC : ℕ} (hK : 0 < nC) (ε α B : ℝ) (hε : 0 < ε) (w : ViTTie.ViTTieWeights nC) (bf16 bf16ConvW : Bool) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) (t : Vec (N * nC)) (ht : ∀ (n : Fin N), ∑ k : Fin nC, StableHLO.batchSlice N nC t n k = 1) :
                                                                                                              ViTNetLossTiedGB gf xN aN epsStr cotN N ε w bf16 bf16ConvW sd img (smoothedBatchLossDiv N nC α B t) (StableHLO.den (smoothedLossCotGraphDiv N nC α B aStr negAK bStr logN ohN (vitNetB gf N ε w sd img) t))

                                                                                                              The loss the artifacts ship: every node is the derivative of the batched label-smoothed cross-entropy smoothedBatchLossDiv, g the softmaxDiv cotangent the render emits — the tie's own g, whose logits are vitNetB N ε w img (vit_logitsB_eq).

                                                                                                              theorem Proofs.ViTTieGB.vit_net_tied_lossGrad {gf : GeluForm} (N : ℕ) {nC : ℕ} (xN aN epsStr cotN aStr negAK bStr logN ohN : String) (ε α B : ℝ) (w : ViTTie.ViTTieWeights nC) (bf16 bf16ConvW : Bool) (sd : Option (Fin 12 → Vec N × Vec N)) (img : Vec (N * (3 * 224 * 224))) (t : Vec (N * nC)) (hK : 0 < nC) (hε : 0 < ε) (ht : ∀ (n : Fin N), ∑ k : Fin nC, StableHLO.batchSlice N nC t n k = 1) :
                                                                                                              have ib1 := StableHLO.batchMap N (patchEmbedFlat 3 224 224 16 196 192 w.Wc w.bc w.cls w.pos) img; have ib2 := StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf w.b1 ε (exampleSite (vitSdA sd 0) n) (exampleSite (vitSdM sd 0) n)) ib1; have ib3 := StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf w.b2 ε (exampleSite (vitSdA sd 1) n) (exampleSite (vitSdM sd 1) n)) ib2; have ib4 := StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf w.b3 ε (exampleSite (vitSdA sd 2) n) (exampleSite (vitSdM sd 2) n)) ib3; have ib5 := StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf w.b4 ε (exampleSite (vitSdA sd 3) n) (exampleSite (vitSdM sd 3) n)) ib4; have ib6 := StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf w.b5 ε (exampleSite (vitSdA sd 4) n) (exampleSite (vitSdM sd 4) n)) ib5; have ib7 := StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf w.b6 ε (exampleSite (vitSdA sd 5) n) (exampleSite (vitSdM sd 5) n)) ib6; have ib8 := StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf w.b7 ε (exampleSite (vitSdA sd 6) n) (exampleSite (vitSdM sd 6) n)) ib7; have ib9 := StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf w.b8 ε (exampleSite (vitSdA sd 7) n) (exampleSite (vitSdM sd 7) n)) ib8; have ib10 := StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf w.b9 ε (exampleSite (vitSdA sd 8) n) (exampleSite (vitSdM sd 8) n)) ib9; have ib11 := StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf w.b10 ε (exampleSite (vitSdA sd 9) n) (exampleSite (vitSdM sd 9) n)) ib10; have ib12 := StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf w.b11 ε (exampleSite (vitSdA sd 10) n) (exampleSite (vitSdM sd 10) n)) ib11; have b12out := StableHLO.batchMapIdx N (fun (n : Fin N) => BlockParamsV.fwdOD gf w.b12 ε (exampleSite (vitSdA sd 11) n) (exampleSite (vitSdM sd 11) n)) ib12; have flB := StableHLO.batchMap N (fun (b : Vec (197 * 192)) => Mat.flatten fun (r : Fin 197) => layerNormVec 192 ε w.γF w.βF (Mat.unflatten b r)) b12out; have hnB := StableHLO.batchMap N (StableHLO.clsSliceFlat 196 192) flB; have logitsB := StableHLO.batchMap N (dense w.Wcls w.bcls) hnB; have g := StableHLO.den (smoothedLossCotGraphDiv N nC α B aStr negAK bStr logN ohN logitsB t); have dy12 := StableHLO.batchMapAux N (vitCotTowerOutV 196 192 nC ε w.γF w.Wcls) b12out g; have dy11 := StableHLO.batchMapAuxIdx N (fun (n : Fin N) => BlockParamsV.cotInD gf w.b12 ε (exampleSite (vitSdA sd 11) n) (exampleSite (vitSdM sd 11) n)) ib12 dy12; have dy10 := StableHLO.batchMapAuxIdx N (fun (n : Fin N) => BlockParamsV.cotInD gf w.b11 ε (exampleSite (vitSdA sd 10) n) (exampleSite (vitSdM sd 10) n)) ib11 dy11; have dy9 := StableHLO.batchMapAuxIdx N (fun (n : Fin N) => BlockParamsV.cotInD gf w.b10 ε (exampleSite (vitSdA sd 9) n) (exampleSite (vitSdM sd 9) n)) ib10 dy10; have dy8 := StableHLO.batchMapAuxIdx N (fun (n : Fin N) => BlockParamsV.cotInD gf w.b9 ε (exampleSite (vitSdA sd 8) n) (exampleSite (vitSdM sd 8) n)) ib9 dy9; have dy7 := StableHLO.batchMapAuxIdx N (fun (n : Fin N) => BlockParamsV.cotInD gf w.b8 ε (exampleSite (vitSdA sd 7) n) (exampleSite (vitSdM sd 7) n)) ib8 dy8; have dy6 := StableHLO.batchMapAuxIdx N (fun (n : Fin N) => BlockParamsV.cotInD gf w.b7 ε (exampleSite (vitSdA sd 6) n) (exampleSite (vitSdM sd 6) n)) ib7 dy7; have dy5 := StableHLO.batchMapAuxIdx N (fun (n : Fin N) => BlockParamsV.cotInD gf w.b6 ε (exampleSite (vitSdA sd 5) n) (exampleSite (vitSdM sd 5) n)) ib6 dy6; have dy4 := StableHLO.batchMapAuxIdx N (fun (n : Fin N) => BlockParamsV.cotInD gf w.b5 ε (exampleSite (vitSdA sd 4) n) (exampleSite (vitSdM sd 4) n)) ib5 dy5; have dy3 := StableHLO.batchMapAuxIdx N (fun (n : Fin N) => BlockParamsV.cotInD gf w.b4 ε (exampleSite (vitSdA sd 3) n) (exampleSite (vitSdM sd 3) n)) ib4 dy4; have dy2 := StableHLO.batchMapAuxIdx N (fun (n : Fin N) => BlockParamsV.cotInD gf w.b3 ε (exampleSite (vitSdA sd 2) n) (exampleSite (vitSdM sd 2) n)) ib3 dy3; have dy1 := StableHLO.batchMapAuxIdx N (fun (n : Fin N) => BlockParamsV.cotInD gf w.b2 ε (exampleSite (vitSdA sd 1) n) (exampleSite (vitSdM sd 1) n)) ib2 dy2; have dyEmbed := StableHLO.batchMapAuxIdx N (fun (n : Fin N) => BlockParamsV.cotInD gf w.b1 ε (exampleSite (vitSdA sd 0) n) (exampleSite (vitSdM sd 0) n)) ib1 dy1; have L := smoothedBatchLossDiv N nC α B t; (BlockParamsV.TiedGB gf w.b1 N xN epsStr cotN ε bf16 (vitSdA sd 0) (vitSdM sd 0) ib1 dy1 ∧ vitBlockLossTiedGB gf N xN epsStr cotN ε w.b1 bf16 (vitSdA sd 0) (vitSdM sd 0) ib1 (fun (p : BlockParamsV (3 * 64) 768) => L (vitNetB gf N ε { Wc := w.Wc, bc := w.bc, cls := w.cls, pos := w.pos, b1 := p, b2 := w.b2, b3 := w.b3, b4 := w.b4, b5 := w.b5, b6 := w.b6, b7 := w.b7, b8 := w.b8, b9 := w.b9, b10 := w.b10, b11 := w.b11, b12 := w.b12, γF := w.γF, βF := w.βF, Wcls := w.Wcls, bcls := w.bcls } sd img)) dy1) ∧ (BlockParamsV.TiedGB gf w.b2 N xN epsStr cotN ε bf16 (vitSdA sd 1) (vitSdM sd 1) ib2 dy2 ∧ vitBlockLossTiedGB gf N xN epsStr cotN ε w.b2 bf16 (vitSdA sd 1) (vitSdM sd 1) ib2 (fun (p : BlockParamsV (3 * 64) 768) => L (vitNetB gf N ε { Wc := w.Wc, bc := w.bc, cls := w.cls, pos := w.pos, b1 := w.b1, b2 := p, b3 := w.b3, b4 := w.b4, b5 := w.b5, b6 := w.b6, b7 := w.b7, b8 := w.b8, b9 := w.b9, b10 := w.b10, b11 := w.b11, b12 := w.b12, γF := w.γF, βF := w.βF, Wcls := w.Wcls, bcls := w.bcls } sd img)) dy2) ∧ (BlockParamsV.TiedGB gf w.b3 N xN epsStr cotN ε bf16 (vitSdA sd 2) (vitSdM sd 2) ib3 dy3 ∧ vitBlockLossTiedGB gf N xN epsStr cotN ε w.b3 bf16 (vitSdA sd 2) (vitSdM sd 2) ib3 (fun (p : BlockParamsV (3 * 64) 768) => L (vitNetB gf N ε { Wc := w.Wc, bc := w.bc, cls := w.cls, pos := w.pos, b1 := w.b1, b2 := w.b2, b3 := p, b4 := w.b4, b5 := w.b5, b6 := w.b6, b7 := w.b7, b8 := w.b8, b9 := w.b9, b10 := w.b10, b11 := w.b11, b12 := w.b12, γF := w.γF, βF := w.βF, Wcls := w.Wcls, bcls := w.bcls } sd img)) dy3) ∧ (BlockParamsV.TiedGB gf w.b4 N xN epsStr cotN ε bf16 (vitSdA sd 3) (vitSdM sd 3) ib4 dy4 ∧ vitBlockLossTiedGB gf N xN epsStr cotN ε w.b4 bf16 (vitSdA sd 3) (vitSdM sd 3) ib4 (fun (p : BlockParamsV (3 * 64) 768) => L (vitNetB gf N ε { Wc := w.Wc, bc := w.bc, cls := w.cls, pos := w.pos, b1 := w.b1, b2 := w.b2, b3 := w.b3, b4 := p, b5 := w.b5, b6 := w.b6, b7 := w.b7, b8 := w.b8, b9 := w.b9, b10 := w.b10, b11 := w.b11, b12 := w.b12, γF := w.γF, βF := w.βF, Wcls := w.Wcls, bcls := w.bcls } sd img)) dy4) ∧ (BlockParamsV.TiedGB gf w.b5 N xN epsStr cotN ε bf16 (vitSdA sd 4) (vitSdM sd 4) ib5 dy5 ∧ vitBlockLossTiedGB gf N xN epsStr cotN ε w.b5 bf16 (vitSdA sd 4) (vitSdM sd 4) ib5 (fun (p : BlockParamsV (3 * 64) 768) => L (vitNetB gf N ε { Wc := w.Wc, bc := w.bc, cls := w.cls, pos := w.pos, b1 := w.b1, b2 := w.b2, b3 := w.b3, b4 := w.b4, b5 := p, b6 := w.b6, b7 := w.b7, b8 := w.b8, b9 := w.b9, b10 := w.b10, b11 := w.b11, b12 := w.b12, γF := w.γF, βF := w.βF, Wcls := w.Wcls, bcls := w.bcls } sd img)) dy5) ∧ (BlockParamsV.TiedGB gf w.b6 N xN epsStr cotN ε bf16 (vitSdA sd 5) (vitSdM sd 5) ib6 dy6 ∧ vitBlockLossTiedGB gf N xN epsStr cotN ε w.b6 bf16 (vitSdA sd 5) (vitSdM sd 5) ib6 (fun (p : BlockParamsV (3 * 64) 768) => L (vitNetB gf N ε { Wc := w.Wc, bc := w.bc, cls := w.cls, pos := w.pos, b1 := w.b1, b2 := w.b2, b3 := w.b3, b4 := w.b4, b5 := w.b5, b6 := p, b7 := w.b7, b8 := w.b8, b9 := w.b9, b10 := w.b10, b11 := w.b11, b12 := w.b12, γF := w.γF, βF := w.βF, Wcls := w.Wcls, bcls := w.bcls } sd img)) dy6) ∧ (BlockParamsV.TiedGB gf w.b7 N xN epsStr cotN ε bf16 (vitSdA sd 6) (vitSdM sd 6) ib7 dy7 ∧ vitBlockLossTiedGB gf N xN epsStr cotN ε w.b7 bf16 (vitSdA sd 6) (vitSdM sd 6) ib7 (fun (p : BlockParamsV (3 * 64) 768) => L (vitNetB gf N ε { Wc := w.Wc, bc := w.bc, cls := w.cls, pos := w.pos, b1 := w.b1, b2 := w.b2, b3 := w.b3, b4 := w.b4, b5 := w.b5, b6 := w.b6, b7 := p, b8 := w.b8, b9 := w.b9, b10 := w.b10, b11 := w.b11, b12 := w.b12, γF := w.γF, βF := w.βF, Wcls := w.Wcls, bcls := w.bcls } sd img)) dy7) ∧ (BlockParamsV.TiedGB gf w.b8 N xN epsStr cotN ε bf16 (vitSdA sd 7) (vitSdM sd 7) ib8 dy8 ∧ vitBlockLossTiedGB gf N xN epsStr cotN ε w.b8 bf16 (vitSdA sd 7) (vitSdM sd 7) ib8 (fun (p : BlockParamsV (3 * 64) 768) => L (vitNetB gf N ε { Wc := w.Wc, bc := w.bc, cls := w.cls, pos := w.pos, b1 := w.b1, b2 := w.b2, b3 := w.b3, b4 := w.b4, b5 := w.b5, b6 := w.b6, b7 := w.b7, b8 := p, b9 := w.b9, b10 := w.b10, b11 := w.b11, b12 := w.b12, γF := w.γF, βF := w.βF, Wcls := w.Wcls, bcls := w.bcls } sd img)) dy8) ∧ (BlockParamsV.TiedGB gf w.b9 N xN epsStr cotN ε bf16 (vitSdA sd 8) (vitSdM sd 8) ib9 dy9 ∧ vitBlockLossTiedGB gf N xN epsStr cotN ε w.b9 bf16 (vitSdA sd 8) (vitSdM sd 8) ib9 (fun (p : BlockParamsV (3 * 64) 768) => L (vitNetB gf N ε { Wc := w.Wc, bc := w.bc, cls := w.cls, pos := w.pos, b1 := w.b1, b2 := w.b2, b3 := w.b3, b4 := w.b4, b5 := w.b5, b6 := w.b6, b7 := w.b7, b8 := w.b8, b9 := p, b10 := w.b10, b11 := w.b11, b12 := w.b12, γF := w.γF, βF := w.βF, Wcls := w.Wcls, bcls := w.bcls } sd img)) dy9) ∧ (BlockParamsV.TiedGB gf w.b10 N xN epsStr cotN ε bf16 (vitSdA sd 9) (vitSdM sd 9) ib10 dy10 ∧ vitBlockLossTiedGB gf N xN epsStr cotN ε w.b10 bf16 (vitSdA sd 9) (vitSdM sd 9) ib10 (fun (p : BlockParamsV (3 * 64) 768) => L (vitNetB gf N ε { Wc := w.Wc, bc := w.bc, cls := w.cls, pos := w.pos, b1 := w.b1, b2 := w.b2, b3 := w.b3, b4 := w.b4, b5 := w.b5, b6 := w.b6, b7 := w.b7, b8 := w.b8, b9 := w.b9, b10 := p, b11 := w.b11, b12 := w.b12, γF := w.γF, βF := w.βF, Wcls := w.Wcls, bcls := w.bcls } sd img)) dy10) ∧ (BlockParamsV.TiedGB gf w.b11 N xN epsStr cotN ε bf16 (vitSdA sd 10) (vitSdM sd 10) ib11 dy11 ∧ vitBlockLossTiedGB gf N xN epsStr cotN ε w.b11 bf16 (vitSdA sd 10) (vitSdM sd 10) ib11 (fun (p : BlockParamsV (3 * 64) 768) => L (vitNetB gf N ε { Wc := w.Wc, bc := w.bc, cls := w.cls, pos := w.pos, b1 := w.b1, b2 := w.b2, b3 := w.b3, b4 := w.b4, b5 := w.b5, b6 := w.b6, b7 := w.b7, b8 := w.b8, b9 := w.b9, b10 := w.b10, b11 := p, b12 := w.b12, γF := w.γF, βF := w.βF, Wcls := w.Wcls, bcls := w.bcls } sd img)) dy11) ∧ (BlockParamsV.TiedGB gf w.b12 N xN epsStr cotN ε bf16 (vitSdA sd 11) (vitSdM sd 11) ib12 dy12 ∧ vitBlockLossTiedGB gf N xN epsStr cotN ε w.b12 bf16 (vitSdA sd 11) (vitSdM sd 11) ib12 (fun (p : BlockParamsV (3 * 64) 768) => L (vitNetB gf N ε { Wc := w.Wc, bc := w.bc, cls := w.cls, pos := w.pos, b1 := w.b1, b2 := w.b2, b3 := w.b3, b4 := w.b4, b5 := w.b5, b6 := w.b6, b7 := w.b7, b8 := w.b8, b9 := w.b9, b10 := w.b10, b11 := w.b11, b12 := p, γF := w.γF, βF := w.βF, Wcls := w.Wcls, bcls := w.bcls } sd img)) dy12) ∧ (vitFinalLNTiedGB N xN epsStr cotN ε w.γF w.βF w.Wcls b12out g ∧ vitHeadTiedGB N aN cotN hnB w.Wcls w.bcls g ∧ vitHeadLossTiedGB N xN aN epsStr cotN ε w.γF w.βF w.Wcls w.bcls b12out (fun (a b : Vec 192) (W : Mat 192 nC) (bb : Vec nC) => L (vitNetB gf N ε { Wc := w.Wc, bc := w.bc, cls := w.cls, pos := w.pos, b1 := w.b1, b2 := w.b2, b3 := w.b3, b4 := w.b4, b5 := w.b5, b6 := w.b6, b7 := w.b7, b8 := w.b8, b9 := w.b9, b10 := w.b10, b11 := w.b11, b12 := w.b12, γF := a, βF := b, Wcls := W, bcls := bb } sd img)) g) ∧ vitEmbedTiedGB N xN cotN w.Wc w.bc w.cls w.pos (bf16 && bf16ConvW) img dyEmbed ∧ vitEmbedLossTiedGB N xN cotN w.Wc w.bc w.cls w.pos (bf16 && bf16ConvW) img (fun (W : Kernel4 192 3 16 16) (b c : Vec 192) (q : Mat 197 192) => L (vitNetB gf N ε { Wc := W, bc := b, cls := c, pos := q, b1 := w.b1, b2 := w.b2, b3 := w.b3, b4 := w.b4, b5 := w.b5, b6 := w.b6, b7 := w.b7, b8 := w.b8, b9 := w.b9, b10 := w.b10, b11 := w.b11, b12 := w.b12, γF := w.γF, βF := w.βF, Wcls := w.Wcls, bcls := w.bcls } sd img)) dyEmbed

                                                                                                              The emitted ViT-Tiny step's gradient nodes ARE the loss's gradient, at one chain. For each of the 200 parameter slots, at ONE cotangent chain (the tie's own, from the emitted smoothed-loss cotangent g): the node denotes its layer's Jacobian against the chain cotangent (vit_net_tiedGB), and the batched smoothed loss of vitNetB with that one slot varied is differentiable there with the node as its gradient (vit_net_lossGrad_smoothedCE). The tie's final-LN and classifier conjuncts pair with the one head conjunct of the loss side. The tie spells each block input as its own let; the proof rewrites the loss side's vitPre* into those lets (vitPreE_apply, …) and the loss side's logits into the tie's (vit_logitsB_eq).