Forward- or reverse-mode automatic differentiation: What's the difference?

Automatic differentiation (AD) has been a topic of interest for researchers in many disciplines, with increased popularity since its application to machine learning and neural networks. Although many researchers appreciate and know how to apply AD, it remains a challenge to truly understand the unde...

Full description

Saved in:
Bibliographic Details
Published in:Science of computer programming Vol. 231; p. 103010
Main Authors: van den Berg, Birthe, Schrijvers, Tom, McKinna, James, Vandenbroucke, Alexander
Format: Journal Article
Language:English
Published: Elsevier B.V 01.01.2024
Subjects:
ISSN:0167-6423, 1872-7964
Online Access:Get full text
Tags: Add Tag
No Tags, Be the first to tag this record!
Description
Summary:Automatic differentiation (AD) has been a topic of interest for researchers in many disciplines, with increased popularity since its application to machine learning and neural networks. Although many researchers appreciate and know how to apply AD, it remains a challenge to truly understand the underlying processes. From an algebraic point of view, however, AD appears surprisingly natural: it originates from the differentiation laws. In this work we use Algebra of Programming techniques to reason about different AD variants, leveraging Haskell to illustrate our observations. Our findings stem from three fundamental algebraic abstractions: (1) the notion of semimodule, (2) Nagata's construction of the ‘idealization of a module’, and (3) Kronecker's delta function, that together allow us to write a single-line abstract definition of AD. From this single-line definition, and by instantiating our algebraic structures in various ways, we derive different AD variants, that have the same extensional behaviour, but different intensional properties, mainly in terms of (asymptotic) computational complexity. We show the different variants equivalent by means of Kronecker isomorphisms, a further elaboration of our Haskell infrastructure which guarantees correctness by construction. With this framework in place, this paper seeks to make AD variants more comprehensible, taking an algebraic perspective on the matter. •Basic forward mode AD is the fusion of two semiring homomorphisms: symbolic differentiation and evaluation.•Three fundamental algebraic abstractions lay the foundations of a single-line definition of AD algorithms.•Different AD algorithms can be obtained using isomorphisms.•Our approach supports common extensions: more primitives, overloading, let-sharing, higher derivatives, non-commutativity.
ISSN:0167-6423
1872-7964
DOI:10.1016/j.scico.2023.103010