Automatic Differentiation of Programs with Discrete Randomness
Gaurav Arya, Moritz Schauer, Frank Schäfer, Christopher Rackauckas
Abstract
Automatic differentiation (AD), a technique for constructing new programs which compute the derivative of an original program, has become ubiquitous throughout scientific computing and deep learning due to the improved performance afforded by gradient-based optimization. However, AD systems have been restricted to the subset of programs that have a continuous dependence on parameters. Programs that have discrete stochastic behaviors governed by distribution parameters, such as flipping a coin with probability of being heads, pose a challenge to these systems because the connection between the result (heads vs tails) and the parameters () is fundamentally discrete. In this paper we develop a new reparameterization-based methodology that allows for generating programs whose expectation is the derivative of the expectation of the original program. We showcase how this method gives an unbiased and low-variance estimator which is as automated as traditional AD mechanisms. We demonstrate unbiased forward-mode AD of discrete-time Markov chains, agent-based models such as Conway's Game of Life, and unbiased reverse-mode AD of a particle filter. Our code package is available at https://github.com/gaurav-arya/StochasticAD.jl.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext 3e17ed38-e6d8-4fe4-843a-9489873e22c1Cited by top-tier papers10
- ADEV: Sound Automatic Differentiation of Expected Values of Probabilistic ProgramsAlexander K. Lew, Mathieu Huot, Sam Staton, Vikash K. MansinghkaPOPL 2023 · 16 citations
- Probabilistic Programming with Programmable Variational InferenceMcCoy R. Becker, Alexander K. Lew, Xiaoyan Wang, Matin Ghavami et al.PLDI 2024 · 8 citations
- Auto-Differentiation of Relational Computations for Very Large Scale Machine LearningYuxin Tang, Zhimin Ding, Dimitrije Jankov, Binhang Yuan et al.ICML 2023 · 7 citations
- Learning Individual Behavior in Agent-Based Models with Graph Diffusion NetworksFrancesco Cozzi, Marco Pangallo, Alan Perotti, André Panisson et al.NeurIPS 2025 · 5 citations
- Generalizing Stochastic Smoothing for Differentiation and Gradient EstimationFelix Petersen, Christian Borgelt, Aashwin Mishra, Stefano ErmonICML 2026 · 4 citations
Builds on4
- Differentiable Particle Filtering via Entropy-Regularized Optimal TransportAdrien Corenflos, James Thornton, George Deligiannidis, Arnaud DoucetICML 2021 · 91 citations
- Storchastic: A Framework for General Stochastic Automatic DifferentiationEmile van Krieken, Jakub M. Tomczak, Annette ten TeijeNeurIPS 2021 · 19 citations
- ADEV: Sound Automatic Differentiation of Expected Values of Probabilistic ProgramsAlexander K. Lew, Mathieu Huot, Sam Staton, Vikash K. MansinghkaPOPL 2023 · 16 citations
- Direct Policy Gradients: Direct Optimization of Policies in Discrete Action SpacesGuy Lorberbom, Chris J. Maddison, Nicolas Heess, Tamir Hazan et al.NeurIPS 2020 · 8 citations
Related papers
- Randomized Automatic DifferentiationDeniz Oktay, Nick McGreivy, Joshua Aduol, Alex Beatson et al.ICLR 2021 · 31 citations
- Fiber Monte CarloNick Richardson, Deniz Oktay, Yaniv Ovadia, James C. Bowden et al.ICLR 2024
- GO Hessian for Expectation-Based ObjectivesYulai Cong, Miaoyun Zhao, Jianqiao Li, Junya Chen et al.AAAI 2021
- Diffusion Differentiable ResamplingJennifer R. Andersson, Zheng ZhaoICML 2026 · 2 citations
- Slice Sampling Reparameterization GradientsDavid M. Zoltowski, Diana Cai, Ryan P. AdamsNeurIPS 2021 · 8 citations
