EfficientNet-B0's data-parallel step at SYNCHRONISED BatchNorm IS the single-device step at R·N #
EfficientNetStepTieG.lean threads the label-smoothed loss cotangent down the batch-BN
backward chain on ONE device and ties every parameter gradient node to the certified gradient.
This is its data-parallel twin, for the render EfficientNetRender.Basic emits at replicas > 1: R
replicas at batch N, every one of the 49 BatchNorms synchronised (bnFwdSite / bnBackSite /
bnGammaSite), every parameter gradient all-reduced by its mean. The capstone
efficientnet_net_syncTiedG says that, for every parameter,
mean over the R replicas of replica r's gradient node, loss divided by B
= the single-device gradient node at the global batch R·N, loss divided by R·B
— the gradient node EnetTieG.efficientnet_net_tiedG at N := R·N ties to the certified
gradient. The spec it is stated against has not moved: the right-hand side is the single-device
tie's chain at N := R·N — its forward prefixes, loss cotangent and block .backwards verbatim,
and its in-block cotangents as named definitions (xCotEc, tCotDn, …) that unfold to
enetExpTiedG's lets, so each right-hand node is the single-device tie's node by rfl.
Five steps #
ResNet-34's four (ResNet34SyncStepTieB.lean), and one B0 needs because of how its single-device
tie is written.
- The block VJP is the chain (§ 0). The single-device tie threads each block's input cotangent
as a certified VJP's
.backward; a replica computes its own by the explicit chain, and only the explicit chain can be sharded.xCotIn_eq_vjpand its four peers say the two agree — theBatched.BackLinksstage graphs, read at an.operandleaf, withbnBatchLABack_faithfulturning the one non-rfllink intobnBackB. - Sharding (§§ 2, 5). Every non-BN link is per-example — conv, depthwise and strided
depthwise input-VJPs, swish and sigmoid masks, and the squeeze-excite backward: the gate
cotangent
gateCotB(seReduceB'sden) and the fused input-VJPseInB(seBackBatched's) both read one example at a time, so they shard like ResNet-34's pool backward. The BN link isbnSyncInB, P2 on the graph, read throughbnInB_eq_bnBackBonto the single-device tie'sbnBackB. - The collectives. ResNet-34's conv, dense and BatchNorm ones, plus the depthwise,
strided-depthwise and XLA-
SAMEstem conv weights fromDataParallel.SyncKit, which also holds the depthwise, GAP and dense links of steps 1 and 3 that MobileNetV2 shares. - Homogeneity (§§ 1, 4). Every link is linear in its cotangent; most are a certified VJP's
.backward, soHasVJP.backward_smulis the whole proof. - The divisor. Replica
r's loss cotangent isR ×its shard of the global one (replicaLossCot_eq), and steps 1–3 carry thatRdown to cancel each collective's1/R.
What is covered, and what is NOT claimed #
The DP render runs convBias := false, so it emits 213 parameter collectives — stem 3, b1 10,
fifteen MBConv6 blocks × 13, head 5 — and all 213 are tied. The single-device tie carries 49 more
conjuncts, one per conv bias (a bnBetaGradB at the conv-output cotangent), for the
convBias := true census; the DP artifacts do not emit them and they are not tied here.
Note: the replicas' saved forward activations enter as the shards of the single-device forward's;
that the sync forward graph computes exactly those is EfficientNetSyncB's
efficientnetFwdGraphSyncFull_shard, the forward half. Note: that the replicas' inputs are the
shards of one batch is the driver's. Note: the lowerer's all_reduce is trusted as every other
op's lowering is.
The training masks are optional sites on the statement, as in EfficientNetStepTieG: the
capstone takes the GLOBAL masks sd : Option (Fin 9 → Vec (R * N)) (stochastic depth, nine
blocks) and cd : Option (Vec ((R * N) * 1280)) (classifier dropout), and replica r runs its
chain at shard r of each — exampleShard of a per-example scale, batchShard of the
per-element mask — which is what the DP render's per-replica %dp<i> / %do inputs are. none
is the drop-free DP artifacts' statement exactly as it was; some reaches
efficientnetin_emarmsdp64dropdowxeps0001bf16's chain. Each site is linear in the cotangent and
commutes with the batch cut (dropPathOpt_smul / _shard, dropoutOpt_smul / _shard,
Foundation.DropSites), so the five steps are unchanged: a residual block's replica chain feeds
its branch the family dropPathOptFam and the single-device one dropPathOpt … dy, the invariant
passing the site by dropPathOptFam_scaled; the head's dense collective reads the dropped
activation on every replica. The forward half with the sites is
StableHLO.efficientnetFwdGraphSyncFullDrop_shard.
Precision is a flag on the statement. The ImageNet run the book reports trains from
efficientnetin_emarmsdp64dropdowxeps0001bf16, whose conv and depthwise weight gradients are the
bf16 kinds. Every conv and depthwise weight collective below is stated on the renderers' switch —
ConvWSyncAt bf16 / ConvStridedXlaWSyncAt bf16 / DepthwiseWSyncAt bf16 /
DepthwiseStridedXlaWSyncAt bf16 (Foundation.GradNodesBAt): the replicas' nodes and the
batch-R·N node are the f32 kind at false and the bf16 kind at true — and the capstone takes
bf16, so it covers the f32 DP artifacts and the *bf16 ones' step read over ℝ at the identity
rounding (Bf16Erasure), where each bf16 collective is 1/R of the batch-R·N bf16 node exactly
as at f32. At a real rounding the bf16 weight-gradient collective differs from the single-device
node by the per-replica rounding of each partial sum, which DataParallel.SyncBf16 states and
this file does not model, as the f32 tie does not model f32 rounding.
The tail's forward activations, from the depthwise conv output dc — enetExpTiedG's dn,
dr, s, e1, z, e2, se, pc, definitionally.
Equations
- Proofs.EnetSyncTieG.tS N h w t dc = Proofs.StableHLO.batchMap N (Proofs.globalAvgPoolFlat mid h w) (Proofs.EnetSyncTieG.tDr✝ N h w t dc)
Instances For
The tail's backward chain from the block-output cotangent dy — enetExpTiedG's cotPbn …
cotDc, definitionally.
Equations
- Proofs.EnetSyncTieG.tCotDc N h w t hd hp dc dy = Proofs.BackLinks.bnBackB N mid h w t.dε hd t.dγ t.dβ dc (Proofs.EnetSyncTieG.tCotDn✝ N h w t hp dc dy)
Instances For
The stride-1 expand front (b3, b5, …, and the widenings b9 / b16).
The widening block's input cotangent — the expand conv's input-VJP.
Equations
- Proofs.EnetSyncTieG.xCotIn N h w p he hd hp xin dy = Proofs.BackLinks.cInB N p.eW p.eb (Proofs.EnetSyncTieG.xCotEc✝ N h w p he hd hp xin dy)
Instances For
The residual block's input cotangent — the body's at the branch cotangent (the block-output cotangent through the drop site when it is rendered), plus the identity skip's raw one.
Equations
- Proofs.EnetSyncTieG.rCotIn N h w p s he hd hp xin dy i = Proofs.EnetSyncTieG.xCotIn N h w p he hd hp xin (Proofs.dropPathOpt N (c * h * w) s dy) i + dy i
Instances For
The strided front (b2, b4, b6, b12): expand at the input grid 2h×2w.
The strided block's input cotangent.
Equations
- Proofs.EnetSyncTieG.sCotIn N h w p he hd hp xin dy = Proofs.BackLinks.cInB N p.eW p.eb (Proofs.EnetSyncTieG.sCotEc✝ N h w p he hd hp xin dy)
Instances For
The MBConv1 front (b1): the depthwise runs on the block input.
Equations
- Proofs.EnetSyncTieG.nDc N h w p xin = Proofs.StableHLO.batchMap N (Proofs.depthwiseFlat p.dW p.db) xin
Instances For
The MBConv1 block's input cotangent — the depthwise's input-VJP.
Equations
- Proofs.EnetSyncTieG.nCotIn N h w p hd hp xin dy = Proofs.BackLinks.dInB N p.dW p.db (Proofs.EnetSyncTieG.tCotDc N h w p.toEnTail hd hp (Proofs.EnetSyncTieG.nDc N h w p xin) dy)
Instances For
The stem (enetStemTiedG's chain) and the head (enetHeadTiedG's).
The head's input cotangent — the 1×1 conv's input-VJP.
Equations
- Proofs.EnetSyncTieG.hdCotIn N h w Wh bh εh hεh γh βh Wfc cd xin g = Proofs.BackLinks.cInB N Wh bh (Proofs.EnetSyncTieG.hdCotHbn✝ N h w Wh bh εh hεh γh βh Wfc cd xin g)
Instances For
Each block's input cotangent IS its certified VJP #
The single-device tie threads the block-output cotangents by the block VJPs' .backward; the
replicas compute theirs by the explicit chain. These say the two agree, so the sharding argument
(which needs the explicit chain) lands on the single-device tie's own .backward terms.
HasVJP.backward_unique swaps the bundle-level witness for the unfolded one, a vjpComp of the
stage VJPs, which vjpComp_backward takes apart into the stage backwards.
The tail, on the replicas #
The fronts, on the replicas #
A replica's input cotangent at a widening block (b9, b16).
Equations
- Proofs.EnetSyncTieG.xsCotIn R hR N h w p XIN dys r = Proofs.BackLinks.cInB N p.eW p.eb (Proofs.EnetSyncTieG.xsCotEc✝ R hR N h w p XIN dys r)
Instances For
A replica's input cotangent at a residual block — the body's at the branch cotangents (each
replica's block-output cotangent through its shard of the site's mask, dropPathOptFam) plus
the skip's raw one.
Equations
- Proofs.EnetSyncTieG.rsCotIn R hR N h w p s XIN dys r i = Proofs.EnetSyncTieG.xsCotIn R hR N h w p XIN (Proofs.dropPathOptFam R N (c * h * w) s dys) r i + dys r i
Instances For
A replica's input cotangent at a strided block (b2, b4, b6, b12).
Equations
- Proofs.EnetSyncTieG.ssCotIn R hR N h w p XIN dys r = Proofs.BackLinks.cInB N p.eW p.eb (Proofs.EnetSyncTieG.ssCotEc✝ R hR N h w p XIN dys r)
Instances For
A replica's input cotangent at the MBConv1 block (b1).
Equations
- Proofs.EnetSyncTieG.nsCotIn R hR N h w p XIN dys r = Proofs.BackLinks.dInB N p.dW p.db (Proofs.EnetSyncTieG.tsCotDc R hR N h w p.toEnTail (Proofs.EnetSyncTieG.nDc (R * N) h w p XIN) dys r)
Instances For
A replica's input cotangent at the head.
Equations
- Proofs.EnetSyncTieG.hdsCotIn R hR N h w Wh bh εh γh βh Wfc cd XIN gs r = Proofs.BackLinks.cInB N Wh bh (Proofs.EnetSyncTieG.hdsCotHbn✝ R hR N h w Wh bh εh γh βh Wfc cd XIN gs r)
Instances For
The scaled-shard invariant across each block #
Replicas at R × the shards of the single-device block-output cotangent DY hand the next block
up R × the shards of the single-device tie's own .backward — sharding, then the explicit chain
IS the VJP (§ 0), then HasVJP.backward_smul.
The tail, DP-tied — nine collectives: the depthwise BatchNorm's γ and β, the SE reduce and excite dense layers' weight and bias, the project conv weight, the project BatchNorm's γ and β. Each equals the single-device gradient node at the global batch, at the single-device tie's chain cotangents.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A stride-1 MBConv6 block, DP-tied (the nine residual blocks and the two widenings) —
thirteen collectives: the expand conv weight, the expand BatchNorm's γ and β, the depthwise
weight, then the tail's nine. The body is the same with or without the identity skip; the skip
lives in the cotangent thread (rsCotIn).
Equations
- One or more equations did not get rendered due to their size.
Instances For
A strided MBConv6 block, DP-tied (b2, b4, b6, b12) — thirteen collectives, the expand pair
at the input grid 2h×2w and the depthwise strided.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The MBConv1 block, DP-tied (b1) — ten collectives: the depthwise weight, then the tail's nine.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The stem, DP-tied — three collectives: the 3×3/s2 XLA-SAME conv weight and its
BatchNorm's γ and β.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The head, DP-tied — five collectives: the 1×1 conv weight, its BatchNorm's γ and β, and the classifier's weight and bias, the last two at the loss cotangent itself.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The whole-net statement, named — so the capstone (cotangents bound) and its smoothed-CE
corollary (cotangents instantiated) state exactly one thing. The forward prefixes a0 … a16
and the block-output cotangents dy16 … dy0 are EnetTieG.efficientnet_net_tiedG's chain at
N := R·N, driven by the global cotangent g; e16 … e0 are the replicas' sync-BN chain,
driven by the family gs; the 18 conjuncts are one per stage.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The synchronised-BN data-parallel EfficientNet-B0 step IS the single-device step at the
global batch. R replicas at batch N, each running the render's sync-BN backward chain from
its own cotangent gs r, with gs r the R-scaled shard of a global cotangent g; every
parameter's all-reduced mean gradient — stem 3, b1 10, fifteen MBConv6 blocks × 13, head 5: the
213 the render emits at convBias := false — equals the single-device batch-BN gradient node at
batch R·N, at the cotangent the single-device tie's chain delivers there from g.
The right-hand chain is EnetTieG.efficientnet_net_tiedG's at N := R·N: verbatim for the
forward prefixes a0 … a16 and the block-output cotangents dy16 … dy0 threaded by the
certified block VJPs' .backward; by rfl for the in-block cotangents, which are this file's
named chain. That capstone ties those nodes to the certified gradient, so the two together say
the DP step's update is the certified gradient of the global-batch step. It takes hεw
(w.EpsPos), because the single-device chain does, and the global masks sd / cd of the
two optional sites (the module's Scope), none the drop-free DP artifacts and some the
dropdo one the book's run trains.
efficientnet_net_syncTiedG_smoothedCE discharges the hypothesis for the label-smoothed chain
the artifacts emit.
The left-hand chain is the replicas' own: sync-BN backward at every one of the 49
BatchNorms (bnSyncInB, a collective each), per-example conv / depthwise / squeeze-excite /
swish / head links. bf16 selects the conv and depthwise weight collectives' kind on both
sides — true is the *bf16 renders', read at the identity rounding (Bf16Erasure).
…and at the loss the artifacts emit. efficientnet_net_syncTiedG with its cotangent
hypothesis discharged by replicaLossCot_eq: each replica runs the label-smoothed softmax chain
(smoothedLossCotGraph) on its shard of the logits and targets with divisor B; the
single-device step runs it on the whole R·N batch with divisor R·B. Then every all-reduced
gradient the DP render emits, at either precision, IS the single-device node at batch R·N,
loss divided by R·B.