Higher derivatives through reverse accumulation #
A reverse pass reads saved activations, computes local pullbacks, and adds their contributions. The jet relation tracks all three operations, with arbitrary tensor shapes and finite derivative order. Seeds can depend smoothly on the inputs, as they do when differentiating a composed loss.
These theorems use the existing GraphData.backpropCtx. They identify nested-dual execution with
derivatives of its real implementation. Identifying that implementation with the adjoint of the
forward derivative requires the separate first-order correctness certificate.
Zero-initialized gradient buffers contain no nonzero derivative coefficients.
Place a tensor's full jet at one typed input and zero-fill the other gradient buffers.
Gradient accumulation preserves mixed derivatives, including shared-parent contributions.
Splitting off a node's cotangent preserves both parts of the derivative information.
The implemented pullback preserves full jets of activations and smoothly varying seeds. This law concerns differentiation of the pullback; its first-order adjoint law is separate.
Instances For
Passing a seed directly to one input preserves its full jet.
Sum independently certified contributions, even when they target the same input.
Scatter seed * coefficient to one typed input, preserving all mixed derivatives.
Scatter coefficient * seed to one typed input, preserving all mixed derivatives.
Local jet laws for both saved forward values and the pullbacks in an executable graph.
- nil
{E : Type u_1}
[NormedAddCommGroup E]
[NormedSpace ℝ E]
{n : ℕ}
{Δ : Type}
{Γ : List Spec.Shape}
: PreservesPullbackJet E n GraphData.nil GraphData.nil
The empty reverse pass returns its supplied cotangents.
- snoc
{E : Type u_1}
[NormedAddCommGroup E]
[NormedSpace ℝ E]
{n : ℕ}
{Δ : Type}
{Γ shapes : List Spec.Shape}
{shape : Spec.Shape}
{real : GraphData ℝ Δ Γ shapes}
{nested : GraphData (Runtime.Autograd.Model.Dual.Nested ℝ n) Δ Γ shapes}
{realNode : NodeData ℝ Δ (Γ ++ shapes) shape}
{nestedNode : NodeData (Runtime.Autograd.Model.Dual.Nested ℝ n) Δ (Γ ++ shapes) shape}
(previous : PreservesPullbackJet E n real nested)
(forward : NodeData.PreservesJet E n realNode.forward nestedNode.forward)
(pullback : NodeData.PreservesPullbackJet E n realNode.vjp nestedNode.vjp)
: PreservesPullbackJet E n (real.snoc realNode) (nested.snoc nestedNode)
Extend a graph with independent forward and pullback jet laws.
Instances For
Reverse-mode certificates also certify the saved activations used by each pullback.
Reverse accumulation preserves all derivative coefficients of every input cotangent.
Extracting a reverse result gives the iterated derivative of the implemented real pullback. The seed may vary with the input; a fixed loss cotangent is a special case.