Documentation

LeanMlir.Proofs.Nets.ResNet.ResNet50SyncB

ResNet-50's data-parallel forward at SYNCHRONISED BatchNorm — replica r IS shard r #

ResNet50FullB says the typed batch-BN graph denotes resnet50ForwardBFull N q w on one device (resnet50FwdGraphBFull_faithful). At replicas > 1 the data-parallel render makes every BatchNorm site 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 that theorem'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 (resnet50FwdGraphSyncFull R hR N q epsStr w bf16 e r)
  = batchShard R N nCls (resnet50ForwardBFull (R * N) q 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 resnet50ForwardBFull, at N := R·N. The resolution stays a binder: one statement covers q = 7 (224 px) and q = 5 (160 px), the ladder written as the single-device graph writes it, 2 * (…) nests throughout.

How it is proved #

By induction on the chain, one block at a time, exactly as resnet50FwdGraphBFull_faithful is — with the shard hypothesis ∀ r, den (e r) = batchShard R N _ X r as the invariant carried from block to block. Every piece that is not about the bottleneck is ResNet34SyncB's, imported:

What is new is the three bottleneck forms at variable shapes (N ic mid oc h w all variables), each with three sync sites (four with the projection). The two projection forms add in the RENDER's order, addVB(body, projection), where residualProj proj body adds proj + body; that costs one commutation, den_addVB_shard_comm, exactly the add_comm the single-device graph carries.

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 sync site carries the relabelling as castIdx on the AST value (ResNet-34's bnSyncSiteLA), which changes no emitted text.

What is NOT claimed here #

No stochastic depth: the graph is the drop-path-free forward, as the single-device graph is. The nodes at either precision — bf16 selects the conv kinds at every site, as ResNet34SyncB, true being the bf16 DP artifacts' graph (resnet50in160_lambaccdp4x128wxclipbcebf16, …), read at the identity rounding (Bf16Erasure). The DP artifacts run with no conv biases; the bias operand is biasName false "" c, the render's own function, and the bias fields stay ∀-quantified as in ResNet50FullB. The backward and the parameter collectives are ResNet50SyncTieB.r50_net_syncTiedB's. That the R replicas' inputs ARE the shards of one batch is the driver's, as in DataParallel.Sync. The lowerer's all_reduce is trusted as every other op's lowering is.

def Proofs.StableHLO.r50IdGraphSync (p epsStr : String) (R : ℕ) (hR : 0 < R) (N h w : ℕ) {mid oc : ℕ} (pw : R50IdW mid oc) (bf16 : Bool) (e : Fin R → SHlo (N * (oc * h * w))) :
Fin R → SHlo (N * (oc * h * w))

Identity bottleneck at sync-BN, over the replica family: relu(addVB(bn₃(conv₃(relu(bn₂(conv₂(relu(bn₁(conv₁ e))))))), e)), every BatchNorm a bnSyncSiteLA. The single-device r50IdGraphB with the three sites swapped.

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    theorem Proofs.StableHLO.r50IdGraphSync_shard (p epsStr : String) (R : ℕ) (hR : 0 < R) (N h w : ℕ) {mid oc : ℕ} (hN : 0 < N) (hh : 0 < h) (hw : 0 < w) (pw : R50IdW mid oc) (bf16 : Bool) (e : Fin R → SHlo (N * (oc * h * w))) (X : Vec (R * N * (oc * h * w))) (he : ∀ (r : Fin R), den (e r) = batchShard R N (oc * h * w) X r) (r : Fin R) :
    den (r50IdGraphSync p epsStr R hR N h w pw bf16 e r) = batchShard R N (oc * h * w) (r50IdB (R * N) h w pw X) r
    def Proofs.StableHLO.r50ProjGraphSync (p epsStr : String) (R : ℕ) (hR : 0 < R) (N h w : ℕ) {ic mid oc : ℕ} (pw : R50ProjW ic mid oc) (bf16 : Bool) (e : Fin R → SHlo (N * (ic * h * w))) :
    Fin R → SHlo (N * (oc * h * w))

    Stride-1 projection bottleneck at sync-BN — stage 1 block 0: the identity bottleneck's body plus a 1×1 conv → sync-BN skip at unchanged resolution, added in the render's order addVB(body, projection). Four sync sites.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      theorem Proofs.StableHLO.r50ProjGraphSync_shard (p epsStr : String) (R : ℕ) (hR : 0 < R) (N h w : ℕ) {ic mid oc : ℕ} (hN : 0 < N) (hh : 0 < h) (hw : 0 < w) (pw : R50ProjW ic mid oc) (bf16 : Bool) (e : Fin R → SHlo (N * (ic * h * w))) (X : Vec (R * N * (ic * h * w))) (he : ∀ (r : Fin R), den (e r) = batchShard R N (ic * h * w) X r) (r : Fin R) :
      den (r50ProjGraphSync p epsStr R hR N h w pw bf16 e r) = batchShard R N (oc * h * w) (r50ProjB (R * N) h w pw X) r
      def Proofs.StableHLO.r50DownGraphSync (p epsStr : String) (R : ℕ) (hR : 0 < R) (N h w : ℕ) {ic mid oc : ℕ} (pw : R50ProjW ic mid oc) (bf16 : Bool) (e : Fin R → SHlo (N * (ic * (2 * h) * (2 * w)))) :
      Fin R → SHlo (N * (oc * h * w))

      Strided projection bottleneck at sync-BN — stages 2/3/4 block 0. v1.5: the stride is on the 3×3 and the 1×1 skip, so conv₁ and its sync-BN (bn₁) run at the INPUT resolution 2h × 2w — that site's statistics reduce over N·(2h)·(2w) per replica. Four sync sites, added in the render's order addVB(body, projection).

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        theorem Proofs.StableHLO.r50DownGraphSync_shard (p epsStr : String) (R : ℕ) (hR : 0 < R) (N h w : ℕ) {ic mid oc : ℕ} (hN : 0 < N) (hh : 0 < h) (hw : 0 < w) (pw : R50ProjW ic mid oc) (bf16 : Bool) (e : Fin R → SHlo (N * (ic * (2 * h) * (2 * w)))) (X : Vec (R * N * (ic * (2 * h) * (2 * w)))) (he : ∀ (r : Fin R), den (e r) = batchShard R N (ic * (2 * h) * (2 * w)) X r) (r : Fin R) :
        den (r50DownGraphSync p epsStr R hR N h w pw bf16 e r) = batchShard R N (oc * h * w) (r50DownB (R * N) h w pw X) r
        def Proofs.StableHLO.resnet50FwdGraphSyncFull (R : ℕ) (hR : 0 < R) (N q : ℕ) (epsStr : String) {nCls : ℕ} (w : R50BWeights nCls) (bf16 : Bool) (e : Fin R → SHlo (N * (3 * (2 * (2 * (2 * (2 * (2 * q))))) * (2 * (2 * (2 * (2 * (2 * q)))))))) :
        Fin R → SHlo (N * nCls)

        The sync-BN data-parallel ResNet-50 forward graph, over the replica family. resnet50FwdGraphBFull with every BatchNorm a bnSyncSiteLA over all R replicas; block prefixes (s1b0 … s4b2) and collective tags are the render's. The stem and head are ResNet-34's sync graphs, whose names R50 shares.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          theorem Proofs.StableHLO.resnet50FwdGraphSyncFull_shard (R : ℕ) (hR : 0 < R) (N : ℕ) (hN : 0 < N) (q : ℕ) (hq : 0 < q) (epsStr : String) {nCls : ℕ} (w : R50BWeights nCls) (bf16 : Bool) (e : Fin R → SHlo (N * (3 * (2 * (2 * (2 * (2 * (2 * q))))) * (2 * (2 * (2 * (2 * (2 * q)))))))) (X : Vec (R * N * (3 * (2 * (2 * (2 * (2 * (2 * q))))) * (2 * (2 * (2 * (2 * (2 * q)))))))) (he : ∀ (r : Fin R), den (e r) = batchShard R N (3 * (2 * (2 * (2 * (2 * (2 * q))))) * (2 * (2 * (2 * (2 * (2 * q)))))) X r) (r : Fin R) :
          den (resnet50FwdGraphSyncFull R hR N q epsStr w bf16 e r) = batchShard R N nCls (resnet50ForwardBFull (R * N) q w X) r

          Forward-graph faithfulness 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 resnet50ForwardBFull (R * N) q w X — the committed batch-BN forward, at the global batch, at the same resolution binder q (q = 7 the 224-px net, q = 5 the 160-px one). One block lemma per block, the shard hypothesis threaded from each into the next. 0 < q is what makes every BatchNorm's reduction width nonzero.