One ViT block with its two drop sites, per example — forward, VJP, input cotangent #
The *drop* ViT renders scale the attention branch (after the out-dense, before the first skip
add) and the MLP branch (after fc2, before the second) by the example's own mask entry
(ViTRenderB.vBlockFwdB), and the backward puts the same op on each branch's cotangent while the
skip fan-ins read the raw one (ViTRenderB's block backward; dropPath_vjp_is_self). Per
example, a site is a scalar or absent (dropScalarOpt, Foundation.Batched.Indexed), so this
file states the block at two Option ℝ sites sA sM; the batched ties lift it with
batchMapIdx, example n at exampleSite of the masks.
BlockParamsV.fwdOD— the block forward spelled asvitBlockSpelledMHVwith the two sites; atnone noneit ISfwdO(fwdOD_none,rfl), atsome a, some mit isvitBlockSpelledMHVDrop(ViTFwdDrop).BlockParamsV.cotInD— the input cotangent the render's chain threads:vitBlockCotInAtMHVwith the MLP branch fedsM ⊙ dy(vitCotHVD) and the attention branchsA ⊙ cotH;cotInatnone none(cotInD_none,rfl).BlockParamsV.fwdODHasVJP/cotInD_eq_vjp— the forward is two site residuals (fwdOD_eq_sites), eachsiteResHasVJPover its branch's certified VJP, and the chain IS that witness's backward. The branch backwards are read off the sublayer ties (attnSubFlat_tie_v,mlpSubFlat_tie_v) minus their skip.
Cot at the attention-sublayer output h with the MLP branch's site: dyOut raw on the skip,
sM ⊙ dyOut into fc2's backward (vitCotHV at none).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Cot at the SDPA output with both sites: Woᵀ of sA ⊙ cotH (vitCotAttV at none none).
Equations
- One or more equations did not get rendered due to their size.
Instances For
The multi-head block with its two drop sites, spelled as the render emits it —
vitBlockSpelledMHV with siteScale sA on the out-projection's output and siteScale sM on
fc2's, each before its skip add.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The block's forward at its two sites (vitBlockFwdOMHV at none none).
Equations
- One or more equations did not get rendered due to their size.
Instances For
With no site rendered the block is the drop-free one.
The block's input cotangent at its two sites — vitBlockCotInAtMHV's let chain with the
saves recomputed at the attention site (h reads siteScale sA of the out-projection), the
MLP branch fed sM ⊙ dyOut (vitCotHVD) and the attention branch sA ⊙ cotH; both skip
fan-ins raw.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The block's input cotangent at its two sites (vitBlockCotInAtMHV at none none).
Equations
Instances For
With no site rendered the chain is the drop-free one.
The MLP branch mlp ∘ LN₂, flat.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The attention branch's VJP — the branch half of transformerAttnSublayerVHasVJPMat.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The MLP branch's VJP — the branch half of transformerMlpSublayerVHasVJPMat.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The attention branch's backward is the render's chain (LN₁-back after the multi-head
backward, at the saves of input v): attnSubFlat_tie_v with its skip taken off.
The MLP branch's backward is the render's chain (LN₂-back after the per-row MLP back,
at the saves of input v): mlpSubFlat_tie_v with its skip taken off.
The attention sublayer with its site, flat: v ↦ v + sA ⊙ (mhsa ∘ LN₁) v.
Equations
- Proofs.ViTTieGB.vitAttnSiteF sA ε p v i = v i + Proofs.dropScalarOpt sA (Proofs.ViTTieGB.vitAttnBrF ε p v) i
Instances For
The MLP sublayer with its site, flat: v ↦ v + sM ⊙ (mlp ∘ LN₂) v.
Equations
- Proofs.ViTTieGB.vitMlpSiteF gf sM ε p v i = v i + Proofs.dropScalarOpt sM (Proofs.ViTTieGB.vitMlpBrF gf ε p v) i
Instances For
The attention sublayer's output at its site, as a matrix.
The spelled block with its sites is the two site residuals, composed.
The attention site residual's VJP (siteResHasVJP over the branch).
Equations
- Proofs.ViTTieGB.vitAttnSiteHasVJP sA ε hε p = Proofs.siteResHasVJP sA (Proofs.ViTTieGB.vitAttnBrF ε p) ⋯ (Proofs.ViTTieGB.vitAttnBrHasVJP ε hε p)
Instances For
The MLP site residual's VJP (siteResHasVJP over the branch).
Equations
- Proofs.ViTTieGB.vitMlpSiteHasVJP gf sM ε hε p = Proofs.siteResHasVJP sM (Proofs.ViTTieGB.vitMlpBrF gf ε p) ⋯ (Proofs.ViTTieGB.vitMlpBrHasVJP gf ε hε p)
Instances For
The block's VJP at its two sites: the attention site residual, then the MLP one, each
siteResHasVJP over its branch's certified VJP.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The block VJP's backward, unfolded: the MLP branch reads sM ⊙ dy at the attention output, the
attention branch sA ⊙ the resulting skip cotangent; both skips raw.
The attention half of the chain's algebra: the block-input fan-in of the three dense
cotangents the core hands back from Woᵀ w is c plus the attention branch's backward of w
(vitCotXin_eq_blockBack's attention step, at a general skip cotangent c).
The MLP half: vitCotHVD is the raw skip plus the MLP branch's backward of sM ⊙ dy.
The chain's block-input cotangent at the two sites is the block VJP's backward.