ViT-Tiny step tie — the SGD-inline train step, all 200 parameters at the real backward chain #
What this file is. The tie of verified_mlir/vit_train_step.mlir — the SGD-inline step
ViTRender.lean writes — at the fused θ − lr·g ops: vit_net_tied_certified (the last theorem)
threads all 200 ViT-Tiny parameters through the committed multi-head (3 heads, d_head 64),
depth-12, vector-LayerNorm forward and the loss-driven backward cotangent chain. The statement is
per example, at one image and a hard label; the artifact runs a batch of 32, and that batch and
its mean lie outside this statement. Its batched peer at the un-fused gradient node, the smoothed
loss and a batch binder — the chain of the drop-free f32 vitin_* artifacts — is
ViTTieGB.vit_net_tiedGB, built from this file's block ties by batchMap / batchMapAux.
The file has two layers:
vit_block_tiedMHV/vit_block_tiedAtMHV— one multi-head (3 heads, d_head 64) vector-LN block, generic in the cotangent: the two residual fan-ins (vitCotHV,vitCotXinV), the three-way fan-in at LN₁ (vitCotLn1), and the per-head SDPA backward (ViTMultiHeadChain'svitCotD{Q,K,V}mh).vit_net_tied_certified— the 200-parameter capstone: the 192 block parameters threaded through all 12 blocks, the final LN, the classifier and the patch embed (vit_cls_dencovers the CLS token atN = 1).
Every conjunct delegates to a ViTFold.*_den fold lemma at the chain cotangent — zero new ops,
zero new bridges. The vector-LN granularity that ships ([192] γ/β) is what is modelled.
Multi-head promotion (3 heads, d_head=64) — the committed-render block tie #
The committed vitTrainStepRenderV is multi-head: the SDPA-internal backward dAtt → dQ/dK/dV
runs per head (vitCotD{Q,K,V}mh, ViTMultiHeadChain), so the Q/K/V dense cotangents are the
multi-head …mh ones rather than the single-head vitCotD{Q,K,V}; everything else (the out-proj
Wo, LN₂, the MLP) is head-agnostic. vitBlockTiedMHV states the block's 16 parameter ties with
those cotangents (no separate ss/p saves — the per-head scores/weights are recomputed inside the
…mh cots from the saved Q/K); every conjunct delegates to a head-agnostic fold generic
ViTFold.*_den.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Multi-head forward + cot-in + input-only block wrappers (the thread template) #
Multi-head forward block step (the committed render's block forward = vitBlockSpelledMHV,
which IS transformerBlockV at general heads by vitBlockSpelledMHV_eq).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Multi-head attention-residual fan-in: the block-input cotangent the chain hands upstream
(vitCotXinV at the multi-head Q/K/V dense cots — vitCotLn1 Wq Wk Wv dQmh dKmh dVmh IS the
multi-head LN₁ fan-in vitCotLn1MH). Recomputes the saves from xin (the vitBlockSpelledMHV
let-chain, multi-head att).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Multi-head input-only block tie — recompute the 9 saves from xin, then vit_block_tiedMHV.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The multi-head input-only block tie holds — unfold the saves, delegate to vit_block_tiedMHV.
The non-block param bundle + the all-200-params capstone (committed ViT-Tiny config) #
vitFinalLNTied/vitHeadTied/vitEmbedTied bundle the final vector-LN γ/β, the classifier Wcls/bcls,
and the patch-embed wConv/bConv/cls/pos as den = certified at their chain cotangents — each a direct
delegation to the fold generics (ViTFold.*_den), with the cls op (denseBiasSgdB N=1) folded by
vit_cls_den (its row-0 batch slice IS clsTokenGrad, closed by clsToken_sgd_certified). Then
vit_net_tied_certified threads the REAL forward + loss-driven backward and bundles all 200 params.
Final vector-LN γF/βF tied at the classifier-back cot vitCotFl.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Patch embed wConv/bConv/cls/pos tied at the embed-output cot dyEmbed.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The ties' weight records #
Twelve blocks as BlockParamsV (ViTDepthK's bundle), plus the patch embed, final LN and head.
The ties share ONE ε across every LN. The dot-notation wrappers are abbrevs over the
constructors above: a statement over a record unfolds to the unpacked one.
ViT-Tiny as the ties bind it.
- Wc : Kernel4 192 3 16 16
- bc : Vec 192
- cls : Vec 192
- pos : Mat 197 192
- b1 : BlockParamsV 192 768
- b2 : BlockParamsV 192 768
- b3 : BlockParamsV 192 768
- b4 : BlockParamsV 192 768
- b5 : BlockParamsV 192 768
- b6 : BlockParamsV 192 768
- b7 : BlockParamsV 192 768
- b8 : BlockParamsV 192 768
- b9 : BlockParamsV 192 768
- b10 : BlockParamsV 192 768
- b11 : BlockParamsV 192 768
- b12 : BlockParamsV 192 768
- γF : Vec 192
- βF : Vec 192
- Wcls : Mat 192 nC
- bcls : Vec nC
Instances For
The block's forward (vitBlockFwdOMHV).
Equations
Instances For
The block's input cotangent (vitBlockCotInAtMHV).
Equations
Instances For
The block's per-example tie (vitBlockTiedAtMHV).
Equations
- One or more equations did not get rendered due to their size.
Instances For
The whole depth-12 multi-head ViT-Tiny train step, tied — all 200 params (the vit peer of
convnext's cnx_net_tied_certified, at the committed config: 3 heads, d_head=64, D=192, N=196,
mlpDim=768, 10 classes, 16×16 patches). The real forward patchEmbed → 12 multi-head vector-LN blocks → final vector-LN → CLS-slice → dense head and the loss-driven backward cotangent chain
(the per-block multi-head fan-ins, the final-LN-back vitCotTowerOutV, the classifier-back vitCotFl,
the embed-output cot = block-1's vitBlockCotInAtMHV output) are threaded, and EVERY param op
denotes θ − lr·(certified per-layer Jacobian · the chain cotangent): the 12 blocks' 192
params (vitBlockTiedAtMHV), the final-LN γ/β, the classifier Wcls/bcls, and the patch-embed
wConv/bConv/cls/pos — 200/200. Each chain cotangent is the certified VJP backward of the
stages above it (vitBlockCotInAtMHV_eq_vjp, vitCotTowerOutV_eq_vjp, below).
The statement is per example, at one image img and a hard label label; the artifact's
batch of 32 and its mean lie outside it (the batched form is ViTTieGB.vit_net_tiedGB).
Every cotangent the capstone threads is a certified VJP backward #
vit_net_tied_certified threads two per-example constructors: the head's vitCotTowerOutV and
each block's vitBlockCotInAtMHV. They are the render's spelling of the
backward — per-head SDPA with pad and slice, LayerNorm as rowScaleFlat then rowLNBackFlat at
γ = 1, separate dense backs — so tying them to the certified VJPs is a proof, not a
definitional match: the lemmas below rewrite each spelling into the one the whole-net tie
(ViTWholeBackCertifiedTie) is stated at. The only hypothesis is the LayerNorm's 0 < ε.
The render's per-token dense backward is perRowFlat of the transposed dense — the spelling
mhsaBackFlat uses.
vitCotDQmh_eq_core for K.
vitCotDQmh_eq_core for V.
The rendered block chain is vitBlockBackV, at any saved activations. The render's
LayerNorm backward (rowScaleFlat γ then rowLNBackFlat at γ = 1) is rowLNVecFlatBack
(rowLNBack_affine_eq); the per-head attention backward is the concatenated core; the MLP
backward is the per-row fold; the Q/K/V fan-in and both residual adds reassociate.
A ViT block's input cotangent is its certified VJP's backward. vitCotXin_eq_blockBack
at the real saved activations, then vitBlockBackVAt_eq_vjp. The one forward fact needed is
that the attention output the chain recomputes (per-head spelled) is transformerAttnSublayerV
(mhsaLayer_spelled).
The head classifier ∘ final LN as one certified VJP, at any class count.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The head's input cotangent — the last block's dyOut — is its certified VJP's backward:
the render's final-LN spelling is rowLNVecFlatBack (rowLNBack_affine_eq), then the
classifier and final-LN leaf ties.