[Paper Review] Storchastic: A Framework for General Stochastic Automatic Differentiation
Storchastic is a novel framework for general stochastic automatic differentiation that enables modelers to apply diverse, low-variance gradient estimation methods at each sampling step in stochastic computation graphs. It provides provably unbiased gradient estimates for any-order derivatives by decomposing estimators into four components—proposal distribution, weighting function, gradient function, and control variate—while supporting advanced techniques like measure-valued derivatives and SPSA.
Modelers use automatic differentiation (AD) of computation graphs to implement complex Deep Learning models without defining gradient computations. Stochastic AD extends AD to stochastic computation graphs with sampling steps, which arise when modelers handle the intractable expectations common in Reinforcement Learning and Variational Inference. However, current methods for stochastic AD are limited: They are either only applicable to continuous random variables and differentiable functions, or can only use simple but high variance score-function estimators. To overcome these limitations, we introduce Storchastic, a new framework for AD of stochastic computation graphs. Storchastic allows the modeler to choose from a wide variety of gradient estimation methods at each sampling step, to optimally reduce the variance of the gradient estimates. Furthermore, Storchastic is provably unbiased for estimation of any-order gradients, and generalizes variance reduction techniques to higher-order gradient estimates. Finally, we implement Storchastic as a PyTorch library at https://github.com/HEmile/storchastic.
Motivation & Objective
- Address the limitations of existing stochastic AD frameworks that are restricted to continuous variables or suffer from high-variance score function estimators.
- Enable modelers to select optimal gradient estimation methods per sampling step to minimize variance without introducing bias.
- Generalize variance reduction techniques, including control variates, to any-order derivative estimation in stochastic computation graphs.
- Provide a formal mathematical foundation ensuring unbiasedness of n-th order derivatives under well-defined conditions on estimator components.
- Implement a practical, open-source PyTorch library to support real-world deployment and experimentation with diverse gradient estimators.
Proposed method
- Decompose stochastic gradient estimators into four core components: proposal distribution, weighting function, gradient function, and control variate.
- Formalize forward-mode AD evaluation using a mathematical framework to support rigorous analysis of gradient propagation.
- Prove that if the four components satisfy specific conditions, the resulting surrogate loss yields unbiased n-th order derivative estimates.
- Integrate advanced gradient estimation techniques such as measure-valued derivatives (MVD) and SPSA into the framework via component decomposition.
- Enable variance reduction for higher-order derivatives by extending control variate techniques to n-th order derivative estimation.
- Implement the framework as a PyTorch library, allowing seamless integration with deep learning workflows and dynamic computation graphs.
Experimental results
Research questions
- RQ1Can a general stochastic AD framework be designed to support a wide range of gradient estimation methods while ensuring unbiasedness for any-order derivatives?
- RQ2How can variance reduction techniques like control variates be systematically extended to higher-order derivative estimation in stochastic computation graphs?
- RQ3What formal conditions on the four components of a gradient estimator guarantee unbiasedness of n-th order derivatives?
- RQ4Can advanced methods like measure-valued derivatives and SPSA be unified under a single, composable framework for stochastic AD?
- RQ5To what extent can modelers freely choose different gradient estimators per sampling step without compromising the correctness of the gradient estimates?
Key findings
- Storchastic is the first framework to formally prove that any-order derivative estimates remain unbiased when the four estimator components satisfy specific mathematical conditions.
- The framework supports a wide range of gradient estimation methods, including reparameterization, score function estimators, RELAX, MAPO, unordered set estimators, and measure-valued derivatives.
- Storchastic enables the extension of control variate-based variance reduction to any-order derivative estimation, a novel contribution to the field.
- The implementation in PyTorch allows modelers to switch between different estimators with minimal code changes, as demonstrated by a single-line modification to compare methods in a VAE experiment.
- Empirical results on MNIST VAEs show that the framework correctly supports diverse estimators, with expected performance ordering matching prior work, despite limited training epochs and no hyperparameter tuning.
- The framework successfully integrates SPSA and measure-valued derivatives into a stochastic AD pipeline, demonstrating its generality and extensibility.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.