ResNet-34's data-parallel forward at SYNCHRONISED BatchNorm — replica r IS shard r #
ResNet34FullB.lean (T2) says the typed batch-BN graph denotes resnet34ForwardB_full N w on
one device. ResNet34RenderB renders the data-parallel step differently since 2026-09-21: at
replicas > 1 every BatchNorm site is bnFwdSite's sync-BN composition — this replica's mean
all-reduced, then Chan's σ²_r + (μ_r − μ)² all-reduced, packed, then bnSyncF — so the
statistics each replica normalises by are the GLOBAL batch's. This file is T2's data-parallel
twin: that forward graph, stated as a family over the R replicas, denotes on replica r
exactly batchShard r of the single-device forward at the global batch R·N.
den (resnet34FwdGraphSync_full R hR N epsStr w e r)
= batchShard R N nCls (resnet34ForwardB_full (R * N) w X) r
given that each replica's input is its shard of one global batch X. ⭐ The spec does not
move: the right-hand side is the committed resnet34ForwardB_full, at N := R·N.
How it is proved #
By induction on the chain, one block at a time, exactly as T2 is — with the shard hypothesis
∀ r, den (e r) = batchShard R N _ X r as the invariant carried from block to block:
- every conv, relu, pool, GAP and dense node is a per-example lift, and sharding commutes with it
(
batchShard_batchMap, andrelupointwise) —den_batchOp_shard,den_relu_shard; - every BatchNorm site is
bnSyncSiteLA, whose shard lemmaden_bnSyncSiteLAisDataParallelSync.den_bnSyncF_allReduce(P1 on the graph) read at the network's index.
The index seam #
The conv/relu chain runs at the left-assoc index N·(c·h·w); bnSyncF and its statistics nodes
at N·(c·(h·w)), the index bnBatchTensor4 is stated at. bnBatchF hides that seam inside its
den (bnBatchLA is bnBatchTensor4 conjugated by the mul_assoc relabelling). The sync site
cannot, because its statistics subgraph is shared across replicas, so it carries the relabelling
as castIdx on the AST value — h ▸ e, the move ConvNeXtRenderB's reassocB already makes.
It changes no emitted text: skel never sees an index, and the render writes the same SSA name
at both types (bnFwdSite's zbn operand beside its zin one).
What is NOT claimed here #
⚠ The backward and the parameter collectives are the T3 half (ResNet34SyncStepTieB.lean). ⚠ That
the R replicas' inputs ARE the shards of one batch is the driver's, as in
DataParallelSync.lean. ⚠ The lowerer's all_reduce is trusted as every other op's lowering is.
Relabel an AST value's index along a proved equality. h ▸ e: the same graph, typed at
m instead of n. The emitted text does not change, because skel erases indices.
Equations
- Proofs.StableHLO.castIdx h e = h ▸ e
Instances For
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.
Identity basic block at sync-BN, over the replica family: relu(addV(bn₂(conv₂(relu(bn₁(conv₁ e)))), e)) with both BatchNorms bnSyncSiteLA.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Downsample basic block at sync-BN, over the replica family: relu(addV(bnₚ(projection), bn₂(conv₂(relu(bn₁(convStrided₁ e)))))) — projection first, as residualProj and the render
order it. Three sync sites.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Stem at sync-BN, over the replica family: 7×7/s2 conv → sync-BN → relu → 3×3/s2 max-pool.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Head over the replica family: GAP then dense — no BatchNorm, so T2's head graph per replica.
Equations
- Proofs.StableHLO.r34HeadGraphSync N h w Wd bd e r = Proofs.StableHLO.r34HeadGraphB N h w Wd bd (e r)
Instances For
The sync-BN data-parallel ResNet-34 forward graph, over the replica family. T2's
resnet34FwdGraphB_full with every BatchNorm a bnSyncSiteLA over all R replicas; block
prefixes and collective tags are ResNet34RenderB's.
Equations
- One or more equations did not get rendered due to their size.
Instances For
⭐⭐ T2 at synchronised BatchNorm: replica r's forward IS shard r of the global-batch
forward. Given that the replicas' inputs are the shards of one batch X of R·N examples,
the sync-BN graph on replica r denotes batchShard r of resnet34ForwardB_full (R * N) w X
— the committed batch-BN forward, at the global batch. One block lemma per stage, the shard
hypothesis threaded from each into the next.