The sync-BN data-parallel kit — sharding, homogeneity and the collectives, per op kind #
Every net's sync-BN twin (T2 forward, T3 step) says that R replicas at batch N, each running the
render's replica program over its shard, compute the single-device step at the global batch R·N.
The per-op facts that argument is assembled from are stated here once:
| what | names | namespace |
|---|---|---|
the c·h·w ↔ c·(h·w) index cast and sharding through it; non-BN nodes commute with the batch cut; the BN sync site | castIdx, laAssoc, batchShard_castIdx, den_batchOp_shard, den_relu_shard, den_addVB_shard, bnSyncSiteLA | StableHLO |
| homogeneity — each cotangent step and gradient node is linear in its cotangent | *_smul | ResNet34SyncTieB, MBConvSyncTieB |
| sharding — each input-VJP is per example, so it commutes with the batch cut; sync-BN's backward is the shard of the global one | *_shard, bnSyncInB_shard | ResNet34SyncTieB, MBConvSyncTieB |
P4 — the replica mean of a weight-gradient node is 1/R of the global node | den_allReduceMeanF_*_shard | both (and DataParallelSync for conv W / BN β) |
per-parameter DP ties at R × the shards of a global cotangent | *Sync, *Sync_of_scaled | both |
the divisor: a replica's loss cotangent is R × its shard of the global one | replicaLossCot_eq | ResNet34SyncTieB |
The namespaces are the nets that first needed each piece; the names are cited by every twin.
Sharding commutes with relabelling the per-example index. The batch axis is outside the per-example one, so relabelling within an example and cutting the batch do not interact.
A per-example node on every replica denotes the shard of the same node on the global batch.
One sync-BN forward site, at the network index, on replica r — bnFwdSite's
replicas > 1 branch: bnSyncF of this replica's operand, reading syncStats over all R
replicas' operands (the mean collective t, then Chan's variance collective t'), with the
mul_assoc relabelling on the way in and out.
Equations
- One or more equations did not get rendered due to their size.
Instances For
⭐⭐ The sync-BN site on replica r is shard r of the global-batch BatchNorm.
den_bnSyncF_allReduce (P1 on the graph), carried across the mul_assoc seam: the right-hand
side is bnBatchLA — what bnBatchF denotes — at N := R·N.
The three-term BatchNorm input-gradient is linear in dy — both its reductions are.
The 3×3/s2 pool's select_and_scatter is linear in the cotangent it scatters.
Replica r's sync-BN input cotangent, as bnBackSite's replicas > 1 branch computes it,
in the network layout: this replica's [μ ‖ σ² ‖ mean(γ·dy) ‖ mean(x̂·γ·dy)]
(bnSyncDyStatsB, reading the forward's syncStats) all-reduced, then bnSyncBack. The
replica peer of ResNet34TieB.bnInB, and like it written as the den of the emitted nodes
over .operand leaves.
Equations
- One or more equations did not get rendered due to their size.
Instances For
reassocB of a shard is the shard of the reassocB.
⭐⭐ The sync-BN backward on replica r is shard r of the global-batch BN backward —
den_bnSyncBack_allReduce (P2 on the graph) at the network index. The right-hand side is
bnInB, the single-device chain's BN link, at N := R·N.
P4 at the STRIDED conv weight — den_allReduceMeanF_convWeightGradB_shard's strided peer.
P4 at the dense weight — the head's Σ_n outer product, split by replica.
P4 at the dense bias — Σ_n cot, split by replica.
One conv weight, DP-tied: the mean over replicas of each replica's weight-gradient node (at its shard of the layer input and its own cotangent) IS the single-device node at the global batch. Tags are the render's: the collective is named for the parameter.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The strided conv weight, DP-tied.
Equations
- One or more equations did not get rendered due to their size.
Instances For
One BatchNorm's γ and β, DP-tied. Each replica's γ node is bnSyncGammaGradB, reading the
forward's all-reduced [μ ‖ σ²] (syncStats over the replicas' pre-BN activations, tagged
{tg}mu / {tg}var as bnFwdSite tags them), so its x̂ is the global batch's; the β node
reads no statistic. The right-hand sides are the single-device bnGammaGradB /
bnBetaGradB at N := R·N — BnPairTiedB's nodes.
Equations
- One or more equations did not get rendered due to their size.
Instances For
⭐ A replica family at R × the shards of COT gives the DP tie — the collective's 1/R
(§4) cancels the R homogeneity (§1) carries. The same three lines for every kind below.
rowB of a shard is the shard of the rowB — a relabelling inside each example.
⭐ The divisor step. Replica r divides its smoothed-CE cotangent by B — the render's
divConstB at the per-replica batch — and the single-device step at the global batch divides
by R·B. At the replica's shard of the logits and targets, the replica's cotangent is R ×
its shard of the global one. Nothing else about the loss differs: softmax, the label-smoothing
shift and the target are per example.
The row-wise input-VJP dX = W·dy (the classifier's, and the SE excite dense's) is linear in
dy.
A HasVJP3 backward is linear in its cotangent — HasVJP.backward_smul's three-axis peer,
read off HasVJP3.correct. The stride-1 depthwise weight gradient is stated through one.
The row-wise input-VJP is batchMap of W·, so it shards like every per-example lift.
P4 at the depthwise weight — each replica's Σ_n over its own examples, averaged, is 1/R
of the global batch's Σ_n.
P4 at the strided depthwise weight.
P4 at the XLA-SAME strided conv weight (the stem) — den_allReduceMeanF_convWeightGradB_shard's
peer. Only the certificate differs from the symmetric strided one; the batch split is the same.
A depthwise weight, DP-tied — the collective over the [c, 1, kH, kW] kernel the render
all-reduces, against the single-device node at the global batch.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The strided depthwise weight, DP-tied.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The stem's XLA-SAME strided conv weight, DP-tied. Tags are the render's: the collective is
named for the parameter, over its [oc, ic, kH, kW] shape.
Equations
- One or more equations did not get rendered due to their size.