EfficientNet-B0 train-step tie (fused SGD) — efficientnet_net_tied #
Every one of B0's 262 parameters' SGD ops, at the cotangent the rendered net's own backward chain
hands it: the real forward (efficientnetForwardBFull) threaded through every parameter op, the
loss cotangent composed back through all 16 MBConv blocks, the residual fan-in at each stride-1
skip and the squeeze-excite gate fan-in included. The batched, un-fused peer (tied at the
*GradB nodes) is EnetTieG.efficientnet_net_tiedG in EfficientNetStepTieG.
What B0 adds over MobileNetV2's tie #
- swish masks (
swBackB) instead of relu6's two-kinkselectMid, at every conv-bn-swish and depthwise-bn-swish stage; - the SE gate fan-in: the cotangent at an SE input is
gate ⊙ dyOut(the fusedseBackBatchedvalue), and the SE dense parameters' cotangents come fromseReduceB(the gate cotangentΣ_{h,w}(x⊙dy)) throughsigmoidBack → denseRowBack(W₂) → swishBack; - true batch-norm backward (
bnBackB, thebnBatchLAVJP), batch-coupled; - the strided depthwise back (
dStridedXlaInB);reassocBbridges the conv/swish(oc·h·w)and BN(oc·(h·w))layouts.
EfficientNetChainClose's whole-net backward is vjpComp of the per-block HasVJPs, so the
tie builds explicit chain-cotangent constructors rather than reading them off.
Contents #
- Per block type, every parameter op at the chain cotangent — each a delegation to the fold
generics
EnetFold.*:enet_exp_tied(16 params) — the stride-1 expand block: the 9 residual blocks and the two widenings b9/b16 (the parameter ops are skip-agnostic; the fan-in lives in the thread);enet_strided_tied(16) — b2/4/6/12: expand at2h×2w, strided depthwise;enet_noexp_tied(12) — b1 (t = 1: depthwise onic→ SE → project);enet_stem_tied(4) — the 3×3/s2 conv-bn-swish stem;enet_head_tied(6) — the 1×1 conv-bn-swish head and the dense, which ties at the loss cotangentg.
efficientnet_net_tied— the whole-net thread. Block inputs are the forward's prefixes (a0..a16); the per-block output cotangents (dy0..dy16) are composed top-down by the proven block VJPs (headFwdBHasVJP,mb{Exp,Resid,Strided,NoExp}WHasVJP) fromg. The residual fan-in is inmbResidW's own VJP (it includes the+ x). One*TiedAtwrapper per block type takes theB0Weightsblock bundle.
Not done: the dense head's total-loss fold (Wfc → ∂CE/∂Wfc, the batched Σ_n analogue of
StableHLO.lossWeightGrad_eq_sum); the head dense ties at g directly.
Residual stride-1 MBConv block — all 16 params tied (expand → dw → SE → project + skip) #
The centerpiece: exercises the genuinely-new content vs mnv2 — swish masks (smooth), the SE gate
fan-in (gateCotB → sigBackB → {zW₂,zb₂} → rowDenseBackFlat → swBackB → {zW₁,zb₁}), and true
batch-norm backward (bnBackB), all at the batched index N·(c·h·w). Backward from dyOut (cot at
project-BN out): project-BN-back → project-conv-back (cot at SE out) → SE backward (fused dx for the
depthwise side; un-fused gate-cot for the SE params) → depthwise swish/BN/conv backs → expand
swish/BN/conv backs. Residual (ic=oc=c): the block-input cotangent fan-in + dyOut lives in the
whole-net thread, not here (the param ops are skip-agnostic — identical to the no-skip widenings).
A conv or depthwise bias, tied, fused SGD form. The emitted bnBetaSgdB node takes the
bias step on the channel sum of the conv-output cotangent cot (network layout); the right side
states that gradient as a per-channel BatchNorm's β-Jacobian at the γ and activation (both
zero here) that β's gradient ignores.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Residual stride-1 MBConv block, tied. All 16 params (expand/project 1×1 conv W+b, depthwise
W+b, SE reduce/excite dense W₁/b₁/W₂/b₂, three true-BN γ/β) denote the certified batched Σ_n
loss-descent step at the real block forward activations + the chain cotangents driven by dyOut.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Strided downsampling MBConv block — all 16 params tied (b2/b4/b6/b12) #
Same as the expand block EXCEPT the expand stage lives at the block-input grid 2h×2w and the
depthwise is strided (depthwiseStridedXlaWeightSgdB, the expand-side cotangent cotEr upsamples h→2h
via dStridedXlaInB). No skip (spatial+channels change).
Strided downsampling MBConv block, tied. All 16 params at the real forward (expand at 2h×2w,
strided depthwise 2h→h) + the chain cotangents driven by dyOut.
Equations
- One or more equations did not get rendered due to their size.
Instances For
No-expand MBConv block (b1, t=1) — all 12 params tied (depthwise on ic → SE → project) #
NO expand conv: the depthwise runs directly on the block input (ic channels). 12 params (4 depthwise+BN,
4 SE, 4 project). The SE squeeze/excite is on ic channels (ic → r → ic).
No-expand MBConv block, tied. All 12 params at the real forward + chain cotangents.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Stem — the 3×3/s2 conv-bn-swish (4 params), feeding block 1 #
swish(bn(convStride2Xla Ws bs x)), 3→32 at 224→112, at the XLA-SAME phase the shipped stem
uses. The cotangent block 1 delivers at the stem swish output (dyStem) lifts through swish-back
- true-BN-back to the conv-out cotangent (the
convStridedXlaWeightSgdBconsumes it; NO conv-back past%x). 4 params.
Stem, tied. The 3×3/s2 conv (Ws/bs) + its true-BN (γs/βs) at the real stem forward +
the cotangent through the stem swish (no maxpool, no conv-back).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Head — the 1×1 conv-bn-swish (4 params) → GAP → dense (Wfc/bfc), + the loss cotangent #
dense(GAP(swish(bn(conv Wh bh))))) (320→1280 conv, GAP, 1280→nClasses dense), then the batched
per-row softmax-CE gradient g = rowSoftmax(logits) − onehot. The head conv params tie at the chain
cotangent (loss → dense-back → GAP-back → swish/BN-back); the dense Wfc/bfc tie at the loss cotangent
g directly.
Head, tied. The 4 head conv-bn params + the 2 dense params (Wfc/bfc) denote the certified step
at the real head forward + the loss-driven cotangent g = rowSoftmax(logits) − onehot.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Bundle-taking *TiedAt wrappers — one per block type, for the whole-net thread #
Each takes the B0Weights block bundle (MBW/MBWNoExp) + its ε-positivity + the block input + the
downstream cotangent dyOut, and delegates to the per-block-type tie.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
The whole-net thread — all 262 params tied through the REAL efficientnetForwardBFull #
The capstone: efficientnetForwardBFull's prefixes are the block inputs (a0..a16 = stem, then the
16 MBConv blocks), and the per-block output cotangents (dy0..dy16) are composed TOP-DOWN by the
proven block VJPs (headFwdBHasVJP, mb{Exp,Resid,Strided,NoExp}WHasVJP) from the loss cotangent
g = rowSoftmax(logits) − onehot. Each block's tie then holds at its real input + threaded dyOut.
The whole-net tie: the WHOLE 16-MBConv (262-param) EfficientNet-B0 train step is den-composed
forward→loss→backward, no free activations, no symbolic cotangent. The residual fan-in at the 9
identity skips is folded into mbResidW's own VJP (it includes the + x), so it is automatic.
The whole 16-MBConv EfficientNet-B0 train step, tied. Threading the real batched (true-BN + SE)
forward efficientnetForwardBFull and the loss-driven backward cotangent chain (swish masks, SE
gate fan-in, true-BN backs, the residual fan-in folded into the block VJPs), the stem, all 16
MBConv blocks, the conv-bn-swish head, and the dense head all denote the certified batched Σ_n
loss-descent step.