Documentation

LeanMlir.Proofs.Nets.ViT.ViTStepTieGB

ViT-Tiny's step tie at the batched index, the un-fused gradient and the smoothed loss #

ViTStepTie.lean ties all 200 parameters of the SGD-inline vit_train_step.mlir: each fused θ − lr·g op dens to the certified step at the cotangent the emitted backward chain delivers, per example, at a hard label. This file is that statement re-pointed along the three axes ConvNeXtStepTieGB.lean moved for ConvNeXt, applied to ViT's per-example capstone.

Axis 1 — the gradient node. Every conjunct is at the raw gradient node (*GradB), which is what vit_adam_train_step.mlir and every f32 vitin_* artifact emit; the fused op appears only in the SGD-inline file. The optimizer update that consumes the node (AdamW, the wx/clip variants, EMA) is outside this statement. ViTFoldGB.lean is the fold each conjunct delegates to.

Precision is a flag on the statement. The bf16 artifacts (vitin_adamwxclipdropbf16 and its EMA, data-parallel, ε and exact-GELU twins) emit the bf16 per-token dense weight gradient (rowDenseWeightGradBBf16) at the six denses of every block, and — only if the render's bf16ConvW is set, which no shipped artifact does — the bf16 patch-embed weight gradient (Foundation.Bf16GradNodes). Both are stated on the renderers' switch: ViTFoldGB.RowDenseWTiedBAt bf16 and patchEmbedWeightGradBAt bf16 id … (StableHLO.PrecisionSwitch), false the f32 node, true the bf16 one. The capstone vit_net_tiedGB takes the renderer's two backward flags, bf16 and bf16ConvW, and passes bf16 && bf16ConvW to the embed as vitBackAllB does, so at bf16 := true, bf16ConvW := false it reaches the shipped bf16 artifacts' gradient nodes read over ℝ exactly as it reads the f32 ones (Bf16Erasure: at the identity rounding the bf16 kind denotes what its f32 peer does). The bias, LayerNorm, CLS, position and classifier nodes carry no flag because no render switches them.

Axis 2 — the loss. g is a binder, instantiated at smoothedLossCotGraphDiv — the six-op chain expe → softmaxDiv → subB → scaleB → addVB → shiftB → divConstB this render emits at the plain width N·K, at a GENERAL target arriving as %onehot. The fused file pins it to softmax − oneHot.

Axis 3 — the index. N is a binder. Every activation is a per-example lift of the prefix the fused file threads (patchEmbedFlat, the block forward, the final LN, clsSliceFlat) and every cotangent a per-example lift of the chain (vitCotTowerOutV, the block's input cotangent, the vitCot* family). The lift is exact for this net because no ViT op couples examples — LayerNorm, attention, GELU and the denses are all per-example, and the *B constructors' den arms say so. A block's lift is the INDEXED one (batchMapIdx / batchMapAuxIdx, Foundation.Batched.Indexed): with stochastic depth example n runs the block at its own mask entries. nC is a binder too (10 on Imagenette, 1000 on ImageNet).

Stochastic depth is a binder. sd : Option (Fin 12 → Vec N × Vec N) is the render's drop flag: none the drop-free artifacts' chain — every family constant, so the lifts are batchMap / batchMapAux and the statement is the drop-free one by rfl — and some the *drop* artifacts', the book's vitin_emadp128x4wxclipdropeps0000001erfbf16 among them: block k's two sites (vitSdA / vitSdM, the %dp<2k> / %dp<2k+1> inputs) scale the out-projection's and fc2's outputs by example n's entries (BlockParamsV.fwdOD), the out-projection and fc2 weight and bias nodes read the dropped cotangent (dropPathOpt, where ViTRenderB emits dropPathB on it), and both skip fan-ins read the raw one (BlockParamsV.cotInD, ViTDropBlock).

The CLS-token conjunct. The CLS token is one shared [192] vector; its gradient is the sum of every example's CLS-row cotangent. The fused file's vit_cls_den is at denseBiasSgdB (N := 1) — "sum one thing", correct there because pretty B performed the batch lift outside the AST. vitEmbedTiedGB's third conjunct is ViTFoldGB.clsGrad_denB at the batched node, denseBiasGradB (N := N) on batchMap N clsSliceFlat of the embed cotangent, with the batch sum inside den.

Relation to the per-example file #

Every save, every chain cotangent and every Jacobian witness is ViTStepTie.lean's, lifted; every conjunct's proof is one ViTFoldGB.*_den lemma. The per-example saves and internal cotangents are repackaged as functions of the block INPUT and its two sites (blkSaves, cAtt … cM1) so that the indexed lift has something to lift — the let chains of vitBlockTiedAtMHV and vitBlockCotInAtMHV with the sites in. ViT has no *BackBatchedGraph_faithful family and needs none here: the batchMap lift is the batched statement, as it was for ConvNeXt.

Conventions carried unchanged from the fused file: the VECTOR LayerNorm (γ β : Vec D) at all 25 sites, 3 heads × d_head 64, depth 12, D 192, MLP 768, 16×16 patches, GELU (no kink — no smoothness hypothesis anywhere). Stated at ViT-Tiny's literal dims; S and B are other nets.

Scope. One replica: in vitin_adamdp128x4* (four replicas of 128) every gradient node feeds allReduceMeanF, and DataParallel.Node composes the per-replica statement with the replica mean.

Per-example saves and internal cotangents as functions of a block's INPUT #

vitBlockTiedMHV takes the nine saved activations as arguments; batchMapAux lifts a function of (one saved value, one input), so the batched block tie needs each save as a function of xin and each internal cotangent as a function of (xin, dyOut) — exactly the let chains of ViTTie.vitBlockTiedAtMHV and vitBlockCotInAtMHV, packaged.

structure Proofs.ViTTieGB.BlkSaves (Np1 heads d mlpDim : ℕ) :

The nine saved activations of one multi-head block, flattened.

  • ln1 : Vec (Np1 * (heads * d))
  • q : Vec (Np1 * (heads * d))
  • k : Vec (Np1 * (heads * d))
  • v : Vec (Np1 * (heads * d))
  • att : Vec (Np1 * (heads * d))
  • h : Vec (Np1 * (heads * d))
  • ln2 : Vec (Np1 * (heads * d))
  • m1 : Vec (Np1 * mlpDim)
  • g : Vec (Np1 * mlpDim)
Instances For
    noncomputable def Proofs.ViTTieGB.blkSaves (gf : GeluForm) {Np1 heads d mlpDim : ℕ} (ε : ℝ) (γ1 β1 γ2 β2 : Vec (heads * d)) (Wq Wk Wv Wo : Mat (heads * d) (heads * d)) (bq bk bv bo : Vec (heads * d)) (Wfc1 : Mat (heads * d) mlpDim) (bfc1 : Vec mlpDim) (sA : Option ℝ) (xin : Vec (Np1 * (heads * d))) :
    BlkSaves Np1 heads d mlpDim

    The saves from the block input — vitBlockTiedAtMHV's let chain, verbatim.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      noncomputable def Proofs.ViTTieGB.cAtt (gf : GeluForm) {Np1 heads d mlpDim : ℕ} (ε : ℝ) (γ1 β1 γ2 β2 : Vec (heads * d)) (Wq Wk Wv Wo : Mat (heads * d) (heads * d)) (bq bk bv bo : Vec (heads * d)) (Wfc1 : Mat (heads * d) mlpDim) (bfc1 : Vec mlpDim) (Wfc2 : Mat mlpDim (heads * d)) (sA sM : Option ℝ) (xin dyOut : Vec (Np1 * (heads * d))) :
      Vec (Np1 * (heads * d))

      Per example, the attention-output cotangent (vitCotAttV), from the block input and output cotangent.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        noncomputable def Proofs.ViTTieGB.cQ (gf : GeluForm) {Np1 heads d mlpDim : ℕ} (ε : ℝ) (γ1 β1 γ2 β2 : Vec (heads * d)) (Wq Wk Wv Wo : Mat (heads * d) (heads * d)) (bq bk bv bo : Vec (heads * d)) (Wfc1 : Mat (heads * d) mlpDim) (bfc1 : Vec mlpDim) (Wfc2 : Mat mlpDim (heads * d)) (sA sM : Option ℝ) (xin dyOut : Vec (Np1 * (heads * d))) :
        Vec (Np1 * (heads * d))

        Per example, the Q cotangent, per head (vitCotDQmh), from the block input and output cotangent.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          noncomputable def Proofs.ViTTieGB.cK (gf : GeluForm) {Np1 heads d mlpDim : ℕ} (ε : ℝ) (γ1 β1 γ2 β2 : Vec (heads * d)) (Wq Wk Wv Wo : Mat (heads * d) (heads * d)) (bq bk bv bo : Vec (heads * d)) (Wfc1 : Mat (heads * d) mlpDim) (bfc1 : Vec mlpDim) (Wfc2 : Mat mlpDim (heads * d)) (sA sM : Option ℝ) (xin dyOut : Vec (Np1 * (heads * d))) :
          Vec (Np1 * (heads * d))

          Per example, the K cotangent, per head, from the block input and output cotangent.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For
            noncomputable def Proofs.ViTTieGB.cV (gf : GeluForm) {Np1 heads d mlpDim : ℕ} (ε : ℝ) (γ1 β1 γ2 β2 : Vec (heads * d)) (Wq Wk Wv Wo : Mat (heads * d) (heads * d)) (bq bk bv bo : Vec (heads * d)) (Wfc1 : Mat (heads * d) mlpDim) (bfc1 : Vec mlpDim) (Wfc2 : Mat mlpDim (heads * d)) (sA sM : Option ℝ) (xin dyOut : Vec (Np1 * (heads * d))) :
            Vec (Np1 * (heads * d))

            Per example, the V cotangent, per head, from the block input and output cotangent.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              noncomputable def Proofs.ViTTieGB.cLn1 (gf : GeluForm) {Np1 heads d mlpDim : ℕ} (ε : ℝ) (γ1 β1 γ2 β2 : Vec (heads * d)) (Wq Wk Wv Wo : Mat (heads * d) (heads * d)) (bq bk bv bo : Vec (heads * d)) (Wfc1 : Mat (heads * d) mlpDim) (bfc1 : Vec mlpDim) (Wfc2 : Mat mlpDim (heads * d)) (sA sM : Option ℝ) (xin dyOut : Vec (Np1 * (heads * d))) :
              Vec (Np1 * (heads * d))

              Per example, the LN₁-output cotangent: the three-way Q/K/V fan-in (vitCotLn1), from the block input and output cotangent.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                noncomputable def Proofs.ViTTieGB.cH (gf : GeluForm) {Np1 heads d mlpDim : ℕ} (ε : ℝ) (γ1 β1 γ2 β2 : Vec (heads * d)) (Wq Wk Wv Wo : Mat (heads * d) (heads * d)) (bq bk bv bo : Vec (heads * d)) (Wfc1 : Mat (heads * d) mlpDim) (bfc1 : Vec mlpDim) (Wfc2 : Mat mlpDim (heads * d)) (sA sM : Option ℝ) (xin dyOut : Vec (Np1 * (heads * d))) :
                Vec (Np1 * (heads * d))

                Per example, the MLP-residual fan-in at h (vitCotHV), from the block input and output cotangent.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  noncomputable def Proofs.ViTTieGB.cLn2 (gf : GeluForm) {Np1 heads d mlpDim : ℕ} (ε : ℝ) (γ1 β1 γ2 β2 : Vec (heads * d)) (Wq Wk Wv Wo : Mat (heads * d) (heads * d)) (bq bk bv bo : Vec (heads * d)) (Wfc1 : Mat (heads * d) mlpDim) (bfc1 : Vec mlpDim) (Wfc2 : Mat mlpDim (heads * d)) (sA sM : Option ℝ) (xin dyOut : Vec (Np1 * (heads * d))) :
                  Vec (Np1 * (heads * d))

                  Per example, the LN₂-output cotangent (vitCotLn2), from the block input and output cotangent.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    noncomputable def Proofs.ViTTieGB.cM1 (gf : GeluForm) {Np1 heads d mlpDim : ℕ} (ε : ℝ) (γ1 β1 γ2 β2 : Vec (heads * d)) (Wq Wk Wv Wo : Mat (heads * d) (heads * d)) (bq bk bv bo : Vec (heads * d)) (Wfc1 : Mat (heads * d) mlpDim) (bfc1 : Vec mlpDim) (Wfc2 : Mat mlpDim (heads * d)) (sA sM : Option ℝ) (xin dyOut : Vec (Np1 * (heads * d))) :
                    Vec (Np1 * mlpDim)

                    Per example, the fc1-output cotangent through the GELU mask (vitCotM1), from the block input and output cotangent.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For

                      The multi-head block — all 16 gradient nodes, batched #

                      def Proofs.ViTTieGB.vitBlockTiedGB (gf : GeluForm) (N : ℕ) {Np1 heads d mlpDim : ℕ} (xN epsStr cotN : String) (ε : ℝ) (γ1 β1 γ2 β2 : Vec (heads * d)) (Wq Wk Wv Wo : Mat (heads * d) (heads * d)) (bq bk bv bo : Vec (heads * d)) (Wfc1 : Mat (heads * d) mlpDim) (bfc1 : Vec mlpDim) (Wfc2 : Mat mlpDim (heads * d)) (bfc2 : Vec (heads * d)) (bf16 : Bool) (sA sM : Option (Vec N)) (xin dyOut : Vec (N * (Np1 * (heads * d)))) :

                      One multi-head vector-LN transformer block, tied at the batched gradient nodes. Every one of the block's 16 params, fed the indexed lift of the cotangent the real backward chain delivers at its site, denotes the certified Σ_n gradient — the MLP-residual and attention-residual fan-ins and the three-way LN₁ fan-in, per head, exactly as vitBlockTiedMHV has them per example. At the two drop sites sA sM the out-projection's and fc2's nodes read the dropped cotangent (dropPathOpt); none none is the drop-free block.

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        theorem Proofs.ViTTieGB.vit_block_tiedGB {gf : GeluForm} (N : ℕ) {Np1 heads d mlpDim : ℕ} (xN epsStr cotN : String) (ε : ℝ) (γ1 β1 γ2 β2 : Vec (heads * d)) (Wq Wk Wv Wo : Mat (heads * d) (heads * d)) (bq bk bv bo : Vec (heads * d)) (Wfc1 : Mat (heads * d) mlpDim) (bfc1 : Vec mlpDim) (Wfc2 : Mat mlpDim (heads * d)) (bfc2 : Vec (heads * d)) (bf16 : Bool) (sA sM : Option (Vec N)) (xin dyOut : Vec (N * (Np1 * (heads * d)))) :
                        vitBlockTiedGB gf N xN epsStr cotN ε γ1 β1 γ2 β2 Wq Wk Wv Wo bq bk bv bo Wfc1 bfc1 Wfc2 bfc2 bf16 sA sM xin dyOut

                        Final LN, classifier and patch embedding — batched #

                        def Proofs.ViTTieGB.vitFinalLNTiedGB (N : ℕ) {nC : ℕ} (xN epsStr cotN : String) (ε : ℝ) (γF βF : Vec 192) (Wcls : Mat 192 nC) (b12out : Vec (N * (197 * 192))) (g : Vec (N * nC)) :

                        Final vector-LN γF/βF, tied at the batched classifier-back cotangent vitCotFl per example (the clsPad of Wclsᵀ g_n, exactly what the render's dotOut → clsPad computes).

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

                          Classifier Wcls/bcls, tied at the loss cotangent g — the weight at the batched CLS row, the bias summed over the batch (GradNodeB.headBGradB_den).

                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For
                            theorem Proofs.ViTTieGB.vit_head_tiedGB (N : ℕ) {nC : ℕ} (aN cotN : String) (hn : Vec (N * 192)) (Wcls : Mat 192 nC) (bcls : Vec nC) (g : Vec (N * nC)) :
                            vitHeadTiedGB N aN cotN hn Wcls bcls g
                            def Proofs.ViTTieGB.vitEmbedTiedGB (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))) (dyEmbed : Vec (N * (197 * 192))) :

                            Patch embed wConv/bConv/cls/pos, tied at the batched embed-output cotangent. The third conjunct is the CLS token's gradient with the batch sum INSIDE den — the statement the per-example capstone made only at N = 1.

                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For
                              theorem Proofs.ViTTieGB.vit_embed_tiedGB (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))) (dyEmbed : Vec (N * (197 * 192))) :
                              vitEmbedTiedGB N xN cotN Wc bc cls pos bf16 img dyEmbed

                              Every cotangent the capstone threads is a certified VJP backward #

                              The capstone below threads two per-example constructors: the head's vitCotTowerOutV (batchMapAux N) and each block's cotInD at its sites (batchMapAuxIdx N). Their per-example ties to the certified VJPs are ViTStepTie's vitCotTowerOutV_eq_vjp and ViTDropBlock's cotInD_eq_vjp; the two lemmas below lift them over the batch.

                              theorem Proofs.ViTTieGB.vitBlockCotInB_eq_vjp {gf : GeluForm} (N : ℕ) {Np1 heads d mlpDim : ℕ} (ε : ℝ) (hε : 0 < ε) (p : BlockParamsV (heads * d) mlpDim) (sA sM : Option (Vec N)) (xin : Vec (N * (Np1 * (heads * d)))) :
                              StableHLO.batchMapAuxIdx N (fun (n : Fin N) => BlockParamsV.cotInD gf p ε (exampleSite sA n) (exampleSite sM n)) xin = (batchMapIdxHasVJPAt (fun (n : Fin N) => BlockParamsV.fwdOD gf p ε (exampleSite sA n) (exampleSite sM n)) xin (fun (n : Fin N) => (BlockParamsV.fwdODHasVJP gf p ε hε (exampleSite sA n) (exampleSite sM n)).toHasVJPAt (Mat.unflatten xin n)) ⋯).backward

                              Batched: a block's cotangent at its sites is the lifted block VJP's backward. Example n runs the block at its own two mask entries, so the lift is the indexed one; cotInD_eq_vjp per example. At none none it is the drop-free block's (cotInD_none, fwdOD_none).

                              theorem Proofs.ViTTieGB.vitCotTowerOutB_eq_vjp (N : ℕ) {n D nC : ℕ} (ε : ℝ) (hε : 0 < ε) (γF βF : Vec D) (Wcls : Mat D nC) (bcls : Vec nC) (b : Vec (N * ((n + 1) * D))) :
                              StableHLO.batchMapAux N (vitCotTowerOutV n D nC ε γF Wcls) b = (batchMapHasVJPAt (classifierFlat n D nC Wcls bcls ∘ fun (v : Vec ((n + 1) * D)) => Mat.flatten fun (r : Fin (n + 1)) => layerNormVec D ε γF βF (Mat.unflatten v r)) b (fun (x : Fin N) => (vitHeadHasVJP n D nC ε hε γF βF Wcls bcls).toHasVJPAt (Mat.unflatten b x)) ⋯).backward

                              Batched: the head's batchMapAux cotangent is the lifted head VJP's backward.

                              The whole-net capstone — all 200 params through the REAL batched forward + composed cotangent #

                              The fused file's thread, lifted: ib1 is batchMap N of the patch embedding, ib_{k+1} is batchMapIdx N of the multi-head block forward at block k's sites, the final LN / CLS slice / dense head are batchMap N of theirs, g is the smoothed loss cotangent at a general target, and every cotangent is the lift of the per-example chain — vitCotTowerOutV at the top, then twelve cotInD attention-residual fan-ins down to the embed-output cotangent.

                              def Proofs.ViTTieGB.vitSdA {N L : ℕ} (sd : Option (Fin L → Vec N × Vec N)) (k : Fin L) :

                              Block k's attention-site masks, when the render carries stochastic depth: the first of the pair the *drop* artifacts feed block k (%dp<2k>, ViTRenderB.vitSiteIdx k 0).

                              Equations
                              Instances For
                                def Proofs.ViTTieGB.vitSdM {N L : ℕ} (sd : Option (Fin L → Vec N × Vec N)) (k : Fin L) :

                                Block k's MLP-site masks (%dp<2k+1>).

                                Equations
                                Instances For
                                  @[simp]
                                  theorem Proofs.ViTTieGB.vitSdA_none {N L : ℕ} (k : Fin L) :
                                  @[simp]
                                  theorem Proofs.ViTTieGB.vitSdM_none {N L : ℕ} (k : Fin L) :
                                  @[reducible, inline]
                                  abbrev Proofs.BlockParamsV.TiedGB (gf : GeluForm) {Np1 heads d mlpDim : ℕ} (p : BlockParamsV (heads * d) mlpDim) (N : ℕ) (xN epsStr cotN : String) (ε : ℝ) (bf16 : Bool) (sA sM : Option (Vec N)) (xin dyOut : Vec (N * (Np1 * (heads * d)))) :

                                  The block's batched tie (vitBlockTiedGB), over its BlockParamsV record.

                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  Instances For
                                    theorem Proofs.BlockParamsV.tied_gb {gf : GeluForm} {Np1 heads d mlpDim : ℕ} (p : BlockParamsV (heads * d) mlpDim) (N : ℕ) (xN epsStr cotN : String) (ε : ℝ) (bf16 : Bool) (sA sM : Option (Vec N)) (xin dyOut : Vec (N * (Np1 * (heads * d)))) :
                                    TiedGB gf p N xN epsStr cotN ε bf16 sA sM xin dyOut
                                    theorem Proofs.ViTTieGB.vit_net_tiedGB {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)) :
                                    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; BlockParamsV.TiedGB gf w.b1 N xN epsStr cotN ε bf16 (vitSdA sd 0) (vitSdM sd 0) ib1 dy1 ∧ BlockParamsV.TiedGB gf w.b2 N xN epsStr cotN ε bf16 (vitSdA sd 1) (vitSdM sd 1) ib2 dy2 ∧ BlockParamsV.TiedGB gf w.b3 N xN epsStr cotN ε bf16 (vitSdA sd 2) (vitSdM sd 2) ib3 dy3 ∧ BlockParamsV.TiedGB gf w.b4 N xN epsStr cotN ε bf16 (vitSdA sd 3) (vitSdM sd 3) ib4 dy4 ∧ BlockParamsV.TiedGB gf w.b5 N xN epsStr cotN ε bf16 (vitSdA sd 4) (vitSdM sd 4) ib5 dy5 ∧ BlockParamsV.TiedGB gf w.b6 N xN epsStr cotN ε bf16 (vitSdA sd 5) (vitSdM sd 5) ib6 dy6 ∧ BlockParamsV.TiedGB gf w.b7 N xN epsStr cotN ε bf16 (vitSdA sd 6) (vitSdM sd 6) ib7 dy7 ∧ BlockParamsV.TiedGB gf w.b8 N xN epsStr cotN ε bf16 (vitSdA sd 7) (vitSdM sd 7) ib8 dy8 ∧ BlockParamsV.TiedGB gf w.b9 N xN epsStr cotN ε bf16 (vitSdA sd 8) (vitSdM sd 8) ib9 dy9 ∧ BlockParamsV.TiedGB gf w.b10 N xN epsStr cotN ε bf16 (vitSdA sd 9) (vitSdM sd 9) ib10 dy10 ∧ BlockParamsV.TiedGB gf w.b11 N xN epsStr cotN ε bf16 (vitSdA sd 10) (vitSdM sd 10) ib11 dy11 ∧ BlockParamsV.TiedGB gf w.b12 N xN epsStr cotN ε bf16 (vitSdA sd 11) (vitSdM sd 11) ib12 dy12 ∧ vitFinalLNTiedGB N xN epsStr cotN ε w.γF w.βF w.Wcls b12out g ∧ vitHeadTiedGB N aN cotN hnB w.Wcls w.bcls g ∧ vitEmbedTiedGB N xN cotN w.Wc w.bc w.cls w.pos (bf16 && bf16ConvW) img dyEmbed

                                    The whole depth-12 multi-head ViT-Tiny train step, tied at the batched index, the gradient nodes and the smoothed loss — all 200 parameters. The real forward patchEmbed → 12 multi-head vector-LN blocks → final vector-LN → CLS-slice → dense head as per-example lifts of the prefixes, the smoothed loss cotangent at a general target t, and the backward chain as the lift of the per-example one (the per-block multi-head fan-ins, vitCotTowerOutV at the top, the embed-output cotangent at the bottom): the twelve blocks' 192 params, the final-LN γ/β, the classifier and the patch-embed wConv/bConv/cls/pos all denote the certified batched Σ_n gradient at their chain cotangent, and each chain cotangent is the backward of its stage's lifted certified VJP (vitCotTowerOutB_eq_vjp, vitBlockCotInB_eq_vjp) — at the gradient nodes vit_adam_train_step.mlir and every vitin_* train step emit: bf16 selects the per-token dense weight nodes' kind and bf16 && bf16ConvW the patch embed's, false the f32 artifacts', true the *bf16 ones', read over ℝ at the identity rounding (Bf16Erasure); the right-hand side is the same certified gradient at every value. The CLS token's gradient sums over the batch inside den, which the per-example capstone could state only at N = 1.

                                    sd is stochastic depth: none the drop-free artifacts' chain, some the *drop* artifacts' — vitin_emadp128x4wxclipdropeps0000001erfbf16's, the book's run — each block's out-projection and fc2 nodes at the dropped cotangent and both skips at the raw one, so the book's ViT job is reached at every gradient node with only its EMA tail outside.

                                    N and nC are binders and there is no smoothness hypothesis (GELU, no kink). The batch enters only through the per-example lifts, because no ViT op couples examples. The statement is at one replica and at ViT-Tiny's literal dims.