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, every node is ∂L/∂θ of the WHOLE
net vitNetB with that one parameter varied. 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), socolSlabApplygeneralises tocolSlabApplyHand its 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.pdiv_param_batchMap_through, ParamGrad): 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. 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,vitCotB2outB_eq_vjp), and eachΦidentified with the whole net at updated weights by a standalonevit_factor_*theorem.
Two nodes are stated as in the tie. The classifier bias node biasGradB is the identity on
its operand and the batch reduce is emitted text, so its statement is the sum over the batch of
the node's per-example slices. The CLS token's node carries the batch sum inside den.
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. Drop-path and the bf16 nodes
are outside this statement, as they are outside the tie. Stated at ViT-Tiny's literal dims, as the
tie is.
colSlabApply with its own map on each head's slab: output column (h, j) is column j of
g h applied to input slab h. The attention core in one of Q, K, V is one, since head
h reads the other two projections' slab h.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The Jacobian stays block-diagonal across heads — pdivMat_colIndep with a per-slab map:
zero unless the input and output slabs agree, and g h's own Jacobian on slab h if they do.
Lift per-slab VJPs to colSlabApplyH — colSlabwiseHasVJPMat with a per-slab map: the
backward runs slab h's own backward on slab h.
Equations
- One or more equations did not get rendered due to their size.
Instances For
colSlabApplyH is differentiable, flattened, when every slab's map is.
Single-head attention is differentiable in Q, flattened (K, V fixed).
…in K.
…in V (the softmax weights are a constant).
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 flat MLP sublayer h ↦ h + MLP(LN₂ h).
Equations
- Proofs.ViTTiePoCGB.vitMlpSubF ε p v = (Proofs.transformerMlpSublayerV Np1 heads d mlpDim ε p.γ2 p.β2 p.Wfc1 p.bfc1 p.Wfc2 p.bfc2 (Proofs.Mat.unflatten v)).flatten
Instances For
The flat MLP sublayer is differentiable (0 < ε, the LayerNorm).
vitCotHV is the MLP sublayer's backward in the chain's spelling (vitCotXin_eq_blockBack's
first step).
The block's forward, per example, as named Mats — blkSaves' let chain verbatim.
LN₁'s output.
Equations
- Proofs.ViTTiePoCGB.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.ViTTiePoCGB.vitQM ε p y r = Proofs.dense p.Wq p.bq (Proofs.ViTTiePoCGB.vitLn1M ε p y r)
Instances For
The K projection.
Equations
- Proofs.ViTTiePoCGB.vitKM ε p y r = Proofs.dense p.Wk p.bk (Proofs.ViTTiePoCGB.vitLn1M ε p y r)
Instances For
The V projection.
Equations
- Proofs.ViTTiePoCGB.vitVM ε p y r = Proofs.dense p.Wv p.bv (Proofs.ViTTiePoCGB.vitLn1M ε p y r)
Instances For
The attention core's output (the out-projection's input).
Equations
- Proofs.ViTTiePoCGB.vitAttM ε p y = Proofs.ViTTiePoCGB.attnCore (Proofs.ViTTiePoCGB.vitQM ε p y) (Proofs.ViTTiePoCGB.vitKM ε p y) (Proofs.ViTTiePoCGB.vitVM ε p y)
Instances For
The out-projection's output.
Equations
- Proofs.ViTTiePoCGB.vitOM ε p y r = Proofs.dense p.Wo p.bo (Proofs.ViTTiePoCGB.vitAttM ε p y r)
Instances For
The attention sublayer's output h.
Equations
- Proofs.ViTTiePoCGB.vitHM ε p y r s = Proofs.Mat.unflatten y r s + Proofs.ViTTiePoCGB.vitOM ε p y r s
Instances For
LN₂'s output.
Equations
- Proofs.ViTTiePoCGB.vitLn2M ε p y r kk = Proofs.layerScale p.γ2 (fun (s : Fin (heads * d)) => Proofs.layerNormForward (heads * d) ε 1 0 (Proofs.ViTTiePoCGB.vitHM ε p y r) s) kk + p.β2 kk
Instances For
fc1's output (pre-GELU).
Equations
- Proofs.ViTTiePoCGB.vitM1M ε p y r = Proofs.dense p.Wfc1 p.bfc1 (Proofs.ViTTiePoCGB.vitLn2M ε p y r)
Instances For
The out-projection, flat.
Equations
- Proofs.ViTTiePoCGB.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 residual, then the MLP sublayer.
Equations
- Proofs.ViTTiePoCGB.vitPostO ε p y u = Proofs.ViTTiePoCGB.vitMlpSubF ε p fun (i : Fin (Np1 * (heads * d))) => y i + u i
Instances For
The out-projection's output cotangent is cH — the loss after the out-projection.
The block after the attention core: out-projection, then vitPostO.
The block after the Q projection.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The block after the K projection.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The block after the V projection.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The Q projection's output cotangent is cQ: cAtt pulled back through the core in Q.
The K projection's output cotangent is cK.
The V projection's output cotangent is cV.
The block after LN₁: the multi-head attention layer, then vitPostO.
Equations
- Proofs.ViTTiePoCGB.vitPostL1 ε p y u = Proofs.ViTTiePoCGB.vitPostO ε p 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: 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, then the residual.
Equations
- One or more equations did not get rendered due to their size.
Instances For
LN₂'s output cotangent is cLn2: the MLP body's certified backward
(transformerMlp_back_flat_eq_perRowFlatPR).
The block after fc1: GELU, fc2, then the residual.
Equations
- One or more equations did not get rendered due to their size.
Instances For
fc1's output cotangent is cM1: through fc2 and the GELU.
The block after fc2: the residual.
Equations
- Proofs.ViTTiePoCGB.vitPostF2 ε p y u i = (Proofs.ViTTiePoCGB.vitHM ε p y).flatten i + u i
Instances For
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 #
The per-token dense is differentiable in its weight.
…in its bias.
The per-token vector LayerNorm is differentiable in γ.
…in β.
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). The classifier bias node is
the identity on its operand (the batch reduce is emitted text), so its statement is the batch
sum of the node's slices.
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: the cotangent is the tie's
batchMapAux N (p.cotIn ε) (vitBlockCotInB_eq_vjp).
…and through the batched head (vitCotB2outB_eq_vjp).
ViT-Tiny, batched: the tie's forward, stage by stage — batchMap N of the patch
embedding, each block, then of the head.
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.ViTTiePoCGB.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
Block b1's output.
Equations
- Proofs.ViTTiePoCGB.vitPreB1 N ε w = Proofs.StableHLO.batchMap N (w.b1.fwdO ε) ∘ Proofs.ViTTiePoCGB.vitPreE N w
Instances For
Block b2's output.
Equations
- Proofs.ViTTiePoCGB.vitPreB2 N ε w = Proofs.StableHLO.batchMap N (w.b2.fwdO ε) ∘ Proofs.ViTTiePoCGB.vitPreB1 N ε w
Instances For
Block b3's output.
Equations
- Proofs.ViTTiePoCGB.vitPreB3 N ε w = Proofs.StableHLO.batchMap N (w.b3.fwdO ε) ∘ Proofs.ViTTiePoCGB.vitPreB2 N ε w
Instances For
Block b4's output.
Equations
- Proofs.ViTTiePoCGB.vitPreB4 N ε w = Proofs.StableHLO.batchMap N (w.b4.fwdO ε) ∘ Proofs.ViTTiePoCGB.vitPreB3 N ε w
Instances For
Block b5's output.
Equations
- Proofs.ViTTiePoCGB.vitPreB5 N ε w = Proofs.StableHLO.batchMap N (w.b5.fwdO ε) ∘ Proofs.ViTTiePoCGB.vitPreB4 N ε w
Instances For
Block b6's output.
Equations
- Proofs.ViTTiePoCGB.vitPreB6 N ε w = Proofs.StableHLO.batchMap N (w.b6.fwdO ε) ∘ Proofs.ViTTiePoCGB.vitPreB5 N ε w
Instances For
Block b7's output.
Equations
- Proofs.ViTTiePoCGB.vitPreB7 N ε w = Proofs.StableHLO.batchMap N (w.b7.fwdO ε) ∘ Proofs.ViTTiePoCGB.vitPreB6 N ε w
Instances For
Block b8's output.
Equations
- Proofs.ViTTiePoCGB.vitPreB8 N ε w = Proofs.StableHLO.batchMap N (w.b8.fwdO ε) ∘ Proofs.ViTTiePoCGB.vitPreB7 N ε w
Instances For
Block b9's output.
Equations
- Proofs.ViTTiePoCGB.vitPreB9 N ε w = Proofs.StableHLO.batchMap N (w.b9.fwdO ε) ∘ Proofs.ViTTiePoCGB.vitPreB8 N ε w
Instances For
Block b10's output.
Equations
- Proofs.ViTTiePoCGB.vitPreB10 N ε w = Proofs.StableHLO.batchMap N (w.b10.fwdO ε) ∘ Proofs.ViTTiePoCGB.vitPreB9 N ε w
Instances For
Block b11's output.
Equations
- Proofs.ViTTiePoCGB.vitPreB11 N ε w = Proofs.StableHLO.batchMap N (w.b11.fwdO ε) ∘ Proofs.ViTTiePoCGB.vitPreB10 N ε w
Instances For
Block b12's output.
Equations
- Proofs.ViTTiePoCGB.vitPreB12 N ε w = Proofs.StableHLO.batchMap N (w.b12.fwdO ε) ∘ Proofs.ViTTiePoCGB.vitPreB11 N ε w
Instances For
The net after block b12 — the head.
Equations
- Proofs.ViTTiePoCGB.vitSufB12 N ε w = Proofs.StableHLO.batchMap N (Proofs.ViTTiePoCGB.vitHeadO ε w.γF w.βF w.Wcls w.bcls)
Instances For
The net after block b11: block b12, then the rest.
Equations
- Proofs.ViTTiePoCGB.vitSufB11 N ε w y = Proofs.ViTTiePoCGB.vitSufB12 N ε w (Proofs.StableHLO.batchMap N (w.b12.fwdO ε) y)
Instances For
The net after block b10: block b11, then the rest.
Equations
- Proofs.ViTTiePoCGB.vitSufB10 N ε w y = Proofs.ViTTiePoCGB.vitSufB11 N ε w (Proofs.StableHLO.batchMap N (w.b11.fwdO ε) y)
Instances For
The net after block b9: block b10, then the rest.
Equations
- Proofs.ViTTiePoCGB.vitSufB9 N ε w y = Proofs.ViTTiePoCGB.vitSufB10 N ε w (Proofs.StableHLO.batchMap N (w.b10.fwdO ε) y)
Instances For
The net after block b8: block b9, then the rest.
Equations
- Proofs.ViTTiePoCGB.vitSufB8 N ε w y = Proofs.ViTTiePoCGB.vitSufB9 N ε w (Proofs.StableHLO.batchMap N (w.b9.fwdO ε) y)
Instances For
The net after block b7: block b8, then the rest.
Equations
- Proofs.ViTTiePoCGB.vitSufB7 N ε w y = Proofs.ViTTiePoCGB.vitSufB8 N ε w (Proofs.StableHLO.batchMap N (w.b8.fwdO ε) y)
Instances For
The net after block b6: block b7, then the rest.
Equations
- Proofs.ViTTiePoCGB.vitSufB6 N ε w y = Proofs.ViTTiePoCGB.vitSufB7 N ε w (Proofs.StableHLO.batchMap N (w.b7.fwdO ε) y)
Instances For
The net after block b5: block b6, then the rest.
Equations
- Proofs.ViTTiePoCGB.vitSufB5 N ε w y = Proofs.ViTTiePoCGB.vitSufB6 N ε w (Proofs.StableHLO.batchMap N (w.b6.fwdO ε) y)
Instances For
The net after block b4: block b5, then the rest.
Equations
- Proofs.ViTTiePoCGB.vitSufB4 N ε w y = Proofs.ViTTiePoCGB.vitSufB5 N ε w (Proofs.StableHLO.batchMap N (w.b5.fwdO ε) y)
Instances For
The net after block b3: block b4, then the rest.
Equations
- Proofs.ViTTiePoCGB.vitSufB3 N ε w y = Proofs.ViTTiePoCGB.vitSufB4 N ε w (Proofs.StableHLO.batchMap N (w.b4.fwdO ε) y)
Instances For
The net after block b2: block b3, then the rest.
Equations
- Proofs.ViTTiePoCGB.vitSufB2 N ε w y = Proofs.ViTTiePoCGB.vitSufB3 N ε w (Proofs.StableHLO.batchMap N (w.b3.fwdO ε) y)
Instances For
The net after block b1: block b2, then the rest.
Equations
- Proofs.ViTTiePoCGB.vitSufB1 N ε w y = Proofs.ViTTiePoCGB.vitSufB2 N ε w (Proofs.StableHLO.batchMap N (w.b2.fwdO ε) y)
Instances For
The net after the patch embedding: block b1, then the rest.
Equations
- Proofs.ViTTiePoCGB.vitSufE N ε w y = Proofs.ViTTiePoCGB.vitSufB1 N ε w (Proofs.StableHLO.batchMap N (w.b1.fwdO ε) y)
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).
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).