Efficient Dual-Numbers Reverse AD via Well-Known Program Transformations

07/07/2022
by   Tom Smeding, et al.
0

Where dual-numbers forward-mode automatic differentiation (AD) pairs each scalar value with its tangent value, dual-numbers reverse-mode AD attempts to achieve reverse AD using a similarly simple idea: by pairing each scalar value with a backpropagator function. Its correctness and efficiency on higher-order input languages have been analysed by Brunel, Mazza and Pagani, but this analysis used a custom operational semantics for which it is unclear whether it can be implemented efficiently. We take inspiration from their use of linear factoring to optimise dual-numbers reverse-mode AD to an algorithm that has the correct complexity and enjoys an efficient implementation in a standard functional language with support for mutable arrays, such as Haskell. Aside from the linear factoring ingredient, our optimisation steps consist of well-known ideas from the functional programming community. We demonstrate the practical use of our technique by providing a performant implementation that differentiates most of Haskell98.

READ FULL TEXT
research
05/23/2022

Dual-Numbers Reverse AD, Efficiently

Where dual-numbers forward-mode automatic differentiation (AD) pairs eac...
research
07/05/2023

Using Rewrite Strategies for Efficient Functional Automatic Differentiation

Automatic Differentiation (AD) has become a dominant technique in ML. AD...
research
07/10/2020

Reverse AD at Higher Types: Pure, Principled and Denotationally Correct

We show how to define source-code transformations for forward- and rever...
research
01/11/2018

Review of theory and implementation of hyper-dual numbers for first and second order automatic differentiation

In this review we present hyper-dual numbers as a tool for the automatic...
research
11/06/2020

Automatic Differentiation in PCF

We study the correctness of automatic differentiation (AD) in the contex...
research
01/11/2018

Note on usage and theory of hyper-dual numbers for first and second order automatic differentiation

Similar to dual numbers, hyper-dual numbers are extended numbers that ca...
research
08/22/2017

Divide-and-Conquer Checkpointing for Arbitrary Programs with No User Annotation

Classical reverse-mode automatic differentiation (AD) imposes only a sma...

Please sign up or login with your details

Forgot password? Click here to reset