TorchLean API

NN.Proofs.Autograd.Tape.Core.Soundness

Soundness #

Tape-style (SSA/DAG) reverse-mode soundness for the proved-correct layer.

We model a dynamic graph as a sequence of nodes that may reference any previously computed values (so sharing/fan-out is allowed). For each node we assume a local JVP/VJP adjointness law, then prove the global reverse-mode accumulation algorithm is sound.

This is a proof-only layer; the runtime engine in NN.Runtime.Autograd.Engine is an executable implementation of the same idea.

PyTorch correspondence / citations #

References (background):

Dot product over contexts: sum of per-entry tensor dot products.

Informally: dotList xs ys is the “context inner product” used to state global adjointness for tape evaluation and backprop.

Instances For

    At ℝ the context dot product agrees with the backend-generic one in Algebra, entry by entry through dot_eq_tensorAlgebra_dot.

    A node with local JVP/VJP and an adjointness proof against the tensor dot product.

    Instances For

      A tape/SSA graph: nodes are appended in topological order and may reference any previous value.

      Instances For

        Evaluate a tape/graph, returning the full context (inputs ++ intermediates).

        Instances For

          Evaluate the JVP (“forward-mode tangent”) of a graph, producing tangents for all values in the extended context Γ ++ ss.

          Instances For

            Reverse-mode backpropagation on a tape/graph, returning gradients for the inputs Γ.

            This is the proof model of what PyTorch calls “running backward” starting from an output seed cotangent and accumulating gradients at shared parents.

            Instances For

              Embed an analytic node as an algebraic node over ℝ with a trivial environment.

              Instances For

                Embed an analytic graph as an algebraic graph over ℝ with a trivial environment.

                Instances For

                  Embedding preserves evaluation.

                  Embedding preserves the JVP.

                  Embedding preserves the reverse pass.

                  Global tape soundness: if each node satisfies a local JVP/VJP adjointness law, then the global reverse-mode accumulation algorithm (backpropCtx) is correct.

                  Informally: for any input perturbation dx and any output seed cotangent seed,

                  ⟪JVP(g, x, dx), seed⟫ = ⟪dx, backprop(g, x, seed)⟫.

                  This is the formal analogue of PyTorch’s guarantee that backward() computes vector–Jacobian products and accumulates them through a dynamic DAG/tape. It is the ℝ, Δ := Unit instance of Algebra.Graph.backprop_correct.