Lune

SC2021Top-tier venue

Reverse-mode automatic differentiation and optimization of GPU kernels via enzyme

William S. Moses, Valentin Churavy, Ludger Paehler, Jan Hückelheim, Sri Hari Krishna Narayanan, Michel Schanen, Johannes Doerfert

Abstract

Computing derivatives is key to many algorithms in scientific computing and machine learning such as optimization, uncertainty quantification, and stability analysis. Enzyme is a LLVM compiler plugin that performs reverse-mode automatic differentiation (AD) and thus generates high performance gradients of programs in languages including C/C++, Fortran, Julia, and Rust. Prior to this work, Enzyme and other AD tools were not capable of generating gradients of GPU kernels. Our paper presents a combination of novel techniques that make Enzyme the first fully automatic reversemode AD tool to generate gradients of GPU kernels. Since unlike other tools Enzyme performs automatic differentiation within a general-purpose compiler, we are able to introduce several novel GPU and AD-specific optimizations. To show the generality and efficiency of our approach, we compute gradients of five GPU-based HPC applications, executed on NVIDIA and AMD GPUs. All benchmarks run within an order of magnitude of the original program's execution time. Without GPU and AD-specific optimizations, gradients of GPU kernels either fail to run from a lack of resources or have infeasible overhead. Finally, we demonstrate that increasing the problem size by either increasing the number of threads or increasing the work per thread, does not substantially impact the overhead from differentiation.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

6 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • AD for an Array Language with Nested Parallelism cites Instead of Rewriting Foreign Code for Machine Learning, Automatically Synthesize Fast Gradients
  • DR.JIT: a just-in-time compiler for differentiable rendering cites DiffTaichi: Differentiable Programming for Physical Simulation
  • DR.JIT: a just-in-time compiler for differentiable rendering cites Instead of Rewriting Foreign Code for Machine Learning, Automatically Synthesize Fast Gradients
  • Scalable Automatic Differentiation of Multiple Parallel Paradigms through Compiler Augmentation cites AD for an Array Language with Nested Parallelism
  • Scalable Automatic Differentiation of Multiple Parallel Paradigms through Compiler Augmentation cites Instead of Rewriting Foreign Code for Machine Learning, Automatically Synthesize Fast Gradients
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers6

  1. DR.JIT: a just-in-time compiler for differentiable renderingWenzel Jakob, Sébastien Speierer, Nicolas Roussel, Delio ViciniSIGGRAPH 2022 · 160 citations
  2. High-Performance GPU-to-CPU Transpilation and Optimization via High-Level Parallel ConstructsWilliam S. Moses, Ivan R. Ivanov, Jens Domke, Toshio Endo et al.PPoPP 2023 · 27 citations
  3. Scalable Automatic Differentiation of Multiple Parallel Paradigms through Compiler AugmentationWilliam S. Moses, Sri Hari Krishna Narayanan, Ludger Paehler, Valentin Churavy et al.SC 2022 · 25 citations
  4. Aδ: autodiff for discontinuous programs - applied to shadersYuting Yang, Connelly Barnes, Andrew Adams, Adam FinkelsteinSIGGRAPH 2022 · 17 citations
  5. AD for an Array Language with Nested ParallelismRobert Schenck, Ola Rønning, Troels Henriksen, Cosmin E. OanceaSC 2022 · 11 citations

Builds on3

  1. DiffTaichi: Differentiable Programming for Physical SimulationYuanming Hu, Luke Anderson, Tzu-Mao Li, Qi Sun et al.ICLR 2020 · 479 citations
  2. JAX MD: A Framework for Differentiable PhysicsSamuel S. Schoenholz, Ekin Dogus CubukNeurIPS 2020 · 195 citations
  3. Instead of Rewriting Foreign Code for Machine Learning, Automatically Synthesize Fast GradientsWilliam S. Moses, Valentin ChuravyNeurIPS 2020 · 144 citations

Related papers

  1. Descend: A Safe GPU Systems Programming LanguageBastian Köpcke, Sergei Gorlatch, Michel SteuwerPLDI 2024 · 7 citations
  2. Locality-Aware Automatic Differentiation on the GPU for Mesh-Based ComputationsAhmed H. Mahmoud, Rahul Goel, Jonathan Ragan-Kelley, Justin SolomonSIGGRAPH 2026
  3. A simple differentiable programming languageMartín Abadi, Gordon D. PlotkinPOPL 2020 · 49 citations
  4. Efficient Dual-Numbers Reverse AD via Well-Known Program TransformationsTom Smeding, Matthijs VákárPOPL 2023 · 10 citations
  5. Provably correct, asymptotically efficient, higher-order reverse-mode automatic differentiationFaustyna Krawiec, Simon Peyton Jones, Neel Krishnaswami, Tom Ellis et al.POPL 2022 · 27 citations
Dusk over the sea between two cliffs drawn in fine vertical lines