Documentation

LeanMlir.Proofs.Nets.ConvNeXt.ConvNeXtFoldG

ConvNeXt-T un-fused gradient nodes at the per-example index #

Three per-example lemmas that ConvNeXtFoldGB lifts over the batch: the per-channel layer-scale γ gradient (layerScaleChGammaGrad_den) and the channel-LN γ/β gradients (chanLnGammaGrad_den, chanLnBetaGrad_den). Each is den-faithful at the RAW gradient node, the one every optimizer tail (AdamW, the clipped and weight-decayed variants, SGD) consumes. The fusion is rfl (StableHLO.lean's *Sgd_eq_grad family), so each proof is its fused peer's in ConvNeXtFold with the θ − lr· wrapper dropped. Every Adam artifact of this net renders from the batched chain; its fold is ConvNeXtFoldGB.

theorem Proofs.CnxPoCG.layerScaleChGammaGrad_den {c h w : } (xN cotN : String) (x : Vec (c * h * w)) (γ : Vec c) (dy : Vec (c * h * w)) (cc : Fin c) :
StableHLO.den (StableHLO.SHlo.layerScaleChGammaGrad xN x (StableHLO.SHlo.operand cotN dy)) cc = j : Fin (c * h * w), pdiv (fun (γ' : Vec c) => layerScale (fun (k : Fin (c * h * w)) => γ' (StableHLO.chanIdx c h w k)) x) γ cc j * dy j

Per-channel layer-scale γ GRADIENT denotes the certified gradient. The emitted lsGradCh reduce dγ_c = Σ_{k : chanIdx k = c} x_k·dy_k IS the certified Jacobian of layerScaleChF as a function of γ : Vec c, contracted with the cotangent.

theorem Proofs.CnxPoCG.chanLnGammaGrad_den {c h w : } (xN epsStr cotN : String) (ε : ) (β : Vec c) (x : Vec (c * h * w)) (γ : Vec c) (cot : Vec (c * h * w)) (k : Fin c) :
StableHLO.den (StableHLO.SHlo.veclnGammaGrad xN epsStr ε (chanLNRows c h w x) (StableHLO.SHlo.operand cotN (chanLNRows c h w cot))) k = j : Fin (c * h * w), pdiv (fun (γ' : Vec c) => chanLNTensor3 c h w ε γ' β x) γ k j * cot j

Channel-LN γ GRADIENT denotes the certified γ gradient. All 22 spatial sites (1 stem + 18 block + 3 downsample).

theorem Proofs.CnxPoCG.chanLnBetaGrad_den {c h w : } (cotN : String) (ε : ) (γ : Vec c) (x : Vec (c * h * w)) (β : Vec c) (cot : Vec (c * h * w)) (k : Fin c) :
StableHLO.den (StableHLO.SHlo.operand cotN (chanLNRows c h w cot)).rowDenseBiasGrad k = j : Fin (c * h * w), pdiv (fun (β' : Vec c) => chanLNTensor3 c h w ε γ β' x) β k j * cot j

Channel-LN β GRADIENT denotes the certified β gradient. The β gradient is the plain row reduce, so the render uses the same rowDenseBiasGrad op ViT's LN β does.