Manuscript Offprint

arXiv:2608.25631

Propensity Straight-Through Gradients for Discrete Stochastic Systems

Jose M. G. Vilar, Leonor Saiz

Abstract

Continuous-time Markov chains (CTMCs) provide the backbone for modeling discrete stochastic dynamics across applied, physical, and biological sciences. Their integration with modern gradient-based machine learning, however, is limited by the hard categorical event selection intrinsic to Gillespie-type simulation algorithms. We exploit the affine state update to obtain the exact one-step conditional-mean sensitivity by differentiating normalized reaction propensities. We pair this backward rule with exact forward trajectories to define the propensity straight-through (PST) estimator. At the trajectory level, we show that one-step sensitivities composed across events can depart from the exact multistep sensitivity. We derive the resulting per-step discrepancy in closed form and prove that it vanishes identically for affine downstream dependence. PST matches the accuracy of Gumbel-Softmax straight-through across all benchmarks: reversible dimerization (0.06% error), a genetic oscillator (1.7% error), a 50-task repressilator suite (0.17% median error), and patch-clamp ion-channel recordings ( R2=0.988R^{2} = 0.988). Under matched settings, PST converges 3.0-fold faster on the oscillator and 2.1-fold faster on the ion channel. At deep-learning scale, PST trains a 203,796-parameter stochastic reaction network with hard sampling, reaching 98.22% MNIST digit classification accuracy. By differentiating an exact conditional mean rather than a relaxed sample, PST offers a temperature- and Gumbel-free path to scalable gradient-based learning through exact stochastic trajectories.

Introduction

Discrete stochastic dynamics is inherent to physical, chemical, and biological systems whenever individual events remain significant at the scale of the observed behavior. Molecular reactions, conformational transitions, ion-channel openings, and population changes generate fluctuations that determine switching, extinction, oscillatory variability, and rare transitions rather than merely perturb an underlying deterministic trajectory (1–12). Continuous-time Markov chains (CTMCs) provide a natural framework for representing such systems, with event rates specifying both the stochastic timing and identity of discrete state changes. Exact event-driven simulation is therefore particularly important in regimes where diffusion or deterministic approximations can obscure the consequences of individual transitions.

Inference and design increasingly require these mechanistic models to be embedded within optimization procedures. Experimental data may constrain many kinetic parameters simultaneously, while inverse-design and machine-learning applications reach parameter spaces far beyond those accessible to parameter-by-parameter search. Gradient-based optimization is the natural route to such problems, and automatic differentiation has made it routine for deterministic models at scales of millions of parameters.

Exact discrete-event simulation, epitomized by the Gillespie stochastic simulation algorithm (SSA) and the Bortz–Kalos–Lebowitz (BKL) algorithm, generates exact sample paths of continuous-time Markov jump processes by alternating exponential waiting-time sampling with categorical reaction selection (13, 14). The approach is used in statistical physics, stochastic chemical kinetics, systems biology, queueing, epidemiology, and other applications governed by competing event rates. Gradient-based optimization through such a trajectory is difficult because the selected event is discrete and blocks ordinary pathwise differentiation.

The waiting time is straightforwardly differentiable. Conditional on the current state x\mathbf{x}, it can be written as Δt=−log⁡u/a0(x;θ)\Delta t = -\log u / a_0(\mathbf{x}; \boldsymbol{\theta}), where uu is uniform and a0a_0 is the total propensity. The reaction choice, however, is a categorical sample, a piecewise constant function of its probabilities, and its derivative is consequently zero almost everywhere. The piecewise-constant dependence of the categorical sample on its probabilities does not preclude the applicability of score-function, or likelihood-ratio, estimators (15, 16), which differentiate the probability of the sampled reaction rather than the reaction realization itself, but it prevents ordinary pathwise differentiation through the categorical realization.

We address this categorical differentiation problem at the level of the one-step conditional mean by exploiting the affine structure of the SSA state update. If ej\mathbf{e}_j is the one-hot indicator of the selected reaction, equivalently the corresponding reaction-selection vector, and S\mathbf{S} contains the stoichiometric change vectors as columns, the state update is affine, x+=x+Sej\mathbf{x}^+ = \mathbf{x} + \mathbf{S}\mathbf{e}_j. The conditional mean of ej\mathbf{e}_j is the normalized propensity vector π\boldsymbol{\pi}. Therefore, differentiating π\boldsymbol{\pi} gives the exact derivative of the one-step conditional mean state. We use this derivative in the backward pass of automatic differentiation while leaving the waiting-time sampling and hard reaction selection unchanged, defining the propensity straight-through (PST) estimator. The affine structure is essential because the exactness applies to the one-step conditional mean and affine post-reaction observables.

Differentiable Gillespie approaches have also been developed by smoothing discontinuous operations in the forward dynamics (17). Recent exact-forward differentiable SSA implementations instead retain hard categorical reaction selection and use the Gumbel-Softmax straight-through estimator (GS-ST), differentiating a temperature-dependent relaxed realization only in the backward pass (18, 19). The relaxation temperature is a backward-pass hyperparameter rather than a property of the stochastic model, and the GS-ST settings represented across existing applications and the comparisons considered here vary markedly between systems. PST removes both this temperature selection and the Gumbel perturbation from the backward reaction-selection rule. PST takes a marginal-based route instead: it retains the same exact forward realization but differentiates the exact categorical mean, given by the normalized propensities, rather than a relaxed realization.

The resulting derivative is exact for the one-step conditional mean, and the discrepancy introduced by trajectory-level composition can be written explicitly. At the categorical level, this construction is closely related to marginal-based straight-through estimation (20), which retains discrete forward samples and differentiates exact sampling marginals. PST belongs to the broader family of straight-through estimators (21) and complements established sensitivity-analysis approaches for discrete stochastic systems, including score-function, finite-difference, unbiased, and pathwise methods (CTMCs) (15, 16, 22–26).

We characterize PST theoretically and evaluate it empirically. We establish exactness for the one-step conditional mean state and affine post-reaction observables, identify the multistep discrepancy as a finite-difference-to-directional-derivative replacement, derive a local curvature bound, connect its small-jump structure to classical expansions of Markov jump processes (27–30). For weighted least-squares population mean-matching objectives, we further show that the PST update field vanishes wherever the simulated population mean equals the target. We then evaluate PST in reversible dimerization, a nonlinear genetic oscillator (31), a two-channel gating model fitted to experimental recordings (32, 33), and a 50-task repressilator benchmark (34), and apply it to a 203,796-parameter stochastic gene-regulatory classifier (18).

References (31)