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.
- Per example (at variable widths): the loss read after each of a block's eight parameterised
ops has the tie's own per-example cotangent as its gradient (
vitPostL1_hasGradAt,vitPostQ_hasGradAt, …,vitPostF1_hasGradAt). Each is a short chain through certified VJPs: the MLP sublayer (mlpSubFlat_tie_vis its backward in the chain's spelling), the out-projection, the full attention layer for LN₁ (mhsaBackFlat_eq_mhsa_vjp). - The attention core in one of
Q,K,Vis the new piece. The render's per-head core is a column-slab map with a different function on each head's slab (headhreadsK's andV's slabh), so it is Attention'scolSlabApplyH, whose Jacobian stays block-diagonal (pdivMat_colIndepH). Each head's VJP is the certified single-headsdpaBack{Q,K,V}, and the lifted backward IS the tie'scoreQFlat/coreKFlat/coreVFlat(attnCoreQ_backward, …, allrfl). - Lifted (
HasGradAt.param_batchMapIdx_through,Foundation.Batched.Indexed): read against the linear loss⟨·, dyₙ⟩per example, those gradients turn each tied node'sΣ_n Σ_j ∂per/∂θ · cotₙinto∂G/∂θof the batched block,Gthe loss at the block's output. Examplen's prefix and suffix are at its own drop sites (exampleSite), so the lift is the indexed one; the parameterised op itself is shared. Each node needs the block forward read as "the rest of the block ∘ the node's op ∘ the prefix" (vit_fwd_Wq, …), an equation up toMat.unflatten_flatten. - Per net: the loss read after each stage (
vitSuf*), pulled back through the certified batched block and head VJPs (vitBlockCotInB_eq_vjp,vitCotTowerOutB_eq_vjp), and eachΦidentified with the whole net at updated weights by a standalonevit_factor_*theorem.
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.
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
The core in Q is a per-slab map: each head's attention on its own Q slab
(sum_headPadMat_apply).
…in K.
…in 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
The core is differentiable in Q, flattened.
…in K.
…in V.
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.
LN₁'s output.
Equations
- Proofs.ViTTieGB.vitLn1M ε p y r kk = Proofs.layerScale p.γ1 (fun (s : Fin (heads * d)) => Proofs.layerNormForward (heads * d) ε 1 0 (Proofs.Mat.unflatten y r) s) kk + p.β1 kk
Instances For
The Q projection.
Equations
- Proofs.ViTTieGB.vitQM ε p y r = Proofs.dense p.Wq p.bq (Proofs.ViTTieGB.vitLn1M ε p y r)
Instances For
The K projection.
Equations
- Proofs.ViTTieGB.vitKM ε p y r = Proofs.dense p.Wk p.bk (Proofs.ViTTieGB.vitLn1M ε p y r)
Instances For
The V projection.
Equations
- Proofs.ViTTieGB.vitVM ε p y r = Proofs.dense p.Wv p.bv (Proofs.ViTTieGB.vitLn1M ε p y r)
Instances For
The attention core's output (the out-projection's input).
Equations
- Proofs.ViTTieGB.vitAttM ε p y = Proofs.ViTTieGB.attnCore (Proofs.ViTTieGB.vitQM ε p y) (Proofs.ViTTieGB.vitKM ε p y) (Proofs.ViTTieGB.vitVM ε p y)
Instances For
The out-projection's output.
Equations
- Proofs.ViTTieGB.vitOM ε p y r = Proofs.dense p.Wo p.bo (Proofs.ViTTieGB.vitAttM ε p y r)
Instances For
The attention sublayer's output h, the out-projection through the attention site.
Equations
- Proofs.ViTTieGB.vitHM ε p sA y r s = Proofs.Mat.unflatten y r s + Proofs.siteScale sA (Proofs.ViTTieGB.vitOM ε p y r s)
Instances For
LN₂'s output.
Equations
- Proofs.ViTTieGB.vitLn2M ε p sA y r kk = Proofs.layerScale p.γ2 (fun (s : Fin (heads * d)) => Proofs.layerNormForward (heads * d) ε 1 0 (Proofs.ViTTieGB.vitHM ε p sA y r) s) kk + p.β2 kk
Instances For
fc1's output (pre-GELU).
Equations
- Proofs.ViTTieGB.vitM1M ε p sA y r = Proofs.dense p.Wfc1 p.bfc1 (Proofs.ViTTieGB.vitLn2M ε p sA y r)
Instances For
The out-projection, flat.
Equations
- Proofs.ViTTieGB.vitWoF p v = Proofs.Mat.flatten fun (r : Fin Np1) => Proofs.dense p.Wo p.bo (Proofs.Mat.unflatten v r)
Instances For
The block after the out-projection: the attention site and residual, then the MLP sublayer at its site.
Equations
- Proofs.ViTTieGB.vitPostO gf ε p sA sM y u = Proofs.ViTTieGB.vitMlpSiteF gf sM ε p fun (i : Fin (Np1 * (heads * d))) => y i + Proofs.dropScalarOpt sA u i
Instances For
The attention residual's flat sum is h, flattened.
The out-projection's output cotangent is sA ⊙ cH — the loss after the out-projection;
the site's backward is the site (dropScalarOptHasVJP).
The block after LN₁: the multi-head attention layer, then vitPostO.
Equations
- Proofs.ViTTieGB.vitPostL1 gf ε p sA sM y u = Proofs.ViTTieGB.vitPostO gf ε p sA sM y (Proofs.mhsaLayer Np1 heads d p.Wq p.Wk p.Wv p.Wo p.bq p.bk p.bv p.bo (Proofs.Mat.unflatten u)).flatten
Instances For
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.
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
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).
LN₂'s output cotangent is cLn2: the MLP body's certified backward
(transformerMlp_back_flat_eq_perRowFlatPR) at sM ⊙ dy.
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
The block after fc2: the MLP site, then the residual.
Equations
- Proofs.ViTTieGB.vitPostF2 ε p sA sM y u i = (Proofs.ViTTieGB.vitHM ε p sA y).flatten i + Proofs.dropScalarOpt sM u i
Instances For
fc2's output cotangent is sM ⊙ dy.
The block forward, read after each node #
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*).
Differentiability #
Each vitPost* is differentiable (0 < ε where the MLP sublayer's LN₂ is inside).
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
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
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
The patch embedding is differentiable in its conv weight.
…in its conv bias.
…in the CLS token.
…in the position embedding.
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
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).
…and through the batched head (vitCotTowerOutB_eq_vjp).
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
The patch embedding's output — block b1's input (the tie's ib1).
Equations
- Proofs.ViTTieGB.vitPreE N w = Proofs.StableHLO.batchMap N (Proofs.patchEmbedFlat 3 224 224 16 196 192 w.Wc w.bc w.cls w.pos)
Instances For
The net after block b12 — the head.
Equations
- Proofs.ViTTieGB.vitSufB12 N ε w = Proofs.StableHLO.batchMap N (Proofs.ViTTieGB.vitHeadO ε w.γF w.βF w.Wcls w.bcls)
Instances For
The net with the patch embedding varied is the suffix after it at the varied embedding.
The net with block b1's weights varied is the suffix after it at the varied block.
The net with block b2's weights varied is the suffix after it at the varied block.
The net with block b3's weights varied is the suffix after it at the varied block.
The net with block b4's weights varied is the suffix after it at the varied block.
The net with block b5's weights varied is the suffix after it at the varied block.
The net with block b6's weights varied is the suffix after it at the varied block.
The net with block b7's weights varied is the suffix after it at the varied block.
The net with block b8's weights varied is the suffix after it at the varied block.
The net with block b9's weights varied is the suffix after it at the varied block.
The net with block b10's weights varied is the suffix after it at the varied block.
The net with block b11's weights varied is the suffix after it at the varied block.
The net with block b12's weights varied is the suffix after it at the varied block.
The net with the head varied is the head at the varied parameters.
The logits the tie's loss cotangent reads are vitNetB's. The tie spells the head as
three batched ops (batchMap_comp).
A block's forward is the depth-k fold's flat block: the spelled multi-head block
(vitBlockFwdOMHV) is blockV (vitBlockSpelledMHV_eq).
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.
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
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.
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).
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).