⭐⭐ vitInputGradKB IS the certified whole-net ViT-Tiny gradient AT A BATCH #
ViTWholeBackCertifiedTie.lean closed T6 for ONE image: vitInputGradK, the reverse of
vitForwardKV over that image's N + 1 tokens, IS the certified gradient. Every shipped ViT
artifact runs a batch — vit_adam_train_step and the vitin_* family at 128 or 512 per
device — and its batched T3 tie (ViTStepTieGB.lean) states every activation as
StableHLO.batchMap B of the per-example prefix and every cotangent as batchMapAux B of the
per-example chain, because no ViT op couples examples. This file closes T6 at that index: the
five-stage batched chain vitInputGradKB (ViTBackChains.lean) IS the certified gradient of
batchMap B vitForwardKV at every batch x, for every B. ViT was the one net without a
batched whole-net tie; with this the *InputGradB_eq_*_vjp family covers all seven nets.
Nothing here is new mathematics, and it is lighter than ResNet-34's batched tie because ViT is
smooth everywhere: every stage has a GLOBAL HasVJP, so its batched witness is
batchMap_has_vjp_at (4.1c's field-by-field lift, BatchMapVJPAt.lean) over
HasVJP.toHasVJPAt at each row — no smooth-point hypothesis anywhere, only 0 < ε.
batchMap_comp(BatchMapVJPAt.lean, shared with ConvNeXt's batched tie) —batchMap B (g ∘ f) = batchMap B g ∘ batchMap B f, the lemma the shape check needs and the reason the chain saves its activations stage by stage: the two spellings agree only up tofinProdFinEquiv.symm_apply_apply, which is notrfl.- The batched leaf ties. The patch-embed stage needs none (its backward is
rfl); the other three arefunextto one example, one rewrite of the per-example tie at that example's row (vitTowerBackK_eq_vjp,vitFinalLNBack_eq_vjp,vitHeadBack_eq_classifier_vjp), thenrfl—batchMapAux's slice and the lift's.backwardrow are the same term, as r34's pool endpoint found. vitKVB_has_vjp_at— the four-stage apex, threevjp_comp_diff_ats over the batched stage witnesses — andvitInputGradKB_eq_vitKVB_vjp, the tie: three leaf rewrites, thenrfl.vitForwardKVB_eq_chain— the shape check: the four batched stages compose tobatchMap B vitForwardKV, byvitForwardKV_eq_chainand threebatchMap_comps — andvitInputGradKB_eq_batchMap_vitForwardKV_vjp, the tie carried to the committed GLOBAL witnessbatchMap_has_vjp (vitForwardKV …)throughHasVJPAt.backward_unique_of_eq(BatchMapVJPAt.lean;batchMap_has_vjpis▸-transported, so its.backwarddoes not reduce; uniqueness is the escape every whole-net tie in this repo takes), plus the∑ pdivreading.vitTinyInputGradB_eq_vitTiny_vjp— the capstone at ViT-Tiny's literal dims,Ba binder.
The batched patch-embed witness at x: batchMap_has_vjp_at over the global per-example
witness at each row.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The batched tower witness at v.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The batched final-LayerNorm witness at v.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The batched classifier-head witness at v.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The batched tower tie. batchMapAux B of the depth-k tower backward at the batched
saved input IS the lift's backward: one example, one rewrite of vitTowerBackK_eq_vjp at
that example's row, rfl.
The batched head tie. batchMap B of the CLS scatter after batchMap B of the free dense
backward IS the lift's backward at any saved v (the head is linear): fuse the two lifts by
batchMap_comp, then vitHeadBack_eq_classifier_vjp at one example's row.
The batched whole-net witness, four batched stages composed by vjp_comp_diff_at, each
at the batched saved activation the chain uses (vitSavedPEB, vitSavedBodyB).
Equations
- One or more equations did not get rendered due to their size.
Instances For
⭐⭐ THE BATCHED TIE. vitInputGradKB — the five-stage batched chain, every slot a lift of
the per-example backward at the batched saved activation — IS the batched apex's backward.
Three leaf rewrites (tower, final LN, head), then rfl: the patch-embed leaf is definitional.
The shape check. The four batched stages the apex is stated at compose to
batchMap B vitForwardKV, the committed per-example forward lifted whole: the per-example
shape check vitForwardKV_eq_chain and three batchMap_comps.
vitForwardKV is differentiable everywhere (only 0 < ε): the four stage lemmas composed.
⭐⭐ THE APEX, at the committed batched witness. vitInputGradKB IS
(batchMap_has_vjp (vitForwardKV …) …).backward x — the certified gradient of the per-example
net lifted whole over B examples. Carried from the chain-shaped apex by
HasVJPAt.backward_unique_of_eq along the shape check.
The batched apex, read as the Jacobian. vitInputGradKB is the pdiv-contracted Jacobian
transpose of batchMap B vitForwardKV, at EVERY batch and EVERY cotangent. Only 0 < ε.
⭐⭐ ViT-Tiny's BATCHED whole-net backward tie — tier T6 at the paper net and the shipped
index. vitInputGradKB_eq_batchMap_vitForwardKV_vjp at the exact vitTiny spec
(3×224×224, 16×16 patches, 196 + CLS tokens, D = 192 = 3 × 64, MLP 768, 12 distinct
blocks, vector-[D] LayerNorm, 10 classes), at a variable batch B — 128 or 512 per device
in the shipped vitin_* artifacts, and neither number appears here. ViT's entry in the batched
T6 column beside r34InputGradB_eq_r34B_full_vjp and mnv2InputGradB_eq_mobilenetv2B_full_vjp.