StableHLO — the emitted-graph AST and its ℝ semantics #
The verified renderers build the computation in each verified_mlir/ artifact from pretty of
terms of one typed AST, SHlo, and add hand-written text around it: the function signature and
constants, the report-only %loss block, the %bc1/%bc2 passthroughs of the AdamW steps, and
the carve-outs each renderer's docstring names (for ConvNeXt: the GAP-backward block, the %dy
divide, and in the SGD step the stem weight's update). This file holds that AST and its semantic
reading; the syntactic one, pretty, is in
StableHLO.Pretty.
- Semantic —
den : SHlo n → Vec n, the ℝ denotation in StableHLO-spec terms (explicit contraction / reduce / divide). The*_faithful/*_dentheorems sayden (graph) = <proven math>; every train-step tie inNets/is stated aboutden. - Syntactic (
StableHLO.Pretty) —prettyrenders the same term to StableHLO text. SSA names are annotationsdenignores.prettyis trusted: the proofs are about the termdenreads, not about the text.
Layout, in file order:
| part | where |
|---|---|
BatchableOp — the per-example ops SHlo.batchOp lifts by batchMap | top |
inductive SHlo (≈215 constructors; suffixes: F forward/optimizer op, B/Batched batched index, Grad/GradB raw gradient node, Sgd/SgdB fused θ − lr·g, Bf16/F8 reduced precision) | § StableHLO-subset AST |
den, the denStep/denStepApp dsimprocs, the per-op *_faithful lemmas | after the AST |
| chapter graphs and their faithfulness (linear, MLP, CNN, CIFAR) and the optimizer/clip ops | § Chapter 1–3, § Param gradients, § Global-norm clipping |
Trusted residue. den is over ℝ, so the ℝ→Float32 gap stays trusted. Everything here closes
under [propext, Classical.choice, Quot.sound]
(tests/AuditAxioms.lean).
A batch-separable EfficientNet op, shape-indexed by per-example in/out
length. The descriptor carried by SHlo.batchOp; its denOp is the proven
per-example forward, lifted by batchMap.
On the pointwise ops. The descriptor-less swish/sigmoid/relu/addV tokens do
denote block-diagonally at the batched index N·(c·h·w), but they do not EMIT
correctly there. SHlo.swishF's token carries only the SHlo index n and emits
tensor<B×n>, i.e. it reads the index as a PER-EXAMPLE width; a descriptor-less
pointwise node at the batched index N·s therefore emits tensor<B×(N·s)>,
which does not even typecheck against its own operand. Giving the pointwise ops
descriptors separates the two numbers — N (batch, denotation) from n
(per-example width, emit) — which is what lets a whole graph sit at N := B
where the batch-coupled dens (bnBatchF, the *SgdB family) are honest.
The per-example renderers keep the descriptor-less tokens unchanged.
- conv {ic oc h w kH kW : ℕ} (wName bName : String) (W : Kernel4 oc ic kH kW) (bias : Vec oc) : BatchableOp (ic * h * w) (oc * h * w)
- convStrided {ic oc h w kH kW : ℕ} (wName bName : String) (W : Kernel4 oc ic kH kW) (bias : Vec oc) : BatchableOp (ic * (2 * h) * (2 * w)) (oc * h * w)
- convBf16 {ic oc h w kH kW : ℕ} (rnd : ℝ → ℝ) (wName bName : String) (W : Kernel4 oc ic kH kW) (bias : Vec oc) : BatchableOp (ic * h * w) (oc * h * w)
- convF8 {ic oc h w kH kW : ℕ} (rnd : ℝ → ℝ) (wName bName : String) (W : Kernel4 oc ic kH kW) (bias : Vec oc) : BatchableOp (ic * h * w) (oc * h * w)
- convStridedBf16 {ic oc h w kH kW : ℕ} (rnd : ℝ → ℝ) (wName bName : String) (W : Kernel4 oc ic kH kW) (bias : Vec oc) : BatchableOp (ic * (2 * h) * (2 * w)) (oc * h * w)
- convStridedXla {ic oc h w kH kW : ℕ} (wName bName : String) (W : Kernel4 oc ic kH kW) (bias : Vec oc) : BatchableOp (ic * (2 * h) * (2 * w)) (oc * h * w)
- convStridedXlaBf16 {ic oc h w kH kW : ℕ} (rnd : ℝ → ℝ) (wName bName : String) (W : Kernel4 oc ic kH kW) (bias : Vec oc) : BatchableOp (ic * (2 * h) * (2 * w)) (oc * h * w)
- depthwise {c h w kH kW : ℕ} (wName bName : String) (W : DepthwiseKernel c kH kW) (bias : Vec c) : BatchableOp (c * h * w) (c * h * w)
- depthwiseBf16 {c h w kH kW : ℕ} (rnd : ℝ → ℝ) (wName bName : String) (W : DepthwiseKernel c kH kW) (bias : Vec c) : BatchableOp (c * h * w) (c * h * w)
- depthwiseStridedXla {c h w kH kW : ℕ} (wName bName : String) (W : DepthwiseKernel c kH kW) (bias : Vec c) : BatchableOp (c * (2 * h) * (2 * w)) (c * h * w)
- depthwiseStridedXlaBf16 {c h w kH kW : ℕ} (rnd : ℝ → ℝ) (wName bName : String) (W : DepthwiseKernel c kH kW) (bias : Vec c) : BatchableOp (c * (2 * h) * (2 * w)) (c * h * w)
- depthwiseStrided {c h w kH kW : ℕ} (wName bName : String) (W : DepthwiseKernel c kH kW) (bias : Vec c) : BatchableOp (c * (2 * h) * (2 * w)) (c * h * w)
- depthwiseStridedBf16 {c h w kH kW : ℕ} (rnd : ℝ → ℝ) (wName bName : String) (W : DepthwiseKernel c kH kW) (bias : Vec c) : BatchableOp (c * (2 * h) * (2 * w)) (c * h * w)
- dense {a c : ℕ} (wName bName : String) (W : Mat a c) (bias : Vec c) : BatchableOp a c
- gap {c h w : ℕ} : BatchableOp (c * h * w) c
- seBlock {c h w r : ℕ} (w1Name b1Name w2Name b2Name : String) (W₁ : Mat c r) (b₁ : Vec r) (W₂ : Mat r c) (b₂ : Vec c) : BatchableOp (c * h * w) (c * h * w)
- bnEval {oc h w : ℕ} (gName bName muName varName epsStr : String) (ε : ℝ) (γ β μ var : Vec oc) : BatchableOp (oc * h * w) (oc * h * w)
- swish {n : ℕ} : BatchableOp n n
- relu {n : ℕ} : BatchableOp n n
- relu6 {n : ℕ} : BatchableOp n n
- maxPool {c h w : ℕ} : BatchableOp (c * (2 * h) * (2 * w)) (c * h * w)
- maxPool3s2 {c h w : ℕ} : BatchableOp (c * (2 * h) * (2 * w)) (c * h * w)
- softmaxRow {m n : ℕ} : BatchableOp (m * n) (m * n)
- denseRowBack {rows a c : ℕ} (wName : String) (W : Mat a c) : BatchableOp (rows * c) (rows * a)
- denseRowBackBf16 {rows a c : ℕ} (rnd : ℝ → ℝ) (wName : String) (W : Mat a c) : BatchableOp (rows * c) (rows * a)
- gelu {n : ℕ} : BatchableOp n n
- transpose {m n : ℕ} : BatchableOp (m * n) (n * m)
- convStride4 {ic oc h w kH kW : ℕ} (wName bName : String) (W : Kernel4 oc ic kH kW) (bias : Vec oc) : BatchableOp (ic * (2 * (2 * h)) * (2 * (2 * w))) (oc * h * w)
- convStride4Bf16 {ic oc h w kH kW : ℕ} (rnd : ℝ → ℝ) (wName bName : String) (W : Kernel4 oc ic kH kW) (bias : Vec oc) : BatchableOp (ic * (2 * (2 * h)) * (2 * (2 * w))) (oc * h * w)
- layerScaleCh {c h w : ℕ} (γName : String) (γ : Vec c) : BatchableOp (c * h * w) (c * h * w)
- dotOut {m n : ℕ} (wName : String) (W : Mat m n) : BatchableOp n m
- expe {n : ℕ} : BatchableOp n n
- softmaxDiv {n : ℕ} : BatchableOp n n
- lnRow {m n : ℕ} (gName bName epsStr : String) (ε γ β : ℝ) : BatchableOp (m * n) (m * n)
- rowScale {m n : ℕ} (gName : String) (γ : Vec n) : BatchableOp (m * n) (m * n)
- rowBias {m n : ℕ} (bName : String) (β : Vec n) : BatchableOp (m * n) (m * n)
- denseRow {N a c : ℕ} (wName bName : String) (W : Mat a c) (b : Vec c) : BatchableOp (N * a) (N * c)
- denseRowBf16 {N a c : ℕ} (rnd : ℝ → ℝ) (wName bName : String) (W : Mat a c) (b : Vec c) : BatchableOp (N * a) (N * c)
- patchEmbed {ic H W P N D : ℕ} (wName bName clsName posName : String) (Wc : Kernel4 D ic P P) (bc cls : Vec D) (pos : Mat (N + 1) D) : BatchableOp (ic * H * W) ((N + 1) * D)
- patchEmbedBf16 {ic H W P N D : ℕ} (rnd : ℝ → ℝ) (wName bName clsName posName : String) (Wc : Kernel4 D ic P P) (bc cls : Vec D) (pos : Mat (N + 1) D) : BatchableOp (ic * H * W) ((N + 1) * D)
- clsSlice {N D : ℕ} : BatchableOp ((N + 1) * D) D
- clsPad {N D : ℕ} : BatchableOp D ((N + 1) * D)
- headSlice {N heads d : ℕ} (h : Fin heads) : BatchableOp (N * (heads * d)) (N * d)
- headPad {N heads d : ℕ} (h : Fin heads) : BatchableOp (N * d) (N * (heads * d))
Instances For
A StableHLO-subset expression, shape-indexed by result length. Leaves carry
both a value (for den) and an SSA name (for pretty); the name is
denotation-irrelevant. One constructor per emitted op.
- operand {n : ℕ} (name : String) (v : Vec n) : SHlo n
- dotIn {m n : ℕ} (wName : String) (W : Mat m n) : SHlo m → SHlo n
- dotInBf16 {m n : ℕ} (rnd : ℝ → ℝ) (wName : String) (W : Mat m n) : SHlo m → SHlo n
- dotOut {m n : ℕ} (wName : String) (W : Mat m n) : SHlo n → SHlo m
- addBcast {n : ℕ} (bName : String) (b : Vec n) : SHlo n → SHlo n
- expe {n : ℕ} : SHlo n → SHlo n
- softmaxDiv {n : ℕ} : SHlo n → SHlo n
- sub {n : ℕ} : SHlo n → SHlo n → SHlo n
- weightSgd {m n : ℕ} (xName wName lrStr : String) (x : Vec m) (W : Mat m n) (lr : ℝ) : SHlo n → SHlo (m * n)
- biasSgd {n : ℕ} (bName lrStr : String) (b : Vec n) (lr : ℝ) : SHlo n → SHlo n
- reluF {n : ℕ} : SHlo n → SHlo n
- selectPos {n : ℕ} (xName : String) (x : Vec n) : SHlo n → SHlo n
- relu6F {n : ℕ} : SHlo n → SHlo n
- selectMid {n : ℕ} (xName : String) (x : Vec n) : SHlo n → SHlo n
- convertF {n : ℕ} (rnd : ℝ → ℝ) : SHlo n → SHlo n
- flatConvF {ic oc h w kH kW : ℕ} (wName bName : String) (W : Kernel4 oc ic kH kW) (b : Vec oc) : SHlo (ic * h * w) → SHlo (oc * h * w)
- flatConvFBf16 {ic oc h w kH kW : ℕ} (rnd : ℝ → ℝ) (wName bName : String) (W : Kernel4 oc ic kH kW) (b : Vec oc) : SHlo (ic * h * w) → SHlo (oc * h * w)
- maxPoolF {c h w : ℕ} : SHlo (c * (2 * h) * (2 * w)) → SHlo (c * h * w)
- maxPool3s2F {c h w : ℕ} : SHlo (c * (2 * h) * (2 * w)) → SHlo (c * h * w)
- convBack {ic oc h w kH kW : ℕ} (wName : String) (W : Kernel4 oc ic kH kW) (b : Vec oc) (v : Vec (ic * h * w)) : SHlo (oc * h * w) → SHlo (ic * h * w)
- maxPoolBack {c h w : ℕ} (xName : String) (x : Vec (c * (2 * h) * (2 * w))) : SHlo (c * h * w) → SHlo (c * (2 * h) * (2 * w))
- maxPool3s2Back {c h w : ℕ} (xName : String) (x : Vec (c * (2 * h) * (2 * w))) : SHlo (c * h * w) → SHlo (c * (2 * h) * (2 * w))
- convWeightSgd {ic oc h w kH kW : ℕ} (xName wName lrStr : String) (b : Vec oc) (x : Tensor3 ic h w) (W : Kernel4 oc ic kH kW) (lr : ℝ) : SHlo (oc * h * w) → SHlo (oc * ic * kH * kW)
- convBiasSgd {ic oc h w kH kW : ℕ} (bName lrStr : String) (W : Kernel4 oc ic kH kW) (x : Tensor3 ic h w) (b : Vec oc) (lr : ℝ) : SHlo (oc * h * w) → SHlo oc
- bnGammaSgd {oc h w : ℕ} (gName vName epsStr lrStr : String) (ε : ℝ) (γ : Vec oc) (v : Vec (oc * h * w)) (lr : ℝ) : SHlo (oc * h * w) → SHlo oc
- bnBetaSgd {oc h w : ℕ} (bName lrStr : String) (β : Vec oc) (lr : ℝ) : SHlo (oc * h * w) → SHlo oc
- bnF {n : ℕ} (gName bName epsStr : String) (ε γ β : ℝ) : SHlo n → SHlo n
- bnBack {n : ℕ} (gName xName epsStr : String) (ε γ : ℝ) (x : Vec n) : SHlo n → SHlo n
- addV {n : ℕ} : SHlo n → SHlo n → SHlo n
- addVB {N n : ℕ} : SHlo (N * n) → SHlo (N * n) → SHlo (N * n)
- subB {N n : ℕ} : SHlo (N * n) → SHlo (N * n) → SHlo (N * n)
- gapF {c h w : ℕ} : SHlo (c * h * w) → SHlo c
- gapBack {c h w : ℕ} : SHlo c → SHlo (c * h * w)
- broadcastBack {c h w : ℕ} : SHlo (c * h * w) → SHlo c
- flatConvStridedF {ic oc h w kH kW : ℕ} (wName bName : String) (W : Kernel4 oc ic kH kW) (b : Vec oc) : SHlo (ic * (2 * h) * (2 * w)) → SHlo (oc * h * w)
- flatConvStridedXlaF {ic oc h w kH kW : ℕ} (wName bName : String) (W : Kernel4 oc ic kH kW) (b : Vec oc) : SHlo (ic * (2 * h) * (2 * w)) → SHlo (oc * h * w)
- convStridedBack {ic oc h w kH kW : ℕ} (wName : String) (W : Kernel4 oc ic kH kW) (b : Vec oc) (v : Vec (ic * (2 * h) * (2 * w))) : SHlo (oc * h * w) → SHlo (ic * (2 * h) * (2 * w))
- convStridedWeightSgd {ic oc h w kH kW : ℕ} (xName wName lrStr : String) (b : Vec oc) (x : Vec (ic * (2 * h) * (2 * w))) (W : Kernel4 oc ic kH kW) (lr : ℝ) : SHlo (oc * h * w) → SHlo (oc * ic * kH * kW)
- convStridedBiasSgd {ic oc h w kH kW : ℕ} (bName lrStr : String) (W : Kernel4 oc ic kH kW) (x : Vec (ic * (2 * h) * (2 * w))) (b : Vec oc) (lr : ℝ) : SHlo (oc * h * w) → SHlo oc
- convStridedXlaWeightSgd {ic oc h w kH kW : ℕ} (xName wName lrStr : String) (b : Vec oc) (x : Vec (ic * (2 * h) * (2 * w))) (W : Kernel4 oc ic kH kW) (lr : ℝ) : SHlo (oc * h * w) → SHlo (oc * ic * kH * kW)
- convStridedXlaBiasSgd {ic oc h w kH kW : ℕ} (bName lrStr : String) (W : Kernel4 oc ic kH kW) (x : Vec (ic * (2 * h) * (2 * w))) (b : Vec oc) (lr : ℝ) : SHlo (oc * h * w) → SHlo oc
- depthwiseWeightSgd {c h w kH kW : ℕ} (xName wName lrStr : String) (b : Vec c) (x : Tensor3 c h w) (W : DepthwiseKernel c kH kW) (lr : ℝ) : SHlo (c * h * w) → SHlo (c * kH * kW)
- depthwiseBiasSgd {c h w kH kW : ℕ} (bName lrStr : String) (W : DepthwiseKernel c kH kW) (x : Tensor3 c h w) (b : Vec c) (lr : ℝ) : SHlo (c * h * w) → SHlo c
- depthwiseStridedWeightSgd {c h w kH kW : ℕ} (xName wName lrStr : String) (b : Vec c) (x : Vec (c * (2 * h) * (2 * w))) (W : DepthwiseKernel c kH kW) (lr : ℝ) : SHlo (c * h * w) → SHlo (c * kH * kW)
- depthwiseStridedBiasSgd {c h w kH kW : ℕ} (bName lrStr : String) (W : DepthwiseKernel c kH kW) (x : Vec (c * (2 * h) * (2 * w))) (b : Vec c) (lr : ℝ) : SHlo (c * h * w) → SHlo c
- depthwiseStridedXlaWeightSgd {c h w kH kW : ℕ} (xName wName lrStr : String) (b : Vec c) (x : Vec (c * (2 * h) * (2 * w))) (W : DepthwiseKernel c kH kW) (lr : ℝ) : SHlo (c * h * w) → SHlo (c * kH * kW)
- depthwiseStridedXlaBiasSgd {c h w kH kW : ℕ} (bName lrStr : String) (W : DepthwiseKernel c kH kW) (x : Vec (c * (2 * h) * (2 * w))) (b : Vec c) (lr : ℝ) : SHlo (c * h * w) → SHlo c
- layerScaleChGammaSgd {c h w : ℕ} (gName xName lrStr : String) (x : Vec (c * h * w)) (γ : Vec c) (lr : ℝ) : SHlo (c * h * w) → SHlo c
- lnGammaSgd {n : ℕ} (gName xName epsStr lrStr : String) (ε : ℝ) (x : Vec n) (γ : Vec 1) (lr : ℝ) : SHlo n → SHlo 1
- lnBetaSgd {n : ℕ} (bName lrStr : String) (β : Vec 1) (lr : ℝ) : SHlo n → SHlo 1
- veclnGammaSgd {N D : ℕ} (gName xName epsStr lrStr : String) (ε : ℝ) (x : Vec (N * D)) (γ : Vec D) (lr : ℝ) : SHlo (N * D) → SHlo D
- patchEmbedWeightSgd {ic H W P N D : ℕ} (wName xName lrStr : String) (x : Vec (ic * H * W)) (Wp : Kernel4 D ic P P) (lr : ℝ) : SHlo ((N + 1) * D) → SHlo (D * ic * P * P)
- patchEmbedBiasSgd {N c : ℕ} (bName lrStr : String) (b : Vec c) (lr : ℝ) : SHlo ((N + 1) * c) → SHlo c
- posEmbedSgd {N D : ℕ} (pName lrStr : String) (pos : Mat (N + 1) D) (lr : ℝ) : SHlo ((N + 1) * D) → SHlo ((N + 1) * D)
- flatConvStride4F {ic oc h w kH kW : ℕ} (wName bName : String) (W : Kernel4 oc ic kH kW) (b : Vec oc) : SHlo (ic * (2 * (2 * h)) * (2 * (2 * w))) → SHlo (oc * h * w)
- bnPerChannelF {oc h w : ℕ} (gName bName epsStr : String) (ε : ℝ) (γ β : Vec oc) : SHlo (oc * h * w) → SHlo (oc * h * w)
- bnPerChannelBack {oc h w : ℕ} (gName xName epsStr : String) (ε : ℝ) (γ : Vec oc) (x : Vec (oc * h * w)) : SHlo (oc * h * w) → SHlo (oc * h * w)
- bnPerChannelEvalF {oc h w : ℕ} (gName bName muName varName epsStr : String) (ε : ℝ) (γ β μ var : Vec oc) : SHlo (oc * h * w) → SHlo (oc * h * w)
- depthwiseF {c h w kH kW : ℕ} (wName bName : String) (W : DepthwiseKernel c kH kW) (b : Vec c) : SHlo (c * h * w) → SHlo (c * h * w)
- depthwiseBack {c h w kH kW : ℕ} (wName : String) (W : DepthwiseKernel c kH kW) (b : Vec c) (v : Vec (c * h * w)) : SHlo (c * h * w) → SHlo (c * h * w)
- depthwiseStridedF {c h w kH kW : ℕ} (wName bName : String) (W : DepthwiseKernel c kH kW) (b : Vec c) : SHlo (c * (2 * h) * (2 * w)) → SHlo (c * h * w)
- depthwiseStridedXlaF {c h w kH kW : ℕ} (wName bName : String) (W : DepthwiseKernel c kH kW) (b : Vec c) : SHlo (c * (2 * h) * (2 * w)) → SHlo (c * h * w)
- depthwiseStridedBack {c h w kH kW : ℕ} (wName : String) (W : DepthwiseKernel c kH kW) (b : Vec c) (v : Vec (c * (2 * h) * (2 * w))) : SHlo (c * h * w) → SHlo (c * (2 * h) * (2 * w))
- depthwiseStridedXlaBack {c h w kH kW : ℕ} (wName : String) (W : DepthwiseKernel c kH kW) (b : Vec c) (v : Vec (c * (2 * h) * (2 * w))) : SHlo (c * h * w) → SHlo (c * (2 * h) * (2 * w))
- swishF {n : ℕ} : SHlo n → SHlo n
- swishBack {n : ℕ} (xName : String) (x : Vec n) : SHlo n → SHlo n
- sigmoidF {n : ℕ} : SHlo n → SHlo n
- sigmoidBack {n : ℕ} (xName : String) (x : Vec n) : SHlo n → SHlo n
- maxPoolBackB {N c h w : ℕ} (xName : String) (x : Vec (N * (c * (2 * h) * (2 * w)))) : SHlo (N * (c * h * w)) → SHlo (N * (c * (2 * h) * (2 * w)))
- maxPool3s2BackB {N c h w : ℕ} (xName : String) (x : Vec (N * (c * (2 * h) * (2 * w)))) : SHlo (N * (c * h * w)) → SHlo (N * (c * (2 * h) * (2 * w)))
- convBiasSgdB {N ic oc h w kH kW : ℕ} (bName lrStr : String) (W : Kernel4 oc ic kH kW) (x : Vec (N * (ic * h * w))) (b : Vec oc) (lr : ℝ) : SHlo (N * (oc * h * w)) → SHlo oc
- convStridedBiasSgdB {N ic oc h w kH kW : ℕ} (bName lrStr : String) (W : Kernel4 oc ic kH kW) (x : Vec (N * (ic * (2 * h) * (2 * w)))) (b : Vec oc) (lr : ℝ) : SHlo (N * (oc * h * w)) → SHlo oc
- selectPosB {N n : ℕ} (xName : String) (x : Vec (N * n)) : SHlo (N * n) → SHlo (N * n)
- selectMidB {N n : ℕ} (xName : String) (x : Vec (N * n)) : SHlo (N * n) → SHlo (N * n)
- dropPathB {N n : ℕ} (mName : String) (s : Vec N) : SHlo (N * n) → SHlo (N * n)
- dropoutB {N n : ℕ} (mName : String) (mask : Vec (N * n)) : SHlo (N * n) → SHlo (N * n)
- swishBackB {N n : ℕ} (xName : String) (x : Vec (N * n)) : SHlo (N * n) → SHlo (N * n)
- geluBackB {N n : ℕ} (xName : String) (x : Vec (N * n)) : SHlo (N * n) → SHlo (N * n)
- convStride4WeightGradB {N ic oc h w kH kW : ℕ} (xName : String) (b : Vec oc) (x : Vec (N * (ic * (2 * (2 * h)) * (2 * (2 * w))))) (W : Kernel4 oc ic kH kW) : SHlo (N * (oc * h * w)) → SHlo (oc * ic * kH * kW)
- convStride4WeightGradBBf16 {N ic oc h w kH kW : ℕ} (rnd : ℝ → ℝ) (xName : String) (b : Vec oc) (x : Vec (N * (ic * (2 * (2 * h)) * (2 * (2 * w))))) (W : Kernel4 oc ic kH kW) : SHlo (N * (oc * h * w)) → SHlo (oc * ic * kH * kW)
- layerScaleChGammaGradB {N c h w : ℕ} (xName : String) (x : Vec (N * (c * h * w))) : SHlo (N * (c * h * w)) → SHlo c
- veclnGammaGradB {N R D : ℕ} (xName epsStr : String) (ε : ℝ) (x : Vec (N * (R * D))) : SHlo (N * (R * D)) → SHlo D
- rowDenseBiasGradB {N R c : ℕ} : SHlo (N * (R * c)) → SHlo c
- weightGradB {N m n : ℕ} (xName : String) (x : Vec (N * m)) : SHlo (N * n) → SHlo (m * n)
- biasGradB {N n : ℕ} : SHlo (N * n) → SHlo (N * n)
- lnRowBackB {N m n : ℕ} (gName xName epsStr : String) (ε γ : ℝ) (x : Vec (N * (m * n))) : SHlo (N * (m * n)) → SHlo (N * (m * n))
- sigmoidB {N n : ℕ} : SHlo (N * n) → SHlo (N * n)
- sigmoidBackB {N n : ℕ} (xName : String) (x : Vec (N * n)) : SHlo (N * n) → SHlo (N * n)
- matmulFB {N m k n : ℕ} : SHlo (N * (m * k)) → SHlo (N * (k * n)) → SHlo (N * (m * n))
- matmulFBBf16 {N m k n : ℕ} (rnd : ℝ → ℝ) : SHlo (N * (m * k)) → SHlo (N * (k * n)) → SHlo (N * (m * n))
- softmaxRowBackB {N m n : ℕ} (xName : String) (preAct : Vec (N * (m * n))) : SHlo (N * (m * n)) → SHlo (N * (m * n))
- rowDenseWeightGradB {N tk a c : ℕ} (xName : String) (x : Vec (N * (tk * a))) : SHlo (N * (tk * c)) → SHlo (a * c)
- rowDenseWeightGradBBf16 {N tk a c : ℕ} (rnd : ℝ → ℝ) (xName : String) (x : Vec (N * (tk * a))) : SHlo (N * (tk * c)) → SHlo (a * c)
- posEmbedGradB {N tk D : ℕ} : SHlo (N * ((tk + 1) * D)) → SHlo ((tk + 1) * D)
- patchEmbedWeightGradB {N ic H W P tk D : ℕ} (xName : String) (x : Vec (N * (ic * H * W))) : SHlo (N * ((tk + 1) * D)) → SHlo (D * ic * P * P)
- patchEmbedWeightGradBBf16 {N ic H W P tk D : ℕ} (rnd : ℝ → ℝ) (xName : String) (x : Vec (N * (ic * H * W))) : SHlo (N * ((tk + 1) * D)) → SHlo (D * ic * P * P)
- patchEmbedBiasGradB {N tk c : ℕ} : SHlo (N * ((tk + 1) * c)) → SHlo c
- geluF {n : ℕ} : SHlo n → SHlo n
- geluBack {n : ℕ} (xName : String) (x : Vec n) : SHlo n → SHlo n
- layerScaleF {n : ℕ} (γName : String) (γ : Vec n) : SHlo n → SHlo n
- layerScaleChF {c h w : ℕ} (γName : String) (γ : Vec c) : SHlo (c * h * w) → SHlo (c * h * w)
- softmaxRowF {m n : ℕ} : SHlo (m * n) → SHlo (m * n)
- softmaxRowBack {m n : ℕ} (xName : String) (preAct : Vec (m * n)) : SHlo (m * n) → SHlo (m * n)
- matmulF {m k n : ℕ} : SHlo (m * k) → SHlo (k * n) → SHlo (m * n)
- transposeF {m n : ℕ} : SHlo (m * n) → SHlo (n * m)
- scaleF {n : ℕ} (sStr : String) (s : ℝ) : SHlo n → SHlo n
- lnRowF {m n : ℕ} (gName bName epsStr : String) (ε γ β : ℝ) : SHlo (m * n) → SHlo (m * n)
- lnRowBack {m n : ℕ} (gName xName epsStr : String) (ε γ : ℝ) (x : Vec (m * n)) : SHlo (m * n) → SHlo (m * n)
- denseRowF {N a c : ℕ} (wName bName : String) (W : Mat a c) (b : Vec c) : SHlo (N * a) → SHlo (N * c)
- denseRowBack {N a c : ℕ} (wName : String) (W : Mat a c) : SHlo (N * c) → SHlo (N * a)
- patchEmbedF {ic H W P N D : ℕ} (wName bName clsName posName : String) (Wc : Kernel4 D ic P P) (bc cls : Vec D) (pos : Mat (N + 1) D) : SHlo (ic * H * W) → SHlo ((N + 1) * D)
- patchEmbedBack {ic H W P N D : ℕ} (wName : String) (Wc : Kernel4 D ic P P) : SHlo ((N + 1) * D) → SHlo (ic * H * W)
- clsSliceF {N D : ℕ} : SHlo ((N + 1) * D) → SHlo D
- clsPadF {N D : ℕ} : SHlo D → SHlo ((N + 1) * D)
- headSliceF {N heads d : ℕ} (h : Fin heads) : SHlo (N * (heads * d)) → SHlo (N * d)
- headPadF {N heads d : ℕ} (h : Fin heads) : SHlo (N * d) → SHlo (N * (heads * d))
- rowScaleF {m n : ℕ} (gName : String) (γ : Vec n) : SHlo (m * n) → SHlo (m * n)
- rowBiasF {m n : ℕ} (bName : String) (β : Vec n) : SHlo (m * n) → SHlo (m * n)
- batchOp {N a b : ℕ} (op : BatchableOp a b) : SHlo (N * a) → SHlo (N * b)
- bnBatchF {N oc h w : ℕ} (gName bName epsStr : String) (ε : ℝ) (γ β : Vec oc) : SHlo (N * (oc * h * w)) → SHlo (N * (oc * h * w))
- bnBatchBack {N oc h w : ℕ} (gName xName epsStr : String) (ε : ℝ) (γ : Vec oc) (x : Vec (N * (oc * (h * w)))) : SHlo (N * (oc * (h * w))) → SHlo (N * (oc * (h * w)))
- convBackBatched {N ic oc h w kH kW : ℕ} (wName : String) (W : Kernel4 oc ic kH kW) (b : Vec oc) : SHlo (N * (oc * h * w)) → SHlo (N * (ic * h * w))
- convStridedBackBatched {N ic oc h w kH kW : ℕ} (wName : String) (W : Kernel4 oc ic kH kW) (b : Vec oc) : SHlo (N * (oc * h * w)) → SHlo (N * (ic * (2 * h) * (2 * w)))
- convBackBatchedBf16 {N ic oc h w kH kW : ℕ} (rnd : ℝ → ℝ) (wName : String) (W : Kernel4 oc ic kH kW) (b : Vec oc) : SHlo (N * (oc * h * w)) → SHlo (N * (ic * h * w))
- convBackBatchedF8 {N ic oc h w kH kW : ℕ} (rnd : ℝ → ℝ) (wName : String) (W : Kernel4 oc ic kH kW) (b : Vec oc) : SHlo (N * (oc * h * w)) → SHlo (N * (ic * h * w))
- convStridedBackBatchedBf16 {N ic oc h w kH kW : ℕ} (rnd : ℝ → ℝ) (wName : String) (W : Kernel4 oc ic kH kW) (b : Vec oc) : SHlo (N * (oc * h * w)) → SHlo (N * (ic * (2 * h) * (2 * w)))
- depthwiseBackBatched {N c h w kH kW : ℕ} (wName : String) (W : DepthwiseKernel c kH kW) (b : Vec c) : SHlo (N * (c * h * w)) → SHlo (N * (c * h * w))
- depthwiseBackBatchedBf16 {N c h w kH kW : ℕ} (rnd : ℝ → ℝ) (wName : String) (W : DepthwiseKernel c kH kW) (b : Vec c) : SHlo (N * (c * h * w)) → SHlo (N * (c * h * w))
- depthwiseStridedBackBatched {N c h w kH kW : ℕ} (wName : String) (W : DepthwiseKernel c kH kW) (b : Vec c) : SHlo (N * (c * h * w)) → SHlo (N * (c * (2 * h) * (2 * w)))
- depthwiseStridedBackBatchedBf16 {N c h w kH kW : ℕ} (rnd : ℝ → ℝ) (wName : String) (W : DepthwiseKernel c kH kW) (b : Vec c) : SHlo (N * (c * h * w)) → SHlo (N * (c * (2 * h) * (2 * w)))
- depthwiseStridedXlaBackBatched {N c h w kH kW : ℕ} (wName : String) (W : DepthwiseKernel c kH kW) (b : Vec c) : SHlo (N * (c * h * w)) → SHlo (N * (c * (2 * h) * (2 * w)))
- depthwiseStridedXlaBackBatchedBf16 {N c h w kH kW : ℕ} (rnd : ℝ → ℝ) (wName : String) (W : DepthwiseKernel c kH kW) (b : Vec c) : SHlo (N * (c * h * w)) → SHlo (N * (c * (2 * h) * (2 * w)))
- bnBatchLABack {N oc h w : ℕ} (gName xName epsStr : String) (ε : ℝ) (γ : Vec oc) (x : Vec (N * (oc * h * w))) : SHlo (N * (oc * h * w)) → SHlo (N * (oc * h * w))
- seBackBatched {N c h w r : ℕ} (w1Name b1Name w2Name b2Name vName : String) (W₁ : Mat c r) (b₁ : Vec r) (W₂ : Mat r c) (b₂ : Vec c) (v : Vec (N * (c * h * w))) : SHlo (N * (c * h * w)) → SHlo (N * (c * h * w))
- seReduceB {N c h w : ℕ} (xName : String) (x : Vec (N * (c * h * w))) : SHlo (N * (c * h * w)) → SHlo (N * c)
- gapBackBatched {N c h w : ℕ} : SHlo (N * c) → SHlo (N * (c * h * w))
- bnGammaSgdB {N oc h w : ℕ} (gName vName epsStr lrStr : String) (ε : ℝ) (γ : Vec oc) (v : Vec (N * (oc * (h * w)))) (lr : ℝ) : SHlo (N * (oc * (h * w))) → SHlo oc
- bnBetaSgdB {N oc h w : ℕ} (bName lrStr : String) (β : Vec oc) (lr : ℝ) : SHlo (N * (oc * (h * w))) → SHlo oc
- denseWeightSgdB {N a c : ℕ} (xName wName lrStr : String) (x : Vec (N * a)) (W : Mat a c) (lr : ℝ) : SHlo (N * c) → SHlo (a * c)
- denseBiasSgdB {N c : ℕ} (bName lrStr : String) (b : Vec c) (lr : ℝ) : SHlo (N * c) → SHlo c
- convWeightGradB {N ic oc h w kH kW : ℕ} (xName : String) (b : Vec oc) (x : Vec (N * (ic * h * w))) (W : Kernel4 oc ic kH kW) : SHlo (N * (oc * h * w)) → SHlo (oc * ic * kH * kW)
- convStridedWeightGradB {N ic oc h w kH kW : ℕ} (xName : String) (b : Vec oc) (x : Vec (N * (ic * (2 * h) * (2 * w)))) (W : Kernel4 oc ic kH kW) : SHlo (N * (oc * h * w)) → SHlo (oc * ic * kH * kW)
- convWeightGradBBf16 {N ic oc h w kH kW : ℕ} (rnd : ℝ → ℝ) (xName : String) (b : Vec oc) (x : Vec (N * (ic * h * w))) (W : Kernel4 oc ic kH kW) : SHlo (N * (oc * h * w)) → SHlo (oc * ic * kH * kW)
- convWeightGradBF8 {N ic oc h w kH kW : ℕ} (rnd : ℝ → ℝ) (xName : String) (b : Vec oc) (x : Vec (N * (ic * h * w))) (W : Kernel4 oc ic kH kW) : SHlo (N * (oc * h * w)) → SHlo (oc * ic * kH * kW)
- convStridedWeightGradBBf16 {N ic oc h w kH kW : ℕ} (rnd : ℝ → ℝ) (xName : String) (b : Vec oc) (x : Vec (N * (ic * (2 * h) * (2 * w)))) (W : Kernel4 oc ic kH kW) : SHlo (N * (oc * h * w)) → SHlo (oc * ic * kH * kW)
- convBiasGradB {N ic oc h w kH kW : ℕ} (W : Kernel4 oc ic kH kW) (x : Vec (N * (ic * h * w))) (b : Vec oc) : SHlo (N * (oc * h * w)) → SHlo oc
- convStridedBiasGradB {N ic oc h w kH kW : ℕ} (W : Kernel4 oc ic kH kW) (x : Vec (N * (ic * (2 * h) * (2 * w)))) (b : Vec oc) : SHlo (N * (oc * h * w)) → SHlo oc
- convStridedXlaWeightGradB {N ic oc h w kH kW : ℕ} (xName : String) (b : Vec oc) (x : Vec (N * (ic * (2 * h) * (2 * w)))) (W : Kernel4 oc ic kH kW) : SHlo (N * (oc * h * w)) → SHlo (oc * ic * kH * kW)
- convStridedXlaWeightGradBBf16 {N ic oc h w kH kW : ℕ} (rnd : ℝ → ℝ) (xName : String) (b : Vec oc) (x : Vec (N * (ic * (2 * h) * (2 * w)))) (W : Kernel4 oc ic kH kW) : SHlo (N * (oc * h * w)) → SHlo (oc * ic * kH * kW)
- convStridedXlaBiasGradB {N ic oc h w kH kW : ℕ} (W : Kernel4 oc ic kH kW) (x : Vec (N * (ic * (2 * h) * (2 * w)))) (b : Vec oc) : SHlo (N * (oc * h * w)) → SHlo oc
- bnGammaGradB {N oc h w : ℕ} (vName epsStr : String) (ε : ℝ) (v : Vec (N * (oc * (h * w)))) : SHlo (N * (oc * (h * w))) → SHlo oc
- bnBetaGradB {N oc h w : ℕ} : SHlo (N * (oc * (h * w))) → SHlo oc
- denseWeightGradB {N a c : ℕ} (xName : String) (x : Vec (N * a)) : SHlo (N * c) → SHlo (a * c)
- denseBiasGradB {N c : ℕ} : SHlo (N * c) → SHlo c
- bnBatchMeanB {N oc h w : ℕ} : SHlo (N * (oc * (h * w))) → SHlo oc
- bnBatchVarB {N oc h w : ℕ} : SHlo (N * (oc * (h * w))) → SHlo oc
- bnBatchVarAtB {N oc h w : ℕ} : SHlo (N * (oc * (h * w))) → SHlo oc → SHlo oc
- bnPackB {oc : ℕ} : SHlo oc → SHlo oc → SHlo (oc + oc)
- bnSyncF {N oc h w : ℕ} (gName bName epsStr : String) (ε : ℝ) (γ β : Vec oc) : SHlo (N * (oc * (h * w))) → SHlo (oc + oc) → SHlo (N * (oc * (h * w)))
- bnSyncDyStatsB {N oc h w : ℕ} (gName xName epsStr : String) (ε : ℝ) (γ : Vec oc) (x : Vec (N * (oc * (h * w)))) : SHlo (N * (oc * (h * w))) → SHlo (oc + oc) → SHlo (oc + oc + (oc + oc))
- bnSyncBack {N oc h w : ℕ} (gName xName epsStr : String) (ε : ℝ) (γ : Vec oc) (x : Vec (N * (oc * (h * w)))) : SHlo (N * (oc * (h * w))) → SHlo (oc + oc + (oc + oc)) → SHlo (N * (oc * (h * w)))
- bnSyncGammaGradB {N oc h w : ℕ} (xName epsStr : String) (ε : ℝ) (x : Vec (N * (oc * (h * w)))) : SHlo (N * (oc * (h * w))) → SHlo (oc + oc) → SHlo oc
- bnStatsMeanB {oc : ℕ} : SHlo (oc + oc) → SHlo oc
- bnStatsVarB {oc : ℕ} : SHlo (oc + oc) → SHlo oc
- scaleB {N n : ℕ} (sStr : String) (s : ℝ) : SHlo (N * n) → SHlo (N * n)
- shiftB {N n : ℕ} (sStr : String) (s : ℝ) : SHlo (N * n) → SHlo (N * n)
- divConstB {N n : ℕ} (sStr : String) (s : ℝ) : SHlo (N * n) → SHlo (N * n)
- allReduceMeanF {n : ℕ} (R : ℕ) (hR : 0 < R) (t : String) (ds : List ℕ) (g : Fin R → SHlo n) : SHlo n
- rowDenseWeightSgd {N a c : ℕ} (xName wName lrStr : String) (x : Vec (N * a)) (W : Mat a c) (lr : ℝ) : SHlo (N * c) → SHlo (a * c)
- rowDenseBiasSgd {N c : ℕ} (bName lrStr : String) (b : Vec c) (lr : ℝ) : SHlo (N * c) → SHlo c
- convWeightSgdB {N ic oc h w kH kW : ℕ} (xName wName lrStr : String) (b : Vec oc) (x : Vec (N * (ic * h * w))) (W : Kernel4 oc ic kH kW) (lr : ℝ) : SHlo (N * (oc * h * w)) → SHlo (oc * ic * kH * kW)
- convStridedWeightSgdB {N ic oc h w kH kW : ℕ} (xName wName lrStr : String) (b : Vec oc) (x : Vec (N * (ic * (2 * h) * (2 * w)))) (W : Kernel4 oc ic kH kW) (lr : ℝ) : SHlo (N * (oc * h * w)) → SHlo (oc * ic * kH * kW)
- convStridedXlaWeightSgdB {N ic oc h w kH kW : ℕ} (xName wName lrStr : String) (b : Vec oc) (x : Vec (N * (ic * (2 * h) * (2 * w)))) (W : Kernel4 oc ic kH kW) (lr : ℝ) : SHlo (N * (oc * h * w)) → SHlo (oc * ic * kH * kW)
- depthwiseWeightSgdB {N c h w kH kW : ℕ} (xName wName lrStr : String) (b : Vec c) (x : Vec (N * (c * h * w))) (W : DepthwiseKernel c kH kW) (lr : ℝ) : SHlo (N * (c * h * w)) → SHlo (c * kH * kW)
- depthwiseStridedWeightSgdB {N c h w kH kW : ℕ} (xName wName lrStr : String) (b : Vec c) (x : Vec (N * (c * (2 * h) * (2 * w)))) (W : DepthwiseKernel c kH kW) (lr : ℝ) : SHlo (N * (c * h * w)) → SHlo (c * kH * kW)
- weightGrad {m n : ℕ} (xName : String) (x : Vec m) : SHlo n → SHlo (m * n)
- biasGrad {n : ℕ} : SHlo n → SHlo n
- convWeightGrad {ic oc h w kH kW : ℕ} (xName : String) (b : Vec oc) (x : Tensor3 ic h w) (W : Kernel4 oc ic kH kW) : SHlo (oc * h * w) → SHlo (oc * ic * kH * kW)
- convBiasGrad {ic oc h w kH kW : ℕ} (W : Kernel4 oc ic kH kW) (x : Tensor3 ic h w) (b : Vec oc) : SHlo (oc * h * w) → SHlo oc
- convStridedWeightGrad {ic oc h w kH kW : ℕ} (xName : String) (b : Vec oc) (x : Vec (ic * (2 * h) * (2 * w))) (W : Kernel4 oc ic kH kW) : SHlo (oc * h * w) → SHlo (oc * ic * kH * kW)
- convStride4WeightGrad {ic oc h w kH kW : ℕ} (xName : String) (b : Vec oc) (x : Vec (ic * (2 * (2 * h)) * (2 * (2 * w)))) (W : Kernel4 oc ic kH kW) : SHlo (oc * h * w) → SHlo (oc * ic * kH * kW)
- convStridedBiasGrad {ic oc h w kH kW : ℕ} (W : Kernel4 oc ic kH kW) (x : Vec (ic * (2 * h) * (2 * w))) (b : Vec oc) : SHlo (oc * h * w) → SHlo oc
- bnGammaGrad {oc h w : ℕ} (vName epsStr : String) (ε : ℝ) (v : Vec (oc * h * w)) : SHlo (oc * h * w) → SHlo oc
- bnBetaGrad {oc h w : ℕ} : SHlo (oc * h * w) → SHlo oc
- rowDenseWeightGrad {N a c : ℕ} (xName : String) (x : Vec (N * a)) : SHlo (N * c) → SHlo (a * c)
- rowDenseBiasGrad {N c : ℕ} : SHlo (N * c) → SHlo c
- veclnGammaGrad {N D : ℕ} (xName epsStr : String) (ε : ℝ) (x : Vec (N * D)) : SHlo (N * D) → SHlo D
- patchEmbedWeightGrad {ic H W P N D : ℕ} (xName : String) (x : Vec (ic * H * W)) : SHlo ((N + 1) * D) → SHlo (D * ic * P * P)
- patchEmbedBiasGrad {N c : ℕ} : SHlo ((N + 1) * c) → SHlo c
- posEmbedGrad {N D : ℕ} : SHlo ((N + 1) * D) → SHlo ((N + 1) * D)
- depthwiseWeightGradB {N c h w kH kW : ℕ} (xName : String) (b : Vec c) (x : Vec (N * (c * h * w))) (W : DepthwiseKernel c kH kW) : SHlo (N * (c * h * w)) → SHlo (c * kH * kW)
- depthwiseWeightGradBBf16 {N c h w kH kW : ℕ} (rnd : ℝ → ℝ) (xName : String) (b : Vec c) (x : Vec (N * (c * h * w))) (W : DepthwiseKernel c kH kW) : SHlo (N * (c * h * w)) → SHlo (c * kH * kW)
- depthwiseStridedWeightGradB {N c h w kH kW : ℕ} (xName : String) (b : Vec c) (x : Vec (N * (c * (2 * h) * (2 * w)))) (W : DepthwiseKernel c kH kW) : SHlo (N * (c * h * w)) → SHlo (c * kH * kW)
- depthwiseStridedWeightGradBBf16 {N c h w kH kW : ℕ} (rnd : ℝ → ℝ) (xName : String) (b : Vec c) (x : Vec (N * (c * (2 * h) * (2 * w)))) (W : DepthwiseKernel c kH kW) : SHlo (N * (c * h * w)) → SHlo (c * kH * kW)
- depthwiseBiasGradB {N c h w kH kW : ℕ} (W : DepthwiseKernel c kH kW) (x : Vec (N * (c * h * w))) (b : Vec c) : SHlo (N * (c * h * w)) → SHlo c
- depthwiseStridedBiasGradB {N c h w kH kW : ℕ} (W : DepthwiseKernel c kH kW) (x : Vec (N * (c * (2 * h) * (2 * w)))) (b : Vec c) : SHlo (N * (c * h * w)) → SHlo c
- depthwiseStridedXlaWeightGradB {N c h w kH kW : ℕ} (xName : String) (b : Vec c) (x : Vec (N * (c * (2 * h) * (2 * w)))) (W : DepthwiseKernel c kH kW) : SHlo (N * (c * h * w)) → SHlo (c * kH * kW)
- depthwiseStridedXlaWeightGradBBf16 {N c h w kH kW : ℕ} (rnd : ℝ → ℝ) (xName : String) (b : Vec c) (x : Vec (N * (c * (2 * h) * (2 * w)))) (W : DepthwiseKernel c kH kW) : SHlo (N * (c * h * w)) → SHlo (c * kH * kW)
- depthwiseStridedXlaBiasGradB {N c h w kH kW : ℕ} (W : DepthwiseKernel c kH kW) (x : Vec (N * (c * (2 * h) * (2 * w)))) (b : Vec c) : SHlo (N * (c * h * w)) → SHlo c
- depthwiseWeightGrad {c h w kH kW : ℕ} (xName : String) (b : Vec c) (x : Tensor3 c h w) (W : DepthwiseKernel c kH kW) : SHlo (c * h * w) → SHlo (c * kH * kW)
- depthwiseBiasGrad {c h w kH kW : ℕ} (W : DepthwiseKernel c kH kW) (x : Tensor3 c h w) (b : Vec c) : SHlo (c * h * w) → SHlo c
- lnGammaGrad {n : ℕ} (xName epsStr : String) (ε : ℝ) (x : Vec n) : SHlo n → SHlo 1
- lnBetaGrad {n : ℕ} : SHlo n → SHlo 1
- layerScaleChGammaGrad {c h w : ℕ} (xName : String) (x : Vec (c * h * w)) : SHlo (c * h * w) → SHlo c
- adamMNextF {n : ℕ} (mName b1Name ob1Name : String) (ds : List ℕ) (β₁ : ℝ) (m : Vec n) : SHlo n → SHlo n
- adamVNextF {n : ℕ} (vName b2Name ob2Name : String) (ds : List ℕ) (β₂ : ℝ) (v : Vec n) : SHlo n → SHlo n
- adamWParamF {n : ℕ} (θName mName vName b1Name ob1Name b2Name ob2Name bc1Name bc2Name lrName epsName wdName : String) (ds : List ℕ) (β₁ β₂ ε lr wd bc₁ bc₂ : ℝ) (θ m v : Vec n) : SHlo n → SHlo n
- sgdParamF {n : ℕ} (θName lrName : String) (ds : List ℕ) (lr : ℝ) (θ : Vec n) : SHlo n → SHlo n
- momVNextF {n : ℕ} (vName muName : String) (ds : List ℕ) (μ : ℝ) (v : Vec n) : SHlo n → SHlo n
- momParamF {n : ℕ} (θName vName muName lrName : String) (ds : List ℕ) (μ lr : ℝ) (θ v : Vec n) : SHlo n → SHlo n
- rmsBufNextF {n : ℕ} (sqName bufName rhoName orhoName muName epsName : String) (ds : List ℕ) (ρ μ ε : ℝ) (sq buf : Vec n) : SHlo n → SHlo n
- gradSumSqAccF {n : ℕ} (ds : List ℕ) : SHlo 1 → SHlo n → SHlo 1
- clipScaleF {n : ℕ} (clipStr epsStr : String) (c ε : ℝ) (ds : List ℕ) : SHlo 1 → SHlo n → SHlo n
- lambDirF {n : ℕ} (θName mName vName b1Name ob1Name b2Name ob2Name bc1Name bc2Name epsName wdName : String) (ds : List ℕ) (β₁ β₂ ε wd bc₁ bc₂ : ℝ) (θ m v : Vec n) : SHlo n → SHlo n
- lambScaleF {n : ℕ} (ds : List ℕ) : SHlo 1 → SHlo n → SHlo n
Instances For
3×3/s2 max-pool backward (flattened) — the peer of maxPoolBackFlat at He et al.'s stem
pool, matching maxPool3s2HasVJPAt3.backward lifted through HasVJPAt3.toHasVJPAt. Total
in the saved input xv (the no-ties proof lives only in .correct).
This is a SUM where the 2×2 peer is a lookup, and that is the whole difference between the
two pools. maxPool2's windows tile, so each input is the argmax of at most one output and
the backward can name it directly. 3×3/s2 windows OVERLAP, so an input can be the argmax of up
to four outputs (win3Row_mem_le_two squared) and the cotangent must ACCUMULATE. Nothing in
HasVJPAt3.correct had to change for that — it already states the backward as a sum over all
outputs, and maxPool2's peer merely collapses it using disjointness.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Row-softmax (flattened) — apply the 1-D softmax (MLP.lean) to each of
the m rows of the row-major Vec (m*n). Definitionally equal to
Mat.flatten ∘ rowSoftmax ∘ Mat.unflatten (Attention.lean's rowSoftmax; the
tie is rowSoftmaxFlat_flat in ViTFwdGraph).
Equations
- Proofs.StableHLO.rowSoftmaxFlat m n v = Proofs.Mat.flatten fun (i : Fin m) => Proofs.softmax n (Proofs.Mat.unflatten v i)
Instances For
Row-softmax backward (flattened) — per row, the proven closed form
pᵢ⊙(dyᵢ − ⟨pᵢ,dyᵢ⟩) with pᵢ = softmax(preActᵢ). Definitionally equal to
Mat.flatten ∘ rowSoftmaxHasVJPMat.backward (Mat.unflatten preAct) ∘ Mat.unflatten
(since softmaxHasVJP.backward z dy i = let p := softmax z; p i·(dy i − ⟨p,dy⟩)).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Flattened matrix multiply C = A·B on row-major flat operands.
Definitionally Mat.flatten ∘ Mat.mul ∘ Mat.unflatten².
Equations
- Proofs.StableHLO.matMulFlat m k n a b = ((Proofs.Mat.unflatten a).mul (Proofs.Mat.unflatten b)).flatten
Instances For
Row-wise LayerNorm (flattened) — each of the m token rows gets the 1-D
bnForward over its n features (LayerNorm IS per-example BN:
layerNormForward := bnForward definitionally, LayerNorm.lean).
Equations
- Proofs.StableHLO.rowLNFlat m n ε γ β v = Proofs.Mat.flatten fun (i : Fin m) => Proofs.bnForward n ε γ β (Proofs.Mat.unflatten v i)
Instances For
Row-wise LayerNorm input-VJP (flattened) — per row the consolidated
three-term bnGradInput, recomputing x̂/istd from the saved pre-LN input.
Equations
- Proofs.StableHLO.rowLNBackFlat m n ε γ x dy = Proofs.Mat.flatten fun (i : Fin m) => Proofs.bnGradInput n ε γ (Proofs.Mat.unflatten x i) (Proofs.Mat.unflatten dy i)
Instances For
Per-token dense (flattened) — every row of the [N,a] flat through the
same dense W b.
Equations
- Proofs.StableHLO.rowDenseFlat N a c W b v = Proofs.Mat.flatten fun (i : Fin N) => Proofs.dense W b (Proofs.Mat.unflatten v i)
Instances For
Per-token dense input-VJP (flattened) — per row dX = W·dy (=
(denseHasVJP W b).backward's Mat.mulVec W, MLP.lean).
Equations
- Proofs.StableHLO.rowDenseBackFlat N a c W dy = Proofs.Mat.flatten fun (i : Fin N) => W.mulVec (Proofs.Mat.unflatten dy i)
Instances For
ViT patch-embedding input-VJP (flattened) — the proven patchEmbedInputGradFormula
(Attention.lean), i.e. patchEmbedFlatHasVJP.backward: the strided patchify conv's input-VJP
on the patch-token rows of the cotangent. The CLS row and the position-add (a +constant)
contribute nothing.
Instances For
ViT patch-embedding weight-grad (flattened) — TokenParamGrad's patchEmbedWeightGrad,
flattened (that file is downstream of this one; the tie is
patchEmbed_weight_sgd_certified). The non-overlapping 16×16/s16 patchify conv's weight-VJP:
dW_(d,c,kh,kw) = Σ_patches (patch pixel read)·dy_(patch.succ, d) — token 0 is the CLS row
(excluded); the pixel read mirrors patchEmbedFlat's, and dy (finProdFinEquiv (p.succ, d))
mirrors patchEmbedBackFlat.
Equations
- One or more equations did not get rendered due to their size.
Instances For
ViT patch embedding at bf16 operands (flattened) — patchEmbedFlat's body with the three
roundings the emit actually performs, and nothing else.
The placement of each rnd is the whole content of this definition, so read it against
the emitted text rather than against the f32 peer:
rnd (W_conv …)andrnd (img …)are the two operand casts — thestablehlo.converts that make the convolution's inputsbf16.- the outer
rndon the patch sum is the bf16 STORE: the convolution is emitted with abf16-TYPED result, so the hardware accumulates the MAC in f32 and rounds on the way out. Dropping it would claim more precision than the hardware delivers — the unsound direction. b_conv,cls_tokenandpos_embedare added outside every rounding, because the emit adds them after the convert-back, in f32. They are f32 parameters that never reach a tensor core.
The CLS row (n = 0) carries no convolution at all, so no rounding touches it — which is why
the if is INSIDE the roundings' scope rather than outside it.
Equations
- One or more equations did not get rendered due to their size.
Instances For
CLS slice (flattened) — gather row 0 of the [N+1,D] flat (= the proven
clsTokenFlat, Attention.lean; tie is rfl in ViTFwdGraph).
Equations
- Proofs.StableHLO.clsSliceFlat N D v k = v (finProdFinEquiv (0, k))
Instances For
CLS pad (flattened) — scatter dy to row 0, zeros elsewhere (= the proven
clsTokenFlatHasVJP.backward; tie is rfl in ViTFwdGraph).
Equations
- Proofs.StableHLO.clsPadFlat N D dy idx = if (finProdFinEquiv.symm idx).1 = 0 then dy (finProdFinEquiv.symm idx).2 else 0
Instances For
Per-head column slice (flattened) — head h's [N,d] block of the
[N,heads·d] flat: the finProdFinEquiv (h, ·) column gather mhsaLayer
uses to feed each head's SDPA.
Equations
- Proofs.StableHLO.headSliceFlat N heads d h v = Proofs.Mat.flatten fun (r : Fin N) (j : Fin d) => Proofs.Mat.unflatten v r (finProdFinEquiv (h, j))
Instances For
Per-head column pad (flattened) — scatter an [N,d] head block into head
h's columns of a zero [N,heads·d]. mhsaLayer's concat is the sum of
these over heads; it is also headSliceFlat's VJP.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Row-broadcast scale (flattened) — every token row elementwise-scaled by the
shared γ : Vec n (= rowwise layerScale γ).
Equations
- Proofs.StableHLO.rowScaleFlat m n γ v = Proofs.Mat.flatten fun (r : Fin m) => Proofs.layerScale γ (Proofs.Mat.unflatten v r)
Instances For
Row-broadcast bias (flattened) — + β on every token row.
Equations
- Proofs.StableHLO.rowBiasFlat m n β v = Proofs.Mat.flatten fun (r : Fin m) (k : Fin n) => Proofs.Mat.unflatten v r k + β k
Instances For
Channel index of a flat c·h·w position (the repo's left-assoc
finProdFinEquiv convention: k ↔ ((chan, row), col)). Used to expand a
per-channel parameter (Vec c) to the flat per-element map.
Equations
- Proofs.StableHLO.chanIdx c h w k = (finProdFinEquiv.symm (finProdFinEquiv.symm k).1).1
Instances For
The proven per-example forward of a BatchableOp — exactly the existing
batch-1 op (flatConv/depthwiseFlat/dense/globalAvgPoolFlat/seBlockFull/…).
SHlo.batchOp's den is batchMap N (denOp op).
Equations
- One or more equations did not get rendered due to their size.
- Proofs.StableHLO.denOp (Proofs.StableHLO.BatchableOp.conv wName bName W bias) = Proofs.flatConv W bias
- Proofs.StableHLO.denOp (Proofs.StableHLO.BatchableOp.convStrided wName bName W bias) = Proofs.flatConvStride2 W bias
- Proofs.StableHLO.denOp (Proofs.StableHLO.BatchableOp.convStridedXla wName bName W bias) = Proofs.flatConvStride2Xla W bias
- Proofs.StableHLO.denOp (Proofs.StableHLO.BatchableOp.depthwise wName bName W bias) = Proofs.depthwiseFlat W bias
- Proofs.StableHLO.denOp (Proofs.StableHLO.BatchableOp.depthwiseStrided wName bName W bias) = Proofs.depthwiseStride2Flat W bias
- Proofs.StableHLO.denOp (Proofs.StableHLO.BatchableOp.depthwiseStridedXla wName bName W bias) = Proofs.depthwiseStride2FlatXla W bias
- Proofs.StableHLO.denOp (Proofs.StableHLO.BatchableOp.dense wName bName W bias) = Proofs.dense W bias
- Proofs.StableHLO.denOp Proofs.StableHLO.BatchableOp.gap = Proofs.globalAvgPoolFlat x✝ h w
- Proofs.StableHLO.denOp (Proofs.StableHLO.BatchableOp.seBlock w1Name b1Name w2Name b2Name W₁ b₁ W₂ b₂) = Proofs.seBlockFull W₁ b₁ W₂ b₂
- Proofs.StableHLO.denOp (Proofs.StableHLO.BatchableOp.bnEval gName bName muName varName epsStr ε γ β μ var) = Proofs.bnPerChannelEvalTensor3 oc h w ε γ β μ var
- Proofs.StableHLO.denOp Proofs.StableHLO.BatchableOp.swish = Proofs.swish x✝
- Proofs.StableHLO.denOp Proofs.StableHLO.BatchableOp.relu = Proofs.relu x✝
- Proofs.StableHLO.denOp Proofs.StableHLO.BatchableOp.relu6 = Proofs.relu6 x✝
- Proofs.StableHLO.denOp Proofs.StableHLO.BatchableOp.maxPool = Proofs.maxPoolFlat c h w
- Proofs.StableHLO.denOp Proofs.StableHLO.BatchableOp.maxPool3s2 = Proofs.maxPool3s2Flat c h w
- Proofs.StableHLO.denOp Proofs.StableHLO.BatchableOp.softmaxRow = Proofs.StableHLO.rowSoftmaxFlat m n
- Proofs.StableHLO.denOp (Proofs.StableHLO.BatchableOp.denseRowBack wName W) = Proofs.StableHLO.rowDenseBackFlat rows a c W
- Proofs.StableHLO.denOp Proofs.StableHLO.BatchableOp.gelu = Proofs.gelu x✝
- Proofs.StableHLO.denOp Proofs.StableHLO.BatchableOp.transpose = Proofs.StableHLO.transposeFlat m n
- Proofs.StableHLO.denOp (Proofs.StableHLO.BatchableOp.convStride4 wName bName W bias) = Proofs.flatConvStride4 W bias
- Proofs.StableHLO.denOp (Proofs.StableHLO.BatchableOp.dotOut wName W) = fun (v : Proofs.Vec x✝¹) (i : Fin x✝) => ∑ j : Fin x✝¹, W i j * v j
- Proofs.StableHLO.denOp Proofs.StableHLO.BatchableOp.expe = fun (v : Proofs.Vec x✝) (j : Fin x✝) => Real.exp (v j)
- Proofs.StableHLO.denOp Proofs.StableHLO.BatchableOp.softmaxDiv = fun (v : Proofs.Vec x✝) (j : Fin x✝) => v j / ∑ k : Fin x✝, v k
- Proofs.StableHLO.denOp (Proofs.StableHLO.BatchableOp.lnRow gName bName epsStr ε γ β) = Proofs.StableHLO.rowLNFlat m n ε γ β
- Proofs.StableHLO.denOp (Proofs.StableHLO.BatchableOp.rowScale gName γ) = Proofs.StableHLO.rowScaleFlat m n γ
- Proofs.StableHLO.denOp (Proofs.StableHLO.BatchableOp.rowBias bName β) = Proofs.StableHLO.rowBiasFlat m n β
- Proofs.StableHLO.denOp (Proofs.StableHLO.BatchableOp.denseRow wName bName W b) = Proofs.StableHLO.rowDenseFlat N a c W b
- Proofs.StableHLO.denOp (Proofs.StableHLO.BatchableOp.patchEmbed wName bName clsName posName Wc bc cls pos) = Proofs.patchEmbedFlat ic H W P N D Wc bc cls pos
- Proofs.StableHLO.denOp (Proofs.StableHLO.BatchableOp.patchEmbedBf16 rnd wName bName clsName posName Wc bc cls pos) = Proofs.StableHLO.patchEmbedFlatBf16 rnd ic H W P N D Wc bc cls pos
- Proofs.StableHLO.denOp Proofs.StableHLO.BatchableOp.clsSlice = Proofs.StableHLO.clsSliceFlat N x✝
- Proofs.StableHLO.denOp Proofs.StableHLO.BatchableOp.clsPad = Proofs.StableHLO.clsPadFlat N x✝
- Proofs.StableHLO.denOp (Proofs.StableHLO.BatchableOp.headSlice h) = Proofs.StableHLO.headSliceFlat N heads d h
- Proofs.StableHLO.denOp (Proofs.StableHLO.BatchableOp.headPad h) = Proofs.StableHLO.headPadFlat N heads d h
Instances For
Which BatchNorm a batched forward chain emits, for the renders whose one traversal produces both the training forward and its frozen-stats eval partner (EfficientNet, MobileNetV4).
The distinction is not cosmetic: a .train chain reduces its statistics out of the activation
(bnBatchF, which couples the batch), a .eval chain consumes frozen per-channel running stats
as graph inputs (the bnEval descriptor, which does not). A net trained on one and scored
with the other is evaluating a different function.
- train : BnMode
Training: batch statistics reduced out of the activation (
bnBatchF, reduce[0,2,3], n = B·H·W). What the train step differentiates. - eval : BnMode
Inference: frozen per-channel running stats arriving as graph inputs
%{p}mu/%{p}var(thebnEvaldescriptor). Class-batch-independent.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
AST denotation ⟦·⟧ₐ — our reading of each StableHLO op's spec, over ℝ, in primitive
terms — independent of dense/Mat.mulVec. The per-example constructors denote one example;
batchOp and the *B/*GradB/bnBatchF constructors denote at the batched index N·n
(the batch-statistic and gradient-sum arms couple the batch); allReduceMeanF denotes the
mean over its R replica children. SSA names are ignored.
Instances For
What simp only should name instead of den. Naming den itself makes Lean build
den.eq_def — about four minutes for the 215-arm match, on the critical path of this module
and anything that first asks for it. denStepApp is the same step where den e is applied
to an index, which simp does not visit as den e.
Equations
- Proofs.StableHLO.denStep e = do let __x ← liftM (Proofs.StableHLO.denUnfold? e) match __x with | some e' => pure (Lean.TransformStep.visit e') | x => pure Lean.TransformStep.continue
Instances For
denStep where den e is applied to an index.
Equations
- Proofs.StableHLO.denStepApp e = do let __x ← liftM (Proofs.StableHLO.denUnfold? e) match __x with | some e' => pure (Lean.TransformStep.visit e') | x => pure Lean.TransformStep.continue
Instances For
The mixed-precision matmul denotes the EXACT sum over ROUNDED operands. The fp32
accumulate is why the ∑ carries no rounding of its own — the whole deviation from
dotIn sits in the two rnds, which is the structural reason bf16 is the easy twin
of fp8 (no block scale to factor through the sum).
The bundling is inert. dotInBf16 on raw operands denotes exactly what dotIn
denotes on PRE-rounded ones — so every tie already proven in the dotIn vocabulary
(e.g. Bf16PoC.bf16_render_faithful) transfers to the emittable node by rewriting
with this, rather than being reproved.
The round node is den-faithful for any rounding. This is the equation
Proofs/Float/Bf16Fold.lean asks for by name to lift its depth-1 tie to
depth > 1: rounding an intermediate activation is now an in-graph op whose
denotation is exactly post-composition with rnd. No bf16 specifics appear here —
bf16 round-to-nearest is one instance, and the accuracy half is supplied separately
by dense_close_mixed at u_leaf = 2⁻⁸.
A batched token denotes its per-example op, lifted. den (.batchOp op e) is batchMap N of
denOp op, the proven per-example map, by rfl; simp only [den_batchOp, denOp] reads a
batched graph's denotation off denOp's arms. skel erases values, so a descriptor with the
wrong denOp emits identical bytes: this equation is the half the emit ties cannot see. The
true-batch-norm token is not a descriptor; it denotes bnBatchLA (den_bnBatchF).
The descriptor form of swish denotes exactly what the descriptor-less swishF denoted at the
same index — the batched graph computes the same function, only the emit width now travels
separately from the batch.
The softmax denominator is PER EXAMPLE — the property this descriptor exists for. Example
k's output divides by example k's own sum, not by the sum over the whole batch.
This is the half the emit tie structurally cannot see. .softmaxDiv's emitted MLIR was
already per-example (it reduces over dimensions = [1] of tensor<B,n>), so the batched and
per-example forms render byte-for-byte identically and always would — while the descriptor-less
den at index N·n reads v j / ∑ k, v k over ALL N·n coordinates, i.e. it divides by the
batch's total. Same bytes, different function, and only this statement separates them.
THE CLS SLICE IS THE ONE PLACE THE BATCH AND THE TOKEN AXIS COULD SWAP SILENTLY.
clsSlice takes (tk+1)*D to D — it CONTRACTS — and batchMap N of it takes N*((tk+1)*D)
to N*D. A render that read the batch as the token axis would take (N+1)*D to D, i.e. drop
every example but one and still type-check at N = tk. Stated so the two indices are pinned
apart by a theorem rather than by a naming convention.
At R = 1 the two-round statistics subgraph is [μ ‖ σ²] of the batch itself: the
replica's own mean, and its own two-pass variance with a zero offset.
THE DROP-IN, on actual graph nodes: at R = 1 the sync-BN subgraph denotes
bnBatchTensor4.
The Foundation anchors say the sync forward at its own statistics is the batch forward; this
says the GRAPH a sync render emits — bnSyncF fed by bnPackB of the two one-replica
collectives (μ, then σ² at μ) — is that, once R = 1 collapses every collective to its
single operand.
So a single-device sync render computes exactly what today's bnBatchF render computes, and
the R = 1 artifacts need not move. The R > 1 case is then purely a question about how
shard statistics compose (bnMean_shard / bnVar_shard_chan), with BatchNorm itself already
accounted for here.
THE DROP-IN, backward half: at R = 1 the sync-BN backward subgraph denotes
bnBatchTensor4GradInput.
The peer of den_bnSyncF_allReduce_R1. The graph is the one a sync render emits — an outer
allReduceMeanF over bnSyncDyStatsB, itself fed by the packed forward statistics — and at
R = 1 every collective collapses to its single operand, leaving the committed three-term
backward. hx ties the saved host activation to the graph value it came from, which is the
renderer's own invariant.
THE DROP-IN, γ half: at R = 1 the sync γ-gradient node denotes bnGammaGradB.
The third anchor beside den_bnSyncF_allReduce_R1 / den_bnSyncBack_allReduce_R1: fed the
collapsed collectives, the sync γ node reads the batch's own statistics and is the committed
γ gradient.
R = 1: the handed-back sync mean IS bnBatchMeanB.
R = 1: the handed-back sync variance IS bnBatchVarB — the batch's own two-pass
variance, offset zero.
The two-level contraction is real, and this is what would have been silently lost. At
N = 1 the batched bias gradient collapses to its per-example peer — so a render that dropped
the batch sum type-checks, emits the same bytes and agrees on a one-example batch. The gate
that catches it has to run at N > 1, which is why the emit tie alone is not enough here.
lnRowBackB hands each example its OWN saved activation — the property that forced it to be
a constructor rather than a descriptor, stated so it can be cited instead of re-argued. Example
k's output block is the per-example backward applied to batchSlice k x, never to the whole
x and never to example 0's. A descriptor would give the latter, silently: same types, same
emitted bytes, different function.
sigmoidB denotes Proofs.sigmoid at the batched index — rfl, the same function
sigmoidF_faithful states one index down. This is BCE-with-logits' only new op.
ViT increment 2 — the six forms that cannot be descriptors #
ATTENTION'S MATMUL IS PER-EXAMPLE IN BOTH OPERANDS, which is the property the whole
matmulF scoping worry was about. Example k's output is Qₖ·Kₖᵀ — its own Q against its
own K — never Q₀ against Kₖ, and never the whole batch flattened into one big matrix.
All three of those type-check. At the batched index N*(m*k), a den that read the
index as one matrix would compute matMulFlat at the wrong m and still be a Vec; a
descriptor would hand every example operand 0's left factor. What separates them is this
statement, and the emit tie cannot make it — the emitted dot_general carries
batching_dims = [0] x [0] in every one of those worlds.
Each example's softmax backward recomputes from ITS OWN saved scores. The descriptor
version would hand all N example 0's — same types, same bytes, different function.
lnRowBackB's statement, on attention.
THE BATCH SUM IS INVISIBLE AT N = 1. At one example the outer ∑ b has a single term,
so a render that dropped it type-checks, emits the same bytes and agrees exactly — which is why
any gate on these four must run at N > 1. den_rowDenseBiasGradB_at_one says the same thing
for ConvNeXt's bias gradient; this is ViT's positional embedding, where the shared parameter is
the whole (tk+1) × D table.
Forward logits graph @linear_fwd: broadcast(b) + dot_general(x, W).
Equations
- Proofs.StableHLO.fwdGraph W b x = Proofs.StableHLO.SHlo.addBcast "%b0" b (Proofs.StableHLO.SHlo.dotIn "%W0" W (Proofs.StableHLO.SHlo.operand "%x" x))
Instances For
Dense input-VJP graph (@linear_back): dot_general(dy, W).
Equations
- Proofs.StableHLO.backGraph W dy = Proofs.StableHLO.SHlo.dotOut "%W0" W (Proofs.StableHLO.SHlo.operand "%dy" dy)
Instances For
Softmax-CE loss-cotangent graph softmax(logits) − onehot. The one-hot is
a parameter (a graph input %onehot); den reads it, pretty ignores it.
Equations
- Proofs.StableHLO.lossCotGraph W b x oh = (Proofs.StableHLO.fwdGraph W b x).expe.softmaxDiv.sub (Proofs.StableHLO.SHlo.operand "%onehot" oh)
Instances For
Forward faithfulness. The forward graph denotes mnistLinear W b.
The softmax sub-graph denotes the proven softmax.
Loss-cotangent faithfulness (to the proven gradient). Via
IR.lossCot_bridge: the cotangent graph denotes ∂(crossEntropy)/∂logits
at the linear logits.
Weight-gradient (per-example): the batch-contracting dot_general, i.e.
the outer product x ⊗ dy.
Equations
- Proofs.StableHLO.wGrad x dy = Proofs.Mat.outer x dy
Instances For
Bias-gradient (per-example): the batch reduce-add is the cotangent.
Equations
- Proofs.StableHLO.bGrad dy = dy
Instances For
The emitted weight SGD update W − lr·(x⊗dy), with dy the proven
softmax-CE cotangent.
Equations
- Proofs.StableHLO.sgdW W b x lr label i j = W i j - lr * Proofs.StableHLO.wGrad x (Proofs.StableHLO.den (Proofs.StableHLO.lossCotGraph W b x (Proofs.oneHot n label))) i j
Instances For
The emitted bias SGD update b − lr·dy.
Equations
- Proofs.StableHLO.sgdB W b x lr label j = b j - lr * Proofs.StableHLO.bGrad (Proofs.StableHLO.den (Proofs.StableHLO.lossCotGraph W b x (Proofs.oneHot n label))) j
Instances For
SGD weight-step faithfulness. The emitted update subtracts lr times
the certified ∂/∂W Jacobian contracted with the proven loss cotangent —
plain-SGD optimizer promoted from trusted to proven.
The relu descriptor denotes exactly what the descriptor-less reluF denoted at the same
index: the batched graph computes the same function, only the emit width now travels
separately from the batch. The ResNet-34 peer of den_batchOp_swish_eq_swishF.
Batched ReLU backward faithfulness. selectPosB denotes the same proven
reluHasVJPAt backward as selectPos, now over the whole batch — which is what the
emitted xName holds. This is the statement that would be FALSE had selectPos been made
a BatchableOp descriptor (that den would apply one example's mask to all N).
ReLU6 backward faithfulness (smooth point). select(0<x<6,·,0) denotes the
proven relu6HasVJPAt backward — the two-sided kink's mask, smooth iff
x≠0 ∧ x≠6 (both bounds, unlike ReLU's one-sided x≠0).
Batched ReLU6 forward faithfulness. The relu6 descriptor at the batched index
denotes exactly relu6F's per-example clamp applied across the batch — the MobileNetV2 peer
of den_batchOp_relu_eq_reluF. This is the statement that keeps the emit width off the SHlo
index: at N := B the descriptor emits tensor<B×n>, not tensor<B×(N·n)>.
Batched ReLU6 backward faithfulness. selectMidB denotes the same proven
relu6HasVJPAt backward as selectMid, now over the whole batch — which is what the
emitted xName holds. FALSE had selectMid been made a BatchableOp descriptor beside
relu6 (that den would apply one example's two-sided mask to all N). Note the smoothness
hypothesis is TWO-sided (x ≠ 0 ∧ x ≠ 6), unlike selectPosB_faithful's x ≠ 0.
Stochastic-depth forward faithfulness. dropPathB denotes Proofs.dropPath, the per-sample
residual-branch scale. rfl, because dropPath is layerScale at a per-example-broadcast
scale and this op is that multiply.
Stochastic-depth BACKWARD faithfulness — and it is the SAME constructor. A diagonal
linear map is its own transpose, so the renderer emits dropPathB on the cotangent at the same
scale, and that IS the certified VJP. No *Grad peer exists to drift out of step with this one,
which is the whole reason this feature costs one op rather than two.
Classifier-dropout forward faithfulness. dropoutB denotes Proofs.dropout, the
per-ELEMENT inverted mask. rfl, because dropout is layerScale at a mask of the value's own
type — no lift, which is what makes it cheaper than dropPathB rather than dearer.
Classifier-dropout BACKWARD faithfulness — the SAME constructor, dropPathB_back_faithful
one mask rank up. This covers the cotangent flowing THROUGH the site and nothing else; see
Proofs.dropout_vjp_is_self on the classifier weight gradient, which reads the dense's input
and must therefore read the DROPPED activation.
The ones-mask identity on the AST, which is what licenses emitting the dropout site in
the FORWARD artifact: @efficientnet_do_fwd and @efficientnet_adamdo_train_step are then one
graph differing only in the mask the driver supplies, and the prefix audit survives.
THE TWO OPS AGREE EXACTLY WHEN THE MASK IS LIFTED, AND THE AST SAYS SO.
Proofs.dropout_of_dropScale at the node level: a dropoutB carrying dropScale N n s denotes
what the dropPathB at s denotes. This is the substitution that would be a silent regulariser
swap if it were made in the other direction on an unlifted mask, and it is stated here so that
the containment is checkable rather than argued.
A dense forward layer graph: broadcast(bias) + dot_general(·, W).
Equations
- Proofs.StableHLO.denseF wN bN W bias e = Proofs.StableHLO.SHlo.addBcast bN bias (Proofs.StableHLO.SHlo.dotIn wN W e)
Instances For
bf16 conv forward faithfulness. The bf16 stablehlo.convolution op denotes the
proven flatConv on ROUNDED operands, with the accumulated sum rounded and the bias
added afterwards in f32 — i.e. exactly what the emitted graph computes.
Contrast flatConvF_faithful, which has no rounding, and dotInBf16, which rounds
the operands but NOT the result. The outer rnd here is not decoration: the emit gives
the convolution a bf16-typed result, so the hardware stores the accumulator rounded.
The bundling is inert at the identity rounding. At rnd = id the bf16 op denotes
exactly what flatConvF does. The dotInBf16_eq_dotIn_rounded analogue: it says the op
adds ROUNDING and nothing else — no reassociation, no dropped bias, no moved padding.
Without it, "the emit is bf16" and "the emit is the same conv" are two separate hopes.
Conv backward faithfulness. The reversed-kernel stablehlo.convolution
(transpose+reverse+conv) denotes the proven conv input-VJP — the flattened
conv2dHasVJP3 backward (conv is linear, so this is a global VJP).
Max-pool backward faithfulness (smooth point). The emitted
select_and_scatter graph denotes the proven maxPoolFlatHasVJPAt
backward — routing the cotangent to each window's argmax (the codegen's
no-ties convention), under the MaxPool smoothness hypothesis.
3×3/s2 max-pool backward faithfulness (smooth point). The emitted select_and_scatter
graph at window 3 / stride 2 / symmetric padding 1 denotes the proven
maxPool3s2FlatHasVJPAt backward, under MaxPool3s2Smooth.
The hypothesis is stated over positions, not window offsets, and that is not a stylistic
difference from maxPoolBack_faithful: with overlapping windows two offsets can name one input
cell (the clamped duplicate at the first window), where the values are equal by construction
and smoothness must say nothing. maxPool2 has no analogue because there distinct offsets
always meant distinct positions. See MaxPool3s2.lean's header.
BN forward faithfulness. The per-example reduce/normalize/affine graph
(γ·(x−μ)·istd + β, μ/var over the feature axis) denotes the proven
bnForward (BatchNorm.lean).
Residual-add faithfulness (= den_addV). The binary stablehlo.add
denotes pointwise vector addition — the fan-in of a residual/skip
connection. (rfl, so kept out of the axiom audit.)
Strided-conv forward faithfulness. The window_strides=[2,2]
stablehlo.convolution denotes the proven flatConvStride2
(= decimate ∘ stride-1 conv, StridedConv.lean).
The XLA-SAME peer's faithfulness. flatConvStride2Xla, NOT flatConvStride2 — identical
types, so this rfl is the only place the distinction is recorded.
Strided-conv input-VJP faithfulness. The zero-upsample (lhs_dilation)
- reversed-kernel conv denotes the proven
flatConvStride2HasVJPbackward.
Stride-4 conv forward faithfulness. The window_strides=[4,4]
stablehlo.convolution (the ConvNeXt 4×4/s4 patchify stem) denotes the proven
flatConvStride4 (= decimate ∘ decimate ∘ stride-1 conv, StridedConv.lean).
BN backward faithfulness. The consolidated three-term graph denotes the
proven BN input-VJP — equal to the pdiv-contracted Jacobian of bnForward
(bn_input_grad_correct), under 0 < ε. β-independent (a constant shift
does not enter the Jacobian).
Per-channel BN forward faithfulness. The 4-D reshape + per-channel
reduce/normalize (μ/var over the spatial axes [2,3], rank-1 γ/β dims=[1])
denotes the proven bnPerChannelTensor3 (PerChannelBN.lean). (rfl: den's arm is this function by definition.)
Dense weight-gradient faithfulness — the outer product xᵢ·dyⱼ.
The gradient ops agree with the SGD ops they were split out of. Each says
den (θSgd …) = θ − lr · den (θGrad …) coordinatewise — so un-fusing the update did not
quietly change the gradient, and anything already proven about a *Sgd output transfers to
θ − lr·(*Grad). All rfl: the *Grad den is literally the subterm.
The TRANSFORMER peers of the same statement — the ViT family's un-fused gradients, which the
certified vit_adam_train_step render uses. Same rfl discipline.
The depthwise BIAS gradients (MobileNetV2) #
MobileNetV2RenderB is AdamW-only, like ResNet34RenderB — mnv2's SGD render stays at the
per-example index, so there is deliberately no fused depthwise{,Strided}BiasSgdB peer and hence
no *SgdB_eq_grad statement to make. What pins these two ops instead is that den IS the
shared-parameter batch sum of the proven per-example depthwise bias VJP, which is what the emitted
reduce … [0, 2, 3] computes. The emit side is covered separately by the byte-PREFIX case in
tests/TestBatchedEmitTie.lean against the per-example fused depthwiseBiasSgd.
The ConvNeXt five — same statement, the last *Sgd/*Grad pairs the kit was missing #
den (xSgd …) = θ − lr · den (xGrad …), all rfl. Together with the emit-side byte-PREFIX checks
in tests/TestBatchedEmitTie.lean this is what lets convnext_adam_train_step hand its gradients
to adamWParamF instead of to the SGD tail — the fusion was the blocker, never Adam.
Stride-4 weight-gradient faithfulness (ConvNeXt's patchify stem). den IS the proven
flatConvStride4WeightGradHasVJP backward. There is no fused convStride4WeightSgd peer —
nothing but ConvNeXt's stem is stride-4, and its AdamW render consumes the un-fused gradient
directly — so this, not a *Sgd_eq_grad statement, is what pins the op's den.
den (xSgdB …) = θ − lr · den (xGradB …) — the BATCHED peers of the *Sgd_eq_grad set #
All rfl, and all carrying the same content as the per-example *Sgd_eq_grad set: the fused
*SgdB op IS θ − lr· applied to the un-fused gradient, so handing the gradient to AdamW instead
of to the SGD tail changes nothing about what is computed. The batched AdamW renders
(resnet34_adam_train_step, …) rely on this.
AdamW parameter-step faithfulness. The node's denotation is Proofs.adamWParam of the
child's gradient (by definition of den), so ties stated over den can use it; the 26-op
text emitTok prints for it is trusted, like every op's. Well-definedness of the √v̂ + ε denominator is
Proofs.adam_denom_pos; there is deliberately no descent claim, because Adam is not a
monotone descent method (AMSGrad counterexample).
The rendered AdamW triple is Proofs.adamWStep. Bundles the three ops into the
(θ', m', v') a train step returns per parameter — the whole optimizer, denoted.
Rendered plain SGD is Proofs.sgdParam — θ − lr·g with lr a runtime arg.
Rendered Nesterov velocity is Proofs.momVNext — v' = μ·v + g.
Rendered Nesterov update is Proofs.momParam — θ' = θ − lr·(g + μ·v').
The rendered Nesterov pair is Proofs.momStep. The momentum analogue of
adamW_triple_faithful: the (θ', v') a momentum train step returns per parameter, denoted.
The m slot is a passthrough and so appears nowhere here — that is the packed-[θ|m|v]
signature being shared verbatim with the AdamW render, not an omission.
μ = 0 makes the rendered Nesterov update the rendered SGD update. Ties the two new op
families to each other at the denotation level, so the mom and sgd renders provably agree
in the limit rather than merely looking similar.
Rendered RMSProp buffer is Proofs.rmsBufNext — b' = μ·b + g/√(ρ·s + (1−ρ)·g² + ε),
TensorFlow's ε placement.
The rendered RMSProp triple is Proofs.rmsPropStep. The RMSProp analogue of
adamW_triple_faithful / mom_pair_faithful: (θ', b', s') as the three ops the render
actually emits, denoted together.
Read the composition off this statement — it is the whole "one new op" claim, checked:
the parameter slot is sgdParamF applied to this op's SSA output (.operand, so the buffer
is emitted once and threaded, since pretty has no CSE), and the mean-square slot is the EXISTING
adamVNextF at β₂ := ρ. Only rmsBufNextF is new.
The mean-square slot really is the Adam op. adamVNextF at β₂ := ρ denotes RMSProp's
s', so reusing it is licensed rather than assumed — the emit-side twin of
Proofs.rmsSqNext_eq_adamVNext, and the reason this optimizer cost ONE op and not three.
μ = 0 makes the rendered RMSProp buffer the bare normalised gradient. The mu_zero
bridge momParamF_mu_zero provides for Nesterov, at the denotation level.
The scalar fold is Proofs.gradSumSq accumulated — acc + ∑ᵢ gᵢ² for one parameter,
reduced to a rank-0 scalar. SHlo 1 denoting a rank-0 tensor<f32> is lnBetaGrad's
established reading, not a new convention.
This op is what makes the global reduction an ordinary SHlo TREE. The norm reads like a
shared DAG node — one scalar consumed by 200 sites — and SHlo is a tree; the resolution is
that SHlo is single-OUTPUT, not single-INPUT, so folding 200 subtrees into one scalar is just
a left-nested chain of this constructor, seeded at %zero. Nothing is recomputed, because every
gradient it consumes is already an .operand leaf.
lambDirF denotes Proofs.lambDir — rfl, i.e. the rendered LAMB direction IS the ℝ
definition, structurally. Same bar as adamWParamF_faithful.
lambScaleF denotes Proofs.lambScale. The trust ratio is computed from THIS tensor's
own norm, which is what makes it layer-wise; clipScaleF's factor is shared across every
parameter. The two ops look alike and differ in exactly that quantifier.
The rescale is Proofs.clipScale at Proofs.clipFactor of the summed total — the
reference's g * jnp.minimum(1.0, CLIP / (gn + 1e-6)) with gn = sqrt(total).
The factor is derived from the op's FIRST CHILD, the already-summed global total, so this
constructor cannot express a per-parameter clip: it never receives enough to compute one. The
c/ε ℝ fields pair with clipStr/epsStr exactly as bnF's ε/epsStr do.
The factor is recomputed at every site rather than emitted once and threaded, for
adamWParamF's reason — SHlo is single-result, so each output is its own node, and XLA's CSE
folds the duplicates.
THE WHOLE CLIP, END TO END, FOR TWO PARAMETERS — this is the transcription check.
Read the reference's two lines off the right-hand side: gn = √(Σ_leaves Σ g²) folded from
%zero, then g * min(1, CLIP/(gn + 1e-6)). Stated at TWO parameters because one cannot
exhibit the property that matters — see clipShared_faithful. Holds by rfl.
Below the threshold the rendered clip is the EXACT identity, so a clip-on render at a large
c must agree with the clip-off render on every byte (x * 1.0 is exact in binary32). The
emit-side reading of Proofs.clipGrad_id_below, and the licence for clip-tie's gate 3.
It is also why gate 3 alone is not evidence: at factor 1 a per-parameter clip and a global one
are the SAME FUNCTION, so an identity gate cannot see which was rendered.
Inference per-channel BN forward faithfulness. The 4-D reshape + affine
γ·(x−μ)·rsqrt(var+ε)+β with rank-1 μ/var/γ/β (dims=[1]) denotes the proven
bnPerChannelEvalTensor3 (PerChannelBN.lean). (rfl, so kept out of the axiom audit.)
Per-channel BN backward faithfulness. The block-diagonal three-term graph
(per-channel, reducing over the spatial axes) denotes the proven per-channel BN
input-VJP — equal to the pdiv-contracted (block-diagonal) Jacobian of
bnPerChannelTensor3 (bnPerChannelTensor3GradInput_correct), under 0 < ε.
Depthwise-conv forward faithfulness. The feature_group_count = c
stablehlo.convolution (with a [c,1,kH,kW] kernel, one filter per channel)
denotes the proven depthwiseFlat (= flatten ∘ depthwiseConv2d ∘ unflatten,
Depthwise.lean). (rfl: den's arm is this function by definition.)
Depthwise-conv input-VJP faithfulness. The reversed-kernel depthwise
stablehlo.convolution (reverse the per-channel filters over the spatial axes
[2,3]; the channel groups are 1×1 so no o↔i transpose, same
feature_group_count = c) denotes the proven depthwiseFlatHasVJP backward
(depthwise is linear, so this is a global VJP).
Strided-depthwise forward faithfulness. The window_strides=[2,2],
feature_group_count = c stablehlo.convolution denotes the proven
depthwiseStride2Flat (= decimate ∘ stride-1 depthwise, Depthwise.lean).
Strided-depthwise input-VJP faithfulness. The zero-upsample (stablehlo.pad
interior=1) + reversed-kernel stride-1 depthwise denotes the proven
depthwiseStride2FlatHasVJP backward.
Swish input-VJP faithfulness. The closed-form dy ⊙ σ(x)·(1 + x·(1−σ(x)))
graph (recomputing σ from the saved pre-activation x) denotes the proven GLOBAL
swishHasVJP backward (dy ⊙ swishScalarDeriv x; swish is smooth everywhere, so
this is a global VJP — no smoothness hypothesis).
Sigmoid input-VJP faithfulness. The closed-form dy ⊙ σ(x)·(1−σ(x)) graph
(recomputing σ from the saved pre-activation x) denotes the proven GLOBAL
sigmoidHasVJP backward (dy ⊙ sigmoidScalarDeriv x; sigmoid is smooth
everywhere, so this is a global VJP — no smoothness hypothesis).
Per-channel layer-scale faithfulness. The [c]-broadcast multiply denotes
the proven layerScale at the channel-expanded vector. (rfl.)
GELU input-VJP faithfulness. The closed-form dy ⊙ gelu'(x) graph
(recomputing tanh(u(x)) from the saved pre-activation x) denotes the proven
GLOBAL geluHasVJP backward (dy ⊙ geluScalarDeriv x; GELU is smooth
everywhere, so this is a global VJP — no smoothness hypothesis).
Row-softmax forward faithfulness. The per-row exp / reduce[last] / divide
graph denotes rowSoftmaxFlat (= flattened rowSoftmax, Attention.lean). Plain
exp/sum, no max-shift (matches the proven softmax). Smooth everywhere.
(rfl: den's arm is this function by definition.)
Row-softmax input-VJP faithfulness. The per-row closed-form
p ⊙ (dy − ⟨p,dy⟩) graph (recomputing p from the saved pre-softmax scores)
denotes rowSoftmaxBackFlat (= flattened rowSoftmaxHasVJPMat.backward).
Softmax is smooth, so this is a global VJP — no smoothness hypothesis.
Matrix-multiply faithfulness. The reshape + batching-dim-0 dot_general
(contracting [2] x [1]) + reshape graph denotes matMulFlat (= the flattened
Mat.mul). Bilinear; the attention backwards reuse this token (dA = dC·Bᵀ,
dB = Aᵀ·dC). (rfl: den's arm is this function by definition.)
Transpose faithfulness. stablehlo.transpose dims=[0,2,1] (after reshape
to rank 3) denotes transposeFlat (= the flattened Mat.transpose). (rfl.)
Row-LayerNorm forward faithfulness. The rank-3 reduce[2]/normalize/affine
graph (per token row, scalar γ/β) denotes rowLNFlat (rowwise bnForward =
rowwise layerNormForward, definitionally). (rfl.)
Row-LayerNorm input-VJP faithfulness. The per-row consolidated three-term
graph (recomputing x̂/istd from the saved pre-LN input, reductions over the row
axis) denotes rowLNBackFlat (rowwise bnGradInput — faithful to the
pdiv-Jacobian per row under 0 < ε, bn_input_grad_correct).
Per-token dense forward faithfulness. The dot_general [2] x [0] + bias
broadcast dims=[2] graph denotes rowDenseFlat (rowwise dense W b). (rfl.)
Per-token dense input-VJP faithfulness. The dot_general [2] x [1] graph
(dy against W's output axis) denotes rowDenseBackFlat (rowwise Mat.mulVec W
= the proven denseHasVJP backward; dense is affine — global VJP).
Patch-embedding faithfulness. The stride-P VALID conv + channels-last
flatten + CLS concatenate + position-embed add graph denotes patchEmbedFlat
(the local re-spelling of the proven patchEmbedFlat; the tie is rfl in
ViTFwdGraph). (rfl, coarse-token like seBlock.)
CLS-slice faithfulness. The row-0 stablehlo.slice denotes clsSliceFlat
(= the proven clsTokenFlat). (rfl.)
CLS-pad faithfulness. The zero-pad scatter-to-row-0 denotes clsPadFlat
(= the proven clsTokenFlatHasVJP.backward; linear — global VJP). (rfl.)
Per-head slice faithfulness. The feature-axis stablehlo.slice of head h's
contiguous column block denotes headSliceFlat (= mhsaLayer's per-head column
gather). Linear reindex. (rfl.)
Per-head pad faithfulness. The feature-axis zero-pad into head h's column
block denotes headPadFlat (the slice's VJP; summed over heads it is
mhsaLayer's concat). Linear. (rfl.)
Row-broadcast scale faithfulness. The reshape + broadcast-γ-over-rows +
multiply graph denotes rowScaleFlat (rowwise layerScale γ). Diagonal-linear —
its own input-VJP, so the backward reuses this token on the cotangent. (rfl.)
Row-broadcast bias faithfulness. The broadcast-β-over-rows + add graph denotes
rowBiasFlat. Translation — identity input-VJP. (rfl.)
The conv-bias SSA name. Every conv in ResNet-34 is immediately followed by
BatchNorm, and BN subtracts the batch mean, so in ℝ a conv bias cannot reach the BN output and
its gradient is identically zero. He et al.'s .convBn therefore carries no conv bias, and
this repo's render did — 8,512 parameters the reference does not have.
With convBias := false the bias operand becomes a zero CONSTANT rather than a function
argument: the op is the same proven flatConvF/flatConvStridedF at bias = 0, so den and
every faithfulness theorem are untouched, and x + 0.0 is exact in IEEE, so the forward is
bit-identical to the biased render fed zeros. What changes is the signature.
In f32 the gradient is NOT exactly zero — the BN mean is a rounded sum, leaving a residue of
the conv-weight gradient — and under AdamW's scale-free update that residue still moves θ. The
biases are safe to drop because the FORWARD does not depend on them, not because they stay
zero. See tests/TestConvBiasZero.lean.