TorchLean Transformer IBP Workflow #
Small end-to-end workflow:
TorchLean (MHA + LayerNorm + MSE) → lower to NN.IR.Graph → run:
- IBP (
runIBP) - optional CROWN output bounds (
outputBoxCROWN?) - optional objective-dependent backward CROWN (
backwardObjectiveBox?)
The example has one batch, two tokens, two features, and one attention head. On the CLI's rounded backends, both CROWN queries use directed backward propagation and may fall back to IBP bounds. This is a runtime integration check, not a checked model certificate.
Run:
lake exe verify -- torchlean-transformer-ibp
lake exe verify -- torchlean-transformer-ibp --with-crown
lake exe verify -- torchlean-transformer-ibp --arithmetic ieee
Sequence length for the transformer verification example.
Instances For
Model embedding dimension.
Instances For
Number of attention heads.
Instances For
Per-head embedding dimension.
Instances For
Batch size for the transformer verification example.
Instances For
Input shape (batch × n × dModel).
Instances For
Projection weight shape for Q/K/V: (dModel × (numHeads*headDim)).
Instances For
Output projection weight shape: ((numHeads*headDim) × dModel).
Instances For
LayerNorm scale parameter shape, matching the feature dimension.
Instances For
LayerNorm beta shape, matching the feature dimension.
Instances For
MSE target shape (matches the model output shape).
Instances For
Parameter shapes list for modelLoss (Wq,Wk,Wv,Wo,gamma,beta,target).
Instances For
TorchLean program: mha -> layer_norm -> mse_loss, returning a scalar loss.
Instances For
Runtime-selected typed runner used by the CLI entrypoint.
Instances For
CLI entry point for the transformer-IBP workflow.
This is wired into lake exe verify -- torchlean-transformer-ibp.
By default this command lowers the small attention/LayerNorm example to the verification IR and
runs IBP on its scalar loss. Pass --with-crown to also request CROWN output and objective bounds.
The separate torchlean-crown-ops command exercises linear/softmax and linear/MSE examples.
Missing bounds or unexpected output dimensions fail the command.