ResNet-34 AdamW train step rendered from the verified AST, at the BATCHED index #
The sole writer of every ResNet-34 artifact.
- BatchNorm is
bnBatchF— μ/var reduced over[0,2,3], coupling the batch — notbnPerChannelF's per-example[2,3]. That is the semantics the AdamW trainer runs; a per-example-BN render would be a different function. - The whole graph sits at
N := B, so every batch-coupleddenhere is honest:bnBatchF,bnBatchBack, and the whole*GradBfamily reduce over the batch, and atN = 1they would each describe a one-example function while the emitted text reduces over allB.
The optimizer is the proven adamMNextF/adamVNextF/adamWParamF triple applied to the un-fused
*GradB gradients. β₁/β₂/ε/wd are baked; %lr/%bc1/%bc2 arrive as runtime tensor<f32> args.
The cotangent is composed from kit ops, not fused:
softmaxRow → subB → scaleB → addVB → shiftB → divConstB (label smoothing α = 0.1, K =
nClasses), every line pretty of a verified node. %loss is report-only and stays outside the
AST, exactly as cifar8_adam_train_step's does.
Render is value-independent (skel erases values), so placeholder zeros and lr := 0/ε := 0 are
passed; the emitted literals carry the real values.
A basic block's eval forward: its code and its output name (the next block's input).
Instances For
Equations
The ResNet-34 parameters in net.paramShapes (= func-arg) order, names + types.
The forward, the eval forward and the train step all take their signature from here, so the
arity/type/order contract the driver relies on cannot drift between renders.
110 at the shipped convBias := false — stem 3 + 13 identity blocks × 6 + 3 downsample
blocks × 9 + dense 2 — and 146 with the conv biases in. Every writer below omits the argument,
so every committed artifact is the 110 one; the biases are zeroBiasPrelude's zero constants.
Instances For
The 72 running-stat inputs — 36 BN layers × (μ, var), each [oc], in BN-forward order:
stem, then per identity block n1 n2, per downsample block n1 n2 np. This is exactly the
order VerifiedNet.bnChannels is listed in, which is how the driver packs runningBnStats
(bnChannels.foldl (fun acc c => acc ++ #[#[c], #[c]])) — μ and var interleaved per layer,
NOT all-μ-then-all-var. Appended after the parameters, so @resnet34_fwd_eval takes
1 + 110 + 72 = 183 inputs as committed (1 + 146 + 72 = 219 at convBias := true).
Equations
- One or more equations did not get rendered due to their size.
Instances For
The ResNet-34 eval forward: its code and the logits name the eval function returns. (The train
step walks the batched r34FwdChainB instead.)
Instances For
@resnet34_fwd_eval rendered ENTIRELY from the verified AST — the inference forward, with
every BN site consuming frozen per-channel running stats (bnPerChannelEvalF) instead of
reducing statistics out of its activation. Same net, same parameters in the same order, plus
the 72 stat inputs of r34StatSigList: 183 inputs as committed, returning logits
[B, nClasses].
This is the eval partner of resnet34AdamTrainStepText (this file), whose 72 returned
batch statistics the driver EMAs into exactly these slots.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Identity block forward: conv1→BN1→relu1→conv2→BN2→(+x)→relu, all at N := B.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Downsample block forward: strided body + strided projection skip. cin→c, 2hh→hh.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The driver's variant slug for a given (B, replicas): the artifact is
verified_mlir/resnet34_<variant>_train_step.mlir, the entry point is
@resnet34_<variant>_train_step, and LEAN_MLIR_VARIANT selects it.
All three must agree. The shim checks the entry name and refuses a mismatch outright ("entry
mismatch") rather than running the wrong graph — which is exactly what it did the first time the
DP render kept the single-device name. Deriving the name here, from the same two
numbers the render is built from, is what stops it drifting from the #eval paths below; the
#guards at the bottom pin those literal paths against this function.
B = 32 is deliberately unsuffixed, so the two existing artifacts keep their names and bytes.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Everything the whole-net render needs out of ONE forward traversal of ResNet-34 at the BATCHED index: the emitted code, the logits and GAP names, and every saved activation the backward reads.
This exists so @resnet34_fwd and the batch-BN train steps cannot be different nets: a
forward built from a PER-EXAMPLE chain (bnPerChannelF, reduce [2,3], divisor H·W) next to
batch-BN train steps (reduce [0,2,3], divisor B·H·W) is a different function. This is
ResNet50RenderB.r50FwdChainB's shape, for R50's reason.
The EVAL forward is deliberately NOT moved onto this chain, exactly as R50's is not:
bnPerChannelEvalF reads frozen per-channel statistics and reduces nothing, so
resnet34_fwd_eval.mlir is BatchNorm-world-agnostic and correct against both chains.
Extracting the traversal is byte-neutral for the train step: pretty's SSA counter follows
the call SEQUENCE, and the sequence is unchanged.
Instances For
Equations
Stem forward: 7×7/s2 conv → batch BN → relu → He et al.'s 3×3/s2 max-pool, on %x.
A 2×2 non-overlapping .maxPool would give the identical 112→56 output shape and be a
different function, so no shape check tells them apart.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Head forward: GAP(7×7) → dense(512→nClasses) on the last block's output xName. Returns the
text and the GAP and logit names.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The ResNet-34 forward chain at the BATCHED index — one traversal, consumed by both
@resnet34_fwd and every train step that differentiates it.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@resnet34_fwd rendered from the BATCHED chain — the same traversal every batch-BN train
step in this file differentiates, so the net that scores and the net that trains are one graph
by construction. The writer of verified_mlir/resnet34_fwd.mlir.
Takes %x plus the parameters in r34SigList order — 111 inputs at the shipped
convBias := false — and returns logits [B, nClasses].
Equations
- One or more equations did not get rendered due to their size.
Instances For
ResNet-34 [3,4,6,3] AdamW train step, batch-BN, rendered from the verified AST at N := B.
407 inputs at the shipped convBias := false (%x, 110 θ, 110 m, 110 v,
%lr/%bc1/%bc2, 72 running-stat slots, %onehot) and 405 outputs (110 θ', 110 m', 110 v',
%loss/%bc1/%bc2, 72 batch stats); 146 θ at convBias := true. Parameter ORDER comes from
r34SigList, the same single source both forwards use, so the arity/order contract cannot
drift between them.