The MNIST-CNN train step at batch N — CnnFold with the batch stated #
CnnFold certifies the ten parameter outputs of cnn_train_step.mlir for ONE example.
tests/TestSmallNetsBatchedEmit.lean pins that text, byte for byte, as the print of a graph at
the batched index: batchOp lifts of conv/relu/maxPool/dense/expe/softmaxDiv/
dotOut, subB, selectPosB, maxPoolBackB, the convBackP descriptor (the per-example
conv input-VJP spelling, at the batched index) and the convWeightSgdB/convBiasSgdB/
denseWeightSgdB/denseBiasSgdB nodes. This file reads every node's den at a batch of N:
- the batched forward's slices are the per-example forward (
hc1B_slice, …,logitsB_slice); - the batched loss cotangent's slices are
softmax(logitsₖ) − onehotₖ(cotB_slice); - the batched backward chain's slices are the per-example chain — the dense head's
mlpCotOut1/mlpCotOut0, thenCnnChainClose'scnnChainCotW2(relu mask over the select-and-scatter pool-back of the head cotangent) and, for odd kernels,cnnChainCotW1(relu mask over the reversed-kernel conv-back) —dhc2B_slice,dhc1B_slice; - each of the ten parameter nodes denotes
θ − lr·Σₖ (certified per-layer Jacobian at example k · that example's chain cotangent), the output weight at the whole loss (cnn_train_step_tiedB).Nis a binder; the artifact isN = 128.
Unlike CnnFold, the chain cotangents here ARE the emitted subgraphs' denotations (the pool-back
and conv-back are maxPoolBackB/convBackP nodes, not the hand-named cnnChainCot* values), so
the "cotangent SSA ↔ chain-cot per-op trust" CnnFold's Scope records is closed at the batched
index: dhc2B_slice/dhc1B_slice prove the two readings agree.
Scope #
- per-op
den⇄ MLIR text (shared with the suite); the committed-bytes tie is CI's regenerate-and-diff plus the batched-emit pin; ℝ → Float32 isFloatBridge. dhc1B_slice's identification withcnnChainCotW1needs odd kernels (hkH,hkW): the reversed-kernel conv is the conv input-VJP only there (IR.conv_back_bridge). The node theorems themselves carry no such hypothesis; the artifact's kernels are 3×3.
The SSA names the renderer threads between the pieces. Denotation-irrelevant; kept so every node is stated with the leaf names the emitted text uses.
- lrStr : String
- ac1N : String
- hc1N : String
- ac2N : String
- hc2N : String
- poolN : String
- a3N : String
- h3N : String
- a4N : String
- h4N : String
- dyN : String
- dy4N : String
- dy3N : String
- dx3N : String
- dac2N : String
- dhc2N : String
- dac1N : String
- dhc1N : String
Instances For
Per-example shorthands at example k (the forward CnnFold states, at slice k) #
Equations
- Proofs.CnnFoldB.hc1 N W₁ b₁ xB k = Proofs.flatConv W₁ b₁ (Proofs.CnnFoldB.xk N xB k)
Instances For
Equations
- Proofs.CnnFoldB.ac1 N W₁ b₁ xB k = Proofs.relu (c * (2 * h) * (2 * w)) (Proofs.CnnFoldB.hc1 N W₁ b₁ xB k)
Instances For
Equations
- Proofs.CnnFoldB.hc2 N W₁ b₁ W₂ b₂ xB k = Proofs.flatConv W₂ b₂ (Proofs.CnnFoldB.ac1 N W₁ b₁ xB k)
Instances For
Equations
- Proofs.CnnFoldB.ac2 N W₁ b₁ W₂ b₂ xB k = Proofs.relu (c * (2 * h) * (2 * w)) (Proofs.CnnFoldB.hc2 N W₁ b₁ W₂ b₂ xB k)
Instances For
Equations
- Proofs.CnnFoldB.pool N W₁ b₁ W₂ b₂ xB k = Proofs.maxPoolFlat c h w (Proofs.CnnFoldB.ac2 N W₁ b₁ W₂ b₂ xB k)
Instances For
Equations
- Proofs.CnnFoldB.h3 N W₁ b₁ W₂ b₂ W₃ b₃ xB k = Proofs.dense W₃ b₃ (Proofs.CnnFoldB.pool N W₁ b₁ W₂ b₂ xB k)
Instances For
Equations
- Proofs.CnnFoldB.h4 N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ xB k = Proofs.dense W₄ b₄ (Proofs.relu d1 (Proofs.CnnFoldB.h3 N W₁ b₁ W₂ b₂ W₃ b₃ xB k))
Instances For
Equations
- Proofs.CnnFoldB.a4 N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ xB k = Proofs.relu d1 (Proofs.CnnFoldB.h4 N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ xB k)
Instances For
The softmax-CE loss cotangent at example k.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The batched forward, nested #
Equations
- Proofs.CnnFoldB.hc1B N W₁ b₁ xB = Proofs.StableHLO.SHlo.batchOp (Proofs.StableHLO.BatchableOp.conv "%W1" "%b1" W₁ b₁) (Proofs.StableHLO.SHlo.operand "%x" xB)
Instances For
Equations
- Proofs.CnnFoldB.ac1B N W₁ b₁ xB = Proofs.StableHLO.SHlo.batchOp Proofs.StableHLO.BatchableOp.relu (Proofs.CnnFoldB.hc1B N W₁ b₁ xB)
Instances For
Equations
- Proofs.CnnFoldB.hc2B N W₁ b₁ W₂ b₂ xB = Proofs.StableHLO.SHlo.batchOp (Proofs.StableHLO.BatchableOp.conv "%W2" "%b2" W₂ b₂) (Proofs.CnnFoldB.ac1B N W₁ b₁ xB)
Instances For
Equations
- Proofs.CnnFoldB.ac2B N W₁ b₁ W₂ b₂ xB = Proofs.StableHLO.SHlo.batchOp Proofs.StableHLO.BatchableOp.relu (Proofs.CnnFoldB.hc2B N W₁ b₁ W₂ b₂ xB)
Instances For
Equations
- Proofs.CnnFoldB.poolB N W₁ b₁ W₂ b₂ xB = Proofs.StableHLO.SHlo.batchOp Proofs.StableHLO.BatchableOp.maxPool (Proofs.CnnFoldB.ac2B N W₁ b₁ W₂ b₂ xB)
Instances For
Equations
- Proofs.CnnFoldB.h3B N W₁ b₁ W₂ b₂ W₃ b₃ xB = Proofs.StableHLO.SHlo.batchOp (Proofs.StableHLO.BatchableOp.dense "%W3" "%b3" W₃ b₃) (Proofs.CnnFoldB.poolB N W₁ b₁ W₂ b₂ xB)
Instances For
Equations
- Proofs.CnnFoldB.a3B N W₁ b₁ W₂ b₂ W₃ b₃ xB = Proofs.StableHLO.SHlo.batchOp Proofs.StableHLO.BatchableOp.relu (Proofs.CnnFoldB.h3B N W₁ b₁ W₂ b₂ W₃ b₃ xB)
Instances For
Equations
- Proofs.CnnFoldB.h4B N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ xB = Proofs.StableHLO.SHlo.batchOp (Proofs.StableHLO.BatchableOp.dense "%W4" "%b4" W₄ b₄) (Proofs.CnnFoldB.a3B N W₁ b₁ W₂ b₂ W₃ b₃ xB)
Instances For
Equations
- Proofs.CnnFoldB.a4B N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ xB = Proofs.StableHLO.SHlo.batchOp Proofs.StableHLO.BatchableOp.relu (Proofs.CnnFoldB.h4B N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ xB)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
The batched backward chain — each piece a node over an operand leaf carrying the previous #
piece's den, as the renderer threads them
relu'(h4) ⊙ (W₅ · dy).
Equations
- One or more equations did not get rendered due to their size.
Instances For
relu'(h3) ⊙ (W₄ · dy4).
Equations
- One or more equations did not get rendered due to their size.
Instances For
W₃ · dy3, the cotangent at the pool output.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The select-and-scatter pool backward at the saved pool input.
Equations
- One or more equations did not get rendered due to their size.
Instances For
relu'(hc2) ⊙ dac2, the cotangent at conv₂'s output.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The conv₂ input-VJP (the convBackP descriptor: .convBack's text at the batched index).
Equations
- One or more equations did not get rendered due to their size.
Instances For
relu'(hc1) ⊙ dac1, the cotangent at conv₁'s output.
Equations
- One or more equations did not get rendered due to their size.
Instances For
maxPoolBackFlat is the flattened maxPoolBackDenote: the same first-maximum routing.
The conv₂-output cotangent, batched, IS cnnChainCotW2 at each example. The emitted
selectPosB over maxPoolBackB over the head chain denotes, at slice k, exactly the
hand-named chain cotangent CnnFold is stated at.
The conv₁-output cotangent, batched, IS cnnChainCotW1 at each example — for odd kernels.
convBackP denotes the certified conv input-VJP; cnnChainCotW1 is written with the
reversed-kernel convBackDenote, and the two agree exactly when the kernel is odd
(IR.conv_back_bridge).
The ten parameter nodes at batch N #
A batched dense weight SGD node, tied: θ − lr·Σₙ (certified ∂dense/∂W at slice n · cotₙ).
Equations
- One or more equations did not get rendered due to their size.
Instances For
A batched conv weight SGD node, tied: θ − lr·Σₙ (certified ∂conv/∂W at slice n · cotₙ).
Equations
- One or more equations did not get rendered due to their size.
Instances For
A batched conv bias SGD node, tied.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Output weight at the whole loss, summed over the batch.
Whole CNN train step at batch N, tied. All ten parameter nodes, each at the real batched
forward activation and the slice-pinned chain cotangent: the dense head against
g/mlpCotOut1/mlpCotOut0 per example (dy4B_slice, dy3B_slice), conv₂ against the
emitted pool-back chain (dhc2B_slice = cnnChainCotW2), conv₁ against the emitted conv-back
chain (dhc1B_slice = cnnChainCotW1 for odd kernels). The output weight folds to the whole
loss in w5B_tied.