Documentation

LeanMlir.Proofs.Nets.MobileNet.MobileNetV2WholeBackCertifiedTieB

⭐⭐ mnv2InputGradB IS the certified whole-net MobileNetV2 gradient AT BATCH BATCH-NORM #

The per-example seventeen-bottleneck tie (retired 2026-09-19 with MobileNetV2PaperWholeBackCertifiedTie.lean) closed this for the forward the retired MobileNetV2Render.lean emitted. This file closes it for the net the shipped trainers run: mobilenetv2ForwardB_full, the same [t,c,n,s] ladder at bnBatchLA, at a variable batch N. It is tier T6 of planning/archive/proofs_tier_to_paper_nets.md §4.2, alongside ResNet34BackCertifiedTieB.lean.

⭐⭐ One apex, every stage opaque #

mobilenetv2PaperPC_has_vjp_at (below; it moved here from the retired per-example tie, whose apex it was) is a twenty-one-stage chain generic in every dimension and in every stage, so the batched net instantiates it directly: stem at mnv2StemB, the seventeen bottlenecks at the batched block maps, and the head's three stages at cbrB / batchMap gap / batchMap dense. opaqueA0 … A17 are OpaquePrefix.lean's. So this file defines no prefix defs — where ResNet-34's peer had to, because its committed apex bundles the stem's pool into stem and its head into one stage.

The three pieces #

  1. mnv2StemBBack_eq_vjp_backward and cbrBBack_eq_vjp_backward — the two concrete conv-BN-relu6 endpoints, one rw of a conv leaf tie and then rfl each. ⚠ The stem's is the XLA-SAME leaf (flatConvStride2XlaBack) and the head's the plain one; that is the one convention this net and ResNet-34 do not share.
  2. mnv2InputGradB_eq_mobilenetv2B_full_vjp and mnv2InputGradB_correct — the tie, and its reading as ∑ pdiv … * dy: the chain IS the Jacobian-transpose of the twenty-one-stage composition, at every batch size.
  3. mobilenetv2ForwardB_full_eq_slots — the shape check: those twenty-one stages ARE mobilenetv2ForwardB_full, the forward mobilenetv2FwdGraphB_full_faithful (4.2b) says the typed graph denotes. Without it the tie would be a statement about variables.

Why the blocks stay opaque, measured on ResNet-34's peer. Instantiating a tie of this shape at the concrete blocks is a kernel deterministic timeout: the block witnesses are HasVJPAt at opaqueA{k-1} … x and a caller's are at mnv2PreB{k-1} N w x, which is seventeen defeq checks between seventeen-deep nested applications spelled through different definition chains. B0's file takes that step only because swish has no kink, so its witnesses are GLOBAL HasVJP and carry no point at all. The shape check is what replaces it, and it is the same answer the per-example file gave.

⚠ It stays a SMOOTH-POINT statement: relu6 is kinked on BOTH sides, so each of the 35 sites carries ≠ 0 ∧ ≠ 6. ⛔ MobileNetV2's two clauses per block are the expand relu6 and the depthwise relu6, both INSIDE the body — not ResNet-34's mid-relu and post-residual outer relu. Those are 4.2b's bundles, reused verbatim; this file adds no hypothesis of its own.

What this does NOT reach. Every gradient node in mobilenetv2in_rmsdp64 is followed by an all-reduce emitted as text outside the AST, so this is at the per-replica gradient (§4d). And it is about the INPUT gradient; the parameter gradients are MobileNetV2StepTieB.lean's tie (§4.2c).

noncomputable def Proofs.mobilenetv2PaperPC_has_vjp_at {s0 s1 s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 s12 s13 s14 s15 s16 s17 s18 s19 s20 s21 : } (stem : Vec s0Vec s1) (b1 : Vec s1Vec s2) (b2 : Vec s2Vec s3) (b3 : Vec s3Vec s4) (b4 : Vec s4Vec s5) (b5 : Vec s5Vec s6) (b6 : Vec s6Vec s7) (b7 : Vec s7Vec s8) (b8 : Vec s8Vec s9) (b9 : Vec s9Vec s10) (b10 : Vec s10Vec s11) (b11 : Vec s11Vec s12) (b12 : Vec s12Vec s13) (b13 : Vec s13Vec s14) (b14 : Vec s14Vec s15) (b15 : Vec s15Vec s16) (b16 : Vec s16Vec s17) (b17 : Vec s17Vec s18) (head : Vec s18Vec s19) (gap : Vec s19Vec s20) (dns : Vec s20Vec s21) (x : Vec s0) (hstem : HasVJPAt stem x ×' DifferentiableAt stem x) (hb1 : HasVJPAt b1 (opaqueA0 stem x) ×' DifferentiableAt b1 (opaqueA0 stem x)) (hb2 : HasVJPAt b2 (opaqueA1 stem b1 x) ×' DifferentiableAt b2 (opaqueA1 stem b1 x)) (hb3 : HasVJPAt b3 (opaqueA2 stem b1 b2 x) ×' DifferentiableAt b3 (opaqueA2 stem b1 b2 x)) (hb4 : HasVJPAt b4 (opaqueA3 stem b1 b2 b3 x) ×' DifferentiableAt b4 (opaqueA3 stem b1 b2 b3 x)) (hb5 : HasVJPAt b5 (opaqueA4 stem b1 b2 b3 b4 x) ×' DifferentiableAt b5 (opaqueA4 stem b1 b2 b3 b4 x)) (hb6 : HasVJPAt b6 (opaqueA5 stem b1 b2 b3 b4 b5 x) ×' DifferentiableAt b6 (opaqueA5 stem b1 b2 b3 b4 b5 x)) (hb7 : HasVJPAt b7 (opaqueA6 stem b1 b2 b3 b4 b5 b6 x) ×' DifferentiableAt b7 (opaqueA6 stem b1 b2 b3 b4 b5 b6 x)) (hb8 : HasVJPAt b8 (opaqueA7 stem b1 b2 b3 b4 b5 b6 b7 x) ×' DifferentiableAt b8 (opaqueA7 stem b1 b2 b3 b4 b5 b6 b7 x)) (hb9 : HasVJPAt b9 (opaqueA8 stem b1 b2 b3 b4 b5 b6 b7 b8 x) ×' DifferentiableAt b9 (opaqueA8 stem b1 b2 b3 b4 b5 b6 b7 b8 x)) (hb10 : HasVJPAt b10 (opaqueA9 stem b1 b2 b3 b4 b5 b6 b7 b8 b9 x) ×' DifferentiableAt b10 (opaqueA9 stem b1 b2 b3 b4 b5 b6 b7 b8 b9 x)) (hb11 : HasVJPAt b11 (opaqueA10 stem b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 x) ×' DifferentiableAt b11 (opaqueA10 stem b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 x)) (hb12 : HasVJPAt b12 (opaqueA11 stem b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 x) ×' DifferentiableAt b12 (opaqueA11 stem b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 x)) (hb13 : HasVJPAt b13 (opaqueA12 stem b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 x) ×' DifferentiableAt b13 (opaqueA12 stem b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 x)) (hb14 : HasVJPAt b14 (opaqueA13 stem b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 x) ×' DifferentiableAt b14 (opaqueA13 stem b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 x)) (hb15 : HasVJPAt b15 (opaqueA14 stem b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 x) ×' DifferentiableAt b15 (opaqueA14 stem b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 x)) (hb16 : HasVJPAt b16 (opaqueA15 stem b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 x) ×' DifferentiableAt b16 (opaqueA15 stem b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 x)) (hb17 : HasVJPAt b17 (opaqueA16 stem b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 x) ×' DifferentiableAt b17 (opaqueA16 stem b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 x)) (hhead : HasVJPAt head (opaqueA17 stem b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 x) ×' DifferentiableAt head (opaqueA17 stem b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 x)) (hgap : HasVJPAt gap (head (opaqueA17 stem b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 x)) ×' DifferentiableAt gap (head (opaqueA17 stem b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 x))) (hdns : HasVJPAt dns (gap (head (opaqueA17 stem b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 x))) ×' DifferentiableAt dns (gap (head (opaqueA17 stem b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 x)))) :
HasVJPAt (dns gap head b17 b16 b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 stem) x

The whole-network MobileNetV2 VJP at opaque stages (moved here 2026-09-19 from the retired per-example tie, whose apex it was). dns ∘ gap ∘ head ∘ b17 ∘ … ∘ b1 ∘ stem. Twenty vjp_comp_diff_ats and nothing else: MobileNetV2's skips live INSIDE the block maps and its strides inside the strided bodies, so there is no ChainData list and no separate downsample slot at any depth. Dimension-generic and parametric in every component.

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    theorem Proofs.mnv2StemBBack_eq_vjp_backward {N ic oc h w kH kW : } (hkH : 2 * ((kH - 1) / 2) + 1 = kH) (hkW : 2 * ((kW - 1) / 2) + 1 = kW) (Ws : Kernel4 oc ic kH kW) (bs : Vec oc) (ε : ) ( : 0 < ε) (γ β : Vec oc) (x : Vec (N * (ic * (2 * h) * (2 * w)))) (hs : MNV2StemSmoothAtB N h w Ws bs ε γ β x) :
    (StableHLO.batchMap N (flatConvStride2XlaBack Ws) (bnBatchLA_has_vjp N oc h w ε γ β).backward (StableHLO.batchMap N (flatConvStride2Xla Ws bs) x) reluMaskBack fun (i : Fin (N * (oc * h * w))) => 0 < StableHLO.bnBatchLA N oc h w ε γ β (StableHLO.batchMap N (flatConvStride2Xla Ws bs) x) i StableHLO.bnBatchLA N oc h w ε γ β (StableHLO.batchMap N (flatConvStride2Xla Ws bs) x) i < 6) = (mnv2StemB_has_vjp_at N h w Ws bs ε γ β x hs).backward

    The STEM tie. batchMap (flatConvStride2XlaBack) ∘ bnBack ∘ reluMaskBack IS mnv2StemB's certified backward at a smooth point. One rw of the odd-kernel XLA-SAME strided leaf tie, then rfl — the stage's VJP is vjp_comp_at-built so its backward is already the composition, and a convolution's backward ignores its primal argument, so the row-wise batchMap lift matches at every saved input.

    theorem Proofs.cbrBBack_eq_vjp_backward {N ic oc h w kH kW : } (hkH : 2 * ((kH - 1) / 2) + 1 = kH) (hkW : 2 * ((kW - 1) / 2) + 1 = kW) (Wh : Kernel4 oc ic kH kW) (bh : Vec oc) (ε : ) ( : 0 < ε) (γ β : Vec oc) (v : Vec (N * (ic * h * w))) (hs : ∀ (k : Fin (N * (oc * h * w))), StableHLO.bnBatchLA N oc h w ε γ β (StableHLO.batchMap N (flatConv Wh bh) v) k 0 StableHLO.bnBatchLA N oc h w ε γ β (StableHLO.batchMap N (flatConv Wh bh) v) k 6) :
    (StableHLO.batchMap N (convFlatBack Wh) (bnBatchLA_has_vjp N oc h w ε γ β).backward (StableHLO.batchMap N (flatConv Wh bh) v) reluMaskBack fun (i : Fin (N * (oc * h * w))) => 0 < StableHLO.bnBatchLA N oc h w ε γ β (StableHLO.batchMap N (flatConv Wh bh) v) i StableHLO.bnBatchLA N oc h w ε γ β (StableHLO.batchMap N (flatConv Wh bh) v) i < 6) = (StableHLO.cbrB_has_vjp_at N Wh bh ε γ β v hs).backward

    The HEAD's conv-BN-relu6 tie. batchMap (convFlatBack) ∘ bnBack ∘ reluMaskBack IS cbrB's certified backward at a smooth point — the stride-1 peer of the stem's, at the plain (non-XLA) convolution leaf. ⚠ MobileNetV2's head is NOT hypothesis-free, unlike ResNet-34's: it puts this relu6 in front of the pool, so the net's 35th kink site is here.

    theorem Proofs.mnv2InputGradB_eq_mobilenetv2B_full_vjp (N : ) {nCls : } (Ws : Kernel4 32 3 3 3) (bs : Vec 32) (εs : ) (hεs : 0 < εs) (γs βs : Vec 32) (Wh : Kernel4 1280 320 1 1) (bh : Vec 1280) (εh : ) (hεh : 0 < εh) (γh βh : Vec 1280) (Wfc : Mat 1280 nCls) (bfc : Vec nCls) (b1 : Vec (N * (32 * 112 * 112))Vec (N * (16 * 112 * 112))) (b2 : Vec (N * (16 * 112 * 112))Vec (N * (24 * 56 * 56))) (b3 : Vec (N * (24 * 56 * 56))Vec (N * (24 * 56 * 56))) (b4 : Vec (N * (24 * 56 * 56))Vec (N * (32 * 28 * 28))) (b5 b6 : Vec (N * (32 * 28 * 28))Vec (N * (32 * 28 * 28))) (b7 : Vec (N * (32 * 28 * 28))Vec (N * (64 * 14 * 14))) (b8 b9 b10 : Vec (N * (64 * 14 * 14))Vec (N * (64 * 14 * 14))) (b11 : Vec (N * (64 * 14 * 14))Vec (N * (96 * 14 * 14))) (b12 b13 : Vec (N * (96 * 14 * 14))Vec (N * (96 * 14 * 14))) (b14 : Vec (N * (96 * 14 * 14))Vec (N * (160 * 7 * 7))) (b15 b16 : Vec (N * (160 * 7 * 7))Vec (N * (160 * 7 * 7))) (b17 : Vec (N * (160 * 7 * 7))Vec (N * (320 * 7 * 7))) (x : Vec (N * (3 * (2 * 112) * (2 * 112)))) (h_stem : MNV2StemSmoothAtB N 112 112 Ws bs εs γs βs x) (hb1 : HasVJPAt b1 (opaqueA0 (mnv2StemB N 112 112 Ws bs εs γs βs) x) ×' DifferentiableAt b1 (opaqueA0 (mnv2StemB N 112 112 Ws bs εs γs βs) x)) (hb2 : HasVJPAt b2 (opaqueA1 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 x) ×' DifferentiableAt b2 (opaqueA1 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 x)) (hb3 : HasVJPAt b3 (opaqueA2 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 x) ×' DifferentiableAt b3 (opaqueA2 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 x)) (hb4 : HasVJPAt b4 (opaqueA3 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 x) ×' DifferentiableAt b4 (opaqueA3 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 x)) (hb5 : HasVJPAt b5 (opaqueA4 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 x) ×' DifferentiableAt b5 (opaqueA4 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 x)) (hb6 : HasVJPAt b6 (opaqueA5 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 x) ×' DifferentiableAt b6 (opaqueA5 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 x)) (hb7 : HasVJPAt b7 (opaqueA6 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 x) ×' DifferentiableAt b7 (opaqueA6 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 x)) (hb8 : HasVJPAt b8 (opaqueA7 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 x) ×' DifferentiableAt b8 (opaqueA7 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 x)) (hb9 : HasVJPAt b9 (opaqueA8 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 x) ×' DifferentiableAt b9 (opaqueA8 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 x)) (hb10 : HasVJPAt b10 (opaqueA9 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 x) ×' DifferentiableAt b10 (opaqueA9 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 x)) (hb11 : HasVJPAt b11 (opaqueA10 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 x) ×' DifferentiableAt b11 (opaqueA10 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 x)) (hb12 : HasVJPAt b12 (opaqueA11 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 x) ×' DifferentiableAt b12 (opaqueA11 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 x)) (hb13 : HasVJPAt b13 (opaqueA12 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 x) ×' DifferentiableAt b13 (opaqueA12 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 x)) (hb14 : HasVJPAt b14 (opaqueA13 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 x) ×' DifferentiableAt b14 (opaqueA13 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 x)) (hb15 : HasVJPAt b15 (opaqueA14 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 x) ×' DifferentiableAt b15 (opaqueA14 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 x)) (hb16 : HasVJPAt b16 (opaqueA15 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 x) ×' DifferentiableAt b16 (opaqueA15 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 x)) (hb17 : HasVJPAt b17 (opaqueA16 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 x) ×' DifferentiableAt b17 (opaqueA16 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 x)) (h_head : MNV2HeadSmoothAtB N 7 7 Wh bh εh γh βh (opaqueA17 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 x)) :
    (mnv2InputGradB N Ws Wh Wfc ((bnBatchLA_has_vjp N 32 112 112 εs hεs γs βs).backward (StableHLO.batchMap N (flatConvStride2Xla Ws bs) x)) ((bnBatchLA_has_vjp N 1280 7 7 εh hεh γh βh).backward (StableHLO.batchMap N (flatConv Wh bh) (opaqueA17 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 x))) hb1.fst.backward hb2.fst.backward hb3.fst.backward hb4.fst.backward hb5.fst.backward hb6.fst.backward hb7.fst.backward hb8.fst.backward hb9.fst.backward hb10.fst.backward hb11.fst.backward hb12.fst.backward hb13.fst.backward hb14.fst.backward hb15.fst.backward hb16.fst.backward hb17.fst.backward (fun (i : Fin (N * (32 * 112 * 112))) => 0 < StableHLO.bnBatchLA N 32 112 112 εs γs βs (StableHLO.batchMap N (flatConvStride2Xla Ws bs) x) i StableHLO.bnBatchLA N 32 112 112 εs γs βs (StableHLO.batchMap N (flatConvStride2Xla Ws bs) x) i < 6) fun (i : Fin (N * (1280 * 7 * 7))) => 0 < StableHLO.bnBatchLA N 1280 7 7 εh γh βh (StableHLO.batchMap N (flatConv Wh bh) (opaqueA17 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 x)) i StableHLO.bnBatchLA N 1280 7 7 εh γh βh (StableHLO.batchMap N (flatConv Wh bh) (opaqueA17 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 x)) i < 6) = (mobilenetv2PaperPC_has_vjp_at (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 (StableHLO.cbrB N Wh bh εh γh βh) (StableHLO.batchMap N (globalAvgPoolFlat 1280 7 7)) (StableHLO.batchMap N (dense Wfc bfc)) x mnv2StemB_has_vjp_at N 112 112 Ws bs εs hεs γs βs x h_stem, hb1 hb2 hb3 hb4 hb5 hb6 hb7 hb8 hb9 hb10 hb11 hb12 hb13 hb14 hb15 hb16 hb17 StableHLO.cbrB_has_vjp_at N Wh bh εh hεh γh βh (opaqueA17 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 x) h_head, (batchMap_has_vjp (globalAvgPoolFlat 1280 7 7) (globalAvgPoolFlat_has_vjp 1280 7 7) ).toHasVJPAt (StableHLO.cbrB N Wh bh εh γh βh (opaqueA17 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 x)), (batchMap_has_vjp (dense Wfc bfc) (dense_has_vjp Wfc bfc) ).toHasVJPAt (StableHLO.batchMap N (globalAvgPoolFlat 1280 7 7) (StableHLO.cbrB N Wh bh εh γh βh (opaqueA17 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 x))), ).backward

    ⭐⭐ mnv2InputGradB IS the certified whole-net batch-BN MobileNetV2 gradient. The committed backward chain, with its two BatchNorm and two relu6-mask slots filled by the certified per-op backwards and its seventeen bottlenecks left OPAQUE, equals the backward of mobilenetv2PaperPC_has_vjp_at at those twenty-one stages. unfold, three rws, rfl.

    theorem Proofs.mnv2InputGradB_correct (N : ) {nCls : } (Ws : Kernel4 32 3 3 3) (bs : Vec 32) (εs : ) (hεs : 0 < εs) (γs βs : Vec 32) (Wh : Kernel4 1280 320 1 1) (bh : Vec 1280) (εh : ) (hεh : 0 < εh) (γh βh : Vec 1280) (Wfc : Mat 1280 nCls) (bfc : Vec nCls) (b1 : Vec (N * (32 * 112 * 112))Vec (N * (16 * 112 * 112))) (b2 : Vec (N * (16 * 112 * 112))Vec (N * (24 * 56 * 56))) (b3 : Vec (N * (24 * 56 * 56))Vec (N * (24 * 56 * 56))) (b4 : Vec (N * (24 * 56 * 56))Vec (N * (32 * 28 * 28))) (b5 b6 : Vec (N * (32 * 28 * 28))Vec (N * (32 * 28 * 28))) (b7 : Vec (N * (32 * 28 * 28))Vec (N * (64 * 14 * 14))) (b8 b9 b10 : Vec (N * (64 * 14 * 14))Vec (N * (64 * 14 * 14))) (b11 : Vec (N * (64 * 14 * 14))Vec (N * (96 * 14 * 14))) (b12 b13 : Vec (N * (96 * 14 * 14))Vec (N * (96 * 14 * 14))) (b14 : Vec (N * (96 * 14 * 14))Vec (N * (160 * 7 * 7))) (b15 b16 : Vec (N * (160 * 7 * 7))Vec (N * (160 * 7 * 7))) (b17 : Vec (N * (160 * 7 * 7))Vec (N * (320 * 7 * 7))) (x : Vec (N * (3 * (2 * 112) * (2 * 112)))) (h_stem : MNV2StemSmoothAtB N 112 112 Ws bs εs γs βs x) (hb1 : HasVJPAt b1 (opaqueA0 (mnv2StemB N 112 112 Ws bs εs γs βs) x) ×' DifferentiableAt b1 (opaqueA0 (mnv2StemB N 112 112 Ws bs εs γs βs) x)) (hb2 : HasVJPAt b2 (opaqueA1 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 x) ×' DifferentiableAt b2 (opaqueA1 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 x)) (hb3 : HasVJPAt b3 (opaqueA2 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 x) ×' DifferentiableAt b3 (opaqueA2 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 x)) (hb4 : HasVJPAt b4 (opaqueA3 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 x) ×' DifferentiableAt b4 (opaqueA3 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 x)) (hb5 : HasVJPAt b5 (opaqueA4 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 x) ×' DifferentiableAt b5 (opaqueA4 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 x)) (hb6 : HasVJPAt b6 (opaqueA5 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 x) ×' DifferentiableAt b6 (opaqueA5 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 x)) (hb7 : HasVJPAt b7 (opaqueA6 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 x) ×' DifferentiableAt b7 (opaqueA6 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 x)) (hb8 : HasVJPAt b8 (opaqueA7 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 x) ×' DifferentiableAt b8 (opaqueA7 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 x)) (hb9 : HasVJPAt b9 (opaqueA8 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 x) ×' DifferentiableAt b9 (opaqueA8 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 x)) (hb10 : HasVJPAt b10 (opaqueA9 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 x) ×' DifferentiableAt b10 (opaqueA9 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 x)) (hb11 : HasVJPAt b11 (opaqueA10 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 x) ×' DifferentiableAt b11 (opaqueA10 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 x)) (hb12 : HasVJPAt b12 (opaqueA11 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 x) ×' DifferentiableAt b12 (opaqueA11 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 x)) (hb13 : HasVJPAt b13 (opaqueA12 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 x) ×' DifferentiableAt b13 (opaqueA12 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 x)) (hb14 : HasVJPAt b14 (opaqueA13 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 x) ×' DifferentiableAt b14 (opaqueA13 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 x)) (hb15 : HasVJPAt b15 (opaqueA14 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 x) ×' DifferentiableAt b15 (opaqueA14 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 x)) (hb16 : HasVJPAt b16 (opaqueA15 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 x) ×' DifferentiableAt b16 (opaqueA15 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 x)) (hb17 : HasVJPAt b17 (opaqueA16 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 x) ×' DifferentiableAt b17 (opaqueA16 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 x)) (h_head : MNV2HeadSmoothAtB N 7 7 Wh bh εh γh βh (opaqueA17 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 x)) (dy : Vec (N * nCls)) (i : Fin (N * (3 * (2 * 112) * (2 * 112)))) :
    mnv2InputGradB N Ws Wh Wfc ((bnBatchLA_has_vjp N 32 112 112 εs hεs γs βs).backward (StableHLO.batchMap N (flatConvStride2Xla Ws bs) x)) ((bnBatchLA_has_vjp N 1280 7 7 εh hεh γh βh).backward (StableHLO.batchMap N (flatConv Wh bh) (opaqueA17 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 x))) hb1.fst.backward hb2.fst.backward hb3.fst.backward hb4.fst.backward hb5.fst.backward hb6.fst.backward hb7.fst.backward hb8.fst.backward hb9.fst.backward hb10.fst.backward hb11.fst.backward hb12.fst.backward hb13.fst.backward hb14.fst.backward hb15.fst.backward hb16.fst.backward hb17.fst.backward (fun (i : Fin (N * (32 * 112 * 112))) => 0 < StableHLO.bnBatchLA N 32 112 112 εs γs βs (StableHLO.batchMap N (flatConvStride2Xla Ws bs) x) i StableHLO.bnBatchLA N 32 112 112 εs γs βs (StableHLO.batchMap N (flatConvStride2Xla Ws bs) x) i < 6) (fun (i : Fin (N * (1280 * 7 * 7))) => 0 < StableHLO.bnBatchLA N 1280 7 7 εh γh βh (StableHLO.batchMap N (flatConv Wh bh) (opaqueA17 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 x)) i StableHLO.bnBatchLA N 1280 7 7 εh γh βh (StableHLO.batchMap N (flatConv Wh bh) (opaqueA17 (mnv2StemB N 112 112 Ws bs εs γs βs) b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 x)) i < 6) dy i = j : Fin (N * nCls), pdiv (StableHLO.batchMap N (dense Wfc bfc) StableHLO.batchMap N (globalAvgPoolFlat 1280 7 7) StableHLO.cbrB N Wh bh εh γh βh b17 b16 b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 mnv2StemB N 112 112 Ws bs εs γs βs) x i j * dy j

    ⭐⭐ The batched chain IS the pdiv-contracted Jacobian of the twenty-one-stage net — at every batch size, every input, every loss cotangent and every input pixel. The tie above read through the apex's own .correct; mobilenetv2ForwardB_full_eq_slots below is what says those twenty-one stages are the committed forward.

    theorem Proofs.mobilenetv2ForwardB_full_eq_slots (N : ) {nCls : } (w : MNV2BWeights nCls) (x : Vec (N * (3 * (2 * 112) * (2 * 112)))) :
    mobilenetv2ForwardB_full N w x = (StableHLO.batchMap N (dense w.fcW w.fcb) StableHLO.batchMap N (globalAvgPoolFlat 1280 7 7) StableHLO.cbrB N w.hW w.hb w. w. w. mnv2ExpOnlyB N 7 7 w.b17 mnv2ResidB N 7 7 w.b16 mnv2ResidB N 7 7 w.b15 mnv2StridedB N 7 7 w.b14 mnv2ResidB N 14 14 w.b13 mnv2ResidB N 14 14 w.b12 mnv2ExpOnlyB N 14 14 w.b11 mnv2ResidB N 14 14 w.b10 mnv2ResidB N 14 14 w.b9 mnv2ResidB N 14 14 w.b8 mnv2StridedB N 14 14 w.b7 mnv2ResidB N 28 28 w.b6 mnv2ResidB N 28 28 w.b5 mnv2StridedB N 28 28 w.b4 mnv2ResidB N 56 56 w.b3 mnv2StridedB N 56 56 w.b2 mnv2NoExpB N 112 112 w.b1 mnv2StemB N 112 112 w.sW w.sb w. w. w.) x

    ⭐⭐ THE SHAPE CHECK — the twenty-one slots the tie is about ARE the committed forward. mobilenetv2ForwardB_full, regrouped into exactly the twenty-one arguments mobilenetv2PaperPC_has_vjp_at takes: the XLA-SAME stem, b1 the t = 1 bottleneck, b3/b5/b6/b8/b9/b10/b12/b13/b15/b16 the bodies under the identity skip, b2/b4/b7/b14 the stride-2 downsamplers, b11/b17 the stride-1 bodies whose channels change, and the head's three stages.

    This is the theorem that would have caught ResNet-34's wrong pool (§3.10) — the tie keeps its blocks opaque, so its subject is a chain of VARIABLES and nothing in it says which net they are. It goes through mobilenetv2ForwardB_full_eq_chain (4.2b) for the depth-17 half and then unfolds the named prefixes and the head.