ICFP 2024
Mon 2 - Sat 7 September 2024 Milan, Italy
Fri 6 Sep 2024 11:30 - 12:00 at Orange 2 - Session 2 Chair(s): Martin Elsman

Machine learning, artificial intelligence, and scientific modelling have driven the demand for tools that enable derivative based optimization. Automatic differentiation (AD) is a family of algorithms used to calculate the derivatives of programs with only a constant factor slowdown. Effects and handlers are a powerful programming language control flow construct based on delimited continuations. Mainstream programming languages are increasingly incorporating effects and handlers, notably OCaml 5.0.

We show that effects and handlers are a great match for implementing AD algorithms while maintaining asymptotic efficiency. In particular, effects and handlers allow for succinctness in the presence of the intrinsic complex control flow of AD. We implement four AD algorithms in OCaml 5.0 using effects and handlers. We provide benchmarks to empirically show that we can reach the correct asymptotic complexity for forward and reverse mode AD. We also provide a real-world comparison by adding our implementation to a preexisting benchmark suite which includes systems TensorFlow and PyTorch, and show that our implementation is competitive with systems based on comparable methods, second only to PyTorch and Tensorflow.

Slides (ML 2024 slides.pdf)1.67MiB

Fri 6 Sep

Displayed time zone: Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna change