ResNet-34's data-parallel step at SYNCHRONISED BatchNorm IS the single-device step at R·N #
ResNet34StepTieB.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 per-op
gradient at the cotangent that chain delivers. This is its data-parallel twin, for the render
ResNet34RenderB emits at replicas > 1: R replicas at batch N, every BatchNorm synchronised (bnFwdSite / bnBackSite /
bnGammaSite), every parameter gradient all-reduced by its mean. The capstone
r34_net_syncTiedB 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 r34_net_tiedB at N := R·N ties to the certified per-op gradient. So the sentence
the DP render header carries ("this step IS the single-device step at the global batch") is a
theorem, and the spec it is stated against has not moved: the right-hand side is the existing
single-device chain at N := R·N.
Four steps #
The per-op facts behind each step are in DataParallel.SyncKit; this file states ResNet-34's block
chains and ties over them.
- Sharding — each replica's backward chain, handed its shard of a global cotangent, computes
the shard of the global chain. Every non-BN link (relu mask, conv and strided-conv input-VJP,
the 3×3/s2 pool's scatter, the head) is a per-example map and commutes with sharding by
definition; the BN link is
bnSyncInB, whose shard lemmabnSyncInB_shardis P2 on the graph (DataParallel.Sync.den_bnSyncBack_allReduce) carried across themul_assocseam. - The collectives — the mean over replicas of each replica's gradient node is
1/Rof the global node at the global cotangent (the P4 lemmas ofDataParallel.SyncandDataParallel.SyncKit). The γ node is the sync one,bnSyncGammaGradB, reading the forward's all-reduced statistics — the one parameter gradient sync-BN changes. - Homogeneity — the single-device chain and its gradient nodes are linear in the loss
cotangent (
*_smul):R ×the cotangent givesR ×every node. - The divisor — replica
rdivides its loss byBand the global step byR·B, so replicar's loss cotangent isR ×its shard of the global one (replicaLossCot_eq). Steps 1–3 carry thatRdown the chain and it cancels the collective's1/R.
What is NOT claimed #
The replicas' saved forward activations enter as the shards of the single-device forward's
(batchShard r (r34Pre_k (R*N) w X)); that the sync forward graph computes exactly those is
ResNet34SyncB.resnet34FwdGraphSyncFull_shard, the forward half. That the replicas' inputs are
the shards of one batch is the driver's. The emitted artifacts run convBias := false, so the
conv-bias nodes are not emitted and are not tied here (r34_net_tiedB keeps them for the flag).
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
resnet34in_momdp64bf16, whose conv weight gradients are the bf16 kinds. Every conv weight
collective below is stated on the renderers' switch — ConvWSyncAt bf16 /
ConvStridedWSyncAt 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 that run's 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
(DataParallel.SyncBf16's …_shard_id). 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 SyncBf16 states and this file does not model, as the f32 tie does not model f32 rounding.
The block cotangents, each one line from the previous link's.
The gradient nodes.
The replica's block-INPUT cotangent: the residual fan-in, body plus identity skip.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The replica's block-INPUT cotangent: the projected-residual fan-in.
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
Stem, DP-tied — the 7×7/s2 conv weight and its BatchNorm's γ and β.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Head, DP-tied — the classifier's weight and bias, at the GAP output.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The head's block-side cotangent on a replica, at R × the shards of G, is R × the shard of
the single-device one.
The whole-net statement, named — so the capstone (cotangents bound) and its smoothed-CE
corollary (cotangents instantiated) state exactly one thing. The first 16 lets are
r34_net_tiedB's chain at N := R·N, driven by the global cotangent G; the rest are the
replicas' sync-BN chain, driven by the family gs; the 18 conjuncts are one per stage, every
emitted parameter collective against r34_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 ResNet-34 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, thirteen identity blocks × 6, three downsample blocks × 9,
dense 2: the 110 the render emits — equals the single-device batch-BN gradient node at batch
R·N, at the cotangent r34_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 / relu / pool / head links. The right-hand chain is r34_net_tiedB's
at N := R·N, whose nodes that capstone ties to the certified per-op gradient at the chain
cotangent — so this and it together say each all-reduced gradient equals the single-device
node at the global batch.
r34_net_syncTiedB_smoothedCE discharges the hypothesis for the label-smoothed chain the
artifacts emit. bf16 selects the conv weight collectives' kind on both sides — true is
resnet34in_momdp64bf16's, read at the identity rounding (Bf16Erasure).
Note: with per-replica BatchNorm the mean of the replica gradients is not the global-batch
gradient in general; DataParallel.dpMeanGrad_ne_globalBatchGrad is a two-replica,
one-parameter counterexample.
…and at the loss the artifacts emit. r34_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 the DP render emits IS the single-device node at batch R·N, loss divided by R·B.