⭐⭐ vitInputGradK IS the certified whole-net ViT-Tiny gradient #
The ViT peer of r34InputGrad_eq_resnet34_vjp, mnv2PaperInputGrad_eq_mobilenetv2Paper_vjp,
convnextInputGrad_eq_convNextForwardTCh_vjp and
efficientnetInputGradB_full_eq_efficientnetForwardB_full_vjp — tier T6 of
planning/archive/proofs_tier_to_paper_nets.md, at ViT-Tiny's shipped configuration: depth 12 with
distinct per-block parameters, D = 192 = 3 × 64, 197 tokens, vector-[D] LayerNorm.
Four things assemble it, and only the second is a proof rather than an enumeration:
- The three endpoint leaf ties. The classifier head's backward is the transposed dense
(
dense Wclsᵀ 0) then the CLS scatter (vitHeadBack_eq_classifier_vjp); the final LayerNorm's isrowLNVecFlatBackat the tower's output (rowLNVecFlat_has_vjp_backward_eq, ConvNeXt's, sincevitForwardKV's final-LN witness IShasVJPMat_to_hasVJP (layerNormVec_per_token_has_vjp_mat …)); and the patch embed's ispatchEmbed_input_grad_formula, whichpatchEmbed_flat_has_vjpgives as its backward definitionally — so that endpoint isrfland needs no lemma at all. - ⭐ The depth-
ktower fold (vitTowerBackK_eq_vjp), the one real proof.vitBodyKVFlat'sHasVJPis built head-first (block0runs first), so the backward composes the block backwards in the OPPOSITE order, each at its own saved activation, and the tail's saved input is block0's forward OUTPUT.cnxStageChKBack_eq_vjp's induction verbatim: one rewrite of the block tie and one of the inductive hypothesis. - The apex witness.
vitApexVJPnames the committedvitForwardKV_has_vjp; its.backwardreduces through the fourvjp_compfactors byrfl. - A shape check.
vitForwardKV_eq_chainsays the four-factor composition the apex is stated at IS the committedvitForwardKV, byrfl.
⭐ The result is UNCONDITIONAL except 0 < ε, at EVERY input and every cotangent. ViT has no kink
anywhere — softmax, GELU and LayerNorm are all smooth — so like ConvNeXt-T and unlike ResNet-34 /
MobileNetV2 / EfficientNet-B0 this is a HasVJP and not a smooth-point HasVJPAt, and it carries
no operating point, no batch size and no smoothness witness. 3-axiom-clean.
The classifier-head backward tie. clsScatter ∘ dense Wclsᵀ 0 — the head dense's free
input-VJP, then the CLS-slice scatter — IS (classifier_flat_has_vjp …).backward x, at every
saved input (the head is linear, so the backward does not depend on x).
The final-LayerNorm backward tie. vitForwardKV's final-LN witness is
hasVJPMat_to_hasVJP (layerNormVec_per_token_has_vjp_mat …), which is exactly
rowLNVecFlat_has_vjp — so ConvNeXt's rowLNVecFlat_has_vjp_backward_eq is this tie, read
at the ViT token layout.
⭐⭐ THE TOWER-FOLD TIE. The hand-composed depth-k encoder-tower backward IS
(vitBodyKVFlat_has_vjp k ps).backward. Induction on k: the base is identity_has_vjp's
fun _ dy => dy, and the step is one rewrite of the inductive hypothesis at the shifted saved
activation (blockVFlat (ps 0) v, block 0's OUTPUT) and one of the block tie at v.
The whole-net witness the apex is stated at — the committed vitForwardKV_has_vjp, whose
.backward is the four-factor vjp_comp chain by rfl.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The four-factor composition the apex is stated at IS the committed vitForwardKV. The shape
check ResNet34BackCertifiedTie.lean lacked and ConvNeXt wrote before anyone needed it.
vitInputGradK IS the apex witness's backward. Four rewrites, one per factor: the
tower fold, the final-LN tie, the head tie, and the patch-embed endpoint (rfl).
⭐⭐ THE APEX. vitInputGradK — the whole-net ViT-Tiny input gradient, every slot pinned
to the certified per-op backward at its own saved activation — IS
(vitForwardKV_has_vjp …).backward x, the committed depth-12 witness — vitApexVJP by name.
The apex, read as the Jacobian. vitInputGradK is the pdiv-contracted Jacobian
transpose of the committed vitForwardKV, at EVERY image and EVERY cotangent — the ViT peer
of efficientnetInputGradB_full_correct. Only 0 < ε.
⭐⭐ ViT-Tiny's whole-net backward tie — tier T6 at the paper net.
vitInputGradK_eq_vitForwardKV_vjp instantiated at the exact MainVitTrain.lean vitTiny
spec: a 3×224×224 image, 16×16 patches (196 patch tokens + CLS), D = 192 = 3 heads × 64,
MLP dim 768, 12 transformer blocks with DISTINCT per-block parameters, vector-[D]
LayerNorm at all 25 sites, and Imagenette's 10 classes.
So the hand-written input-gradient chain IS the certified gradient of the committed depth-12
forward, at every image.
The backward peer of vitTiny_has_vjp_correct, and ViT's entry in the T6 column beside
convnextInputGrad_eq_convNextForwardTCh_vjp and
efficientnetInputGradB_full_eq_efficientnetForwardB_full_vjp.