Differentiating through Stochastic Differential Equations: A Primer
Rishi Leburu, Levon Nurbekyan, Lars Ruthotto
TL;DR
This work provides a structured primer on differentiating through stochastic differential equations to compute gradients of expectations with respect to initial conditions and parameters. It presents two complementary narratives: discretize-then-optimize (applicable to Itô and Stratonovich SDEs) and optimize-then-discretize (via continuous adjoints, with Stratonovich as the natural setting), and demonstrates when each approach yields correct limits. Through Black–Scholes and CEV examples, it shows that discretize-then-optimize yields exact gradients for the discretized problem, while optimize-then-discretize converges to the continuous Stratonovich adjoint (requiring drift corrections for Itô) and can be practically implemented with Stratonovich schemes such as Heun. The paper offers practical guidelines, connects to rough-path theory, and outlines applications across finance, machine learning, and optimal control, with public code to reproduce results.
Abstract
Dynamical systems are essential to model various phenomena in physics, finance, economics, and are also of current interest in machine learning. A central modeling task is investigating parameter sensitivity, whether tuning atmospheric coefficients, computing financial Greeks, or optimizing neural networks. These sensitivities are mathematically expressed as derivatives of an objective function with respect to parameters of interest and are rarely available analytically, necessitating numerical methods for approximating them. While the literature for differentiation of deterministic systems is well-covered, the treatment of stochastic systems, such as stochastic differential equations (SDEs), in most curricula is less comprehensive than the subtleties arising from the interplay of noise and discretization require. This paper provides a primer on numerical differentiation of SDEs organized as a two-tale narrative. Tale 1 demonstrates differentiating through discretized SDEs, known the discretize-optimize approach, is reliable for both Itô and Stratonovich calculus. Tale 2 examines the optimize-discretize approach, investigating the continuous limit of backward equations from Tale 1 corresponding to the desired gradients. Our aim is to equip readers with a clear guide on the numerical differentiation of SDEs: computing gradients correctly in both Itô and Stratonovich settings, understanding when discretize-optimize and optimize-discretize agree or diverge, and developing intuition for reasoning about stochastic differentiation beyond the cases explicitly covered.
