ViT scaling pass — the vector-[D] LayerNorm upgrade #
The representative ViT close (Items A–D) used the proof's scalar LN γ/β. The
committed production render (ViTRender.lean, the GPU-trained ViT-Tiny) is MORE
faithful: vector γ, β : [D] per LN site, decomposed as
scalar-LN(1,0) ∘ per-channel scale γ ∘ + β. This file brings the close to that
form — planning/archive/vit_close.md's top scaling-pass item:
layerNormVec— per-token normalize (scalar-LN at γ=1, β=0) then the per-channel affineγ ⊙ · + β, withHasVJPcomposed fromlayerNorm_has_vjp(at 1,0),layerScale_has_vjp(ch9), and the bias translation.transformerBlockV/vitForward2V— the vector-LN block and 2-block net, with the whole-net VJP re-composed through the same sublayer recipe as the scalar one (biPathMat_has_vjp+vjpMat_comp+rowwise_has_vjp_mat). UNCONDITIONAL except0 < ε.vitFwdGraphV+vitFwdGraphV_faithful— the graph spells each LN site with the new broadcast tokens:lnRowF(1,0) →rowScaleF γ→rowBiasF β(exactly the ViTRender decomposition); faithful at heads = 1.- Vector γ/β param bridges (
vit_render_vecln{gamma,beta}_certified) — the per-channel gradsdγ_k = Σ_tokens dy_(r,k)·x̂_r(k),dβ_k = Σ_tokens dy_(r,k)(reduce over batch+tokens, KEEP the channel axis), certified via the masked-gather Jacobian recipe.
Vector-[D] LayerNorm: per-token normalize (the scalar LN at γ=1, β=0 — pure
x̂), then the per-channel affine γ ⊙ x̂ + β. The committed ViTRender LN form.
Equations
- Proofs.layerNormVec D ε γv βv x k = γv k * Proofs.layerNormForward D ε 1 0 x k + βv k
Instances For
The bias translation's VJP — backward is the identity (dx = dy).
Equations
- Proofs.biasAdd_has_vjp βv = { backward := fun (_z dy : Proofs.Vec n) => dy, correct := ⋯ }
Instances For
Vector-LN VJP — (+β) ∘ layerScale γ ∘ LN(1,0), three proven pieces glued
by vjp_comp. Only 0 < ε.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Per-token vector-LN across a sequence — the rowwise lift.
Equations
- Proofs.layerNormVec_per_token_has_vjp_mat N D ε γv βv hε = Proofs.rowwise_has_vjp_mat (Proofs.layerNormVec_has_vjp D ε γv βv hε) ⋯
Instances For
Generic flat differentiability of a rowwise lift — each output coordinate
projects through a row-projection CLM into the per-row map (the
layerNorm_per_token_flat_diff recipe with the row map abstracted).
Attention sublayer with vector-LN: X ↦ X + MHSA(LNᵥ(X)).
Equations
- One or more equations did not get rendered due to their size.
Instances For
MLP sublayer with vector-LN: h ↦ h + MLP(LNᵥ(h)).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Vector-LN transformer block: MLPᵥ-sublayer ∘ attentionᵥ-sublayer —
the ViTRender block form.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Flat Diff of the attentionᵥ sublayer's non-trivial arm (mhsa ∘ LNᵥ).
Flat Diff of the attentionᵥ sublayer.
Attentionᵥ sublayer VJP.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Flat Diff of the MLPᵥ sublayer's non-trivial arm.
Flat Diff of the MLPᵥ sublayer.
MLPᵥ sublayer VJP.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Flat Diff of the vector-LN block.
Vector-LN block VJP — one vjpMat_comp of the two sublayer witnesses.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Distinct-param 2-block ViT forward at vector-[D] LN — the production
ViTRender LN form at the representative architecture.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Whole-net VJP for the vector-LN 2-block ViT (global) — only 0 < ε.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Public correctness theorem for vitForward2V_has_vjp — the vector-LN
2-block ViT's backward equals the pdiv-contracted Jacobian at every input.
The spelled vector-LN block at heads = 1 — each LN site decomposed as the graph
(and ViTRender) emit it: pure normalize (scalar-LN at 1,0) → per-channel scale
→ per-channel bias.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The spelled vector-LN block IS transformerBlockV at one head — the
three-stage LN decomposition collapses to layerNormVec definitionally; the
per-head plumbing collapses via mhsa_layer_one_head.
Row-broadcast scale commutation bridge.
Row-broadcast bias commutation bridge.
One spelled vector-LN block over the tokens: each LN site is
lnRowF(1,0) → rowScaleF γ → rowBiasF β (the ViTRender decomposition);
everything else as vitBlockGraph. oneStr/zeroStr name the rendered
constant-1/0 scalars the pure-normalize sites reference.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Whole vector-LN ViT forward graph: patch embed → 2 spelled vector-LN blocks (distinct params) → final vector-LN (same three-token decomposition) → CLS slice → dense head.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Vector-LN ViT forward faithfulness — the graph denotes vitForward2V at
one head. The scaling-pass peer of vitFwdGraph_faithful.
Jacobian of the rowwise vector-LN site w.r.t. γv —
∂y_(r,k)/∂γv_i = δ_(i,k)·x̂_r(k).
Jacobian of the rowwise vector-LN site w.r.t. βv — ∂y_(r,k)/∂βv_i = δ_(i,k).
The rendered vector-LN γ gradient: per-channel, the batch+token reduce
dγ_k = Σ_r dY_(r,k)·x̂_r(k) (KEEPS the channel axis — ViTRender's form).
Equations
- Proofs.vecLN_grad_gamma N D ε X dY i = ∑ r : Fin N, dY r i * Proofs.layerNormForward D ε 1 0 (X r) i
Instances For
The rendered vector-LN β gradient: dβ_k = Σ_r dY_(r,k).
Equations
- Proofs.vecLN_grad_beta N D dY i = ∑ r : Fin N, dY r i
Instances For
Vector-LN γ-gradient bridge.
Vector-LN β-gradient bridge.
Vector-LN γ output, certified. γvⁿ_k = γv_k − lr·(Σ_tokens dy·x̂)_k denotes
the certified rowwise vector-LN ∂/∂γv contraction. Covers all five LN sites of
the vector-LN representative (and is the ViTRender per-channel LN-γ reduce).
Vector-LN β output, certified.
Cot at the attention-sublayer output h, vector-LN form: dyOut + the
decomposed LN₂ input-VJP (rowScaleFlat γ2 then rowLNBackFlat at γ=1).
Equations
- Proofs.vitCotHV ε γ2 Wfc1 Wfc2 h m1 dyOut i = dyOut i + Proofs.StableHLO.rowLNBackFlat Np1 D ε 1 h (Proofs.StableHLO.rowScaleFlat Np1 D γ2 (Proofs.vitCotLn2 Wfc1 Wfc2 m1 dyOut)) i
Instances For
Cot at the SDPA output, vector-LN form.
Equations
- Proofs.vitCotAttV ε γ2 Wo Wfc1 Wfc2 h m1 dyOut = Proofs.StableHLO.rowDenseBackFlat Np1 D D Wo (Proofs.vitCotHV ε γ2 Wfc1 Wfc2 h m1 dyOut)
Instances For
Cot at the block input, vector-LN form: cotH + the decomposed LN₁
input-VJP of the three-way Q/K/V fan-in.
Equations
- Proofs.vitCotXinV ε γ1 Wq Wk Wv xin dQ dK dV cotH i = cotH i + Proofs.StableHLO.rowLNBackFlat Np1 D ε 1 xin (Proofs.StableHLO.rowScaleFlat Np1 D γ1 (Proofs.vitCotLn1 Wq Wk Wv dQ dK dV)) i
Instances For
Cot at block 2's output, vector-LN form: the decomposed final-LN input-VJP of the classifier-back row-0 scatter.
Equations
- Proofs.vitCotB2outV N D nClasses ε γF Wcls b2out dy = Proofs.StableHLO.rowLNBackFlat (N + 1) D ε 1 b2out (Proofs.StableHLO.rowScaleFlat (N + 1) D γF (Proofs.vitCotFl N D nClasses Wcls dy))
Instances For
Vector LN₂ γ, chain-certified at vitCotLn2 (the fc2-back → GELU mask →
fc1-back cotangent), with the saved attn-sublayer output h as the LN input.
Vector LN₂ β, chain-certified.
Vector LN₁ γ, chain-certified at the three-way Q/K/V fan-in vitCotLn1,
with the saved block input xin as the LN input.
Vector LN₁ β, chain-certified.
Final vector-LN γ, chain-certified at vitCotFl (classifier-back
scattered to row 0), with the saved block-2 output as the LN input.
Final vector-LN β, chain-certified.