Skip to main content
QUICK REVIEW

[Paper Review] Functorial String Diagrams for Reverse-Mode Automatic Differentiation

Mario Alvarez-Picallo, Dan R. Ghica|arXiv (Cornell University)|Jul 28, 2021
Modeling and Simulation SystemsComputer Science9 references7 citations
TL;DR

This paper introduces a novel functorial string diagram calculus with hierarchical features to formally model and prove the soundness of reverse-mode automatic differentiation (AD) for the simply typed lambda calculus. By representing AD as graph rewriting on hierarchical hypergraphs—called hypernets—it provides a principled, efficient, and formally verified implementation framework, establishing the first soundness proof for the Pearlmutter and Siskind AD algorithm in this context.

ABSTRACT

We enhance the calculus of string diagrams for monoidal categories with hierarchical features in order to capture closed monoidal (and cartesian closed) structure. Using this new syntax we formulate an automatic differentiation algorithm for (applied) simply typed lambda calculus in the style of [Pearlmutter and Siskind 2008] and we prove for the first time its soundness. To give an efficient yet principled implementation of the AD algorithm we define a sound and complete representation of hierarchical string diagrams as a class of hierarchical hypergraphs we call hypernets.

Motivation & Objective

  • To formally prove the soundness of the reverse-mode automatic differentiation algorithm by Pearlmutter and Siskind (2008), which had not been established prior to this work.
  • To extend the string diagram calculus for monoidal categories with hierarchical structure to capture closed monoidal and cartesian closed categories, enabling representation of higher-order functions and closures.
  • To develop a concrete, efficient, and formally sound implementation of AD using hierarchical hypergraphs (hypernets) as a data structure, compatible with double-pushout graph rewriting.
  • To unify the conceptual and implementation-level aspects of AD by using a single formalism—functorial string diagrams—for both specification and implementation.

Proposed method

  • Extends string diagram syntax with labelled frames and hierarchical nesting to represent functors, natural transformations, and higher-order constructs in closed monoidal categories.
  • Introduces a rewriting system for forward and reverse passes: the forward pass constructs a primal diagram with embedded backpropagators, while the reverse pass applies pullback diagrams to propagate gradients.
  • Defines a class of hierarchical hypergraphs called 'hypernets' that provide a sound and complete representation of the hierarchical string diagram calculus.
  • Uses double-pushout (DPO) rewriting to implement the AD transformation, ensuring correctness and modularity through well-defined graph rewriting rules.
  • Applies the AD transformation via recursive application of adjoint rules to abstractions and applications, preserving sensitivity information through wire permutations.
  • Employs a diamond property argument (modulo wire permutations) to prove confluence of the rewriting system, supporting deterministic and correct execution.

Experimental results

Research questions

  • RQ1Can the reverse-mode automatic differentiation algorithm for higher-order functions be formally proven sound using a graphical, category-theoretic framework?
  • RQ2How can string diagrams be extended with hierarchical structure to represent closed monoidal and cartesian closed categories in a way that supports AD?
  • RQ3What is a sound and complete graph-based data structure that supports efficient and correct AD implementation via rewriting?
  • RQ4Can the AD transformation be uniformly expressed as a graph rewriting system on hierarchical hypergraphs, preserving correctness and modularity?

Key findings

  • The paper establishes the first formal proof of soundness for the Pearlmutter and Siskind (2008) reverse-mode AD algorithm in the context of the simply typed lambda calculus.
  • The proposed hierarchical string diagram calculus enables a clear, modular, and inductive formulation of the AD algorithm, facilitating the soundness proof.
  • The rewriting systems for forward and reverse passes are shown to satisfy the diamond property up to wire permutation, ensuring confluence and deterministic execution.
  • The class of hypernets provides a sound and complete representation of hierarchical string diagrams, enabling efficient and principled implementation of AD via double-pushout rewriting.
  • The AD transformation correctly computes derivatives, as verified on a concrete example (x² + x), where the backpropagator yields the correct derivative when applied to input 1.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.