Efficient CHAD

Publication date

2024-01-05

Authors

Smeding, Tom J.ORCID 0000-0002-4986-6820ISNI 0000000512623405
Vákár, MatthijsORCID 0000-0003-4603-0523ISNI 0000000464978681

Editors

Advisors

Supervisors

Document Type

Article
Open Access logo

License

cc_by

Abstract

We show how the basic Combinatory Homomorphic Automatic Differentiation (CHAD) algorithm can be optimised, using well-known methods, to yield a simple, composable, and generally applicable reverse-mode automatic differentiation (AD) technique that has the correct computational complexity that we would expect of reverse-mode AD. Specifically, we show that the standard optimisations of sparse vectors and state-passing style code (as well as defunctionalisation/closure conversion, for higher-order languages) give us a purely functional algorithm that is most of the way to the correct complexity, with (functional) mutable updates taking care of the final log-factors. We provide an Agda formalisation of our complexity proof. Finally, we discuss how the techniques apply to differentiating parallel functional array programs: the key observations are 1) that all required mutability is (commutative, associative) accumulation, which lets us preserve task-parallelism and 2) that we can write down data-parallel derivatives for most data-parallel array primitives.

Keywords

automatic differentiation, functional programming, source transformation, Software, Safety, Risk, Reliability and Quality

Citation

Smeding, T J & Vákár, M I L 2024, 'Efficient CHAD', Proceedings of the ACM on Programming Languages, vol. 8, 36. https://doi.org/10.1145/3632878