ResNet-34 — every parameter gradient node IS the loss's derivative in that parameter #
r34_net_tiedB says each of the 146 parameter gradient nodes denotes its layer's parameter
Jacobian contracted with the cotangent the emitted backward chain threads to it; the
*CotIn_eq_vjp lemmas say the block-input cotangents are certified VJP backwards; and
r34_lossCot_is_smoothedCE_grad identifies the loss cotangent row by row. r34_net_lossGrad
composes them: at the same cotangents, the loss of the WHOLE net with that one parameter varied is
differentiable in it and every node is its gradient (HasGradAt), for any loss L of the logits
with gradient g there; r34_net_lossGrad_smoothedCE instantiates it at the batched
label-smoothed cross-entropy (smoothedBatchLoss) the renders emit.
Scope. One replica, at either precision: every conv weight node is stated on the renderers'
switch (convWeightGradBAt bf16 id …, Foundation.GradNodesBAt), so bf16 := true is the bf16
kind resnet34in_momdp64bf16, the book's ImageNet run, emits, read over ℝ at the identity
rounding (Bf16Erasure), and bf16 := false the f32 artifacts'. Sync-BN
data parallelism is reached by composition: r34_net_syncTiedB says each all-reduced gradient is
this net's tied node at N := R·N, which this file's capstone makes the loss's gradient at the
global batch.
How. Three layers, each generic where it can be:
- Per node kind (
ParamGradNodes): a node is∂G/∂θwhenever its cotangent is the gradient ofG— the loss read at that op's output — there (HasGradAt). - Per block kind (this file, at variable widths): the loss read at the block output, pulled
back one certified stage at a time by
ParamGradNodes' pull-backs (hasGradAt_relu,hasGradAt_bnBatchLA,hasGradAt_conv, the skip'shasGradAt_addConst), so each internal activation's gradient is the chain's own cotangent. The stem goes through the argmax gather instead (r34StemGCg_hasGradAt). The bundlesr34IdLossTiedB/r34DownLossTiedB/r34StemLossTiedB/r34HeadLossTiedBstate all of a block's nodes againstΦ, the loss as a function of that block's weight record. - Per net: the loss read after each block (
r34Suf*), its gradient pulled back through the sixteen certified block VJPs (r34IdB_hasGradAt_comp,r34DownB_hasGradAt_comp), andΦidentified with the whole net at updated weights (r34_factor_*) — each a standalonerfl; inside the capstone the same identity is a kernel deep recursion at the literal widths.
Hypotheses. R34PosB (every BN ε > 0), R34LossSmoothAtB (every relu off its kink and every
stem-pool window dead, or its maximum at one position up to cells reading identical input
patches, at the real activations), and L's gradient g at the logits; the smoothed-CE corollary
discharges that from every example's target summing to one and 0 < nCls.
The stem pool's clause is stated for the parameters, not the image. Real batches have stem-pool
windows whose positive maximum sits at two positions, because two cells read identical input
patches (flat image regions). There the net has no derivative in the image, so the input VJP's
R34SmoothAtB rejects them, but the tied cells are the same function of the stem's weights, so the
loss IS differentiable in the parameters. R34LossSmoothAtB allows exactly those ties
(StemPoolTwinAt at StemConvTwin), and the stem's parameter nodes are proved through the argmax
gather they reduce to (r34StemPool_param_germ). At a tied window the render's pool backward
(select_and_scatter with a GE select) sends the cotangent to the window's first maximal cell, and
so does the denotation maxPool3s2BackB (its reindex reads windowArgmax, the first maximum).
Every pool selector (IsMaxPool3s2SelectB) gives the same four stem gradients
(r34Stem_select_grads_eq): r34_net_lossGrad_stemSelect states the stem's nodes at any of them.
The probe script scripts/probes/stem_pool_smooth_probe.py checks the stem's clauses on real
batches.
Identity block, every parameter node a loss derivative. With Gn the loss read at the
block's output and Φ the loss as a function of the block's weight record (hΦ), each of the
eight nodes r34IdTiedB ties — at the same cotangents — is ∂Φ/∂slot with that one slot
varied.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Downsample block, every parameter node a loss derivative — the twelve nodes
r34DownTiedB ties.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Two cells of example r's stem grid read identical input patches: every kernel and bias
give them the same conv output, in every channel. A flat image region does this, and at such
a pair the stem pool can tie at a positive maximum. The tie is then the same at every stem
weight (r34StemZ_twin), which is why the parameter gradient survives it.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Twinned stem cells stay equal through batch BN, at every stem parameter.
Along any family of stem parameters, the pooled stem is a fixed gather, for any pool
selector σ at the stem's post-ReLU activation (IsMaxPool3s2SelectB). The family passes
through the stem's own parameters at θ₀; there the pre-ReLU has no zero entry and every pool
window is smooth up to input-patch twins. Then the pooled stem agrees near θ₀ with the gather
along σ, whichever tied twin σ picks.
Along any family of stem parameters, the pooled stem is the argmax gather: the selector
maxPool3s2LocalReindexB names at the stem's own parameters (r34StemPool_param_germ_select).
The stem's cotangent at the BN output with the pool's cotangent routed along a selector σ:
the scatter along σ, then the stem relu's mask. At the argmax gather it is the render's
r34StemCotN (r34StemCotN_eq_at).
Equations
- One or more equations did not get rendered due to their size.
Instances For
…and at the conv output, through the BN backward.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The render's stem cotangents are the argmax gather's.
…and at the conv output.
Equations
- Proofs.ResNet34TieB.r34StemGCg σ Gn εs γs βs z = Proofs.ResNet34TieB.r34StemGNg σ Gn (Proofs.StableHLO.bnBatchLA N oc (2 * h) (2 * w) εs γs βs z)
Instances For
The gather model's gradients are the stem cotangents routed along σ. No pool
hypothesis: the gather is linear after the ReLU. The loss's gradient at the pooled stem output
transfers because at the stem's own parameters the pool IS the gather along σ (hpt).
The gather model's gradients are the render's stem cotangents (r34StemGCg_hasGradAt_at
at the argmax gather).
Stem, every parameter node a loss derivative, at given cotangents: the four nodes
r34StemTiedB ties, read at the conv-output cotangent cotC and the BN-output cotangent
cotN, Φ the loss as a function of the stem's (W, b, γ, β).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Stem, every parameter node a loss derivative — r34StemLossTiedAtB at the render's
cotangents r34StemCotC / r34StemCotN, the pool's cotangent dy.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Stem, every parameter node a loss derivative, with the pool's cotangent routed by ANY
selector σ at the stem's post-ReLU activation: each node read at the cotangents
r34StemCotCAt σ / r34StemCotNAt σ is the gradient of Φ in its slot. The loss is the
real pooled net's, not a gather model's: along each one-slot family the pooled stem IS the
gather along σ near the stem's parameters (r34StemPool_param_germ_select).
Routing a tied window's cotangent to either twin gives the same stem gradients. For any
pool selector σ at the stem's post-ReLU activation and any pool cotangent dy, the four
stem parameter nodes read at the σ-routed cotangents denote what they denote at the
render's r34StemCotC / r34StemCotN. Tied twins read identical input patches and share a
BN output, so moving a cotangent between them leaves the conv weight and bias gradients and
BN's γ/β gradients unchanged. The proof does not compute this: both node sets are
gradients of one function, the linear loss linLoss dy after the pooled stem, at the same
point (r34_stem_lossTiedB_select, twice), and a gradient is unique.
The stem bundle holds at any selector's routing. r34StemLossTiedB (the render's
cotangents, as the R34 / R50 loss-gradient capstones state it) gives the same four gradients
read at the cotangents routed along any pool selector σ (r34Stem_select_grads_eq): in
particular along the render's select_and_scatter, which picks one maximal cell per window.
Head, both parameter nodes loss derivatives — the classifier weight and bias nodes
r34HeadTiedB ties, Φ the loss as a function of (Wd, bd).
Equations
- One or more equations did not get rendered due to their size.
Instances For
The net after block e1 — the head.
Equations
- Proofs.ResNet34TieB.r34SufE1 N w = Proofs.r34HeadB N 7 7 w.Wd w.bd
Instances For
The net after block e0: block e1, then the rest.
Equations
- Proofs.ResNet34TieB.r34SufE0 N w y = Proofs.ResNet34TieB.r34SufE1 N w (Proofs.r34IdB N 7 7 w.e1 y)
Instances For
The net after block d4: block e0, then the rest.
Equations
- Proofs.ResNet34TieB.r34SufD4 N w y = Proofs.ResNet34TieB.r34SufE0 N w (Proofs.r34IdB N 7 7 w.e0 y)
Instances For
The net after block c4: block d4, then the rest.
Equations
- Proofs.ResNet34TieB.r34SufC4 N w y = Proofs.ResNet34TieB.r34SufD4 N w (Proofs.r34DownB N 7 7 w.d4 y)
Instances For
The net after block c3: block c4, then the rest.
Equations
- Proofs.ResNet34TieB.r34SufC3 N w y = Proofs.ResNet34TieB.r34SufC4 N w (Proofs.r34IdB N 14 14 w.c4 y)
Instances For
The net after block c2: block c3, then the rest.
Equations
- Proofs.ResNet34TieB.r34SufC2 N w y = Proofs.ResNet34TieB.r34SufC3 N w (Proofs.r34IdB N 14 14 w.c3 y)
Instances For
The net after block c1: block c2, then the rest.
Equations
- Proofs.ResNet34TieB.r34SufC1 N w y = Proofs.ResNet34TieB.r34SufC2 N w (Proofs.r34IdB N 14 14 w.c2 y)
Instances For
The net after block c0: block c1, then the rest.
Equations
- Proofs.ResNet34TieB.r34SufC0 N w y = Proofs.ResNet34TieB.r34SufC1 N w (Proofs.r34IdB N 14 14 w.c1 y)
Instances For
The net after block d3: block c0, then the rest.
Equations
- Proofs.ResNet34TieB.r34SufD3 N w y = Proofs.ResNet34TieB.r34SufC0 N w (Proofs.r34IdB N 14 14 w.c0 y)
Instances For
The net after block b2: block d3, then the rest.
Equations
- Proofs.ResNet34TieB.r34SufB2 N w y = Proofs.ResNet34TieB.r34SufD3 N w (Proofs.r34DownB N 14 14 w.d3 y)
Instances For
The net after block b1: block b2, then the rest.
Equations
- Proofs.ResNet34TieB.r34SufB1 N w y = Proofs.ResNet34TieB.r34SufB2 N w (Proofs.r34IdB N 28 28 w.b2 y)
Instances For
The net after block b0: block b1, then the rest.
Equations
- Proofs.ResNet34TieB.r34SufB0 N w y = Proofs.ResNet34TieB.r34SufB1 N w (Proofs.r34IdB N 28 28 w.b1 y)
Instances For
The net after block d2: block b0, then the rest.
Equations
- Proofs.ResNet34TieB.r34SufD2 N w y = Proofs.ResNet34TieB.r34SufB0 N w (Proofs.r34IdB N 28 28 w.b0 y)
Instances For
The net after block a2: block d2, then the rest.
Equations
- Proofs.ResNet34TieB.r34SufA2 N w y = Proofs.ResNet34TieB.r34SufD2 N w (Proofs.r34DownB N 28 28 w.d2 y)
Instances For
The net after block a1: block a2, then the rest.
Equations
- Proofs.ResNet34TieB.r34SufA1 N w y = Proofs.ResNet34TieB.r34SufA2 N w (Proofs.r34IdB N 56 56 w.a2 y)
Instances For
The net after block a0: block a1, then the rest.
Equations
- Proofs.ResNet34TieB.r34SufA0 N w y = Proofs.ResNet34TieB.r34SufA1 N w (Proofs.r34IdB N 56 56 w.a1 y)
Instances For
The net after the stem: block a0, then the rest.
Equations
- Proofs.ResNet34TieB.r34SufStem N w y = Proofs.ResNet34TieB.r34SufA0 N w (Proofs.r34IdB N 56 56 w.a0 y)
Instances For
The net with the stem's parameters varied is the suffix after the stem at the varied stem.
The net with block a0's weights varied is the suffix after a0 at the varied block.
The net with block a1's weights varied is the suffix after a1 at the varied block.
The net with block a2's weights varied is the suffix after a2 at the varied block.
The net with block d2's weights varied is the suffix after d2 at the varied block.
The net with block b0's weights varied is the suffix after b0 at the varied block.
The net with block b1's weights varied is the suffix after b1 at the varied block.
The net with block b2's weights varied is the suffix after b2 at the varied block.
The net with block d3's weights varied is the suffix after d3 at the varied block.
The net with block c0's weights varied is the suffix after c0 at the varied block.
The net with block c1's weights varied is the suffix after c1 at the varied block.
The net with block c2's weights varied is the suffix after c2 at the varied block.
The net with block c3's weights varied is the suffix after c3 at the varied block.
The net with block c4's weights varied is the suffix after c4 at the varied block.
The net with block d4's weights varied is the suffix after d4 at the varied block.
The net with block e0's weights varied is the suffix after e0 at the varied block.
The net with block e1's weights varied is the suffix after e1 at the varied block.
The net with the classifier varied is the head at the varied classifier.
The smooth-point bundle a loss gradient needs — R34SmoothAtB with the stem pool's clause
weakened to allow ties between cells that read identical input patches (StemPoolTwinAt at
StemConvTwin). Those ties exclude an input VJP (the net has no derivative in the image there)
but not a parameter gradient (the tied cells are the same function of the stem's weights), and
real batches have them. Every relu clause is R34SmoothAtB's.
- pool : StemPoolTwinAt N 56 56 (StemConvTwin N 56 56 64 x) (StableHLO.cbReluStridedB N w.sW w.sb w.sε w.sγ w.sβ x)
- a0 : R34IdSmoothAt N 56 56 w.a0 (r34Pre0 N w x)
- a1 : R34IdSmoothAt N 56 56 w.a1 (r34Pre1 N w x)
- a2 : R34IdSmoothAt N 56 56 w.a2 (r34Pre2 N w x)
- d2 : R34DownSmoothAt N 28 28 w.d2 (r34Pre3 N w x)
- b0 : R34IdSmoothAt N 28 28 w.b0 (r34Pre4 N w x)
- b1 : R34IdSmoothAt N 28 28 w.b1 (r34Pre5 N w x)
- b2 : R34IdSmoothAt N 28 28 w.b2 (r34Pre6 N w x)
- d3 : R34DownSmoothAt N 14 14 w.d3 (r34Pre7 N w x)
- c0 : R34IdSmoothAt N 14 14 w.c0 (r34Pre8 N w x)
- c1 : R34IdSmoothAt N 14 14 w.c1 (r34Pre9 N w x)
- c2 : R34IdSmoothAt N 14 14 w.c2 (r34Pre10 N w x)
- c3 : R34IdSmoothAt N 14 14 w.c3 (r34Pre11 N w x)
- c4 : R34IdSmoothAt N 14 14 w.c4 (r34Pre12 N w x)
- d4 : R34DownSmoothAt N 7 7 w.d4 (r34Pre13 N w x)
- e0 : R34IdSmoothAt N 7 7 w.e0 (r34Pre14 N w x)
- e1 : R34IdSmoothAt N 7 7 w.e1 (r34Pre15 N w x)
Instances For
The input-VJP bundle implies the loss-gradient one.
Pull the loss gradient back through an identity block: the certified block VJP, read at the
chain's own fan-in (r34IdCotIn_eq_vjp).
…and through a downsample block (r34DownCotIn_eq_vjp).
Every ResNet-34 parameter gradient node is the gradient of L in that parameter, for a
loss L of the logits and g the cotangent the chain starts from: the 146 nodes
r34_net_tiedB ties, each at the cotangent the emitted chain threads to it, stated against L
of resnet34ForwardBFull with that one parameter varied (a stem field, a block's weight record
w.blk := p with one slot changed, or the classifier). r34_net_lossGrad proves it whenever
g is L's gradient at the logits; r34_net_lossGrad_smoothedCE instantiates it at the loss
the artifacts ship.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Every ResNet-34 parameter gradient node is the gradient of L in that parameter, whenever
g is L's gradient at the logits.
Hypotheses: every BN ε positive (R34PosB), every relu off its kink and every stem-pool
window dead or tied only between cells reading identical input patches, at the real
activations (R34LossSmoothAtB), and hL.
One replica; bf16 selects the conv weight nodes' kind (the module's Scope).
The artifacts' loss: every node is the gradient of the batched label-smoothed
cross-entropy smoothedBatchLoss, g the emitted loss cotangent, given every example's target
summing to one and at least one class.
The stem's gradient nodes at the render's own pool routing. The stem bundle of
r34_net_lossGrad reads the four stem nodes at the cotangent the pool backward
maxPool3s2BackB denotes, which routes each window to maxPool3s2LocalReindexB's cell, the
window's first maximum, as the emitted select_and_scatter does. This corollary states the
nodes at any other routing too: for ANY pool selector σ at the stem's post-ReLU activation, the four nodes read at the cotangents routed along σ are the gradients
of L in the stem's parameters (r34StemLossTiedB.select). The tied windows real ImageNet
batches have are exactly the ones R34LossSmoothAtB's pool clause allows.
The emitted ResNet-34 step's gradient nodes ARE the loss's gradient, at one chain. For each
of the 146 parameter slots, at ONE cotangent chain (the tie's own, from the emitted
smoothed-loss cotangent g): the node denotes its layer's Jacobian against the chain cotangent
(r34_net_tiedB), and the batched smoothed loss of resnet34ForwardBFull with that one slot
varied is differentiable there with the node as its gradient (r34_net_lossGrad_smoothedCE).
The two theorems each state the chain; this one states it once, so an edit to either chain
breaks its proof.