MobileNetV2's data-parallel step at synchronised BatchNorm is the single-device step at R·N #
MobileNetV2StepTieB.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 at
that chain's cotangent.
This is its data-parallel twin, for the render MobileNetV2RenderB emits at replicas > 1: R
replicas at batch N, every one of the 52 BatchNorms synchronised, every parameter gradient
all-reduced by its mean. The capstone mnv2_net_syncTiedB says that, for every parameter the
render emits,
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 mnv2_net_tiedB at N := R·N ties to the certified gradient. The right-hand
side is the existing single-device chain at N := R·N, so the spec has not moved.
The same four steps as ResNet-34's twin #
ResNet34SyncStepTieB.lean is the template, and everything net-agnostic is imported from it
rather than restated: the replica BN link bnSyncInB and its shard lemma, the ConvWSync /
BnSync / DenseSync statements and their *_of_scaled closers, the divisor step
replicaLossCot_eq, and the homogeneity of bnInB and cInB. The inverted-residual pieces it
shares with EfficientNet-B0 — the depthwise, GAP and dense input-VJPs, the depthwise and
XLA-SAME stem weight collectives — come from DataParallel.SyncKit.
- Sharding — each replica's backward chain, handed its shard of a global cotangent, computes
the shard of the global chain. The relu6 mask is pointwise, so it shards by
rfl; the conv, depthwise, XLA-SAMEstrided depthwise, GAP and dense input-VJPs are per-example maps; every BN link isbnSyncInB. - The collectives — the mean over replicas of each replica's gradient node is
1/Rof the global node at the global cotangent. MobileNetV2 adds three kinds the ResNet-34 kit does not have: the XLA-SAMEstrided conv weight (the stem), the depthwise weight and its XLA-SAMEstrided peer (§4). - Homogeneity — the single-device chain and its gradient nodes are linear in the loss
cotangent (§1):
R ×the cotangent givesR ×every node. - The divisor — replica
r's loss cotangent isR ×its shard of the global one, and thatRcancels the collective's1/Rat every parameter.
What the DP render emits, and what is tied #
At the committed convBias := false, MobileNetV2RenderB emits 158 parameter gradients — stem 3
(sW, sg, sbt), b1 6, sixteen blocks × 9 (eW eg ebt dW dg dbt pW pg pbt), head 3 (hW,
hg, hbt), dense 2 (Wd, bd) — and the capstone ties all 158. The 52 conv, depthwise and
project BIAS nodes the single-device tie also states are not emitted at convBias := false and
are not tied here (mnv2_net_tiedB keeps them for the flag).
What is NOT claimed #
The replicas' saved forward activations enter as the shards of the single-device forward's
(batchShard r (mnv2PreB{k} (R*N) w X)); that the sync forward graph computes exactly those is
StableHLO.mobilenetv2FwdGraphSyncFull_shard, the forward half. That the replicas' inputs are
the shards of one batch is the driver's. The lowerer's all_reduce is trusted as every other
op's lowering is.
Precision is a flag on the statement. The ImageNet run the book reports trains from
mobilenetv2in_rmsdp64wxdols0eps0001bf16, 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 (mobilenetv2_adamdp, mobilenetv2in_adamdp64,
mobilenetv2in_rmsdp64, mobilenetv2in_rmsdp128) 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.
Classifier dropout is an optional site on the statement, as in MobileNetV2StepTieB: the
capstone takes cd : Option (Vec ((R * N) * 1280)), the GLOBAL mask, and replica r runs its
chain at batchShard r of it — which is what the DP render's per-replica %do input is. none
is the drop-free DP artifacts' statement exactly as it was; some M reaches
mobilenetv2in_rmsdp64wxdols0eps0001bf16's head: the site is linear in the cotangent
(dropoutOpt_smul) and commutes with the batch cut (dropoutOpt_shard, Foundation.DropSites),
so the four steps above are unchanged, and the dense collective reads the dropped activation on
every replica. The forward half with the site is StableHLO.mobilenetv2FwdGraphSyncFullDo_shard.
The block cotangents, each one line from the previous link's.
b1, replica r: the project BatchNorm's sync backward of the block-output cotangent (the
linear bottleneck has no activation after project). Feeds pW.
Equations
- One or more equations did not get rendered due to their size.
Instances For
b1, replica r: the depthwise BN's output cotangent. Feeds dg/dbt.
Equations
- One or more equations did not get rendered due to their size.
Instances For
b1, replica r: the depthwise conv's output cotangent. Feeds dW.
Equations
- One or more equations did not get rendered due to their size.
Instances For
b1, replica r: the block-INPUT cotangent, handed to the stem.
Equations
- Proofs.MobileNetV2SyncTieB.mnv2NoExpSyncCotIn R hR N h w p XIN dys r = Proofs.BackLinks.dInB N p.dW p.db (Proofs.MobileNetV2SyncTieB.mnv2NoExpSyncCotDc R hR N h w p XIN dys r)
Instances For
Stride-1 body, replica r: the project BatchNorm's sync backward of the block-output
cotangent. Feeds pW.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Stride-1 body, replica r: the depthwise BN's output cotangent. Feeds dg/dbt.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Stride-1 body, replica r: the depthwise conv's output cotangent. Feeds dW.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Stride-1 body, replica r: the expand BN's output cotangent. Feeds eg/ebt.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Stride-1 body, replica r: the expand conv's output cotangent. Feeds eW.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Stride-1 body, replica r: the body's input cotangent — the whole block-input cotangent for a
widening (b11, b17).
Equations
- Proofs.MobileNetV2SyncTieB.mnv2SyncCotInBody R hR N h w p XIN dys r = Proofs.BackLinks.cInB N p.eW p.eb (Proofs.MobileNetV2SyncTieB.mnv2SyncCotEc R hR N h w p XIN dys r)
Instances For
Skip block, replica r: the body branch plus the identity skip.
Equations
- Proofs.MobileNetV2SyncTieB.mnv2ResidSyncCotIn R hR N h w p XIN dys r i = Proofs.MobileNetV2SyncTieB.mnv2SyncCotInBody R hR N h w p XIN dys r i + dys r i
Instances For
Stride-2 block, replica r: the project BatchNorm's sync backward. Feeds pW.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Stride-2 block, replica r: the strided depthwise BN's output cotangent. Feeds dg/dbt.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Stride-2 block, replica r: the strided depthwise conv's output cotangent. Feeds dW.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Stride-2 block, replica r: the expand BN's output cotangent at the 2h x 2w grid — the
strided depthwise's input-VJP (which upsamples) masked by the expand relu6.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Stride-2 block, replica r: the expand conv's output cotangent. Feeds eW.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Stride-2 block, replica r: the block-INPUT cotangent.
Equations
- Proofs.MobileNetV2SyncTieB.mnv2StridedSyncCotIn R hR N h w p XIN dys r = Proofs.BackLinks.cInB N p.eW p.eb (Proofs.MobileNetV2SyncTieB.mnv2SSyncCotEc R hR N h w p XIN dys r)
Instances For
Stem, replica r: the stem relu6's mask of the cotangent b1 hands down. Feeds sg/sbt.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Stem, replica r: the stem BatchNorm's sync backward. Feeds sW.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Head, replica r: the head relu6's mask of the GAP backward of the classifier's input-VJP of
this replica's loss cotangent, through replica r's shard of the dropout mask when the site
is rendered (the render's per-replica %do). Feeds hg/hbt.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Head, replica r: the head BatchNorm's sync backward. Feeds hW.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Head, replica r: the cotangent handed to b17.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Stem, DP-tied — the 3x3/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
t = 1 block (b1), DP-tied — its six emitted collectives: the depthwise weight, the
depthwise BatchNorm's γ and β, the project weight, the project BatchNorm's γ and β.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Stride-1 inverted-residual block, DP-tied — its nine emitted collectives (eW eg ebt dW dg dbt pW pg pbt). One statement for all twelve stride-1 blocks, skip or widening, exactly as
mnv2Stride1TiedB is: the identity skip changes only the cotangent handed to the previous
block, never a parameter's.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Stride-2 downsampling block, DP-tied — its nine emitted collectives (b2, b4, b7,
b14): the expand half at the 2h x 2w input grid, the XLA-SAME strided depthwise.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Head, DP-tied — the 1x1 conv weight, its BatchNorm's γ and β, and the classifier's weight
and bias at the dense's input: the GAP output through the dropout site when it is rendered,
replica r reading shard r of dropoutOpt cd a (its own mask on its own pooled
activation, dropoutOpt_shard).
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 first 18 lets are
mnv2_net_tiedB's chain at N := R·N, driven by the global cotangent G; the next 18 are the
replicas' sync-BN chain, driven by the family gs; the 19 conjuncts are one per stage, every
emitted parameter collective against mnv2_net_tiedB's node at the global batch.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The synchronised-BN data-parallel MobileNetV2 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 6, sixteen blocks × 9, head 3, dense 2:
the 158 the render emits — equals the single-device batch-BN gradient node at batch R·N, at
the cotangent mnv2_net_tiedB's chain delivers there from G.
The left-hand chain is the replicas' own: sync-BN backward (bnSyncInB, a collective per
BN layer), per-example conv / depthwise / relu6 / GAP / dense links. The right-hand chain is
mnv2_net_tiedB's at N := R·N with g := G, whose nodes that capstone ties to the certified
gradient at its chain cotangent — so this and it together say every all-reduced gradient a
DP render emits is the global-batch step's gradient node. bf16 selects the conv and
depthwise weight collectives' kind on both sides — true is the *bf16 renders', read at
the identity rounding (Bf16Erasure). The optimizer update that follows
(RMSProp/AdamW) is not stated here. cd is the classifier-dropout site, the global mask
replica r runs at shard r of — none the drop-free DP artifacts, some M
mobilenetv2in_rmsdp64wxdols0eps0001bf16 (the module's Scope). mnv2_net_syncTiedB_smoothedCE
discharges the hypothesis for the label-smoothed chain the artifacts emit.
With per-replica BatchNorm the corresponding statement is false in general;
DataParallel.dpMeanGrad_ne_globalBatchGrad is a two-replica counterexample.
…and at the loss the artifacts emit. mnv2_net_syncTiedB 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 a DP render emits, at either precision, is the single-device node at batch R·N,
loss divided by R·B.