翻转硬币:通过硬切换训练物理模拟器
摘要
该论文提出了 EventFlip,一种用于训练包含硬性不连续切换的混合物理模拟器的方法。该方法利用反事实轨迹推演,推导出一种将连续路径梯度与跳跃项相结合的无偏梯度估计器。在电网级联故障、爆轰波和皮层扩散性去极化任务中,与十二种基线方法相比,该方法在每项任务上均取得了最低误差。
arXiv:2611.33716v1 Announce Type: new
Abstract: Hybrid simulators embed learnable components such as neural networks in physical solvers and train them on reference trajectories. Many scientific solvers feature hard switches, such as a tripping power line, an igniting grid cell, or depolarizing brain tissue, where the loss exhibits discrete jumps across switch flips, leaving standard automatic differentiation to capture only its smooth part. Existing training paradigms face a fundamentally challenging trade-off, as gradient-based relaxations smooth the switches and introduce bias across jumps, whereas derivative-free methods treat the solver as a black box and discard path gradients of the continuous dynamics. Here we introduce EventFlip, which flips a near-threshold switch from a stored state, replays the original solver, and measures the loss difference between the two runs, in effect a finite difference across the switch. By perturbing every threshold with small Gaussian noise, we cast each switch as a stochastic binary decision and derive an unbiased gradient estimator that combines the continuous path gradient with a jump term constructed from these counterfactual rollouts. EventFlip-Rand optimizes this noise-averaged objective, whereas EventFlip-Hard operates on the deterministic hard-switch simulator used at deployment and provably targets the complete discontinuous loss. Under an identical forward evaluation budget, we benchmark EventFlip against twelve baselines across a power-grid cascade, a detonation wave, and cortical spreading depolarization, achieving the lowest error on every task and reducing the strongest baseline's error by factors of 1.5, 1.4, and 1.4, respectively.
查看缓存全文
缓存时间: 2026/11/26 09:38
# Flipping the Coins: Training Physical Simulators through Hard Switches Source: [https://arxiv.org/html/2611.33716](https://arxiv.org/html/2611.33716) Tianrun Gao Ruiqi Feng Haomin Wen Tailin WuAffiliation:School of Computing and Data Science, The University of Hong KongAffiliation:Department of Artificial Intelligence, School of Engineering, Westlake UniversityAffiliation:Shanghai Innovation Institute, Shanghai, ChinaLiangqiong Qu Xiaomeng Huang Ruiqi ShuAffiliation:School of Computing and Data Science, The University of Hong KongAffiliation:Department of Earth System Science, Tsinghua University\*Equal contribution\. Corresponding authors\.Ruiqi Shu:[srq24@mails\.tsinghua\.edu\.cn](mailto:[email protected])Xiaomeng Huang:[hxm@tsinghua\.edu\.cn](mailto:[email protected]) ###### Abstract Hybrid simulators embed learnable components such as neural networks in physical solvers and train them on reference trajectories\. Many scientific solvers feature hard switches, such as a tripping power line, an igniting grid cell, or depolarizing brain tissue, where the loss exhibits discrete jumps across switch flips, leaving standard automatic differentiation to capture only its smooth part\. Existing training paradigms face a fundamentally challenging trade\-off, as gradient\-based relaxations smooth the switches and introduce bias across jumps, whereas derivative\-free methods treat the solver as a black box and discard path gradients of the continuous dynamics\. Here we introduceEventFlip, which flips a near\-threshold switch from a stored state, replays the original solver, and measures the loss difference between the two runs, in effect a finite difference across the switch\. By perturbing every threshold with small Gaussian noise, we cast each switch as a stochastic binary decision and derive an unbiased gradient estimator that combines the continuous path gradient with a jump term constructed from these counterfactual rollouts\.EventFlip\-Randoptimizes this noise\-averaged objective, whereasEventFlip\-Hardoperates on the deterministic hard\-switch simulator used at deployment and provably targets the complete discontinuous loss\. Under an identical forward evaluation budget, we benchmarkEventFlipagainst twelve baselines across a power\-grid cascade, a detonation wave, and cortical spreading depolarization, achieving the lowest error on every task and reducing the strongest baseline’s error by factors of 1\.5, 1\.4, and 1\.4, respectively\. Figure 1:Representative test cases on the power\-grid cascade and cortical spreading depolarization\.In each row, the leftmost panel depicts the ground\-truth reference, while the remaining panels compare four hybrid simulators trained under an identical forward evaluation budget\. In the top row, line colors indicate the cascade generation in which each transmission line trips, disk areas denote the load shed at each bus, and black crosses mark the two initial line outages\. In the bottom row, the reference panel displays the cellular activation time with contour lines, whereas the four model panels show the corresponding activation\-time error in steps\.## 1 Introduction Scientific machine learning increasingly embeds learnable components into numerical solvers, such as neural networks that correct coarse\-grid errors or networks that supply unknown thresholds and constitutive relations, and trains the resulting hybrid simulator end\-to\-end on reference trajectories\([Um et al\., 2020](https://arxiv.org/html/2611.33716#bib.bib60);[Kochkov et al\., 2021](https://arxiv.org/html/2611.33716#bib.bib25);[Shen et al\., 2023](https://arxiv.org/html/2611.33716#bib.bib49);[Kochkov et al\., 2024](https://arxiv.org/html/2611.33716#bib.bib26)\)\. Many systems targeted by these hybrid simulators are governed by threshold crossings, where the dynamics change abruptly once a state variable crosses a critical value\. In power grids, whether an overloaded line trips determines whether an initial outage stays local or grows into a blackout\([Soltan et al\., 2014](https://arxiv.org/html/2611.33716#bib.bib51)\)\. In combustion, whether a mixture ignites decides whether a detonation forms and how fast it travels, which governs the safety of fuel handling and the operation of combustion devices\([Oran and Gamezo, 2007](https://arxiv.org/html/2611.33716#bib.bib41);[Shepherd, 2009](https://arxiv.org/html/2611.33716#bib.bib50)\)\. In the brain, whether cells cross a depolarization threshold determines whether spreading depolarization waves invade the ischemic penumbra to enlarge an infarct\([Dreier, 2011](https://arxiv.org/html/2611.33716#bib.bib13)\)\. Making these simulators with switches trainable on observed dynamics is therefore a prerequisite for reliably deploying learned models in various high\-consequence physical regimes\. The fundamental obstacle is that many simulators represent threshold crossings as hard switches evaluated at individual grid cells or components\. A switch is a step function of the physical state, so the simulated trajectory is a piecewise\-smooth, discontinuous function of the learnable parameters\. Changing these parameters influences the simulated outcome both by changing the continuous evolution and by advancing or delaying switch flips\. The flips introduce discrete jumps into the subsequent trajectory that standard derivatives cannot capture\. The magnitude of each jump is governed by the nonlinear evolution unfolding after the flip and cannot be deduced from local gradient information at the switch alone\. Figure 2:Overview ofEventFlip\.\(a\) The hard loss exhibits discrete jumps across switch flips, whereas standard automatic differentiation captures only the smooth part\. \(b\) The base trajectory \(blue\) and the flip branch \(orange\) share an identical rollout prefix before diverging at a sampled near\-threshold switch\. \(c\) Both branches re\-evaluate all subsequent switches and arrive at distinct final grid states\. The resulting downstream loss difference weights the jump term, which combines with path gradient to form a complete update\.Existing approaches to training hybrid simulators fall into two classes\. Gradient\-based methods differentiate through the solver\. The most direct approach holds every switch at its current value and differentiates the rest of the solver, as in differentiable hydrological models\([Feng et al\., 2022](https://arxiv.org/html/2611.33716#bib.bib16)\), and therefore misses every jump of the loss\. To recover a gradient at the switch, continuous relaxations replace the threshold with a smooth function such as a sigmoid\([Tsuyuki, 1996](https://arxiv.org/html/2611.33716#bib.bib57);[Seo, 2026](https://arxiv.org/html/2611.33716#bib.bib47)\), while straight\-through estimators keep the hard switch in the forward pass and substitute a smooth derivative in the backward pass\([Bengio et al\., 2013](https://arxiv.org/html/2611.33716#bib.bib7)\)\. All of these methods make the gradient computable by simplifying the switch, so the gradient they return is not that of the hard\-switch simulator\. Derivative\-free methods \(such as ensemble Kalman inversion, evolution strategies, and black\-box reinforcement learning\([Iglesias et al\., 2013](https://arxiv.org/html/2611.33716#bib.bib23);[Salimans et al\., 2017](https://arxiv.org/html/2611.33716#bib.bib44);[Lopez\-Gomez et al\., 2022](https://arxiv.org/html/2611.33716#bib.bib34);[Novati et al\., 2021](https://arxiv.org/html/2611.33716#bib.bib40);[von Bassewitz et al\., 2024](https://arxiv.org/html/2611.33716#bib.bib62)\)\) avoid these simplifications by perturbing parameters or sampling actions, but because they treat the entire simulation as a black box, they cannot exploit path gradients of the smooth solver dynamics\. Neither class uses the simulator itself to measure the downstream consequence of an individual switch flip\. EventFlip, as outlined in Fig\.[2](https://arxiv.org/html/2611.33716#S1.F2), uses interventional differencing to obtain the effect of a switch flip on the loss, which differentiation cannot provide\. It restarts the original simulator from a stored state, sets a switch near its threshold to its other value, reruns to the end of the training window, and takes the difference between the two losses, which contains every consequence of the flip within the window\. The remaining task is to turn these scalar differences into a gradient with respect to the parameters\. Because the gradient of the hard loss contains no information about the jumps, we perturb every threshold with small Gaussian noise during training\. Every switch stays binary in each run, and the hard\-switch loss averaged over this noise approaches the original hard loss as the noise vanishes\. We show that the gradient of this noise\-averaged loss is the sum of a path gradient and a jump term\. The path gradient is readily available from automatic differentiation with all switches held fixed\. In the jump term, each switch contributes the expected loss difference between its on and off states\. This quantity cannot be obtained by differentiation, but the loss difference from interventional differencing is a sample of it\. Estimating the expectations in the jump term from these samples and adding the path gradient yields an unbiased estimator of the gradient of the noise\-averaged loss\. Optimizing the noise\-averaged loss with this estimator givesEventFlip\-Rand, whose training trajectories carry threshold noise\. Since the deployed simulator runs without noise,EventFlip\-Hardinstead carries out the original run and the reruns on the noise\-free simulator and adds the same jump term to the path gradient of the hard loss\. We further prove that this update targets the complete hard loss, both its continuous variation and its jumps\. Under the same forward budget, we compareEventFlipwith twelve baselines on a power\-grid cascade, a detonation wave, and cortical spreading depolarization\. Each variant ofEventFlipachieves lower error than every baseline on all three benchmarks, and the better of the variants lowers the error of the strongest baseline on each by factors of 1\.5, 1\.4, and 1\.4\. We summarize our contributions as follows: - •Formulation and Theory\.We model each hard switch as a random binary decision, so that every jump of the loss becomes a gradient term given by the loss difference between the two outcomes of the switch\. Building on smoothed perturbation analysis, we prove that the resulting estimator is unbiased and that its noise\-free counterpart still targets the complete hard loss\. - •Method\.To our knowledge,EventFlipis the first method that trains hybrid simulators through their hard switches by interventional differencing, in which the simulator is rerun with a flipped switch and the loss difference takes the place of the missing derivative\.EventFlip\-Randtrains under the randomized model, whileEventFlip\-Hardis a principled variant that trains on the complete hard loss with noise\-free simulator that is actually deployed\. - •Empirical Validation and Analysis\.EventFlipachieves the lowest error on all three scenarios we benchmarked\. Ablation studies and gradient analyses further explain why it succeeds where the baselines fail\. ## 2 Related Work Hybrid simulators and learned closures\.Training a closure through the solver has improved turbulence closures and atmospheric models\([Um et al\., 2020](https://arxiv.org/html/2611.33716#bib.bib60);[Belbute\-Peres et al\., 2020](https://arxiv.org/html/2611.33716#bib.bib6);[List et al\., 2022](https://arxiv.org/html/2611.33716#bib.bib32);[Frezat et al\., 2022](https://arxiv.org/html/2611.33716#bib.bib17);[Kochkov et al\., 2021](https://arxiv.org/html/2611.33716#bib.bib25);[Kochkov et al\., 2024](https://arxiv.org/html/2611.33716#bib.bib26);[Shen et al\., 2023](https://arxiv.org/html/2611.33716#bib.bib49)\)\. Derivative\-free approaches learn closures with reinforcement learning\([Novati et al\., 2021](https://arxiv.org/html/2611.33716#bib.bib40);[Bae and Koumoutsakos, 2022](https://arxiv.org/html/2611.33716#bib.bib3);[Kurz et al\., 2023](https://arxiv.org/html/2611.33716#bib.bib30);[von Bassewitz et al\., 2024](https://arxiv.org/html/2611.33716#bib.bib62)\)or ensemble Kalman inversion\([Dunbar et al\., 2021](https://arxiv.org/html/2611.33716#bib.bib15);[Lopez\-Gomez et al\., 2022](https://arxiv.org/html/2611.33716#bib.bib34)\)\. None of this work learns from the switch flips of the solver itself\. Existing models apply automatic differentiation with every switch held constant\([Feng et al\., 2022](https://arxiv.org/html/2611.33716#bib.bib16)\), restructure the model to avoid threshold functions\([Song et al\., 2023](https://arxiv.org/html/2611.33716#bib.bib52)\), relax the threshold into a sigmoid\([Seo, 2026](https://arxiv.org/html/2611.33716#bib.bib47)\), replace it together with its physics\([Kochkov et al\., 2024](https://arxiv.org/html/2611.33716#bib.bib26);[Varbella et al\., 2024](https://arxiv.org/html/2611.33716#bib.bib61);[Poli et al\., 2021](https://arxiv.org/html/2611.33716#bib.bib42);[Chen et al\., 2025](https://arxiv.org/html/2611.33716#bib.bib10)\), or learn a trigger from observations\([Zhang et al\., 2021](https://arxiv.org/html/2611.33716#bib.bib65)\)\. We keep the hard switches and train on the measured consequences of their flips\. Gradients through switches and discontinuities\.Event\-time differentiation and saltation matrices handle a single continuous\-time event or a fixed event sequence\([Chen et al\., 2020](https://arxiv.org/html/2611.33716#bib.bib11);[Kong et al\., 2024](https://arxiv.org/html/2611.33716#bib.bib27)\)\. Our switches are evaluated once per cell and step, so the step of a flip has no derivative and a flip changes which later switches flip\. Randomized smoothing\([Berthet et al\., 2020](https://arxiv.org/html/2611.33716#bib.bib9)\)and straight\-through estimation\([Bengio et al\., 2013](https://arxiv.org/html/2611.33716#bib.bib7);[Yin et al\., 2019](https://arxiv.org/html/2611.33716#bib.bib64);[Liu et al\., 2023](https://arxiv.org/html/2611.33716#bib.bib33)\)smooth the discontinuity or replace its derivative\. First\-order gradients are biased at discontinuities\([Suh et al\., 2022](https://arxiv.org/html/2611.33716#bib.bib54)\)\. Another line of work adds the term that automatic differentiation drops, as edge sampling and reparameterization do for visibility discontinuities in rendering\([Li et al\., 2018](https://arxiv.org/html/2611.33716#bib.bib31);[Loubet et al\., 2019](https://arxiv.org/html/2611.33716#bib.bib35);[Bangaru et al\., 2020](https://arxiv.org/html/2611.33716#bib.bib4)\)\. These methods rely on scene geometry to locate each discontinuity in advance\. In a solver, which switches flip is known only by running it, so we measure each jump by a rerun\. Gradient estimation for discrete and black\-box programs\.Policy\-gradient methods sample actions\([Williams, 1992](https://arxiv.org/html/2611.33716#bib.bib63);[Kool et al\., 2019](https://arxiv.org/html/2611.33716#bib.bib28);[Schulman et al\., 2017](https://arxiv.org/html/2611.33716#bib.bib46)\), discrete\-latent estimators relax the variable or add a score function\([Jang et al\., 2016](https://arxiv.org/html/2611.33716#bib.bib24);[Maddison et al\., 2016](https://arxiv.org/html/2611.33716#bib.bib36);[Tucker et al\., 2017](https://arxiv.org/html/2611.33716#bib.bib58)\), and zeroth\-order methods perturb the parameters\([Salimans et al\., 2017](https://arxiv.org/html/2611.33716#bib.bib44);[Spall, 1992](https://arxiv.org/html/2611.33716#bib.bib53);[Hansen and Ostermeier, 2001](https://arxiv.org/html/2611.33716#bib.bib21);[Nesterov and Spokoiny, 2017](https://arxiv.org/html/2611.33716#bib.bib38)\)\. Smoothed perturbation analysis\([Gong and Ho, 1987](https://arxiv.org/html/2611.33716#bib.bib20);[Glasserman, 1991](https://arxiv.org/html/2611.33716#bib.bib19);[Fu and Hu, 2012](https://arxiv.org/html/2611.33716#bib.bib18)\)and local expectation gradients\([Titsias and Lázaro\-Gredilla, 2015](https://arxiv.org/html/2611.33716#bib.bib55);[Tokui and Sato, 2017](https://arxiv.org/html/2611.33716#bib.bib56);[Ciosek and Whiteson, 2020](https://arxiv.org/html/2611.33716#bib.bib12)\)make the effect of one discrete event differentiable by conditioning on part of the randomness or summing exactly over one choice\. Stochastic automatic differentiation automates such estimators for discrete random variables and leaves deterministic comparisons as future work\([Arya et al\., 2022](https://arxiv.org/html/2611.33716#bib.bib1)\), and DiscoGrad smooths conditional branches by perturbing the program inputs\([Kreikemeyer and Andelfinger, 2023](https://arxiv.org/html/2611.33716#bib.bib29)\)\. Both execute the program inside their own framework, so an existing solver would have to be rewritten\.EventFlipshares the gradient form of this family but needs no such rewriting\. It randomizes only the thresholds of deterministic switches, obtains each loss difference by rerunning the existing solver, and reruns only switches in a threshold band\.EventFlip\-Hardtakes the same measurement on hard\-switch trajectories without noise\. ## 3 Method The loss can jump when a hard switch flips, and its local gradient does not capture these jumps\.EventFlipflips one switch and continues the simulation, comparing the losses of the two trajectories to measure the effect of this change directly\. It combines the measured loss difference and gradients through the continuous dynamics to update the model parameters\. ### 3\.1 Problem Formulation We consider a physical simulator with learnable parametersθ\\thetaand hard switches𝒃\{\\bm\{b\}\}, whose state is updated by 𝒖n\+1=Fθ\(𝒖n,𝒃n\),bn,i=𝟏\[mi\(𝒖n;θ\)≥0\]\.\{\\bm\{u\}\}\_\{n\+1\}=F\_\{\\theta\}\(\{\\bm\{u\}\}\_\{n\},\{\\bm\{b\}\}\_\{n\}\),\\qquad b\_\{n,i\}=\\mathbf\{1\}\[m\_\{i\}\(\{\\bm\{u\}\}\_\{n\};\\theta\)\\geq 0\]\.\(1\)Here𝒖n∈ℝN×C\{\\bm\{u\}\}\_\{n\}\\in\\mathbb\{R\}^\{N\\times C\}is the state at stepnn, withNNcells or components indexed byi=1,…,Ni=1,\\ldots,NandCCfeatures\.FθF\_\{\\theta\}is the state update map\. The vector𝒃n=\(bn,i\)i=1N\{\\bm\{b\}\}\_\{n\}=\(b\_\{n,i\}\)\_\{i=1\}^\{N\}contains the switch values at stepnn\. For cell or componentii,bn,i=1b\_\{n,i\}=1when the relevant physical quantity reaches or exceeds its threshold, andbn,i=0b\_\{n,i\}=0otherwise\. We write this threshold condition in the general parameterized formmi\(𝒖n,θ\)≥0m\_\{i\}\(\{\\bm\{u\}\}\_\{n\};\\theta\)\\geq 0, wheremim\_\{i\}is the switch margin\. The neural network forms the learnable part of the state updateFθF\_\{\\theta\}or the switch marginmi\(⋅,θ\)m\_\{i\}\(\\cdot;\\theta\)\. When it is part ofFθF\_\{\\theta\}, parameter changes affect the physical state and thereby influence later switch decisions\. When it is part ofmi\(⋅,θ\)m\_\{i\}\(\\cdot;\\theta\), parameter changes directly affect the threshold condition\. A switch decision in turn affects subsequent states and may change later switch decisions\. We learnθ\\thetaby fitting reference trajectories\{𝒖n∗\}\\\{\{\\bm\{u\}\}\_\{n\}^\{\*\}\\\}\. Each training window starts from a reference state and advances the simulatorKKsteps according to Eq\. \([1](https://arxiv.org/html/2611.33716#S3.E1)\)\. Summing the prediction errors over these steps gives the window loss of the hard\-switch simulator,Jhard\(θ\)=∑n=1Kℓn\(𝒖n\)J\_\{\\rm hard\}\(\\theta\)=\\sum\_\{n=1\}^\{K\}\\ell\_\{n\}\(\{\\bm\{u\}\}\_\{n\}\)\. Hereℓn\\ell\_\{n\}measures the error between the predicted state𝒖n\{\\bm\{u\}\}\_\{n\}and the reference state𝒖n∗\{\\bm\{u\}\}\_\{n\}^\{\*\}and is differentiable in𝒖n\{\\bm\{u\}\}\_\{n\}\. We call this window loss the hard loss, and training aims to minimize its average over training windows\. We call each evaluation of one switch at one step an*event*, whether or not its value changes, and index theNevtN\_\{\\rm evt\}events of a window byeein temporal order\. Eventeeoccurs at stepnen\_\{e\}in cell or componentiei\_\{e\}with marginme=mie\(𝒖ne,θ\)m\_\{e\}=m\_\{i\_\{e\}\}\(\{\\bm\{u\}\}\_\{n\_\{e\}\};\\theta\)and switch valuebeb\_\{e\}\. The valuesbeb\_\{e\}of a trajectory form its*switch history*\. The pre\-event historyHeH\_\{e\}consists of the state at which eventeeis evaluated and all earlier switch values\. The trajectory of Eq\. \([1](https://arxiv.org/html/2611.33716#S3.E1)\) is the hard\-switch trajectory, and a superscripthhmarks the quantities on it\. ### 3\.2 Theoretical Foundation The total change in the hard lossJhardJ\_\{\\rm hard\}as the parameters vary consists of two parts, the smooth change while the switches stay fixed and the jumps caused by switch flips\. When every switch decision stays fixed, the continuous states along the trajectory can still vary with the parameters, which changes the loss smoothly\. To compute this change, we hold all switch values fixed and differentiate the remaining continuous computations with respect to the parameters, denoting this total derivative by∇θpath\\nabla\_\{\\theta\}^\{\\rm path\}\. Applied to the window loss of a simulated trajectory, it gives the*path gradient*gpathg\_\{\\rm path\}, which is also the gradient returned by automatic differentiation\. On the hard\-switch trajectory, this gradient isgpathh=∇θpathJhardg\_\{\\rm path\}^\{h\}=\\nabla\_\{\\theta\}^\{\\rm path\}J\_\{\\rm hard\}\. When a switch flips as its event margin crosses zero, the subsequent trajectory can jump, and the loss can jump with it\. To describe the consequences of the two switch values of an eventee, we start from its pre\-event state, force its switch tob∈\{0,1\}b\\in\\\{0,1\\\}, and run to the end of the window while every later switch is decided again by Eq\. \([1](https://arxiv.org/html/2611.33716#S3.E1)\)\. We denote the downstream loss byGeh\(b\)=∑n\>neℓnG\_\{e\}^\{h\}\(b\)=\\sum\_\{n\>n\_\{e\}\}\\ell\_\{n\}\. The*flip loss difference*isΔeh=Geh\(1\)−Geh\(0\)\\Delta\_\{e\}^\{h\}=G\_\{e\}^\{h\}\(1\)\-G\_\{e\}^\{h\}\(0\)\. Now consider a continuously differentiable parameter pathθ\(t\)\\theta\(t\),t∈\[0,1\]t\\in\[0,1\]\. On each interval where the switch history stays fixed,gpathh⋅θ˙g\_\{\\rm path\}^\{h\}\\cdot\\dot\{\\theta\}is the rate of change of the loss along the path, and every switch flip along the path adds a jump\. Under the crossing conditions in Appendix[A\.5](https://arxiv.org/html/2611.33716#A1.SS5), Jhard\(θ\(1\)\)−Jhard\(θ\(0\)\)=∫01gpathh⋅θ˙dt\+∑k=1rωkΔekh\.\\displaystyle J\_\{\\rm hard\}\(\\theta\(1\)\)\-J\_\{\\rm hard\}\(\\theta\(0\)\)=\\int\_\{0\}^\{1\}g\_\{\\rm path\}^\{h\}\\cdot\\dot\{\\theta\}\\,dt\+\\sum\_\{k=1\}^\{r\}\\omega\_\{k\}\\,\\Delta\_\{e\_\{k\}\}^\{h\}\.\(2\)Hererris the number of zero crossings along the path,eke\_\{k\}is the event at thekk\-th crossing, andΔekh\\Delta\_\{e\_\{k\}\}^\{h\}is evaluated at that parameter value\. The signωk\\omega\_\{k\}is\+1\+1when the switch turns on and−1\-1when it turns off\. Wherever a small change ofθ\\thetaflips no switch,∇θJhard=gpathh\\nabla\_\{\\theta\}J\_\{\\rm hard\}=g\_\{\\rm path\}^\{h\}, so the gradient of the hard loss contains nothing of the second part\. To let a gradient carry the jumps, we randomize the threshold of every event with small Gaussian noise and define the smoothed objectiveJσJ\_\{\\sigma\}by be=𝟏\[me≥σξe\],ξe∼𝒩\(0,1\)i\.i\.d\.,Jσ\(θ\)=𝔼ξ\[∑n=1Kℓn\(𝒖n\)\]\.\\begin\{gathered\}b\_\{e\}=\\mathbf\{1\}\[m\_\{e\}\\geq\\sigma\\xi\_\{e\}\],\\qquad\\xi\_\{e\}\\sim\\mathcal\{N\}\(0,1\)\\ \\text\{i\.i\.d\.\},\\\\ J\_\{\\sigma\}\(\\theta\)=\\mathbb\{E\}\_\{\\xi\}\\Bigl\[\\,\\sum\_\{n=1\}^\{K\}\\ell\_\{n\}\(\{\\bm\{u\}\}\_\{n\}\)\\Bigr\]\.\\end\{gathered\}\(3\)Hereσ\>0\\sigma\>0is the width,ξ=\(ξe\)e\\xi=\(\\xi\_\{e\}\)\_\{e\}collects the noise of all events, and the sum is the window loss of the randomized simulator\. When no margin of the hard\-switch trajectory is zero,Jσ→JhardJ\_\{\\sigma\}\\to J\_\{\\rm hard\}asσ→0\\sigma\\to 0\(Proposition[A\.2](https://arxiv.org/html/2611.33716#Thmtheorem2a)\(b\) in Appendix[A\.5](https://arxiv.org/html/2611.33716#A1.SS5)\)\. Training with randomized switches minimizesJσJ\_\{\\sigma\}, and deployment uses the hard\-switch simulator\. The switch values stay binary in every randomized run, and the only change is that each switch takes the value11with probabilityPr\(be=1∣He\)=Φ\(me/σ\)\\Pr\(b\_\{e\}=1\\mid H\_\{e\}\)=\\Phi\(m\_\{e\}/\\sigma\), whereΦ\\Phiis the standard normal distribution function\. SoJσ\(θ\)=∑βPθ\(β\)Lθ\(β\)J\_\{\\sigma\}\(\\theta\)=\\sum\_\{\\beta\}P\_\{\\theta\}\(\\beta\)\\,L\_\{\\theta\}\(\\beta\), the lossLθ\(β\)L\_\{\\theta\}\(\\beta\)of each switch historyβ\\betaweighted by its probabilityPθ\(β\)P\_\{\\theta\}\(\\beta\), andθ\\thetaenters both factors\. We call the derivative of the probabilityΦ\(me/σ\)\\Phi\(m\_\{e\}/\\sigma\)with respect to the margin the*sensitivity*,κσ\(m\)=ϕ\(m/σ\)/σ\\kappa\_\{\\sigma\}\(m\)=\\phi\(m/\\sigma\)/\\sigma, whereϕ\\phiis the standard normal density\. It is a Gaussian density of widthσ\\sigmacentered at zero, so it is larger the closer the margin is to zero\. The*advantage*of eventeeis its expected flip loss difference given the history before the event, 𝒜e=𝔼\[Ge\(1\)−Ge\(0\)∣He\]\.\\mathcal\{A\}\_\{e\}=\\mathbb\{E\}\\bigl\[G\_\{e\}\(1\)\-G\_\{e\}\(0\)\\mid H\_\{e\}\\bigr\]\.\(4\)HereGeG\_\{e\}andΔe=Ge\(1\)−Ge\(0\)\\Delta\_\{e\}=G\_\{e\}\(1\)\-G\_\{e\}\(0\)areGehG\_\{e\}^\{h\}andΔeh\\Delta\_\{e\}^\{h\}with the later switches decided by the randomized rule in Eq\. \([3](https://arxiv.org/html/2611.33716#S3.E3)\), and the expectation is over their noise\. Following smoothed perturbation analysis\([Fu and Hu, 2012](https://arxiv.org/html/2611.33716#bib.bib18);[Arya et al\., 2022](https://arxiv.org/html/2611.33716#bib.bib1);[Mohamed et al\., 2020](https://arxiv.org/html/2611.33716#bib.bib37)\), we derive and prove the gradient ofJσJ\_\{\\sigma\}for switches that are deterministic functions of the state with randomized thresholds \(Appendix[A\.2](https://arxiv.org/html/2611.33716#A1.SS2)\)\. ###### Proposition 1\(Gradient of the smoothed objective\)\. Fix a training window and a widthσ\>0\\sigma\>0\. Under the regularity conditions of Appendix[A\.1](https://arxiv.org/html/2611.33716#A1.SS1), ∇θJσ\(θ\)=𝔼ξ\[gpath\+∑e=1Nevt𝒜e⏟Advantage\(on vs\. off\)κσ\(me\)∇θpathme⏟Gradient of probabilitythat the switch is on\]\.\\nabla\_\{\\theta\}J\_\{\\sigma\}\(\\theta\)=\\mathbb\{E\}\_\{\\xi\}\\Bigl\[g\_\{\\rm path\}\+\\sum\_\{e=1\}^\{N\_\{\\rm evt\}\}\\underbrace\{\\mathcal\{A\}\_\{e\}\}\_\{\\begin\{subarray\}\{c\}\\textnormal\{Advantage\}\\\\ \\textnormal\{\(on vs\.\\ off\)\}\\end\{subarray\}\}\\,\\underbrace\{\\kappa\_\{\\sigma\}\(m\_\{e\}\)\\,\\nabla\_\{\\theta\}^\{\\rm path\}m\_\{e\}\}\_\{\\begin\{subarray\}\{c\}\\textnormal\{Gradient of probability\}\\\\ \\textnormal\{that the switch is on\}\\end\{subarray\}\}\\Bigr\]\.\(5\)Heregpathg\_\{\\rm path\},mem\_\{e\}, and𝒜e\\mathcal\{A\}\_\{e\}are evaluated on the randomized trajectory\. The first term, the expected path gradient, is the pathwise term, and the second is the jump term\. Each randomized switch is a coin, a Bernoulli policy that is on with probabilityΦ\(me/σ\)\\Phi\(m\_\{e\}/\\sigma\)\. The parametersθ\\thetaset the bias of this coin through the marginmem\_\{e\}\. Each event contributes how far the parameters push its coin toward on,∇θpathΦ\(me/σ\)=κσ\(me\)∇θpathme\\nabla\_\{\\theta\}^\{\\rm path\}\\Phi\(m\_\{e\}/\\sigma\)=\\kappa\_\{\\sigma\}\(m\_\{e\}\)\\nabla\_\{\\theta\}^\{\\rm path\}m\_\{e\}, times how much more loss the switch gives in expectation when on than when off,𝒜e\\mathcal\{A\}\_\{e\}, so the jump term is an expected policy gradient over switch decisions\([Tokui and Sato, 2017](https://arxiv.org/html/2611.33716#bib.bib56);[Ciosek and Whiteson, 2020](https://arxiv.org/html/2611.33716#bib.bib12)\)\. The path gradient, the sensitivities, and the margin derivatives∇θpathme\\nabla\_\{\\theta\}^\{\\rm path\}m\_\{e\}in Eq\. \([5](https://arxiv.org/html/2611.33716#S3.E5)\) can all be computed on the trajectory that is actually simulated, which we call the*base trajectory*\. The remaining quantity in Eq\. \([5](https://arxiv.org/html/2611.33716#S3.E5)\), the advantage𝒜e\\mathcal\{A\}\_\{e\}, is an expectation and must be estimated from samples\. The*flip branch*of eventee\(Fig\.[2](https://arxiv.org/html/2611.33716#S1.F2)b\) restarts the simulator from the state𝒖ne\{\\bm\{u\}\}\_\{n\_\{e\}\}of the base trajectory, sets the switch of eventeeto1−be1\-b\_\{e\}, decides every later switch under the threshold noise of the base trajectory, and runs to the end of the window\. This gives a sample of the flip loss differenceΔe=Ge\(1\)−Ge\(0\)\\Delta\_\{e\}=G\_\{e\}\(1\)\-G\_\{e\}\(0\), whereGe\(be\)G\_\{e\}\(b\_\{e\}\)is taken from the base trajectory andGe\(1−be\)G\_\{e\}\(1\-b\_\{e\}\)from the flip branch\. The conditional expectation of this sample is the advantage,𝔼\[Δe∣He,be\]=𝒜e\\mathbb\{E\}\[\\Delta\_\{e\}\\mid H\_\{e\},b\_\{e\}\]=\\mathcal\{A\}\_\{e\}\. We share the noise between the two runs so that they differ only through this one flip, to lower the variance of the sample without changing its mean \(Appendix[A\.4](https://arxiv.org/html/2611.33716#A1.SS4)\)\. ### 3\.3EventFlip EventFliphas two variants, which differ in whether the training trajectories draw threshold noise\.EventFlip\-Randdraws the noise as in Eq\. \([3](https://arxiv.org/html/2611.33716#S3.E3)\) and rolls out the base trajectory\. The flip branch of eventeecostsK−neK\-n\_\{e\}solver steps, so a branch for every event is too expensive, and each window therefore runs branches only forMMsampled events\. The base trajectory and theMMflip branches together cost at most\(1\+M\)K\(1\+M\)Ksolver steps per window, all counted in the forward budget\. An event whose two values give the same state update has zero flip loss difference, so only the other events, the*eligible*eventsℰelig\\mathcal\{E\}\_\{\\rm elig\}, need a branch\. The weight of an eligible event in the jump term is its sensitivityκσ\(me\)\\kappa\_\{\\sigma\}\(m\_\{e\}\), which is close to zero once the margin is more than a fewσ\\sigmaaway from the threshold\. We therefore sample only from the*threshold band*ℬτ=\{e∈ℰelig∣\|me\|<τσ\}\\mathcal\{B\}\_\{\\tau\}=\\\{e\\in\\mathcal\{E\}\_\{\\rm elig\}\\mid\|m\_\{e\}\|<\\tau\\sigma\\\}, whereτ\\tauis a fixed cutoff, and an event of the band is selected with probability πe=\(1−λ\)κσ\(me\)∑e′∈ℬτκσ\(me′\)\+λ\|ℬτ\|,e∈ℬτ\.\\pi\_\{e\}=\(1\-\\lambda\)\\,\\frac\{\\kappa\_\{\\sigma\}\(m\_\{e\}\)\}\{\\sum\_\{e^\{\\prime\}\\in\\mathcal\{B\}\_\{\\tau\}\}\\kappa\_\{\\sigma\}\(m\_\{e^\{\\prime\}\}\)\}\+\\frac\{\\lambda\}\{\|\\mathcal\{B\}\_\{\\tau\}\|\},\\qquad e\\in\\mathcal\{B\}\_\{\\tau\}\.\(6\)Hereλ∈\(0,1\]\\lambda\\in\(0,1\]is a fixed uniform fraction\. The first part is proportional to the sensitivity because the sensitivity is the weight of the event in the jump term and is also known before any branch runs, whereas the flip loss difference is known only after its branch\. The uniform part keeps every selection probability in the band away from zero, so the weights1/πe1/\\pi\_\{e\}stay bounded\. For any selection probabilities computed from the base trajectory, the gradient estimate is g^σ=gpath\+1M∑j=1MΔe\(j\)κσ\(me\(j\)\)∇θpathme\(j\)πe\(j\)\.\\widehat\{g\}\_\{\\sigma\}=g\_\{\\rm path\}\+\\frac\{1\}\{M\}\\sum\_\{j=1\}^\{M\}\\frac\{\\Delta\_\{e\_\{\(j\)\}\}\\,\\kappa\_\{\\sigma\}\(m\_\{e\_\{\(j\)\}\}\)\\,\\nabla\_\{\\theta\}^\{\\rm path\}m\_\{e\_\{\(j\)\}\}\}\{\\pi\_\{e\_\{\(j\)\}\}\}\.\(7\)Here the eventse\(1\),…,e\(M\)e\_\{\(1\)\},\\ldots,e\_\{\(M\)\}are drawn fromπ\\piindependently with replacement givenξ\\xi, andve=κσ\(me\)Δe∇θpathmev\_\{e\}=\\kappa\_\{\\sigma\}\(m\_\{e\}\)\\,\\Delta\_\{e\}\\,\\nabla\_\{\\theta\}^\{\\rm path\}m\_\{e\}is the event vector\. The estimate differs from Eq\. \([5](https://arxiv.org/html/2611.33716#S3.E5)\) in two places, where the sampleΔe\\Delta\_\{e\}measured by the flip branch replaces the advantage and the average over theMMsampled events replaces the sum over all events\. Dividing byπe\\pi\_\{e\}makes the expected average over the sampled events equal to the sum ofvev\_\{e\}over every event with positive selection probability\. ###### Proposition 2\(Unbiasedness under full\-support event sampling\)\. Let the flip branches share the later threshold noise of the base trajectory\. Let the selection probabilities in Eq\. \([7](https://arxiv.org/html/2611.33716#S3.E7)\) depend only on the base trajectory and be positive for every eligible event, which we call full\-support event sampling\. Then, under the regularity conditions of Appendix[A\.1](https://arxiv.org/html/2611.33716#A1.SS1), the estimator is unbiased for every integerM≥1M\\geq 1, that is, 𝔼\[g^σ\]=∇θJσ\(θ\)\.\\mathbb\{E\}\[\\widehat\{g\}\_\{\\sigma\}\]=\\nabla\_\{\\theta\}J\_\{\\sigma\}\(\\theta\)\.\(8\) The rule in Eq\. \([6](https://arxiv.org/html/2611.33716#S3.E6)\) gives positive probability only inside the threshold band, so the eligible events outside the band are never drawn\. However, their weightκσ\(me\)\\kappa\_\{\\sigma\}\(m\_\{e\}\)is close to zero, so omitting them leaves a small bias\. The expected update ofEventFlip\-Randdiffers from∇θJσ\\nabla\_\{\\theta\}J\_\{\\sigma\}by a bias whose bound decays ase−τ2/2e^\{\-\\tau^\{2\}/2\}, and this bound holds however many switches are near their thresholds \(Appendix[A\.2](https://arxiv.org/html/2611.33716#A1.SS2)proves Proposition[2](https://arxiv.org/html/2611.33716#Thmtheorem2), Appendix[A\.3](https://arxiv.org/html/2611.33716#A1.SS3)proves the bound, and Appendix[C\.8](https://arxiv.org/html/2611.33716#A3.SS8)measures the bias\)\. EventFlip\-Randtrains with threshold noise, and deployment has none\.EventFlip\-Hardtrains on the hard\-switch simulator, the one that is deployed\. It draws no threshold noise, which setsξ≡0\\xi\\equiv 0, and still uses the estimate in Eq\. \([7](https://arxiv.org/html/2611.33716#S3.E7)\)\. This is possible because every factor of Eq\. \([7](https://arxiv.org/html/2611.33716#S3.E7)\) can be computed on the simulator without noise\. Its base trajectory is the hard\-switch trajectory, on which the path gradientgpathhg\_\{\\rm path\}^\{h\}and the margin derivatives∇θpathmeh\\nabla\_\{\\theta\}^\{\\rm path\}m\_\{e\}^\{h\}are computed as before\. The flip branches decide the later switches by Eq\. \([1](https://arxiv.org/html/2611.33716#S3.E1)\), so they measure the flip loss differenceΔeh\\Delta\_\{e\}^\{h\}of the hard\-switch simulator\. The sensitivity and the selection probabilities are functions of the margins andσ\\sigmaonly\. Hereσ\\sigmais no longer the size of a noise, and as a width it sets how close to the threshold a margin must be for its event to enter the threshold band and how fast the weight of an event in the band decays with this distance\. Averaging Eq\. \([7](https://arxiv.org/html/2611.33716#S3.E7)\) over the event draws gives the expected update ofEventFlip\-Hard, ghard,band=gpathh\+∑e∈ℬτhκσ\(meh\)Δeh∇θpathmeh\.g\_\{\\rm hard,band\}=g\_\{\\rm path\}^\{h\}\+\\sum\_\{e\\in\\mathcal\{B\}\_\{\\tau\}^\{h\}\}\\kappa\_\{\\sigma\}\(m\_\{e\}^\{h\}\)\\,\\Delta\_\{e\}^\{h\}\\,\\nabla\_\{\\theta\}^\{\\rm path\}m\_\{e\}^\{h\}\.\(9\)Its two parts are its pathwise term and its jump term\. The update in Eq\. \([9](https://arxiv.org/html/2611.33716#S3.E9)\) is computed entirely on the hard\-switch simulator, so we compare its integral along a parameter path with the change of the hard loss in Eq\. \([2](https://arxiv.org/html/2611.33716#S3.E2)\)\. ###### Proposition 3\(Consistency ofEventFlip\-Hardwith the hard loss\)\. Letθ\(t\)\\theta\(t\)be a parameter path as in Eq\. \([2](https://arxiv.org/html/2611.33716#S3.E2)\), under the conditions of Appendix[A\.5](https://arxiv.org/html/2611.33716#A1.SS5)\. The expected update in Eq\. \([9](https://arxiv.org/html/2611.33716#S3.E9)\) ofEventFlip\-Hardsatisfies limσ→0∫01ghard,band⋅θ˙𝑑t=∫01gpathh⋅θ˙𝑑t\+\(2Φ\(τ\)−1\)∑k=1rωkΔekh\.\\displaystyle\\lim\_\{\\sigma\\to 0\}\\int\_\{0\}^\{1\}g\_\{\\rm hard,band\}\\cdot\\dot\{\\theta\}\\,dt=\\int\_\{0\}^\{1\}g\_\{\\rm path\}^\{h\}\\cdot\\dot\{\\theta\}\\,dt\+\\bigl\(2\\Phi\(\\tau\)\-1\\bigr\)\\sum\_\{k=1\}^\{r\}\\omega\_\{k\}\\,\\Delta\_\{e\_\{k\}\}^\{h\}\.\(10\) The limit has the same two parts as Eq\. \([2](https://arxiv.org/html/2611.33716#S3.E2)\), with the extra factor2Φ\(τ\)−12\\Phi\(\\tau\)\-1on the jumps\. This factor is the mass of the sensitivityκσ\\kappa\_\{\\sigma\}, a density of total mass one, inside the threshold band, and it differs from11by at moste−τ2/2e^\{\-\\tau^\{2\}/2\}\. The update ofEventFlip\-Hardtherefore targets the complete hard loss, including the jumps that its gradient misses\. The same integral of∇θJσ\\nabla\_\{\\theta\}J\_\{\\sigma\}tends to the full change of the hard loss in Eq\. \([2](https://arxiv.org/html/2611.33716#S3.E2)\) asσ→0\\sigma\\to 0\(Appendix[A\.5](https://arxiv.org/html/2611.33716#A1.SS5)\)\. SoEventFlip\-Randcarries the jumps in its training objectiveJσJ\_\{\\sigma\}, andEventFlip\-Hardin its update\. Algorithm[1](https://arxiv.org/html/2611.33716#algorithm1)in Appendix[A\.4](https://arxiv.org/html/2611.33716#A1.SS4)gives training updates of both variants on one window\. ## 4 Experiments ### 4\.1 Experimental Setup Benchmarks\.We evaluate our method across three physical benchmarks featuring distinct switching regimes \(Table[B\.1](https://arxiv.org/html/2611.33716#A2.T1)\)\. In each benchmark, an embedded neural closure parameterizes unresolved physical processes\. The*power\-grid cascade*simulates a cascading failure on the IEEE 118\-bus transmission network, where any line whose power flow exceeds its rating \(maximum allowable flow\) permanently trips\. The closure predicts these latent line ratings without direct supervision; because the post\-trip power flow depends solely on the network topology, the path gradient vanishes identically\. The*detonation wave*simulates a one\-dimensional combustion wave propagating through unburnt gas on a coarse grid\([Bao and Jin, 2000](https://arxiv.org/html/2611.33716#bib.bib5)\), where a computational cell ignites once its temperature surpasses a critical ignition threshold\. Following standard learned\-closure formulations\([Um et al\., 2020](https://arxiv.org/html/2611.33716#bib.bib60);[Kochkov et al\., 2021](https://arxiv.org/html/2611.33716#bib.bib25)\), the network corrects inter\-cell numerical fluxes to match a fine\-grid reference, with the dominant learning signal propagating through the path gradient\.*Cortical spreading depolarization*models post\-stroke wave propagation across brain tissue\([Dreier and Reiffurth, 2015](https://arxiv.org/html/2611.33716#bib.bib14)\)via the reaction\-diffusion of extracellular K\+on a coarse64×6464\\times 64grid\([Tuckwell and Miura, 1978](https://arxiv.org/html/2611.33716#bib.bib59);[Nicholson and Syková, 1998](https://arxiv.org/html/2611.33716#bib.bib39)\)\. A cell irreversibly activates once its local K\+concentration crosses an excitation threshold\. The domain comprises an unexcitable infarct core surrounded by a vulnerable penumbra with a reduced activation threshold\. The closure similarly predicts inter\-cell K\+flux corrections\. Training configurations\.The twelve baselines fall into two groups \(Appendix[B\.6](https://arxiv.org/html/2611.33716#A2.SS6)\)\. Four are gradient\-based and differentiate through the solver, namely direct differentiation \(Direct\)\([Um et al\., 2020](https://arxiv.org/html/2611.33716#bib.bib60);[Feng et al\., 2022](https://arxiv.org/html/2611.33716#bib.bib16)\), sigmoid relaxation \(Sigmoid\)\([Seo, 2026](https://arxiv.org/html/2611.33716#bib.bib47)\), straight\-through estimation \(STE\)\([Bengio et al\., 2013](https://arxiv.org/html/2611.33716#bib.bib7)\), and AoBG\([Suh et al\., 2022](https://arxiv.org/html/2611.33716#bib.bib54)\)\. The other eight are derivative\-free and use only rollouts of the solver, including ES\([Salimans et al\., 2017](https://arxiv.org/html/2611.33716#bib.bib44)\), SPSA\([Spall, 1992](https://arxiv.org/html/2611.33716#bib.bib53)\), CMA\-ES\([Hansen and Ostermeier, 2001](https://arxiv.org/html/2611.33716#bib.bib21)\), EKI\([Iglesias et al\., 2013](https://arxiv.org/html/2611.33716#bib.bib23)\), RLOO\([Kool et al\., 2019](https://arxiv.org/html/2611.33716#bib.bib28)\), GRPO\-clip\([Shao et al\., 2024](https://arxiv.org/html/2611.33716#bib.bib48)\), PPO\([Schulman et al\., 2017](https://arxiv.org/html/2611.33716#bib.bib46)\), and Closure\-RL\([von Bassewitz et al\., 2024](https://arxiv.org/html/2611.33716#bib.bib62)\), which does not apply to the power grid\. All methods are trained under an identical forward evaluation budget \(750k simulator steps on the power grid and 800k on the remaining two benchmarks\), accounting for all flip branches, ensemble members, and perturbed rollouts \(Appendix[B\.5](https://arxiv.org/html/2611.33716#A2.SS5)\)\. Table[B\.2](https://arxiv.org/html/2611.33716#A2.T2)lists the configurations of all methods\. Evaluation\.We assess performance using a primary metric per benchmark, namely the rollout loss over line flows and shed load for the power\-grid cascade, the relative wave\-speed error for the detonation wave, and the normalized activation\-time error for cortical spreading depolarization, defined as the mean absolute error in first\-activation time normalized by the observation span\. At test time, all trained closures are deployed inside the deterministic hard\-switch simulator \(Appendix[B\.5](https://arxiv.org/html/2611.33716#A2.SS5)\)\. Each method is trained across three random seeds, and test performance is reported at the checkpoint with the lowest validation error on the primary metric\. ### 4\.2 Main Results Table 1:Test error on the primary metric across benchmarks, reported as the mean across three random seeds with standard deviations shown as subscripts\. Bold, underlined and italicized entries denote the lowest, second\-lowest and third\-lowest errors\. Gray entries indicate runs whose error remains within 10% of the untrained closure\.Both variants ofEventFlipconsistently achieve the lowest error across all three benchmarks \(Table[1](https://arxiv.org/html/2611.33716#S4.T1)\)\. Against the strongest baseline in each regime \(namely CMA\-ES on power grid, sigmoid relaxation on detonation wave, and Closure\-RL on cortical spreading depolarization\) our top\-performing variant reduces error by factors of 1\.5, 1\.4, and 1\.4, respectively\. Notably, existing baselines fail to generalize across different switching mechanisms, as the strongest baseline in one benchmark often fails in another, whereasEventFlipranks first across all three\. Figure 3:Test error against forward budget, evaluated using the best validation checkpoint at each budget level \(three\-seed mean\)\. Horizontal dashed lines indicate the full\-budget error of the strongest baseline in each benchmark\. Additional baselines are plotted in gray, with failed runs omitted for clarity\.On the power grid, the lower rollout loss ofEventFlipmeans more faithful predictions of cascading dynamics\. Specifically,EventFlip\-Hardreduces the mean shed\-load error to 0\.63% of the system load, compared with 1\.03% for the strongest baseline, CMA\-ES \(Appendix[C\.1](https://arxiv.org/html/2611.33716#A3.SS1)\), and lowers the rollout loss by 38% on severe cascades \(Appendix[C\.3](https://arxiv.org/html/2611.33716#A3.SS3)\)\. In the representative case shown in Fig\.[1](https://arxiv.org/html/2611.33716#S0.F1),EventFlip\-Hardrecovers the reference cascade trajectory, whereas CMA\-ES and direct differentiation trigger no line trips\. On the detonation wave, CMA\-ES fails to learn beyond initialization, yielding a wave\-speed error of 13\.016% compared with 13\.569% for untrained closure, leaving sigmoid relaxation as the strongest baseline\. This advantage also extends to the post\-shock flow field, whereEventFlip\-Randachieves peak\-pressure errors of 0\.92%, outperforming sigmoid relaxation at 1\.77% \(Appendix[C\.1](https://arxiv.org/html/2611.33716#A3.SS1)\)\. On cortical spreading depolarization, sigmoid relaxation in turn stays near initialization, yielding a nearly untrained error, leaving Closure\-RL and direct differentiation as the closest baselines, whereas Closure\-RL itself fails to train on the detonation wave\. Our performance gain also holds within the penumbra, where accurately capturing wave invasion is clinically critical, withEventFlip\-HardandEventFlip\-Randachieving activation\-time errors of 0\.522% and 0\.544%, respectively, outperforming direct differentiation at 0\.651% and Closure\-RL at 1\.055% \(Appendix[C\.1](https://arxiv.org/html/2611.33716#A3.SS1)\)\. As visualized in Fig\.[1](https://arxiv.org/html/2611.33716#S0.F1),EventFlipkeeps the activation\-time error within two time steps across most of the tissue domain, whereas other baselines exhibit widespread temporal drift\. While the comparisons above evaluate performance at the full forward budget,EventFlipestablishes a clear lead earlier in training \(Fig\.[3](https://arxiv.org/html/2611.33716#S4.F3)\)\. On power grid, both variants already achieve lower loss than the full\-budget performance of every baseline within the first 100k simulator steps\. Similarly, on detonation wave, our top\-performing variant matches the full\-budget error of sigmoid relaxation using only 1/4 of the solver budget\. These sample\-efficiency gains confirm that the advantage ofEventFlipstems from the fidelity of its gradient estimator rather than increased computation\. ### 4\.3 Ablation and Mechanism Analysis Table 2:Test error on ablation study\.Test error on the primary metrics \(mean across three random seeds\)\. On power grid, the jump\-only variants reduce to the full methods \(==\)\.Gradient decomposition\.Proposition[1](https://arxiv.org/html/2611.33716#Thmtheorem1)decomposes the gradient of the smoothed objective into a continuous path gradient and a discrete jump term, as mirrored byEventFlip\-Hardupdate in Eq\. \([9](https://arxiv.org/html/2611.33716#S3.E9)\)\. To isolate their roles, we train with the path gradient alone \(direct differentiation\), the jump term alone, and their combination \(upper block of Table[2](https://arxiv.org/html/2611.33716#S4.T2)\)\. On power grid, where the path gradient vanishes identically, direct differentiation receives zero learning signal and stays at the untrained loss, whereas incorporating the jump term reduces the loss to 0\.067 forEventFlip\-Hard\. Consequently, direct differentiation recovers only 8\.5% of the reference line trips, compared with 71% forEventFlip\-Hard\(Appendix[C\.4](https://arxiv.org/html/2611.33716#A3.SS4)\)\. Because the closure directly parameterizes line ratings whose ground\-truth is known in this benchmark, we can further verify the underlying learning mechanism\. Across line\-case pairs loaded to at least 80% of capacity,EventFlip\-Hardreduces the RMSE of the predicted logarithmic rating from untrained 0\.211 to 0\.026, and from 0\.186 to 0\.046–0\.051 across all pairs \(Appendix[C\.5](https://arxiv.org/html/2611.33716#A3.SS5)\), confirming that the jump term recovers the switching thresholds\. In the remaining two scenarios, where the path gradient is nonzero, we examine whether the jump term remains necessary and whether it suffices in isolation\. On the detonation wave, neither component is sufficient on its own, yielding wave\-speed errors of 0\.641% without the jump term and 4\.3–4\.4% without the path gradient, compared with approximately 0\.1% when both are combined\. Cortical spreading depolarization exhibits the same answer, with both terms together achieving the lowest error, whereas omitting the jump term degrades accuracy more severely than omitting the path gradient, increasing the error to 1\.068%\. Flip\-branch measurement\.Unlike the path gradient, the jump term cannot be computed via automatic differentiation and must instead be estimated from downstream loss difference across the two states of each switch\.EventFlipisolates this effect using a flip branch that diverges from the base trajectory solely at the perturbed switch \(Section[3\.2](https://arxiv.org/html/2611.33716#S3.SS2)\)\. To quantify the importance of this counterfactual rollout, we ablate this design in two stages \(lower block of Table[2](https://arxiv.org/html/2611.33716#S4.T2)\)\. Both ablations preserve the expected gradient update while inflating its variance\. First, we sample independent threshold noise along the flip branch rather than sharing it with the base trajectory\. The resulting variance inflation scales with the number of near\-threshold switches per training window, as uncorrelated noise introduces extraneous stochasticity across all remaining near\-threshold events\. On power\-grid cascade and detonation wave, which average only 1 to 8 near\-threshold switches per window, jump\-term variance and test errors remain largely unaffected \(Appendix[C\.6](https://arxiv.org/html/2611.33716#A3.SS6)\)\. By contrast, on cortical spreading depolarization, where each window contains about 350 near\-threshold switches, independent noise inflates gradient variance by 9×\\timesat the trained closure, degrading the error from 0\.759% to 1\.101%\. Thus, despite remaining unbiased, the estimator loses nearly all gains from the jump term due to variance explosion\. Conversely,EventFlip\-Hardeliminates threshold noise altogether, ensuring that the base and flip trajectories diverge solely at the target switch and achieving a low error of 0\.793%\. Second, we remove flip branches entirely, estimating each switch advantage solely from the downstream loss of the base trajectory, centered by its mean across the remaining minibatch windows\. This REINFORCE\-style ablation\([Williams, 1992](https://arxiv.org/html/2611.33716#bib.bib63)\)is detailed in Appendix[C\.7](https://arxiv.org/html/2611.33716#A3.SS7)\. However, raw downstream losses vary substantially across trajectories and confound the stochastic outcomes of all concurrent switches\. Under the same forward budget, this credit\-assignment noise inflates the jump\-term variance at initialization on cortical spreading depolarization by 4,681×\\timesrelative to the full method\. Consequently, test error degrades sharply with the number of near\-threshold switches\. While accuracy remains comparable on power grid at 0\.064 versus 0\.072, the error rises from 0\.120% to 0\.169% on detonation wave and stalls at 11\.720% on cortical spreading depolarization\. These results demonstrate that unbiasedness alone is insufficient without low\-variance credit assignment\. By perturbing one switch along an otherwise identical rollout, each flip isolates the causal consequence of that event, enablingEventFlipto scale from one switch to hundreds of concurrent switches\. Gradient fidelity\.While the preceding evaluations measure post\-training accuracy, we now directly assess the fidelity of the gradient updates themselves\. By Proposition[2](https://arxiv.org/html/2611.33716#Thmtheorem2), under full\-support event samplingEventFlip\-Randprovides an unbiased gradient estimator for the smoothed objective\. To check the gradient in practice, we project the gradients returned in the training configuration onto probe directions and compare them against finite\-difference directional derivatives of the smoothed objective \(Appendix[C\.8](https://arxiv.org/html/2611.33716#A3.SS8)\)\. Across all three benchmarks and at both untrained and trained checkpoints, the directional derivatives returned byEventFlip\-Randremain within 0\.34–1\.2 times of the reference \(Table[C\.9](https://arxiv.org/html/2611.33716#A3.T9)\)\. Applying the same diagnostic to sigmoid relaxation and straight\-through estimation reveals severe gradient distortion\. Although sigmoid relaxation trains successfully on detonation wave where switches are re\-evaluated at every step, on cortical spreading depolarization, where an activated cell raises its own threshold, both baselines overestimate directional derivatives by10410^\{4\}–10710^\{7\}times at the trained closure, and neither trains there\. Even on detonation wave, straight\-through estimation inflates gradients by10210^\{2\}–10510^\{5\}times at the trained closure, leaving ourEventFlip\-Randas the only method whose gradients consistently stay within a factor of three of the reference across all benchmarks\. ## 5 Discussion and Conclusion We showed that hybrid physical simulators with hard threshold switches can be trained end\-to\-end by querying the native solver to measure the causal consequences of switch flips\. These measured jumps recover the discontinuous gradients omitted by standard automatic differentiation, and perturbing one switch at a time preserves low\-variance credit assignment even when hundreds of events lie near thresholds\. Several promising directions remain for future work\. First, because each flip branch currently re\-executes the solver to the end of the training window, exploiting spatiotemporal locality to reuse unaffected computations from the base trajectory could substantially reduce rollout overhead\. Second, establishing formal convergence guarantees forEventFlip\-Hard, which couples the pathwise gradient of the hard lossJhardJ\_\{\\rm hard\}with deterministic flip loss differences \(Appendix[A\.5](https://arxiv.org/html/2611.33716#A1.SS5)\), remains an open theoretical question\. Finally, we plan to scaleEventFlipto more complex solvers and higher\-capacity neural closures\. #### LLM Usage Statement We used Codex \(OpenAI\) for two purposes\. In the writing, it polished the language of the manuscript text\. In the research, it assisted the literature search for related work, and the authors read and verified every cited paper\. It was not used for scientific ideation, methodology development, or experimental data collection\. The authors have reviewed all AI\-assisted content and take full responsibility for the final manuscript\. #### Acknowledgments This work was supported by the Fundamental and Interdisciplinary Disciplines Breakthrough Plan of the Ministry of Education of China \(JYB2025XDXIM801\) and the National Natural Science Foundation of China \(42125503 and 42430602\)\. #### Ethics Statement This work develops a training method for hybrid physical simulators and evaluates it on numerical benchmarks of a cascading failure in a power grid, a detonation wave, and cortical spreading depolarization in brain tissue\. It involves no human participants or personal data\. Learned simulators of combustion and power systems can inform safety assessments, and those of brain tissue can support mechanistic studies of spreading depolarization\. Their use in such settings requires validation against reference solvers and measurements\. #### Reproducibility Statement Section[3](https://arxiv.org/html/2611.33716#S3)and Algorithm[1](https://arxiv.org/html/2611.33716#algorithm1)specify the estimator and the training update\. Appendix[A](https://arxiv.org/html/2611.33716#A1)gives the complete derivations and proofs, including the conditions of Proposition[1](https://arxiv.org/html/2611.33716#Thmtheorem1)and Proposition[2](https://arxiv.org/html/2611.33716#Thmtheorem2)and the bound of Proposition[A\.1](https://arxiv.org/html/2611.33716#Thmtheorem1a)\. Appendix[B](https://arxiv.org/html/2611.33716#A2)documents all three simulators, the closure architectures, the configuration ofEventFlip, the forward budgets, the training and evaluation protocol, and the configuration of every baseline\. Appendix[C](https://arxiv.org/html/2611.33716#A3)reports the full results on the three simulators\. Source code and training configurations are available at[https://github\.com/gaotianrun1/pderl](https://github.com/gaotianrun1/pderl)\. ## References - Arya et al\. \(2022\)Gaurav Arya, Moritz Schauer, Frank Schäfer, and Christopher Rackauckas\.Automatic differentiation of programs with discrete randomness\.*Advances in Neural Information Processing Systems*, 35:10435–10447, 2022\. - Babaeinejadsarookolaee et al\. \(2019\)Sogol Babaeinejadsarookolaee, Adam Birchfield, Richard D Christie, Carleton Coffrin, Christopher DeMarco, Ruisheng Diao, Michael Ferris, Stephane Fliscounakis, Scott Greene, Renke Huang, et al\.The power grid library for benchmarking AC optimal power flow algorithms\.*arXiv preprint arXiv:1908\.02788*, 2019\. - Bae and Koumoutsakos \(2022\)H Jane Bae and Petros Koumoutsakos\.Scientific multi\-agent reinforcement learning for wall\-models of turbulent flows\.*Nature Communications*, 13\(1\):1443, 2022\. - Bangaru et al\. \(2020\)Sai Praveen Bangaru, Tzu\-Mao Li, and Frédo Durand\.Unbiased warped\-area sampling for differentiable rendering\.*ACM Transactions on Graphics*, 39\(6\):1–18, 2020\.doi:10\.1145/3414685\.3417833\. - Bao and Jin \(2000\)Weizhu Bao and Shi Jin\.The random projection method for hyperbolic conservation laws with stiff reaction terms\.*Journal of Computational Physics*, 163\(1\):216–248, 2000\. - Belbute\-Peres et al\. \(2020\)Filipe De Avila Belbute\-Peres, Thomas Economon, and Zico Kolter\.Combining differentiable PDE solvers and graph neural networks for fluid flow prediction\.In*international conference on machine learning*, pages 2402–2411\. PMLR, 2020\. - Bengio et al\. \(2013\)Yoshua Bengio, Nicholas Léonard, and Aaron Courville\.Estimating or propagating gradients through stochastic neurons for conditional computation\.*arXiv preprint arXiv:1308\.3432*, 2013\. - Bernstein et al\. \(2014\)Andrey Bernstein, Daniel Bienstock, David Hay, Meric Uzunoglu, and Gil Zussman\.Power grid vulnerability to geographically correlated failures—analysis and control implications\.In*IEEE INFOCOM 2014\-IEEE Conference on Computer Communications*, pages 2634–2642\. IEEE, 2014\. - Berthet et al\. \(2020\)Quentin Berthet, Mathieu Blondel, Olivier Teboul, Marco Cuturi, Jean\-Philippe Vert, and Francis Bach\.Learning with differentiable perturbed optimizers\.*Advances in neural information processing systems*, 33:9508–9519, 2020\. - Chen et al\. \(2025\)Qianyi Chen, Tianrun Gao, Chenbo Jiang, and Tailin Wu\.Eqcollide: Equivariant and collision\-aware deformable objects neural simulator\.*arXiv preprint arXiv:2506\.05797*, 2025\. - Chen et al\. \(2020\)Ricky TQ Chen, Brandon Amos, and Maximilian Nickel\.Learning neural event functions for ordinary differential equations\.*arXiv preprint arXiv:2011\.03902*, 2020\. - Ciosek and Whiteson \(2020\)Kamil Ciosek and Shimon Whiteson\.Expected policy gradients for reinforcement learning\.*Journal of Machine Learning Research*, 21\(52\):1–51, 2020\. - Dreier \(2011\)Jens P Dreier\.The role of spreading depression, spreading depolarization and spreading ischemia in neurological disease\.*Nature medicine*, 17\(4\):439–447, 2011\. - Dreier and Reiffurth \(2015\)Jens P Dreier and Clemens Reiffurth\.The stroke\-migraine depolarization continuum\.*Neuron*, 86\(4\):902–922, 2015\. - Dunbar et al\. \(2021\)Oliver RA Dunbar, Alfredo Garbuno\-Inigo, Tapio Schneider, and Andrew M Stuart\.Calibration and uncertainty quantification of convective parameters in an idealized GCM\.*Journal of Advances in Modeling Earth Systems*, 13\(9\):e2020MS002454, 2021\. - Feng et al\. \(2022\)Dapeng Feng, Jiangtao Liu, Kathryn Lawson, and Chaopeng Shen\.Differentiable, learnable, regionalized process\-based models with multiphysical outputs can approach state\-of\-the\-art hydrologic prediction accuracy\.*Water Resources Research*, 58\(10\):e2022WR032404, 2022\. - Frezat et al\. \(2022\)Hugo Frezat, Julien Le Sommer, Ronan Fablet, Guillaume Balarac, and Redouane Lguensat\.A posteriori learning for quasi\-geostrophic turbulence parametrization\.*Journal of Advances in Modeling Earth Systems*, 14\(11\):e2022MS003124, 2022\. - Fu and Hu \(2012\)Michael C Fu and Jian\-Qiang Hu\.*Conditional Monte Carlo: Gradient estimation and optimization applications*, volume 392\.Springer Science & Business Media, 2012\. - Glasserman \(1991\)Paul Glasserman\.*Gradient estimation via perturbation analysis*, volume 116\.Springer Science & Business Media, 1991\. - Gong and Ho \(1987\)Wei\-Bo Gong and Yu\-Chi Ho\.Smoothed \(conditional\) perturbation analysis of discrete event dynamical systems\.*IEEE Transactions on Automatic Control*, 32\(10\):858–866, 1987\. - Hansen and Ostermeier \(2001\)Nikolaus Hansen and Andreas Ostermeier\.Completely derandomized self\-adaptation in evolution strategies\.*Evolutionary computation*, 9\(2\):159–195, 2001\. - IEEE \(2013\)IEEE\.IEEE standard for calculating the current\-temperature relationship of bare overhead conductors\.*IEEE Std 738\-2012 \(Revision of IEEE Std 738\-2006 \- Incorporates IEEE Std 738\-2012 Cor 1\-2013\)*, pages 1–72, 2013\.doi:10\.1109/IEEESTD\.2013\.6692858\. - Iglesias et al\. \(2013\)Marco A Iglesias, Kody JH Law, and Andrew M Stuart\.Ensemble Kalman methods for inverse problems\.*Inverse Problems*, 29\(4\):045001, 2013\. - Jang et al\. \(2016\)Eric Jang, Shixiang Gu, and Ben Poole\.Categorical reparameterization with gumbel\-softmax\.*arXiv preprint arXiv:1611\.01144*, 2016\. - Kochkov et al\. \(2021\)Dmitrii Kochkov, Jamie A Smith, Ayya Alieva, Qing Wang, Michael P Brenner, and Stephan Hoyer\.Machine learning–accelerated computational fluid dynamics\.*Proceedings of the National Academy of Sciences*, 118\(21\):e2101784118, 2021\. - Kochkov et al\. \(2024\)Dmitrii Kochkov, Janni Yuval, Ian Langmore, Peter Norgaard, Jamie Smith, Griffin Mooers, Milan Klöwer, James Lottes, Stephan Rasp, Peter Düben, et al\.Neural general circulation models for weather and climate\.*Nature*, 632\(8027\):1060–1066, 2024\. - Kong et al\. \(2024\)Nathan J Kong, J Joe Payne, James Zhu, and Aaron M Johnson\.Saltation matrices: The essential tool for linearizing hybrid dynamical systems\.*Proceedings of the IEEE*, 112\(6\):585–608, 2024\. - Kool et al\. \(2019\)Wouter Kool, Herke van Hoof, and Max Welling\.Buy 4 REINFORCE samples, get a baseline for free\!ICLR 2019 Workshop on Deep Reinforcement Learning Meets Structured Prediction, 2019\.URL[https://openreview\.net/forum?id=r1lgTGL5DE](https://openreview.net/forum?id=r1lgTGL5DE)\. - Kreikemeyer and Andelfinger \(2023\)Justin N Kreikemeyer and Philipp Andelfinger\.Smoothing methods for automatic differentiation across conditional branches\.*IEEE Access*, 11:143190–143211, 2023\. - Kurz et al\. \(2023\)Marius Kurz, Philipp Offenhäuser, and Andrea Beck\.Deep reinforcement learning for turbulence modeling in large eddy simulations\.*International journal of heat and fluid flow*, 99:109094, 2023\. - Li et al\. \(2018\)Tzu\-Mao Li, Miika Aittala, Frédo Durand, and Jaakko Lehtinen\.Differentiable Monte Carlo ray tracing through edge sampling\.*ACM Transactions on Graphics*, 37\(6\):1–11, 2018\.doi:10\.1145/3272127\.3275109\. - List et al\. \(2022\)Björn List, Li\-Wei Chen, and Nils Thuerey\.Learned turbulence modelling with differentiable fluid solvers: physics\-based loss functions and optimisation horizons\.*Journal of Fluid Mechanics*, 949:A25, 2022\. - Liu et al\. \(2023\)Liyuan Liu, Chengyu Dong, Xiaodong Liu, Bin Yu, and Jianfeng Gao\.Bridging discrete and backpropagation: Straight\-through and beyond\.*Advances in Neural Information Processing Systems*, 36:12291–12311, 2023\. - Lopez\-Gomez et al\. \(2022\)Ignacio Lopez\-Gomez, Costa Christopoulos, Haakon Ludvig Langeland Ervik, Oliver RA Dunbar, Yair Cohen, and Tapio Schneider\.Training physics\-based machine\-learning parameterizations with gradient\-free ensemble Kalman methods\.*Journal of Advances in Modeling Earth Systems*, 14\(8\):e2022MS003105, 2022\. - Loubet et al\. \(2019\)Guillaume Loubet, Nicolas Holzschuch, and Wenzel Jakob\.Reparameterizing discontinuous integrands for differentiable rendering\.*ACM Transactions on Graphics*, 38\(6\):1–14, 2019\.doi:10\.1145/3355089\.3356510\. - Maddison et al\. \(2016\)Chris J Maddison, Andriy Mnih, and Yee Whye Teh\.The concrete distribution: A continuous relaxation of discrete random variables\.*arXiv preprint arXiv:1611\.00712*, 2016\. - Mohamed et al\. \(2020\)Shakir Mohamed, Mihaela Rosca, Michael Figurnov, and Andriy Mnih\.Monte Carlo gradient estimation in machine learning\.*Journal of Machine Learning Research*, 21\(132\):1–62, 2020\. - Nesterov and Spokoiny \(2017\)Yurii Nesterov and Vladimir Spokoiny\.Random gradient\-free minimization of convex functions\.*Foundations of Computational Mathematics*, 17\(2\):527–566, 2017\. - Nicholson and Syková \(1998\)Charles Nicholson and Eva Syková\.Extracellular space structure revealed by diffusion analysis\.*Trends in neurosciences*, 21\(5\):207–215, 1998\. - Novati et al\. \(2021\)Guido Novati, Hugues Lascombes De Laroussilhe, and Petros Koumoutsakos\.Automating turbulence modelling by multi\-agent reinforcement learning\.*Nature Machine Intelligence*, 3\(1\):87–96, 2021\. - Oran and Gamezo \(2007\)Elaine S Oran and Vadim N Gamezo\.Origins of the deflagration\-to\-detonation transition in gas\-phase combustion\.*Combustion and flame*, 148\(1\-2\):4–47, 2007\. - Poli et al\. \(2021\)Michael Poli, Stefano Massaroli, Luca Scimeca, Sanghyuk Chun, Seong Joon Oh, Atsushi Yamashita, Hajime Asama, Jinkyoo Park, and Animesh Garg\.Neural hybrid automata: Learning dynamics with multiple modes and stochastic transitions\.*Advances in Neural Information Processing Systems*, 34:9977–9989, 2021\. - Ros and Hansen \(2008\)Raymond Ros and Nikolaus Hansen\.A simple modification in CMA\-ES achieving linear time and space complexity\.In*International conference on parallel problem solving from nature*, pages 296–305\. Springer, 2008\. - Salimans et al\. \(2017\)Tim Salimans, Jonathan Ho, Xi Chen, Szymon Sidor, and Ilya Sutskever\.Evolution strategies as a scalable alternative to reinforcement learning\.*arXiv preprint arXiv:1703\.03864*, 2017\. - Schulman et al\. \(2015\)John Schulman, Philipp Moritz, Sergey Levine, Michael Jordan, and Pieter Abbeel\.High\-dimensional continuous control using generalized advantage estimation\.*arXiv preprint arXiv:1506\.02438*, 2015\. - Schulman et al\. \(2017\)John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov\.Proximal policy optimization algorithms\.*arXiv preprint arXiv:1707\.06347*, 2017\. - Seo \(2026\)Jaemin Seo\.TokaGrad: End\-to\-end differentiable tokamak simulator for L\-to\-H full scenario optimization\.*arXiv preprint arXiv:2607\.09088*, 2026\. - Shao et al\. \(2024\)Zhihong Shao, Peiyi Wang, Qihao Zhu, Runxin Xu, Junxiao Song, Xiao Bi, Haowei Zhang, Mingchuan Zhang, YK Li, Yang Wu, et al\.DeepSeekMath: Pushing the limits of mathematical reasoning in open language models\.*arXiv preprint arXiv:2402\.03300*, 2024\. - Shen et al\. \(2023\)Chaopeng Shen, Alison P Appling, Pierre Gentine, Toshiyuki Bandai, Hoshin Gupta, Alexandre Tartakovsky, Marco Baity\-Jesi, Fabrizio Fenicia, Daniel Kifer, Li Li, et al\.Differentiable modelling to unify machine learning and physical models for geosciences\.*Nature Reviews Earth & Environment*, 4\(8\):552–567, 2023\. - Shepherd \(2009\)Joseph E Shepherd\.Detonation in gases\.*Proceedings of the Combustion Institute*, 32\(1\):83–98, 2009\. - Soltan et al\. \(2014\)Saleh Soltan, Dorian Mazauric, and Gil Zussman\.Cascading failures in power grids: analysis and algorithms\.In*Proceedings of the 5th international conference on Future energy systems*, pages 195–206, 2014\. - Song et al\. \(2023\)Yalan Song, Wouter JM Knoben, Martyn P Clark, Dapeng Feng, Kathryn E Lawson, and Chaopeng Shen\.When ancient numerical demons meet physics\-informed machine learning: adjoint\-based gradients for implicit differentiable modeling\.*Hydrology and Earth System Sciences Discussions*, 2023:1–35, 2023\. - Spall \(1992\)James C Spall\.Multivariate stochastic approximation using a simultaneous perturbation gradient approximation\.*IEEE transactions on automatic control*, 37\(3\):332–341, 1992\. - Suh et al\. \(2022\)Hyung Ju Suh, Max Simchowitz, Kaiqing Zhang, and Russ Tedrake\.Do differentiable simulators give better policy gradients?In*International Conference on Machine Learning*, pages 20668–20696\. PMLR, 2022\. - Titsias and Lázaro\-Gredilla \(2015\)Michalis Titsias and Miguel Lázaro\-Gredilla\.Local expectation gradients for black box variational inference\.*Advances in neural information processing systems*, 28, 2015\. - Tokui and Sato \(2017\)Seiya Tokui and Issei Sato\.Evaluating the variance of likelihood\-ratio gradient estimators\.In*International Conference on Machine Learning*, pages 3414–3423\. PMLR, 2017\. - Tsuyuki \(1996\)T Tsuyuki\.Variational data assimilation in the tropics using precipitation data part i: Column model\.*Meteorology and Atmospheric Physics*, 60\(1\):87–104, 1996\. - Tucker et al\. \(2017\)George Tucker, Andriy Mnih, Chris J Maddison, John Lawson, and Jascha Sohl\-Dickstein\.Rebar: Low\-variance, unbiased gradient estimates for discrete latent variable models\.*Advances in Neural Information Processing Systems*, 30, 2017\. - Tuckwell and Miura \(1978\)Henry C Tuckwell and Robert M Miura\.A mathematical model for spreading cortical depression\.*Biophysical Journal*, 23\(2\):257–276, 1978\. - Um et al\. \(2020\)Kiwon Um, Robert Brand, Yun Raymond Fei, Philipp Holl, and Nils Thuerey\.Solver\-in\-the\-loop: Learning from differentiable physics to interact with iterative PDE\-solvers\.*Advances in neural information processing systems*, 33:6111–6122, 2020\. - Varbella et al\. \(2024\)Anna Varbella, Kenza Amara, Blazhe Gjorgiev, Mennatallah El\-Assady, and Giovanni Sansavini\.Powergraph: A power grid benchmark dataset for graph neural networks\.*Advances in Neural Information Processing Systems*, 37:110784–110804, 2024\. - von Bassewitz et al\. \(2024\)Jan\-Philipp von Bassewitz, Sebastian Kaltenbach, and Petros Koumoutsakos\.Closure discovery for coarse\-grained partial differential equations using grid\-based reinforcement learning\.*arXiv preprint arXiv:2402\.00972*, 2024\. - Williams \(1992\)Ronald J Williams\.Simple statistical gradient\-following algorithms for connectionist reinforcement learning\.*Machine learning*, 8\(3\):229–256, 1992\. - Yin et al\. \(2019\)Penghang Yin, Jiancheng Lyu, Shuai Zhang, Stanley Osher, Yingyong Qi, and Jack Xin\.Understanding straight\-through estimator in training activation quantized neural nets\.*arXiv preprint arXiv:1903\.05662*, 2019\. - Zhang et al\. \(2021\)Tao Zhang, Wuyin Lin, Andrew M Vogelmann, Minghua Zhang, Shaocheng Xie, Yi Qin, and Jean\-Christophe Golaz\.Improving convection trigger functions in deep convective parameterization schemes using machine learning\.*Journal of Advances in Modeling Earth Systems*, 13\(5\):e2020MS002365, 2021\. - Zimmerman et al\. \(2010\)Ray Daniel Zimmerman, Carlos Edmundo Murillo\-Sánchez, and Robert John Thomas\.MATPOWER: Steady\-state operations, planning, and analysis tools for power systems research and education\.*IEEE Transactions on power systems*, 26\(1\):12–19, 2010\. ## Appendix ATheory and algorithm This appendix proves the propositions of Section[3](https://arxiv.org/html/2611.33716#S3)and gives the training update\. Appendix[A\.1](https://arxiv.org/html/2611.33716#A1.SS1)writes the smoothed objective as a sum over finite event histories and states the regularity conditions\. Appendix[A\.2](https://arxiv.org/html/2611.33716#A1.SS2)sums over the two values of each switch to express the switch contribution in terms of the flip loss difference and thereby proves Propositions[1](https://arxiv.org/html/2611.33716#Thmtheorem1)and[2](https://arxiv.org/html/2611.33716#Thmtheorem2)\. Appendix[A\.3](https://arxiv.org/html/2611.33716#A1.SS3)restricts event sampling to the threshold band and bounds the resulting bias \(Proposition[A\.1](https://arxiv.org/html/2611.33716#Thmtheorem1a)\)\. Appendix[A\.4](https://arxiv.org/html/2611.33716#A1.SS4)then presents the backward implementation\. Finally, Appendix[A\.5](https://arxiv.org/html/2611.33716#A1.SS5)relates both variants to the hard loss \(Propositions[A\.2](https://arxiv.org/html/2611.33716#Thmtheorem2a)and[A\.5](https://arxiv.org/html/2611.33716#Thmtheorem2b)\)\. Table A\.1:Notation for the gradient derivation\.Gradients and event contributions are parameter\-space vectors\.Table[A\.1](https://arxiv.org/html/2611.33716#A1.T1)lists the notation used in the derivations\. ### A\.1 Finite event histories and the path gradient This subsection gives the finite\-history form of the smoothed objective in Section[3\.2](https://arxiv.org/html/2611.33716#S3.SS2)and states the regularity conditions assumed by Propositions[1](https://arxiv.org/html/2611.33716#Thmtheorem1)–[3](https://arxiv.org/html/2611.33716#Thmtheorem3)and[A\.1](https://arxiv.org/html/2611.33716#Thmtheorem1a)–[A\.2](https://arxiv.org/html/2611.33716#Thmtheorem2a)\. We collect the window’s fixed initial state, reference observations, physical inputs, and time\-step schedule into a contextxx\. LetNevtN\_\{\\rm evt\}denote the fixed number of potential binary events\. Throughout this finite\-window derivation, we holdxxfixed and suppress it in the expectation notation\. A complete historyβ=\(β1,…,βNevt\)\\beta=\(\\beta\_\{1\},\\ldots,\\beta\_\{N\_\{\\rm evt\}\}\)specifies every switch value, andβ<e\\beta\_\{<e\}denotes the values preceding eventee\. Once the history is fixed, the simulator is deterministic\. We write the resulting loss asLθ\(β,x\)L\_\{\\theta\}\(\\beta;x\)and the conditional probability that eventeeis on asqe\(θ,β<e,x\)=Φ\(me\(θ,β<e,x\)/σ\)q\_\{e\}\(\\theta,\\beta\_\{<e\};x\)=\\Phi\\bigl\(m\_\{e\}\(\\theta,\\beta\_\{<e\};x\)/\\sigma\\bigr\)\. ##### Regularity conditions\. At the parameter value of interest, we assume an open neighborhood on which every complete history keeps the same outcomes for the simulator’s validity checks and substep selection\. Any history that fails a check receives the penalty of Appendix[B](https://arxiv.org/html/2611.33716#A2)\. On this neighborhood,Lθ\(β,x\)L\_\{\\theta\}\(\\beta;x\)andme\(θ,β<e,x\)m\_\{e\}\(\\theta,\\beta\_\{<e\};x\)are continuously differentiable for every history and its prefixes\. This condition also covers unrandomized numerical operations such as absolute values and limiters\. It holds when, for each fixed history, the branch that every such operation takes does not change on the neighborhood\. In the three simulators of Appendix[B](https://arxiv.org/html/2611.33716#A2), for example, it holds when, for each history, the minmod limiter of the detonation wave keeps its branch in every cell and step and the rollout of cortical spreading depolarization neither enters nor leaves the invalid states\. The power\-grid margins\|f\|/cθ−1\|f\|/c\_\{\\theta\}\-1are continuously differentiable in the closure because the switch history fixes the line flowsff\. Since the margins are finite andσ\>0\\sigma\>0is fixed, we have0<qe<10<q\_\{e\}<1\. Conditions for averaging over contexts are stated at the end of this subsection\. An event is eligible when its two switch values produce different state updates, and we writeℰelig\\mathcal\{E\}\_\{\\rm elig\}for the set of eligible events of a history\. Every potential event, including every ineligible event, receives an independent threshold perturbation\. At an ineligible event, either switch value produces the same state update and zero consequence\. This convention keepsNevtN\_\{\\rm evt\}fixed\. Simultaneous switches are ordered for conditioning, while their physical state update remains joint\. The state𝒖n\{\\bm\{u\}\}\_\{n\}may also store continuous quantities read by the loss, such as fuel consumed between observations, which are updated alongside the other continuous variables\. When a single step evaluates switches across several stages,FθF\_\{\\theta\}composes those stages into one step\. In that case, the state𝒖¯e\\bar\{\\bm\{u\}\}\_\{e\}at which eventeeis tested is the state before that event’s stage, and the lossesℓ1,…,ℓne\\ell\_\{1\},\\ldots,\\ell\_\{n\_\{e\}\}still precede eventee\. Let𝗉e\\mathsf\{p\}\_\{e\}denote the probability of the specified valueβe\\beta\_\{e\}conditioned on the preceding history\. By the chain rule, these conditional probabilities determine the complete\-history probability, so realized events can depend on earlier decisions\. 𝗉e\(θ,β,x\)\\displaystyle\\mathsf\{p\}\_\{e\}\(\\theta,\\beta;x\)=qeβe\(1−qe\)1−βe,\\displaystyle=q\_\{e\}^\{\\beta\_\{e\}\}\(1\-q\_\{e\}\)^\{1\-\\beta\_\{e\}\},Pθ\(β∣x\)\\displaystyle P\_\{\\theta\}\(\\beta\\mid x\)=∏e=1Nevt𝗉e\(θ,β,x\),\\displaystyle=\\prod\_\{e=1\}^\{N\_\{\\rm evt\}\}\\mathsf\{p\}\_\{e\}\(\\theta,\\beta;x\),\(A\.1\)Jσ\(θ∣x\)\\displaystyle J\_\{\\sigma\}\(\\theta\\mid x\)=∑β∈\{0,1\}NevtPθ\(β∣x\)Lθ\(β,x\)\.\\displaystyle=\\sum\_\{\\beta\\in\\\{0,1\\\}^\{N\_\{\\rm evt\}\}\}P\_\{\\theta\}\(\\beta\\mid x\)L\_\{\\theta\}\(\\beta;x\)\.\(A\.2\) Because the threshold noiseξ\\xidetermines the historyβ\\beta, expectations over histories are written𝔼ξ\\mathbb\{E\}\_\{\\xi\}\. The fixed\-history path gradient isgpath\(β,x\)=∇θLθ\(β,x\)g\_\{\\rm path\}\(\\beta;x\)=\\nabla\_\{\\theta\}L\_\{\\theta\}\(\\beta;x\)\. When differentiating a history\-specific loss, state, margin, or probability factor, we holdxxand the specified binary values fixed\. The superscriptpath\\mathrm\{path\}marks this convention explicitly on state\-dependent quantities, so∇θpath\\nabla\_\{\\theta\}^\{\\rm path\}is the total derivative taken with every switch value held fixed, as in Section[3\.2](https://arxiv.org/html/2611.33716#S3.SS2)\. Differentiating the finite sum term by term separates the change in each history’s loss from the contribution of its changing probability\. ∇θJσ\(θ∣x\)\\displaystyle\\nabla\_\{\\theta\}J\_\{\\sigma\}\(\\theta\\mid x\)=∑β∇θ\[Pθ\(β∣x\)Lθ\(β,x\)\]\\displaystyle=\\sum\_\{\\beta\}\\nabla\_\{\\theta\}\\bigl\[P\_\{\\theta\}\(\\beta\\mid x\)L\_\{\\theta\}\(\\beta;x\)\\bigr\]=∑βPθ\(β∣x\)gpath\(β,x\)\+∑βLθ\(β,x\)∇θPθ\(β∣x\)\.\\displaystyle=\\sum\_\{\\beta\}P\_\{\\theta\}\(\\beta\\mid x\)g\_\{\\rm path\}\(\\beta;x\)\+\\sum\_\{\\beta\}L\_\{\\theta\}\(\\beta;x\)\\nabla\_\{\\theta\}P\_\{\\theta\}\(\\beta\\mid x\)\.\(A\.3\) The derivative of the history probability follows by differentiating each conditional factor in turn\. Because every factor is positive, the result can be written as a sum of logarithmic derivatives\. ∇θPθ\(β∣x\)\\displaystyle\\nabla\_\{\\theta\}P\_\{\\theta\}\(\\beta\\mid x\)=∑e=1Nevt\(∏e′≠e𝗉e′\)∇θ𝗉e\\displaystyle=\\sum\_\{e=1\}^\{N\_\{\\rm evt\}\}\\left\(\\prod\_\{e^\{\\prime\}\\neq e\}\\mathsf\{p\}\_\{e^\{\\prime\}\}\\right\)\\nabla\_\{\\theta\}\\mathsf\{p\}\_\{e\}=Pθ\(β∣x\)∑e=1Nevt∇θ𝗉e𝗉e\\displaystyle=P\_\{\\theta\}\(\\beta\\mid x\)\\sum\_\{e=1\}^\{N\_\{\\rm evt\}\}\\frac\{\\nabla\_\{\\theta\}\\mathsf\{p\}\_\{e\}\}\{\\mathsf\{p\}\_\{e\}\}=Pθ\(β∣x\)∑e=1Nevt∇θlog𝗉e\.\\displaystyle=P\_\{\\theta\}\(\\beta\\mid x\)\\sum\_\{e=1\}^\{N\_\{\\rm evt\}\}\\nabla\_\{\\theta\}\\log\\mathsf\{p\}\_\{e\}\.\(A\.4\) Letse=∇θlog𝗉es\_\{e\}=\\nabla\_\{\\theta\}\\log\\mathsf\{p\}\_\{e\}be the conditional probability score\. Withβe\\beta\_\{e\}fixed at zero or one, its Bernoulli form gives log𝗉e\\displaystyle\\log\\mathsf\{p\}\_\{e\}=βelogqe\+\(1−βe\)log\(1−qe\),\\displaystyle=\\beta\_\{e\}\\log q\_\{e\}\+\(1\-\\beta\_\{e\}\)\\log\(1\-q\_\{e\}\),se\\displaystyle s\_\{e\}=βe∇θpathqeqe−\(1−βe\)∇θpathqe1−qe\\displaystyle=\\beta\_\{e\}\\frac\{\\nabla\_\{\\theta\}^\{\\rm path\}q\_\{e\}\}\{q\_\{e\}\}\-\(1\-\\beta\_\{e\}\)\\frac\{\\nabla\_\{\\theta\}^\{\\rm path\}q\_\{e\}\}\{1\-q\_\{e\}\}=\(βeqe−1−βe1−qe\)∇θpathqe\.\\displaystyle=\\left\(\\frac\{\\beta\_\{e\}\}\{q\_\{e\}\}\-\\frac\{1\-\\beta\_\{e\}\}\{1\-q\_\{e\}\}\\right\)\\nabla\_\{\\theta\}^\{\\rm path\}q\_\{e\}\.\(A\.5\) Substituting the probability derivative, written with these scores, yields a pathwise term and a score\-weighted loss term, both averaged over the complete\-history distribution\. ∇θJσ\(θ∣x\)\\displaystyle\\nabla\_\{\\theta\}J\_\{\\sigma\}\(\\theta\\mid x\)=∑βPθ\(β∣x\)gpath\(β,x\)\+∑βPθ\(β∣x\)Lθ\(β,x\)∑ese\\displaystyle=\\sum\_\{\\beta\}P\_\{\\theta\}\(\\beta\\mid x\)g\_\{\\rm path\}\(\\beta;x\)\+\\sum\_\{\\beta\}P\_\{\\theta\}\(\\beta\\mid x\)L\_\{\\theta\}\(\\beta;x\)\\sum\_\{e\}s\_\{e\}=𝔼ξ\[gpath\]\+𝔼ξ\[Lθ∑e=1Nevtse\]\.\\displaystyle=\\mathbb\{E\}\_\{\\xi\}\[g\_\{\\rm path\}\]\+\\mathbb\{E\}\_\{\\xi\}\\left\[L\_\{\\theta\}\\sum\_\{e=1\}^\{N\_\{\\rm evt\}\}s\_\{e\}\\right\]\.\(A\.6\) Even with earlier switches held fixed, the continuous state can still depend on the parameters\. For example, we writeme=me\(𝒖¯e\(θ,β<e,x\),θ\)m\_\{e\}=m\_\{e\}\(\\bar\{\\bm\{u\}\}\_\{e\}\(\\theta,\\beta\_\{<e\};x\);\\theta\), where𝒖¯e\\bar\{\\bm\{u\}\}\_\{e\}is the state at which the threshold of eventeeis tested \(that is,𝒖ne\{\\bm\{u\}\}\_\{n\_\{e\}\}in Eq\. \([1](https://arxiv.org/html/2611.33716#S3.E1)\) when a step evaluates its switches in a single stage\)\. The margin derivative accounts for both direct parameter dependence and the dependence propagated through the preceding continuous states\. ∇θpathme=∇θme\(𝒖,θ\)\|𝒖=𝒖¯e\+\(∂path𝒖¯e∂θ\)𝖳∇𝒖me\(𝒖¯e,θ\)\.\\nabla\_\{\\theta\}^\{\\rm path\}m\_\{e\}=\\left\.\\nabla\_\{\\theta\}m\_\{e\}\(\{\\bm\{u\}\};\\theta\)\\right\|\_\{\{\\bm\{u\}\}=\\bar\{\\bm\{u\}\}\_\{e\}\}\+\\left\(\\frac\{\\partial^\{\\rm path\}\\bar\{\\bm\{u\}\}\_\{e\}\}\{\\partial\\theta\}\\right\)^\{\\\!\\mathsf\{T\}\}\\nabla\_\{\{\\bm\{u\}\}\}m\_\{e\}\(\\bar\{\\bm\{u\}\}\_\{e\};\\theta\)\.\(A\.7\) State derivatives act on the continuous coordinates while the discrete memory remains fixed by the specified history\. The decomposition in Eq\. \([A\.6](https://arxiv.org/html/2611.33716#A1.E6)\) forms the product\-rule basis of pathwise and likelihood\-ratio estimators\([Mohamed et al\., 2020](https://arxiv.org/html/2611.33716#bib.bib37);[Arya et al\., 2022](https://arxiv.org/html/2611.33716#bib.bib1)\)\. ##### Averaging over window contexts\. The training windows in Section[3\.1](https://arxiv.org/html/2611.33716#S3.SS1)start from reference states that do not depend onθ\\theta\. Given a parameter\-independent distributionν\\nuof window contextsxxfor which the losses and derivatives are integrable and differentiation can be interchanged with the expectation, the averaged objective and its gradient are J¯σ\(θ\)\\displaystyle\\overline\{J\}\_\{\\sigma\}\(\\theta\)=𝔼x∼ν\[Jσ\(θ∣x\)\],\\displaystyle=\\mathbb\{E\}\_\{x\\sim\\nu\}\[J\_\{\\sigma\}\(\\theta\\mid x\)\],\(A\.8\)∇θJ¯σ\\displaystyle\\nabla\_\{\\theta\}\\overline\{J\}\_\{\\sigma\}=𝔼x∼ν\[∇θJσ\(θ∣x\)\]\.\\displaystyle=\\mathbb\{E\}\_\{x\\sim\\nu\}\[\\nabla\_\{\\theta\}J\_\{\\sigma\}\(\\theta\\mid x\)\]\.\(A\.9\) ### A\.2 Conditional summation and paired consequences This subsection proves Proposition[1](https://arxiv.org/html/2611.33716#Thmtheorem1)in Section[3\.2](https://arxiv.org/html/2611.33716#S3.SS2)and Proposition[2](https://arxiv.org/html/2611.33716#Thmtheorem2)in Section[3\.3](https://arxiv.org/html/2611.33716#S3.SS3)\. It also shows that each event vector is a Rao–Blackwellization of the corresponding REINFORCE term\. ##### From one switch to many\. Consider first a simulator with a single switch of marginmm\. LetL\(b\)L\(b\)be the window loss with the switch set tob∈\{0,1\}b\\in\\\{0,1\\\}, so thatΔ=L\(1\)−L\(0\)\\Delta=L\(1\)\-L\(0\)is the flip loss difference\. The switch is on with probabilityΦ\(m/σ\)\\Phi\(m/\\sigma\), soJσ=L\(0\)\+Φ\(m/σ\)ΔJ\_\{\\sigma\}=L\(0\)\+\\Phi\(m/\\sigma\)\\,\\Deltaand∇θJσ=\(1−Φ\(m/σ\)\)∇θL\(0\)\+Φ\(m/σ\)∇θL\(1\)\+κσ\(m\)Δ∇θm\\nabla\_\{\\theta\}J\_\{\\sigma\}=\\bigl\(1\-\\Phi\(m/\\sigma\)\\bigr\)\\nabla\_\{\\theta\}L\(0\)\+\\Phi\(m/\\sigma\)\\,\\nabla\_\{\\theta\}L\(1\)\+\\kappa\_\{\\sigma\}\(m\)\\,\\Delta\\,\\nabla\_\{\\theta\}m\. The first two terms are the path gradient averaged over the two switch values, which is the expected path gradient\. The last term comes from differentiating the probability, and in it the flip loss difference is weighted by the sensitivity\. Two things change when a window contains many switches\. Eventeeis on with probabilityΦ\(me/σ\)\\Phi\(m\_\{e\}/\\sigma\)given the earlier switch values, and the probability of a history is the product of these conditional factors, so each factor is differentiated with the earlier switch values fixed and the derivative ofmmbecomes∇θpathme\\nabla\_\{\\theta\}^\{\\rm path\}m\_\{e\}, which still contains the dependence ofmem\_\{e\}onθ\\thetathrough the earlier states\. The loss after eventeedepends on the later randomized switches, so the flip loss difference is replaced by its conditional expectation givenHeH\_\{e\}, the advantage𝒜e\\mathcal\{A\}\_\{e\}of Eq\. \([4](https://arxiv.org/html/2611.33716#S3.E4)\)\. The proof below carries out these two steps\. ###### Proof of Proposition[1](https://arxiv.org/html/2611.33716#Thmtheorem1)\. To evaluate the score contribution of eventee, we condition on its preceding history and continuous state, collected inHeH\_\{e\}, which fixes bothqeq\_\{e\}and its path derivative\. LetL<eL\_\{<e\}be the loss accumulated before the event’s state update, and letGe\(b\)G\_\{e\}\(b\)be the downstream loss when this event is forced tob∈\{0,1\}b\\in\\\{0,1\\\}and every later switch is decided by the randomized rule in Eq\. \([3](https://arxiv.org/html/2611.33716#S3.E3)\), as in Section[3\.2](https://arxiv.org/html/2611.33716#S3.SS2)\. The conditional mean of this downstream loss is𝒬e\(b∣He\)=𝔼\[Ge\(b\)∣He\]\\mathcal\{Q\}\_\{e\}\(b\\mid H\_\{e\}\)=\\mathbb\{E\}\[G\_\{e\}\(b\)\\mid H\_\{e\}\]\. Because the perturbationξe\\xi\_\{e\}is independent of the preceding history and all later threshold perturbations, conditioning on the resulting switch valueβe=b\\beta\_\{e\}=bleaves the distribution of later perturbations unchanged and gives 𝔼\[Lθ∣He,βe=b\]=L<e\+𝒬e\(b∣He\)\.\\mathbb\{E\}\[L\_\{\\theta\}\\mid H\_\{e\},\\beta\_\{e\}=b\]=L\_\{<e\}\+\\mathcal\{Q\}\_\{e\}\(b\\mid H\_\{e\}\)\.\(A\.10\) Conditional on the preceding history, the score averages to zero\. 𝔼\[se∣He\]=qe∇θpathqeqe−\(1−qe\)∇θpathqe1−qe=0\.\\mathbb\{E\}\[s\_\{e\}\\mid H\_\{e\}\]=q\_\{e\}\\frac\{\\nabla\_\{\\theta\}^\{\\rm path\}q\_\{e\}\}\{q\_\{e\}\}\-\(1\-q\_\{e\}\)\\frac\{\\nabla\_\{\\theta\}^\{\\rm path\}q\_\{e\}\}\{1\-q\_\{e\}\}=0\.\(A\.11\) BecauseL<eL\_\{<e\}is fixed byHeH\_\{e\}, this zero\-mean property removes the accumulated loss from the score contribution\. Summing over the two current decisions then leaves the difference between the conditional means of their downstream losses\. 𝔼\[Lθse∣He\]\\displaystyle\\mathbb\{E\}\[L\_\{\\theta\}s\_\{e\}\\mid H\_\{e\}\]=𝔼\[\(Lθ−L<e\)se∣He\]\\displaystyle=\\mathbb\{E\}\[\(L\_\{\\theta\}\-L\_\{<e\}\)s\_\{e\}\\mid H\_\{e\}\]=qe𝒬e\(1∣He\)∇θpathqeqe−\(1−qe\)𝒬e\(0∣He\)∇θpathqe1−qe\\displaystyle=q\_\{e\}\\mathcal\{Q\}\_\{e\}\(1\\mid H\_\{e\}\)\\frac\{\\nabla\_\{\\theta\}^\{\\rm path\}q\_\{e\}\}\{q\_\{e\}\}\-\(1\-q\_\{e\}\)\\mathcal\{Q\}\_\{e\}\(0\\mid H\_\{e\}\)\\frac\{\\nabla\_\{\\theta\}^\{\\rm path\}q\_\{e\}\}\{1\-q\_\{e\}\}=∇θpathqe\[𝒬e\(1∣He\)−𝒬e\(0∣He\)\]\.\\displaystyle=\\nabla\_\{\\theta\}^\{\\rm path\}q\_\{e\}\\bigl\[\\mathcal\{Q\}\_\{e\}\(1\\mid H\_\{e\}\)\-\\mathcal\{Q\}\_\{e\}\(0\\mid H\_\{e\}\)\\bigr\]\.\(A\.12\) Since the conditional advantage is𝒜e=𝒬e\(1∣He\)−𝒬e\(0∣He\)\\mathcal\{A\}\_\{e\}=\\mathcal\{Q\}\_\{e\}\(1\\mid H\_\{e\}\)\-\\mathcal\{Q\}\_\{e\}\(0\\mid H\_\{e\}\), the right\-hand side of Eq\. \([A\.12](https://arxiv.org/html/2611.33716#A1.E12)\) equals∇θpathqe𝒜e\\nabla\_\{\\theta\}^\{\\rm path\}q\_\{e\}\\,\\mathcal\{A\}\_\{e\}\. Equation \([A\.12](https://arxiv.org/html/2611.33716#A1.E12)\) is therefore the expected policy\-gradient form for the binary switch obtained by summing over its two decisions\([Tokui and Sato, 2017](https://arxiv.org/html/2611.33716#bib.bib56);[Ciosek and Whiteson, 2020](https://arxiv.org/html/2611.33716#bib.bib12)\)\. Its left\-hand side is the conditional mean of a REINFORCE term\([Williams, 1992](https://arxiv.org/html/2611.33716#bib.bib63)\)\. Letζe=\{ξe′:e′\>e\}\\zeta\_\{e\}=\\\{\\xi\_\{e^\{\\prime\}\}:e^\{\\prime\}\>e\\\}collect the threshold perturbations for events later in the fixed conditioning order, including those in the same time layer\. As in Section[3\.2](https://arxiv.org/html/2611.33716#S3.SS2), the two continuations of eventeestart from the pre\-event state inHeH\_\{e\}with the switch forced to11and to00\. Both continuations share one realization ofζe\\zeta\_\{e\}, recompute every later margin and switch from their respective states, and give the downstream lossesGe\(1\)G\_\{e\}\(1\)andGe\(0\)G\_\{e\}\(0\)\. The other switches evaluated at the same stage as eventeekeep their values in both continuations because their states and perturbations do not depend on the forced value, whereas switches at later stages of the same step are recomputed\. Because the perturbations inζe\\zeta\_\{e\}are independent ofHeH\_\{e\}andξe\\xi\_\{e\}, for either forced value the continuation follows the same perturbation distribution as the original simulator conditioned onHeH\_\{e\}and that switch value\. Forb∈\{0,1\}b\\in\\\{0,1\\\}, the continuation therefore has expected downstream loss𝒬e\(b∣He\)\\mathcal\{Q\}\_\{e\}\(b\\mid H\_\{e\}\), even when both continuations share the perturbations\. Consequently, their flip loss differenceΔe\\Delta\_\{e\}has conditional mean𝒜e\\mathcal\{A\}\_\{e\}, as follows\. Δe\\displaystyle\\Delta\_\{e\}=Ge\(1,ζe,He\)−Ge\(0,ζe,He\),\\displaystyle=G\_\{e\}\(1;\\zeta\_\{e\},H\_\{e\}\)\-G\_\{e\}\(0;\\zeta\_\{e\},H\_\{e\}\),𝔼ζe\[Δe∣He\]\\displaystyle\\mathbb\{E\}\_\{\\zeta\_\{e\}\}\[\\Delta\_\{e\}\\mid H\_\{e\}\]=𝔼ζe\[Ge\(1\)∣He\]−𝔼ζe\[Ge\(0\)∣He\]\\displaystyle=\\mathbb\{E\}\_\{\\zeta\_\{e\}\}\[G\_\{e\}\(1\)\\mid H\_\{e\}\]\-\\mathbb\{E\}\_\{\\zeta\_\{e\}\}\[G\_\{e\}\(0\)\\mid H\_\{e\}\]=𝒬e\(1∣He\)−𝒬e\(0∣He\)\.\\displaystyle=\\mathcal\{Q\}\_\{e\}\(1\\mid H\_\{e\}\)\-\\mathcal\{Q\}\_\{e\}\(0\\mid H\_\{e\}\)\.\(A\.13\) The realized suffix supplies one side of each pair because the threshold perturbationξe\\xi\_\{e\}affects the simulator only throughβe\\beta\_\{e\}and is independent ofζe\\zeta\_\{e\}\. For the same reason, conditioning also on the realized switch value leaves the mean unchanged,𝔼\[Δe∣He,βe\]=𝒜e\\mathbb\{E\}\[\\Delta\_\{e\}\\mid H\_\{e\},\\beta\_\{e\}\]=\\mathcal\{A\}\_\{e\}\. Whenβe=0\\beta\_\{e\}=0, the flipped\-minus\-base difference equalsGe\(1\)−Ge\(0\)G\_\{e\}\(1\)\-G\_\{e\}\(0\), whereas whenβe=1\\beta\_\{e\}=1its sign is reversed\. The factor1−2βe1\-2\\beta\_\{e\}, written1−2be1\-2b\_\{e\}in Algorithm[1](https://arxiv.org/html/2611.33716#algorithm1), therefore always gives the flip loss differenceΔe\\Delta\_\{e\}\. The derivative of the probabilityqeq\_\{e\}follows from the Gaussian chain rule, since, for any real argumentzz,Φ′\(z\)=ϕ\(z\)\\Phi^\{\\prime\}\(z\)=\\phi\(z\)and the widthσ\\sigmais fixed\. ∇θpathqe=∇θpathΦ\(me/σ\)=ϕ\(me/σ\)σ∇θpathme=κσ\(me\)∇θpathme\.\\begin\{split\}\\nabla\_\{\\theta\}^\{\\rm path\}q\_\{e\}&=\\nabla\_\{\\theta\}^\{\\rm path\}\\Phi\(m\_\{e\}/\\sigma\)=\\frac\{\\phi\(m\_\{e\}/\\sigma\)\}\{\\sigma\}\\nabla\_\{\\theta\}^\{\\rm path\}m\_\{e\}\\\\ &=\\kappa\_\{\\sigma\}\(m\_\{e\}\)\\nabla\_\{\\theta\}^\{\\rm path\}m\_\{e\}\.\\end\{split\}\(A\.14\) BecauseHeH\_\{e\}fixes the probability derivative, averaging the flip loss difference gives the score contribution of the event\. Applying total expectation and the Gaussian chain rule yields 𝔼\[Lθse\]\\displaystyle\\mathbb\{E\}\[L\_\{\\theta\}s\_\{e\}\]=𝔼He\[𝔼\[Lθse∣He\]\]\\displaystyle=\\mathbb\{E\}\_\{H\_\{e\}\}\\bigl\[\\mathbb\{E\}\[L\_\{\\theta\}s\_\{e\}\\mid H\_\{e\}\]\\bigr\]=𝔼He\[∇θpathqe𝔼ζe\[Δe∣He\]\]\\displaystyle=\\mathbb\{E\}\_\{H\_\{e\}\}\\bigl\[\\nabla\_\{\\theta\}^\{\\rm path\}q\_\{e\}\\,\\mathbb\{E\}\_\{\\zeta\_\{e\}\}\[\\Delta\_\{e\}\\mid H\_\{e\}\]\\bigr\]=𝔼He,ζe\[∇θpathqeΔe\]\\displaystyle=\\mathbb\{E\}\_\{H\_\{e\},\\zeta\_\{e\}\}\\bigl\[\\nabla\_\{\\theta\}^\{\\rm path\}q\_\{e\}\\,\\Delta\_\{e\}\\bigr\]=𝔼He,ζe\[κσ\(me\)Δe∇θpathme\]\.\\displaystyle=\\mathbb\{E\}\_\{H\_\{e\},\\zeta\_\{e\}\}\\bigl\[\\kappa\_\{\\sigma\}\(m\_\{e\}\)\\Delta\_\{e\}\\nabla\_\{\\theta\}^\{\\rm path\}m\_\{e\}\\bigr\]\.\(A\.15\)By Eq\. \([A\.13](https://arxiv.org/html/2611.33716#A1.E13)\) and Eq\. \([A\.14](https://arxiv.org/html/2611.33716#A1.E14)\), the second line equals𝔼He\[κσ\(me\)𝒜e∇θpathme\]\\mathbb\{E\}\_\{H\_\{e\}\}\[\\kappa\_\{\\sigma\}\(m\_\{e\}\)\\,\\mathcal\{A\}\_\{e\}\\,\\nabla\_\{\\theta\}^\{\\rm path\}m\_\{e\}\]\. Substituting this expression into Eq\. \([A\.6](https://arxiv.org/html/2611.33716#A1.E6)\) for every event gives Eq\. \([5](https://arxiv.org/html/2611.33716#S3.E5)\)\. ∎ ##### Rao–Blackwellization\. OnceHeH\_\{e\}andζe\\zeta\_\{e\}are fixed, the loss and score depend onξe\\xi\_\{e\}only through the binary switchβe\\beta\_\{e\}, which equals11with probabilityqeq\_\{e\}and00with probability1−qe1\-q\_\{e\}\. We define the score\-weighted lossZe=LθseZ\_\{e\}=L\_\{\\theta\}s\_\{e\}andWe=∇θpathqeΔeW\_\{e\}=\\nabla\_\{\\theta\}^\{\\rm path\}q\_\{e\}\\,\\Delta\_\{e\}, which equals the event vectorvev\_\{e\}defined after Eq\. \([7](https://arxiv.org/html/2611.33716#S3.E7)\)\. Summing over these two switch values gives 𝔼\[Ze∣He,ζe\]\\displaystyle\\mathbb\{E\}\[Z\_\{e\}\\mid H\_\{e\},\\zeta\_\{e\}\]=qe\[L<e\+Ge\(1,ζe,He\)\]∇θpathqeqe−\(1−qe\)\[L<e\+Ge\(0,ζe,He\)\]∇θpathqe1−qe\\displaystyle=q\_\{e\}\[L\_\{<e\}\+G\_\{e\}\(1;\\zeta\_\{e\},H\_\{e\}\)\]\\frac\{\\nabla\_\{\\theta\}^\{\\rm path\}q\_\{e\}\}\{q\_\{e\}\}\-\(1\-q\_\{e\}\)\[L\_\{<e\}\+G\_\{e\}\(0;\\zeta\_\{e\},H\_\{e\}\)\]\\frac\{\\nabla\_\{\\theta\}^\{\\rm path\}q\_\{e\}\}\{1\-q\_\{e\}\}=∇θpathqe\[Ge\(1,ζe,He\)−Ge\(0,ζe,He\)\]\\displaystyle=\\nabla\_\{\\theta\}^\{\\rm path\}q\_\{e\}\\,\[G\_\{e\}\(1;\\zeta\_\{e\},H\_\{e\}\)\-G\_\{e\}\(0;\\zeta\_\{e\},H\_\{e\}\)\]=We\.\\displaystyle=W\_\{e\}\.\(A\.16\) This identity shows that each event vector is a Rao–Blackwellization of its REINFORCE contribution\. Because the window has finitely many histories,ZeZ\_\{e\}is bounded\. Since𝔼\[Ze−We∣He,ζe\]=0\\mathbb\{E\}\[Z\_\{e\}\-W\_\{e\}\\mid H\_\{e\},\\zeta\_\{e\}\]=0, the cross term𝔼\[\(We−𝔼We\)𝖳\(Ze−We\)\]\\mathbb\{E\}\[\(W\_\{e\}\-\\mathbb\{E\}W\_\{e\}\)^\{\\mathsf\{T\}\}\(Z\_\{e\}\-W\_\{e\}\)\]vanishes\. Expanding the centered squared norm therefore gives 𝔼‖Ze−𝔼Ze‖2\\displaystyle\\mathbb\{E\}\\\|Z\_\{e\}\-\\mathbb\{E\}Z\_\{e\}\\\|^\{2\}=𝔼‖We−𝔼We‖2\+𝔼‖Ze−We‖2\\displaystyle=\\mathbb\{E\}\\\|W\_\{e\}\-\\mathbb\{E\}W\_\{e\}\\\|^\{2\}\+\\mathbb\{E\}\\\|Z\_\{e\}\-W\_\{e\}\\\|^\{2\}≥𝔼‖We−𝔼We‖2\.\\displaystyle\\geq\\mathbb\{E\}\\\|W\_\{e\}\-\\mathbb\{E\}W\_\{e\}\\\|^\{2\}\.\(A\.17\) This bound applies to each switch contribution individually, whereas the variance of their sum also includes covariances between switches and with the pathwise term\. ##### Event sampling\. Event selection introduces an additional layer of randomness\. Letξ=\(ξ1,…,ξNevt\)\\xi=\(\\xi\_\{1\},\\ldots,\\xi\_\{N\_\{\\rm evt\}\}\)denote the complete threshold\-noise field, which determines both the base recordHbaseH\_\{\\rm base\}and every potential flip branch prior to event selection\. The selection probabilitiesπe\(θ,Hbase\)\\pi\_\{e\}\(\\theta,H\_\{\\rm base\}\)depend on the base record alone, satisfy∑eπe=1\\sum\_\{e\}\\pi\_\{e\}=1withπe\>0\\pi\_\{e\}\>0for everye∈ℰelige\\in\\mathcal\{E\}\_\{\\rm elig\}, and are written asπe\(ξ\)\\pi\_\{e\}\(\\xi\)when conditioning onξ\\xi\. Givenξ\\xi, we drawe\(1\),…,e\(M\)e\_\{\(1\)\},\\ldots,e\_\{\(M\)\}independently with replacement forM≥1M\\geq 1and form the estimatorg^σ\\widehat\{g\}\_\{\\sigma\}of Eq\. \([7](https://arxiv.org/html/2611.33716#S3.E7)\) with the weights1/\(Mπe\(j\)\(ξ\)\)1/\(M\\pi\_\{e\_\{\(j\)\}\}\(\\xi\)\)\. Because event eligibility is determined by the base trajectory, an empty eligible set gives a zero jump term without sampling\. At fixedxx, the finite number of histories and the assumptions of Appendix[A\.1](https://arxiv.org/html/2611.33716#A1.SS1)ensure finite first moments for the pathwise and jump terms\. When averaging overx∼νx\\sim\\nu, we assume𝔼‖gpath‖<∞\\mathbb\{E\}\\\|g\_\{\\rm path\}\\\|<\\inftyand𝔼∑e‖ve‖<∞\\mathbb\{E\}\\sum\_\{e\}\\\|v\_\{e\}\\\|<\\infty, together with the differentiation\-expectation interchange in Appendix[A\.1](https://arxiv.org/html/2611.33716#A1.SS1.SSS0.Px2)\. ###### Proof of Proposition[2](https://arxiv.org/html/2611.33716#Thmtheorem2)\. Conditioning onξ\\xifixes the base path gradient, event vectors, and selection probabilities\. Importance weighting then recovers the complete jump term\. 𝔼\[ve\(j\)πe\(j\)\(ξ\)\|ξ\]\\displaystyle\\mathbb\{E\}\\left\[\\frac\{v\_\{e\_\{\(j\)\}\}\}\{\\pi\_\{e\_\{\(j\)\}\}\(\\xi\)\}\\,\\middle\|\\,\\xi\\right\]=∑e:πe\(ξ\)\>0ℙ\(e\(j\)=e∣ξ\)veπe\(ξ\)\\displaystyle=\\sum\_\{e:\\pi\_\{e\}\(\\xi\)\>0\}\\mathbb\{P\}\(e\_\{\(j\)\}=e\\mid\\xi\)\\frac\{v\_\{e\}\}\{\\pi\_\{e\}\(\\xi\)\}=∑e:πe\(ξ\)\>0ve=∑e=1Nevtve,\\displaystyle=\\sum\_\{e:\\pi\_\{e\}\(\\xi\)\>0\}v\_\{e\}=\\sum\_\{e=1\}^\{N\_\{\\rm evt\}\}v\_\{e\},𝔼\[g^σ∣ξ\]\\displaystyle\\mathbb\{E\}\[\\widehat\{g\}\_\{\\sigma\}\\mid\\xi\]=gpath\+1M∑j=1M∑eve=gpath\+∑eve\.\\displaystyle=g\_\{\\rm path\}\+\\frac\{1\}\{M\}\\sum\_\{j=1\}^\{M\}\\sum\_\{e\}v\_\{e\}=g\_\{\\rm path\}\+\\sum\_\{e\}v\_\{e\}\.Because every zero\-probability event is ineligible, it hasΔe=0\\Delta\_\{e\}=0andve=0v\_\{e\}=0, so the supported sum equals the complete sum\. The same calculation gives𝔼\[‖ve\(j\)/πe\(j\)‖∣ξ\]=∑e‖ve‖\\mathbb\{E\}\[\\\|v\_\{e\_\{\(j\)\}\}/\\pi\_\{e\_\{\(j\)\}\}\\\|\\mid\\xi\]=\\sum\_\{e\}\\\|v\_\{e\}\\\|and ensures integrability\. Although the proposal may depend onθ\\thetaand the base record, it cancels in the conditional mean at the current parameter value\. It remains to average overξ\\xi\. Since𝔼ξ\[ve\]=𝔼ξ\[Lθse\]\\mathbb\{E\}\_\{\\xi\}\[v\_\{e\}\]=\\mathbb\{E\}\_\{\\xi\}\[L\_\{\\theta\}s\_\{e\}\]for every event by Eq\. \([A\.15](https://arxiv.org/html/2611.33716#A1.E15)\), total expectation and Eq\. \([A\.6](https://arxiv.org/html/2611.33716#A1.E6)\) give 𝔼\[g^σ\]\\displaystyle\\mathbb\{E\}\[\\widehat\{g\}\_\{\\sigma\}\]=𝔼ξ\[𝔼\[g^σ∣ξ\]\]=𝔼ξ\[gpath\]\+∑e𝔼ξ\[ve\]\\displaystyle=\\mathbb\{E\}\_\{\\xi\}\[\\mathbb\{E\}\[\\widehat\{g\}\_\{\\sigma\}\\mid\\xi\]\]=\\mathbb\{E\}\_\{\\xi\}\[g\_\{\\rm path\}\]\+\\sum\_\{e\}\\mathbb\{E\}\_\{\\xi\}\[v\_\{e\}\]=𝔼ξ\[gpath\]\+∑e𝔼ξ\[Lθse\]=∇θJσ\(θ∣x\)\.\\displaystyle=\\mathbb\{E\}\_\{\\xi\}\[g\_\{\\rm path\}\]\+\\sum\_\{e\}\\mathbb\{E\}\_\{\\xi\}\[L\_\{\\theta\}s\_\{e\}\]=\\nabla\_\{\\theta\}J\_\{\\sigma\}\(\\theta\\mid x\)\.Because each draw has the same conditional mean, the result holds for every finiteM≥1M\\geq 1\. Under the context\-average conditions in Appendix[A\.1](https://arxiv.org/html/2611.33716#A1.SS1.SSS0.Px2), averaging overx∼νx\\sim\\nugives𝔼\[g^σ\]=∇θJ¯σ\(θ\)\\mathbb\{E\}\[\\widehat\{g\}\_\{\\sigma\}\]=\\nabla\_\{\\theta\}\\overline\{J\}\_\{\\sigma\}\(\\theta\)\. ∎ ### A\.3 Band sampling and truncation bias This subsection analyzes the selection probabilities in Eq\. \([6](https://arxiv.org/html/2611.33716#S3.E6)\) on the threshold band and proves Proposition[A\.1](https://arxiv.org/html/2611.33716#Thmtheorem1a)\. For a dimensionless cutoffτ\>0\\tau\>0, the threshold band isℬτ=\{e∈ℰelig:\|me\|<τσ\}\\mathcal\{B\}\_\{\\tau\}=\\\{e\\in\\mathcal\{E\}\_\{\\rm elig\}:\|m\_\{e\}\|<\\tau\\sigma\\\}with sizeB=\|ℬτ\|B=\|\\mathcal\{B\}\_\{\\tau\}\|\. The band estimatorg^band=gpath\+g^jump\\widehat\{g\}\_\{\\rm band\}=g\_\{\\rm path\}\+\\widehat\{g\}\_\{\\rm jump\}drawse\(1\),…,e\(M\)e\_\{\(1\)\},\\ldots,e\_\{\(M\)\}only fromℬτ\\mathcal\{B\}\_\{\\tau\}and uses the jump estimateg^jump=M−1∑j=1Mve\(j\)/πe\(j\)\\widehat\{g\}\_\{\\rm jump\}=M^\{\-1\}\\sum\_\{j=1\}^\{M\}v\_\{e\_\{\(j\)\}\}/\\pi\_\{e\_\{\(j\)\}\}, which is zero whenB=0B=0, so that an empty band reduces the estimate to the path gradientgpathg\_\{\\rm path\}\. Conditioning on the same realizationξ\\xileaves only the event\-index selection random and fixes the bandℬτ\\mathcal\{B\}\_\{\\tau\}, its sizeBB, and every event vectorvev\_\{e\}\. All norms below are Euclidean parameter\-space norms\. ##### Band mean\. The selection probabilities in Eq\. \([6](https://arxiv.org/html/2611.33716#S3.E6)\) ofEventFlipcombine a component proportional to the sensitivity with a uniform fractionλ∈\(0,1\]\\lambda\\in\(0,1\]that keeps the importance weights bounded, sinceπe≥λ/B\\pi\_\{e\}\\geq\\lambda/Bgives1/πe≤B/λ1/\\pi\_\{e\}\\leq B/\\lambda\. They are positive on the band and zero outside it\. Conditional onξ\\xi, the importance\-weighting calculation in the proof of Proposition[2](https://arxiv.org/html/2611.33716#Thmtheorem2), restricted to the supportℬτ\\mathcal\{B\}\_\{\\tau\}, gives𝔼\[ve\(j\)/πe\(j\)∣ξ\]=∑e∈ℬτve\\mathbb\{E\}\[v\_\{e\_\{\(j\)\}\}/\\pi\_\{e\_\{\(j\)\}\}\\mid\\xi\]=\\sum\_\{e\\in\\mathcal\{B\}\_\{\\tau\}\}v\_\{e\}for every draw\. Consequently, the jump estimateg^jump\\widehat\{g\}\_\{\\rm jump\}ofg^band\\widehat\{g\}\_\{\\rm band\}has the band sum as its conditional mean\. ##### Truncation bias\. To compare the band mean with the complete gradient, we define the omitted meanRtail\(τ\)R\_\{\\rm tail\}\(\\tau\)by Rtail\(τ\)=𝔼ξ\[∑e∉ℬτve\]\.R\_\{\\rm tail\}\(\\tau\)=\\mathbb\{E\}\_\{\\xi\}\\left\[\\sum\_\{e\\notin\\mathcal\{B\}\_\{\\tau\}\}v\_\{e\}\\right\]\.\(A\.18\) ###### Proposition A\.1\(Truncation bias\)\. Under the conditions of Appendix[A\.1](https://arxiv.org/html/2611.33716#A1.SS1)and with flip branches that share the later threshold noise, let the selection probabilities ofg^band\\widehat\{g\}\_\{\\rm band\}depend only on the base trajectory and be positive exactly onℬτ\\mathcal\{B\}\_\{\\tau\}, as in Eq\. \([6](https://arxiv.org/html/2611.33716#S3.E6)\)\. Suppose\|Δe\|≤D\|\\Delta\_\{e\}\|\\leq Dand‖∇θpathme‖≤Cm\\\|\\nabla\_\{\\theta\}^\{\\rm path\}m\_\{e\}\\\|\\leq C\_\{m\}almost surely for every event\. Then ∥𝔼\[g^band\]−∇θJσ\(θ\)∥≤NevtDCmσ2πe−τ2/2\.\\bigl\\\|\\mathbb\{E\}\[\\widehat\{g\}\_\{\\rm band\}\]\-\\nabla\_\{\\theta\}J\_\{\\sigma\}\(\\theta\)\\bigr\\\|\\leq\\frac\{N\_\{\\rm evt\}\\,D\\,C\_\{m\}\}\{\\sigma\\sqrt\{2\\pi\}\}\\,e^\{\-\\tau^\{2\}/2\}\. ###### Proof of Proposition[A\.1](https://arxiv.org/html/2611.33716#Thmtheorem1a)\. In conditional expectation, the band estimator recovers the band sum\. Subtracting the complete gradient from the mean of the band estimator cancels the full pathwise term and leaves the omitted events\. 𝔼\[g^band\]\\displaystyle\\mathbb\{E\}\[\\widehat\{g\}\_\{\\rm band\}\]=𝔼ξ\[gpath\+∑e∈ℬτve\],\\displaystyle=\\mathbb\{E\}\_\{\\xi\}\\left\[g\_\{\\rm path\}\+\\sum\_\{e\\in\\mathcal\{B\}\_\{\\tau\}\}v\_\{e\}\\right\],∇θJσ\(θ∣x\)\\displaystyle\\nabla\_\{\\theta\}J\_\{\\sigma\}\(\\theta\\mid x\)=𝔼ξ\[gpath\+∑e∈ℬτve\+∑e∉ℬτve\],\\displaystyle=\\mathbb\{E\}\_\{\\xi\}\\left\[g\_\{\\rm path\}\+\\sum\_\{e\\in\\mathcal\{B\}\_\{\\tau\}\}v\_\{e\}\+\\sum\_\{e\\notin\\mathcal\{B\}\_\{\\tau\}\}v\_\{e\}\\right\],𝔼\[g^band\]−∇θJσ\(θ∣x\)\\displaystyle\\mathbb\{E\}\[\\widehat\{g\}\_\{\\rm band\}\]\-\\nabla\_\{\\theta\}J\_\{\\sigma\}\(\\theta\\mid x\)=−𝔼ξ\[∑e∉ℬτve\]=−Rtail\(τ\)\.\\displaystyle=\-\\mathbb\{E\}\_\{\\xi\}\\left\[\\sum\_\{e\\notin\\mathcal\{B\}\_\{\\tau\}\}v\_\{e\}\\right\]=\-R\_\{\\rm tail\}\(\\tau\)\.\(A\.19\)Because the partition is made for each trajectory, this identity also holds for a trajectory\-dependent band\. Every eligible omitted event satisfies\|me\|≥τσ\|m\_\{e\}\|\\geq\\tau\\sigma, which bounds its sensitivity κσ\(me\)=1σ2πexp\(−me22σ2\)≤exp\(−τ2/2\)σ2π\.\\kappa\_\{\\sigma\}\(m\_\{e\}\)=\\frac\{1\}\{\\sigma\\sqrt\{2\\pi\}\}\\exp\\left\(\-\\frac\{m\_\{e\}^\{2\}\}\{2\\sigma^\{2\}\}\\right\)\\leq\\frac\{\\exp\(\-\\tau^\{2\}/2\)\}\{\\sigma\\sqrt\{2\\pi\}\}\.\(A\.20\)Ineligible events contribute zero\. LetNout,τ=\|ℰelig∖ℬτ\|N\_\{\{\\rm out\},\\tau\}=\|\\mathcal\{E\}\_\{\\rm elig\}\\setminus\\mathcal\{B\}\_\{\\tau\}\|denote the eligible omitted\-event count\. Applying Jensen’s inequality to the norm and the triangle inequality to the finite sum then gives ‖Rtail\(τ\)‖\\displaystyle\\\|R\_\{\\rm tail\}\(\\tau\)\\\|≤𝔼ξ\[‖∑e∉ℬτve‖\]\\displaystyle\\leq\\mathbb\{E\}\_\{\\xi\}\\left\[\\left\\\|\\sum\_\{e\\notin\\mathcal\{B\}\_\{\\tau\}\}v\_\{e\}\\right\\\|\\right\]≤𝔼ξ\[∑e∈ℰelig∖ℬτ‖κσ\(me\)Δe∇θpathme‖\]\\displaystyle\\leq\\mathbb\{E\}\_\{\\xi\}\\left\[\\sum\_\{e\\in\\mathcal\{E\}\_\{\\rm elig\}\\setminus\\mathcal\{B\}\_\{\\tau\}\}\\\|\\kappa\_\{\\sigma\}\(m\_\{e\}\)\\Delta\_\{e\}\\nabla\_\{\\theta\}^\{\\rm path\}m\_\{e\}\\\|\\right\]=𝔼ξ\[∑e∈ℰelig∖ℬτκσ\(me\)\|Δe\|‖∇θpathme‖\]\\displaystyle=\\mathbb\{E\}\_\{\\xi\}\\left\[\\sum\_\{e\\in\\mathcal\{E\}\_\{\\rm elig\}\\setminus\\mathcal\{B\}\_\{\\tau\}\}\\kappa\_\{\\sigma\}\(m\_\{e\}\)\|\\Delta\_\{e\}\|\\,\\\|\\nabla\_\{\\theta\}^\{\\rm path\}m\_\{e\}\\\|\\right\]≤DCmexp\(−τ2/2\)σ2π𝔼ξ\[Nout,τ\]\\displaystyle\\leq\\frac\{D\\,C\_\{m\}\\exp\(\-\\tau^\{2\}/2\)\}\{\\sigma\\sqrt\{2\\pi\}\}\\mathbb\{E\}\_\{\\xi\}\[N\_\{\{\\rm out\},\\tau\}\]≤NevtDCmσ2πexp\(−τ2/2\)\.\\displaystyle\\leq\\frac\{N\_\{\\rm evt\}D\\,C\_\{m\}\}\{\\sigma\\sqrt\{2\\pi\}\}\\exp\(\-\\tau^\{2\}/2\)\.\(A\.21\)Atτ=4\\tau=4, the Gaussian factor isexp\(−8\)\\exp\(\-8\)\. ∎ ### A\.4 Backward implementation and variance constructions This subsection gives the backward implementation of the training update of Section[3\.3](https://arxiv.org/html/2611.33716#S3.SS3), written out in Algorithm[1](https://arxiv.org/html/2611.33716#algorithm1), and the variance identity behind the shared noise in Section[3\.2](https://arxiv.org/html/2611.33716#S3.SS2)\. ##### Stop\-gradient\. Letsg\\operatorname\{sg\}denote the stop\-gradient operator andcj=κσ\(me\(j\)\)Δe\(j\)/\(Mπe\(j\)\)c\_\{j\}=\\kappa\_\{\\sigma\}\(m\_\{e\_\{\(j\)\}\}\)\\Delta\_\{e\_\{\(j\)\}\}/\(M\\pi\_\{e\_\{\(j\)\}\}\)the coefficient of drawjj\. With the switch history held fixed, the gradient of the surrogate loss L~θ=∑n=1Kℓn\(𝒖n\)\+∑j=1Msg\(cj\)me\(j\)\\widetilde\{L\}\_\{\\theta\}=\\sum\_\{n=1\}^\{K\}\\ell\_\{n\}\(\{\\bm\{u\}\}\_\{n\}\)\+\\sum\_\{j=1\}^\{M\}\\operatorname\{sg\}\(c\_\{j\}\)\\,m\_\{e\_\{\(j\)\}\}\(A\.22\)equals the estimator in Eq\. \([7](https://arxiv.org/html/2611.33716#S3.E7)\), since each added term differentiates tocj∇θpathme\(j\)c\_\{j\}\\nabla\_\{\\theta\}^\{\\rm path\}m\_\{e\_\{\(j\)\}\}\. An event drawn more than once contributes one term for each draw\. Automatic differentiation holds the binary switches fixed and returns this estimate\. The margins retain their full continuous histories\. Algorithm[1](https://arxiv.org/html/2611.33716#algorithm1)implements Eq\. \([A\.22](https://arxiv.org/html/2611.33716#A1.E22)\) with the default kernel\-weighted proposal in Eq\. \([6](https://arxiv.org/html/2611.33716#S3.E6)\)\. Its line[1](https://arxiv.org/html/2611.33716#algorithm1)selects the variant, drawing the threshold noise forEventFlip\-Randand setting it to zero forEventFlip\-Hard\. The flip branches keep no graph, and a window costs at most\(1\+M\)K\(1\+M\)Ksolver steps\. Batch averaging is described below\. Reported loss and validation selection useLθL\_\{\\theta\}\. Recomputation for the backward pass retains the same binary history and continuous state connections within the window\. Algorithm 1One training update ofEventFlipon one window\.Line[1](https://arxiv.org/html/2611.33716#algorithm1)selects the variant, andκσ\(m\)=ϕ\(m/σ\)/σ\\kappa\_\{\\sigma\}\(m\)=\\phi\(m/\\sigma\)/\\sigma\.Input:Start state 𝒖0\{\\bm\{u\}\}\_\{0\}, reference states \{𝒖n∗\}n=1K\\\{\{\\bm\{u\}\}\_\{n\}^\{\*\}\\\}\_\{n=1\}^\{K\}, parameters θ\\theta, width σ\\sigma, cutoff τ\\tau, number of branches MM, and uniform fraction λ\\lambda\. 1if*EventFlip\-Hard*then ξe←0\\xi\_\{e\}\\leftarrow 0for all events eeelse ξe∼𝒩\(0,1\)\\xi\_\{e\}\\sim\\mathcal\{N\}\(0,1\)i\.i\.d\. 2for*n=0,…,K−1n=0,\\ldots,K\-1*do⊳\\trianglerightbase trajectory, with graph 3 me←mie\(𝒖n,θ\)m\_\{e\}\\leftarrow m\_\{i\_\{e\}\}\(\{\\bm\{u\}\}\_\{n\};\\theta\)and be←𝟏\[me≥σξe\]b\_\{e\}\\leftarrow\\mathbf\{1\}\[m\_\{e\}\\geq\\sigma\\xi\_\{e\}\]for each event eeat step nn\(rule in Eq\. \([3](https://arxiv.org/html/2611.33716#S3.E3)\)\); 𝒖n\+1←Fθ\(𝒖n,𝒃n\)\{\\bm\{u\}\}\_\{n\+1\}\\leftarrow F\_\{\\theta\}\(\{\\bm\{u\}\}\_\{n\},\{\\bm\{b\}\}\_\{n\}\); store 𝒖n\{\\bm\{u\}\}\_\{n\}, 𝒃n\{\\bm\{b\}\}\_\{n\} 4 L←∑n=1Kℓn\(𝒖n\)L\\leftarrow\\sum\_\{n=1\}^\{K\}\\ell\_\{n\}\(\{\\bm\{u\}\}\_\{n\}\); ℬτ←\{eeligible:\|me\|<τσ\}\\mathcal\{B\}\_\{\\tau\}\\leftarrow\\\{e\\ \\text\{eligible\}:\|m\_\{e\}\|<\\tau\\sigma\\\}⊳\\trianglerightif empty, L~θ←L\\widetilde\{L\}\_\{\\theta\}\\leftarrow L, go to line[1](https://arxiv.org/html/2611.33716#algorithm1) 5Compute the selection probabilities πe\\pi\_\{e\}of Eq\. \([6](https://arxiv.org/html/2611.33716#S3.E6)\) for e∈ℬτe\\in\\mathcal\{B\}\_\{\\tau\} 6Draw e\(1\),…,e\(M\)∼πe\_\{\(1\)\},\\ldots,e\_\{\(M\)\}\\sim\\pii\.i\.d\. \(with replacement\) given the base trajectory 7for*j=1,…,Mj=1,\\ldots,M,withe=e\(j\)e=e\_\{\(j\)\}*do⊳\\trianglerightflip branch, no graph 8 𝒖ne\+1flip←Fθ\(𝒖ne,𝒃newithbe→1−be\)\{\\bm\{u\}\}^\{\\rm flip\}\_\{n\_\{e\}\+1\}\\leftarrow F\_\{\\theta\}\(\{\\bm\{u\}\}\_\{n\_\{e\}\},\{\\bm\{b\}\}\_\{n\_\{e\}\}\\text\{ with \}b\_\{e\}\\to 1\-b\_\{e\}\)⊳\\trianglerightrestart from stored 𝒖ne\{\\bm\{u\}\}\_\{n\_\{e\}\} 9for*n=ne\+1,…,K−1n=n\_\{e\}\{\+\}1,\\ldots,K\{\-\}1*do 𝒃nflip←\{\\bm\{b\}\}^\{\\rm flip\}\_\{n\}\\leftarrowrule in Eq\. \([3](https://arxiv.org/html/2611.33716#S3.E3)\) at 𝒖nflip\{\\bm\{u\}\}^\{\\rm flip\}\_\{n\}with the same ξ\\xi; 𝒖n\+1flip←Fθ\(𝒖nflip,𝒃nflip\)\{\\bm\{u\}\}^\{\\rm flip\}\_\{n\+1\}\\leftarrow F\_\{\\theta\}\(\{\\bm\{u\}\}^\{\\rm flip\}\_\{n\},\{\\bm\{b\}\}^\{\\rm flip\}\_\{n\}\); the stored 𝒖n\{\\bm\{u\}\}\_\{n\}, 𝒃n\{\\bm\{b\}\}\_\{n\}stay unchanged 10 Ge\(1−be\)←∑n\>neℓn\(𝒖nflip\)G\_\{e\}\(1\-b\_\{e\}\)\\leftarrow\\sum\_\{n\>n\_\{e\}\}\\ell\_\{n\}\(\{\\bm\{u\}\}^\{\\rm flip\}\_\{n\}\); Ge\(be\)←∑n\>neℓn\(𝒖n\)G\_\{e\}\(b\_\{e\}\)\\leftarrow\\sum\_\{n\>n\_\{e\}\}\\ell\_\{n\}\(\{\\bm\{u\}\}\_\{n\}\); Δe←\(1−2be\)\[Ge\(1−be\)−Ge\(be\)\]\\Delta\_\{e\}\\leftarrow\(1\-2b\_\{e\}\)\\bigl\[G\_\{e\}\(1\-b\_\{e\}\)\-G\_\{e\}\(b\_\{e\}\)\\bigr\]⊳\\trianglerightloss difference Δe\\Delta\_\{e\} 11 cj←κσ\(me\)Δe/\(Mπe\)c\_\{j\}\\leftarrow\\kappa\_\{\\sigma\}\(m\_\{e\}\)\\,\\Delta\_\{e\}/\(M\\pi\_\{e\}\) 12 L~θ←L\+∑j=1Msg\(cj\)me\(j\)\(θ\)\\widetilde\{L\}\_\{\\theta\}\\leftarrow L\+\\sum\_\{j=1\}^\{M\}\\operatorname\{sg\}\(c\_\{j\}\)\\,m\_\{e\_\{\(j\)\}\}\(\\theta\)⊳\\triangleright mem\_\{e\}on the base trajectory 13 θ←OptimizerStep\(θ,∇θL~θ\)\\theta\\leftarrow\\operatorname\{OptimizerStep\}\(\\theta,\\nabla\_\{\\theta\}\\widetilde\{L\}\_\{\\theta\}\)⊳\\trianglerightswitches held constant, so ∇θL~θ\\nabla\_\{\\theta\}\\widetilde\{L\}\_\{\\theta\}is the estimate in Eq\. \([7](https://arxiv.org/html/2611.33716#S3.E7)\) ##### Batch averaging\. For a batch ofNbatch≥1N\_\{\\rm batch\}\\geq 1windows indexed bykk, each surrogateL~θ\(k\)\\widetilde\{L\}\_\{\\theta\}^\{\(k\)\}is computed with its own context, history, and fixed coefficients, after which the update uses the meanNbatch−1∑k=1NbatchL~θ\(k\)N\_\{\\rm batch\}^\{\-1\}\\sum\_\{k=1\}^\{N\_\{\\rm batch\}\}\\widetilde\{L\}\_\{\\theta\}^\{\(k\)\}\. Linearity of differentiation gives the mean of the window gradient estimates\. Averaging preserves their expectation under the context conditions of Appendix[A\.1](https://arxiv.org/html/2611.33716#A1.SS1.SSS0.Px2)\. Independence between windows is not needed for this mean identity\. ##### Shared noise\. Sharing the threshold noise changes the covariance between the two downstream losses\. With finite conditional second moments, Var\(Δe∣He\)\\displaystyle\\operatorname\{Var\}\(\\Delta\_\{e\}\\mid H\_\{e\}\)=Var\(Ge\(1\)∣He\)\+Var\(Ge\(0\)∣He\)−2Cov\(Ge\(1\),Ge\(0\)∣He\)\.\\displaystyle=\\operatorname\{Var\}\(G\_\{e\}\(1\)\\mid H\_\{e\}\)\+\\operatorname\{Var\}\(G\_\{e\}\(0\)\\mid H\_\{e\}\)\-2\\operatorname\{Cov\}\(G\_\{e\}\(1\),G\_\{e\}\(0\)\\mid H\_\{e\}\)\.\(A\.23\) Independent threshold noise gives zero covariance with the same marginal variances\. Shared noise reduces the consequence variance when its induced covariance is positive \(Appendix[C\.6](https://arxiv.org/html/2611.33716#A3.SS6)\)\. With shared noise, the flip branch and the base trajectory use the same threshold noise after eventee, so the two runs differ only through the flipped switch\.EventFlip\-Harddraws no threshold noise, so the same holds for its flip branches\. ### A\.5 The update defined by hard continuation This subsection supports Sections[3\.2](https://arxiv.org/html/2611.33716#S3.SS2)and[3\.3](https://arxiv.org/html/2611.33716#S3.SS3)and proves Propositions[A\.2](https://arxiv.org/html/2611.33716#Thmtheorem2a)and[A\.5](https://arxiv.org/html/2611.33716#Thmtheorem2b), which relate the smoothed objective and the expected updates of both variants to the hard loss\. The window contextxxis fixed and omitted from the notation\. The losses and margins of a fixed history do not depend onσ\\sigma\. Letβh\(θ\)\\beta^\{h\}\(\\theta\)be the hard history, namely the switch history of the deterministic simulator, so thatJhard\(θ\)=Lθ\(βh\)J\_\{\\rm hard\}\(\\theta\)=L\_\{\\theta\}\(\\beta^\{h\}\)\. A superscripthhmarks a quantity evaluated on the hard\-switch trajectory\. Thusbeh=βehb\_\{e\}^\{h\}=\\beta\_\{e\}^\{h\},mehm\_\{e\}^\{h\}, andHehH\_\{e\}^\{h\}are the switch value, the margin, and the pre\-event history of eventee,gpathhg\_\{\\rm path\}^\{h\}is the path gradient, andℬτh\\mathcal\{B\}\_\{\\tau\}^\{h\}is the threshold band of the hard\-switch trajectory\. We writeqeh=Φ\(meh/σ\)q\_\{e\}^\{h\}=\\Phi\(m\_\{e\}^\{h\}/\\sigma\)for the probability that the randomized switch of eventeeis on givenHehH\_\{e\}^\{h\}\. When the earlier events take their hard values, the randomized switch of eventeediffers frombehb\_\{e\}^\{h\}with the flip probabilitypeflip=Φ\(−\|meh\|/σ\)p\_\{e\}^\{\\rm flip\}=\\Phi\(\-\|m\_\{e\}^\{h\}\|/\\sigma\)\. The factor1−2beh1\-2b\_\{e\}^\{h\}turns a flip loss difference into the difference between the flipped value and the hard value\. The hard continuations of eventeestart fromHehH\_\{e\}^\{h\}with the switch forced on and forced off and use hard switches after eventee, withΔeh=Geh\(1\)−Geh\(0\)\\Delta\_\{e\}^\{h\}=G\_\{e\}^\{h\}\(1\)\-G\_\{e\}^\{h\}\(0\)the flip loss difference of the hard\-switch simulator \(Section[3\.2](https://arxiv.org/html/2611.33716#S3.SS2)\)\. We write𝒜eh=𝒜e\(Heh\)\\mathcal\{A\}\_\{e\}^\{h\}=\\mathcal\{A\}\_\{e\}\(H\_\{e\}^\{h\}\)for the advantage in Eq\. \([4](https://arxiv.org/html/2611.33716#S3.E4)\) evaluated atHehH\_\{e\}^\{h\}\. Its two continuations use randomized switches after eventee, whereas the two continuations ofΔeh\\Delta\_\{e\}^\{h\}use hard switches\. Sums overeewithout a range run over allNevtN\_\{\\rm evt\}events\. Wherever no margin of the hard\-switch trajectory is zero, the proof of Proposition[A\.2](https://arxiv.org/html/2611.33716#Thmtheorem2a)\(c\) below shows that∇θJhard=gpathh\\nabla\_\{\\theta\}J\_\{\\rm hard\}=g\_\{\\rm path\}^\{h\}\. The expected update ofEventFlip\-Hard, which is Eq\. \([9](https://arxiv.org/html/2611.33716#S3.E9)\) in the main text, is ghard,band=gpathh\+∑e∈ℬτhκσ\(meh\)Δeh∇θpathmeh\.g\_\{\\rm hard,band\}=g\_\{\\rm path\}^\{h\}\+\\sum\_\{e\\in\\mathcal\{B\}\_\{\\tau\}^\{h\}\}\\kappa\_\{\\sigma\}\(m\_\{e\}^\{h\}\)\\Delta\_\{e\}^\{h\}\\nabla\_\{\\theta\}^\{\\rm path\}m\_\{e\}^\{h\}\.\(A\.24\) EventFlip\-Hardadds the measured flip loss differencesΔeh\\Delta\_\{e\}^\{h\}weighted byκσ\\kappa\_\{\\sigma\}to this path gradient\. Event sampling recovers the specified jump term in expectation and evaluates both the continuous sensitivity and the switch consequences on the hard\-switch trajectory and its hard continuations\. Becauseξ≡0\\xi\\equiv 0, the widthσ\\sigmaenters only through the threshold band andκσ\\kappa\_\{\\sigma\}\. Each summand of Eq\. \([A\.24](https://arxiv.org/html/2611.33716#A1.E24)\) is the jump term of Proposition[1](https://arxiv.org/html/2611.33716#Thmtheorem1)for the objective in which only the threshold of eventeeis randomized and every other switch keeps the hard rule, because the advantage of eventeeunder that objective isΔeh\\Delta\_\{e\}^\{h\}\. That objective is differentiable and the argument of Proposition[1](https://arxiv.org/html/2611.33716#Thmtheorem1)applies to eventeewhen every event beforeeeon the hard\-switch trajectory has a nonzero margin and every other margin on the two hard continuations of eventeeis nonzero\. Under these conditions, the other switches keep their hard values nearθ\\thetaon the hard\-switch trajectory before eventeeand on both continuations\. The two propositions below relate the smoothed objective and the two expected updates toJhardJ\_\{\\rm hard\}\. ###### Proposition A\.2\(The two objectives and the update ofEventFlip\-Hard\)\. Fix a training window and let the conditions of Appendix[A\.1](https://arxiv.org/html/2611.33716#A1.SS1)hold atθ\\theta\. 1. \(a\)For everyσ\>0\\sigma\>0, Jσ\(θ\)−Jhard\(θ\)=∑epeflip\(1−2beh\)𝒜eh\.\\begin\{split\}&J\_\{\\sigma\}\(\\theta\)\-J\_\{\\rm hard\}\(\\theta\)=\\sum\_\{e\}p\_\{e\}^\{\\rm flip\}\\,\(1\-2b\_\{e\}^\{h\}\)\\,\\mathcal\{A\}\_\{e\}^\{h\}\.\\end\{split\}\(A\.25\) 2. \(b\)WithCL=maxβ\|Lθ\(β\)−Lθ\(βh\)\|C\_\{L\}=\\max\_\{\\beta\}\|L\_\{\\theta\}\(\\beta\)\-L\_\{\\theta\}\(\\beta^\{h\}\)\|, \|Jσ\(θ\)−Jhard\(θ\)\|≤CL\[1−Pθ\(βh\)\]≤CL∑epeflip,\\begin\{split\}\|J\_\{\\sigma\}\(\\theta\)\-J\_\{\\rm hard\}\(\\theta\)\|&\\leq C\_\{L\}\\bigl\[1\-P\_\{\\theta\}\(\\beta^\{h\}\)\\bigr\]\\\\ &\\leq C\_\{L\}\\sum\_\{e\}p\_\{e\}^\{\\rm flip\},\\end\{split\}\(A\.26\)andpeflip≤12exp\(−\(meh\)2/\(2σ2\)\)p\_\{e\}^\{\\rm flip\}\\leq\\tfrac\{1\}\{2\}\\exp\\bigl\(\-\(m\_\{e\}^\{h\}\)^\{2\}/\(2\\sigma^\{2\}\)\\bigr\)\. If no margin of the hard\-switch trajectory is zero, thenJσ\(θ\)→Jhard\(θ\)J\_\{\\sigma\}\(\\theta\)\\to J\_\{\\rm hard\}\(\\theta\)asσ→0\\sigma\\to 0\. 3. \(c\)Suppose that no margin of the hard\-switch trajectory atθ\\thetais zero\. Then the hard history is constant on a neighborhood ofθ\\theta, every𝒜eh\\mathcal\{A\}\_\{e\}^\{h\}is continuously differentiable on that neighborhood, and ∇θJσ\\displaystyle\\nabla\_\{\\theta\}J\_\{\\sigma\}=gpathh\+∑eκσ\(meh\)𝒜eh∇θpathmeh\+∑epeflip\(1−2beh\)∇θ𝒜eh\.\\displaystyle=g\_\{\\rm path\}^\{h\}\+\\sum\_\{e\}\\kappa\_\{\\sigma\}\(m\_\{e\}^\{h\}\)\\,\\mathcal\{A\}\_\{e\}^\{h\}\\,\\nabla\_\{\\theta\}^\{\\rm path\}m\_\{e\}^\{h\}\+\\sum\_\{e\}p\_\{e\}^\{\\rm flip\}\\,\(1\-2b\_\{e\}^\{h\}\)\\,\\nabla\_\{\\theta\}\\mathcal\{A\}\_\{e\}^\{h\}\.\(A\.27\)Consequently, the expected update in Eq\. \([A\.24](https://arxiv.org/html/2611.33716#A1.E24)\) satisfies ghard,band−∇θJσ=−∑e∉ℬτhκσ\(meh\)Δeh∇θpathmeh\\displaystyle g\_\{\\rm hard,band\}\-\\nabla\_\{\\theta\}J\_\{\\sigma\}=\-\\sum\_\{e\\notin\\mathcal\{B\}\_\{\\tau\}^\{h\}\}\\kappa\_\{\\sigma\}\(m\_\{e\}^\{h\}\)\\,\\Delta\_\{e\}^\{h\}\\,\\nabla\_\{\\theta\}^\{\\rm path\}m\_\{e\}^\{h\}\+∑eκσ\(meh\)\(Δeh−𝒜eh\)∇θpathmeh\\displaystyle\\qquad\+\\sum\_\{e\}\\kappa\_\{\\sigma\}\(m\_\{e\}^\{h\}\)\\,\(\\Delta\_\{e\}^\{h\}\-\\mathcal\{A\}\_\{e\}^\{h\}\)\\,\\nabla\_\{\\theta\}^\{\\rm path\}m\_\{e\}^\{h\}−∑epeflip\(1−2beh\)∇θ𝒜eh\.\\displaystyle\\qquad\-\\sum\_\{e\}p\_\{e\}^\{\\rm flip\}\\,\(1\-2b\_\{e\}^\{h\}\)\\,\\nabla\_\{\\theta\}\\mathcal\{A\}\_\{e\}^\{h\}\.\(A\.28\) By the Gaussian bound in \(b\), the terms of Eq\. \([A\.25](https://arxiv.org/html/2611.33716#A1.E25)\) that are not exponentially small belong to the events whose hard margins lie within a fewσ\\sigmaof zero\. The three sums in Eq\. \([A\.28](https://arxiv.org/html/2611.33716#A1.E28)\) have distinct sources\. The first comes from band truncation, which omits the events outsideℬτh\\mathcal\{B\}\_\{\\tau\}^\{h\}\. The second arises because eachΔeh\\Delta\_\{e\}^\{h\}is measured with hard continuations, whereas𝒜eh\\mathcal\{A\}\_\{e\}^\{h\}averages over randomized continuations\. The third enters because the update treats each measured flip loss difference as a constant, whereas the advantages in Eq\. \([A\.25](https://arxiv.org/html/2611.33716#A1.E25)\) vary withθ\\theta\. ###### Proof of Proposition[A\.2](https://arxiv.org/html/2611.33716#Thmtheorem2a)\. *Part \(a\)\.*Fore=1,…,Nevt\+1e=1,\\ldots,N\_\{\\rm evt\}\+1, letVe=𝔼\[Lθ∣β<e=β<eh\]V\_\{e\}=\\mathbb\{E\}\[L\_\{\\theta\}\\mid\\beta\_\{<e\}=\\beta^\{h\}\_\{<e\}\]be the expected loss when the events beforeeetake their hard values and the events fromeeon are randomized\. The conditioning event has positive probability because0<qe′<10<q\_\{e^\{\\prime\}\}<1for every evente′e^\{\\prime\}\. No event is fixed inV1V\_\{1\}and every event is fixed inVNevt\+1V\_\{N\_\{\\rm evt\}\+1\}, soV1=Jσ\(θ\)V\_\{1\}=J\_\{\\sigma\}\(\\theta\)andVNevt\+1=Lθ\(βh\)=Jhard\(θ\)V\_\{N\_\{\\rm evt\}\+1\}=L\_\{\\theta\}\(\\beta^\{h\}\)=J\_\{\\rm hard\}\(\\theta\)\. For a fixed history the simulator is deterministic, soβ<e=β<eh\\beta\_\{<e\}=\\beta^\{h\}\_\{<e\}fixes the pre\-event history atHehH\_\{e\}^\{h\}\. GivenHehH\_\{e\}^\{h\}, eventeeis on with probabilityqehq\_\{e\}^\{h\}\. WithL<eL\_\{<e\}denoting the loss accumulated on the hard\-switch trajectory before the state update of eventee, Eq\. \([A\.10](https://arxiv.org/html/2611.33716#A1.E10)\) gives Ve\\displaystyle V\_\{e\}=L<e\+qeh𝒬e\(1∣Heh\)\+\(1−qeh\)𝒬e\(0∣Heh\),\\displaystyle=L\_\{<e\}\+q\_\{e\}^\{h\}\\,\\mathcal\{Q\}\_\{e\}\(1\\mid H\_\{e\}^\{h\}\)\+\(1\-q\_\{e\}^\{h\}\)\\,\\mathcal\{Q\}\_\{e\}\(0\\mid H\_\{e\}^\{h\}\),Ve\+1\\displaystyle V\_\{e\+1\}=L<e\+𝒬e\(beh∣Heh\)\.\\displaystyle=L\_\{<e\}\+\\mathcal\{Q\}\_\{e\}\(b\_\{e\}^\{h\}\\mid H\_\{e\}^\{h\}\)\.Subtracting the two lines, separately forbeh=1b\_\{e\}^\{h\}=1andbeh=0b\_\{e\}^\{h\}=0, gives Ve−Ve\+1\\displaystyle V\_\{e\}\-V\_\{e\+1\}=\(qeh−beh\)×\[𝒬e\(1∣Heh\)−𝒬e\(0∣Heh\)\]\\displaystyle=\(q\_\{e\}^\{h\}\-b\_\{e\}^\{h\}\)\\times\\bigl\[\\mathcal\{Q\}\_\{e\}\(1\\mid H\_\{e\}^\{h\}\)\-\\mathcal\{Q\}\_\{e\}\(0\\mid H\_\{e\}^\{h\}\)\\bigr\]=\(qeh−beh\)𝒜eh\.\\displaystyle=\(q\_\{e\}^\{h\}\-b\_\{e\}^\{h\}\)\\,\\mathcal\{A\}\_\{e\}^\{h\}\.Ifbeh=1b\_\{e\}^\{h\}=1, thenmeh≥0m\_\{e\}^\{h\}\\geq 0andqeh−1=−Φ\(−meh/σ\)=−peflipq\_\{e\}^\{h\}\-1=\-\\Phi\(\-m\_\{e\}^\{h\}/\\sigma\)=\-p\_\{e\}^\{\\rm flip\}\. Ifbeh=0b\_\{e\}^\{h\}=0, thenmeh<0m\_\{e\}^\{h\}<0andqeh=Φ\(−\|meh\|/σ\)=peflipq\_\{e\}^\{h\}=\\Phi\(\-\|m\_\{e\}^\{h\}\|/\\sigma\)=p\_\{e\}^\{\\rm flip\}\. In both casesqeh−beh=peflip\(1−2beh\)q\_\{e\}^\{h\}\-b\_\{e\}^\{h\}=p\_\{e\}^\{\\rm flip\}\(1\-2b\_\{e\}^\{h\}\)\. SummingVe−Ve\+1V\_\{e\}\-V\_\{e\+1\}overe=1,…,Nevte=1,\\ldots,N\_\{\\rm evt\}telescopes toV1−VNevt\+1V\_\{1\}\-V\_\{N\_\{\\rm evt\}\+1\}, which is Eq\. \([A\.25](https://arxiv.org/html/2611.33716#A1.E25)\)\. *Part \(b\)\.*Since the history probabilities sum to one, Eq\. \([A\.2](https://arxiv.org/html/2611.33716#A1.E2)\) givesJσ\(θ\)−Jhard\(θ\)=∑βPθ\(β\)\[Lθ\(β\)−Lθ\(βh\)\]J\_\{\\sigma\}\(\\theta\)\-J\_\{\\rm hard\}\(\\theta\)=\\sum\_\{\\beta\}P\_\{\\theta\}\(\\beta\)\[L\_\{\\theta\}\(\\beta\)\-L\_\{\\theta\}\(\\beta^\{h\}\)\]\. The termβ=βh\\beta=\\beta^\{h\}is zero and every other bracket is at mostCLC\_\{L\}in absolute value, which gives the first inequality\. Given the hard values of the earlier events, eventeetakes its hard value with probability1−peflip1\-p\_\{e\}^\{\\rm flip\}, so Eq\. \([A\.1](https://arxiv.org/html/2611.33716#A1.E1)\) givesPθ\(βh\)=∏e\(1−peflip\)P\_\{\\theta\}\(\\beta^\{h\}\)=\\prod\_\{e\}\(1\-p\_\{e\}^\{\\rm flip\}\)\. Induction on the number of factors then yields1−∏e\(1−peflip\)≤∑epeflip1\-\\prod\_\{e\}\(1\-p\_\{e\}^\{\\rm flip\}\)\\leq\\sum\_\{e\}p\_\{e\}^\{\\rm flip\}\. The bound onpeflipp\_\{e\}^\{\\rm flip\}is the Gaussian tail boundΦ\(−z\)≤12e−z2/2\\Phi\(\-z\)\\leq\\tfrac\{1\}\{2\}e^\{\-z^\{2\}/2\}forz≥0z\\geq 0\. The constantCLC\_\{L\}and the marginsmehm\_\{e\}^\{h\}do not depend onσ\\sigma, so nonzero margins givepeflip→0p\_\{e\}^\{\\rm flip\}\\to 0and the limit follows\. By Eq\. \([A\.10](https://arxiv.org/html/2611.33716#A1.E10)\),L<e\+𝒬e\(b∣Heh\)L\_\{<e\}\+\\mathcal\{Q\}\_\{e\}\(b\\mid H\_\{e\}^\{h\}\)is a conditional mean ofLθL\_\{\\theta\}forb∈\{0,1\}b\\in\\\{0,1\\\}and therefore differs fromLθ\(βh\)L\_\{\\theta\}\(\\beta^\{h\}\)by at mostCLC\_\{L\}\. BecauseL<eL\_\{<e\}cancels in𝒜eh=𝒬e\(1∣Heh\)−𝒬e\(0∣Heh\)\\mathcal\{A\}\_\{e\}^\{h\}=\\mathcal\{Q\}\_\{e\}\(1\\mid H\_\{e\}^\{h\}\)\-\\mathcal\{Q\}\_\{e\}\(0\\mid H\_\{e\}^\{h\}\), we obtain\|𝒜eh\|≤2CL\|\\mathcal\{A\}\_\{e\}^\{h\}\|\\leq 2C\_\{L\}\. This bound does not depend onσ\\sigma, so part \(a\) gives the same limit\. *Part \(c\)\.*The margin of the first event depends on no switch value, is continuous in the parameters, and is nonzero atθ\\theta, so its sign and henceβ1h\\beta\_\{1\}^\{h\}are constant nearθ\\theta\. Ifβ<eh\\beta^\{h\}\_\{<e\}is constant nearθ\\theta, the same argument applied to the marginmem\_\{e\}of the fixed historyβ<eh\\beta^\{h\}\_\{<e\}shows thatβeh\\beta\_\{e\}^\{h\}is constant nearθ\\theta\. After finitely many steps, the hard history is constant on a neighborhood𝒪\\mathcal\{O\}ofθ\\theta\. On𝒪\\mathcal\{O\},JhardJ\_\{\\rm hard\}is the loss of the fixed historyβh\\beta^\{h\}, which gives∇θJhard=gpathh\\nabla\_\{\\theta\}J\_\{\\rm hard\}=g\_\{\\rm path\}^\{h\}on that neighborhood\. By the proof of part \(a\),peflip\(1−2beh\)=Φ\(meh/σ\)−behp\_\{e\}^\{\\rm flip\}\(1\-2b\_\{e\}^\{h\}\)=\\Phi\(m\_\{e\}^\{h\}/\\sigma\)\-b\_\{e\}^\{h\}withbehb\_\{e\}^\{h\}constant on𝒪\\mathcal\{O\}, so its gradient isκσ\(meh\)∇θpathmeh\\kappa\_\{\\sigma\}\(m\_\{e\}^\{h\}\)\\nabla\_\{\\theta\}^\{\\rm path\}m\_\{e\}^\{h\}by Eq\. \([A\.14](https://arxiv.org/html/2611.33716#A1.E14)\)\. By Eq\. \([A\.10](https://arxiv.org/html/2611.33716#A1.E10)\), the advantage is the finite sum 𝒜eh=∑β\(2βe−1\)\[∏e′\>e𝗉e′\(θ,β\)\]Lθ\(β\),\\mathcal\{A\}\_\{e\}^\{h\}=\\sum\_\{\\beta\}\(2\\beta\_\{e\}\-1\)\\Bigl\[\\prod\_\{e^\{\\prime\}\>e\}\\mathsf\{p\}\_\{e^\{\\prime\}\}\(\\theta,\\beta\)\\Bigr\]L\_\{\\theta\}\(\\beta\),taken over the complete historiesβ\\betawithβ<e=β<eh\\beta\_\{<e\}=\\beta^\{h\}\_\{<e\}\. Every factor is continuously differentiable on𝒪\\mathcal\{O\}, so𝒜eh\\mathcal\{A\}\_\{e\}^\{h\}is also continuously differentiable, with gradient denoted by∇θ𝒜eh\\nabla\_\{\\theta\}\\mathcal\{A\}\_\{e\}^\{h\}\. Differentiating Eq\. \([A\.25](https://arxiv.org/html/2611.33716#A1.E25)\) with the product rule gives Eq\. \([A\.27](https://arxiv.org/html/2611.33716#A1.E27)\)\. Subtracting Eq\. \([A\.27](https://arxiv.org/html/2611.33716#A1.E27)\) from Eq\. \([A\.24](https://arxiv.org/html/2611.33716#A1.E24)\) cancelsgpathhg\_\{\\rm path\}^\{h\}\. Substituting𝒜eh=Δeh−\(Δeh−𝒜eh\)\\mathcal\{A\}\_\{e\}^\{h\}=\\Delta\_\{e\}^\{h\}\-\(\\Delta\_\{e\}^\{h\}\-\\mathcal\{A\}\_\{e\}^\{h\}\)into the first sum of Eq\. \([A\.27](https://arxiv.org/html/2611.33716#A1.E27)\) cancels the terms withΔeh\\Delta\_\{e\}^\{h\}for the events inℬτh\\mathcal\{B\}\_\{\\tau\}^\{h\}and leaves them with a minus sign for the events outside the band, which gives Eq\. \([A\.28](https://arxiv.org/html/2611.33716#A1.E28)\)\. ∎ ###### Proposition3\(The two updates and the hard loss, full statement\)\. Letθ\(t\)\\theta\(t\),t∈\[0,1\]t\\in\[0,1\], be a continuously differentiable path in parameter space with velocityθ˙\(t\)\\dot\{\\theta\}\(t\)\. Let the conditions of Appendix[A\.1](https://arxiv.org/html/2611.33716#A1.SS1)hold on an open set containing the path, and suppose that no margin of the hard\-switch trajectory is zero atθ\(0\)\\theta\(0\)or atθ\(1\)\\theta\(1\)\. 1. \(a\)The expected update ofEventFlip\-Randwith full\-support event sampling is∇θJσ\\nabla\_\{\\theta\}J\_\{\\sigma\}by Proposition[2](https://arxiv.org/html/2611.33716#Thmtheorem2), and limσ→0∫01∇θJσ\(θ\(t\)\)⋅θ˙\(t\)𝑑t=Jhard\(θ\(1\)\)−Jhard\(θ\(0\)\)\.\\displaystyle\\lim\_\{\\sigma\\to 0\}\\int\_\{0\}^\{1\}\\nabla\_\{\\theta\}J\_\{\\sigma\}\(\\theta\(t\)\)\\cdot\\dot\{\\theta\}\(t\)\\,dt=J\_\{\\rm hard\}\(\\theta\(1\)\)\-J\_\{\\rm hard\}\(\\theta\(0\)\)\.\(A\.29\) 2. \(b\)Calltta crossing time if some margin of the hard\-switch trajectory atθ\(t\)\\theta\(t\)is zero \(under the conditions below, where the margin is strictly monotone along the path near such a time, the crossing times are the points of the path at which the margin of an event on the hard\-switch trajectory changes sign, as in the text after Eq\. \([2](https://arxiv.org/html/2611.33716#S3.E2)\)\), and suppose that every crossing time satisfies three crossing conditions\. First, exactly one eventeehas zero margin on the hard\-switch trajectory\. Second, with the hard values of the earlier events held fixed, the margin of eventeehas a nonzero derivative along the path, namely∇θpathmeh⋅θ˙\(t\)≠0\\nabla\_\{\\theta\}^\{\\rm path\}m\_\{e\}^\{h\}\\cdot\\dot\{\\theta\}\(t\)\\neq 0\. Third, on each of the two hard continuations that start at eventeewith its switch forced on and forced off, every event other thaneehas a nonzero margin\. These conditions exclude events whose margins are zero at the same time, whether on the hard\-switch trajectory or on either hard continuation\. Then there are finitely many crossing timest1<⋯<trt\_\{1\}<\\cdots<t\_\{r\}\. Leteke\_\{k\}be the event corresponding totkt\_\{k\}, letωk∈\{−1,1\}\\omega\_\{k\}\\in\\\{\-1,1\\\}be the sign of∇θpathmekh⋅θ˙\(tk\)\\nabla\_\{\\theta\}^\{\\rm path\}m\_\{e\_\{k\}\}^\{h\}\\cdot\\dot\{\\theta\}\(t\_\{k\}\), and evaluateΔekh\\Delta\_\{e\_\{k\}\}^\{h\}atθ\(tk\)\\theta\(t\_\{k\}\)\. The hard loss along the path is continuously differentiable between crossing times with derivativegpathh⋅θ˙g\_\{\\rm path\}^\{h\}\\cdot\\dot\{\\theta\}, it jumps byωkΔekh\\omega\_\{k\}\\Delta\_\{e\_\{k\}\}^\{h\}attkt\_\{k\}, and, as in Eq\. \([2](https://arxiv.org/html/2611.33716#S3.E2)\) of the main text, Jhard\(θ\(1\)\)−Jhard\(θ\(0\)\)=∫01gpathh⋅θ˙𝑑t\+∑k=1rωkΔekh\.\\displaystyle J\_\{\\rm hard\}\(\\theta\(1\)\)\-J\_\{\\rm hard\}\(\\theta\(0\)\)=\\int\_\{0\}^\{1\}g\_\{\\rm path\}^\{h\}\\cdot\\dot\{\\theta\}\\,dt\+\\sum\_\{k=1\}^\{r\}\\omega\_\{k\}\\,\\Delta\_\{e\_\{k\}\}^\{h\}\.\(A\.30\)The expected update in Eq\. \([A\.24](https://arxiv.org/html/2611.33716#A1.E24)\) ofEventFlip\-Hardsatisfies limσ→0∫01ghard,band\(θ\(t\)\)⋅θ˙\(t\)𝑑t=∫01gpathh⋅θ˙𝑑t\+\(2Φ\(τ\)−1\)∑k=1rωkΔekh\.\\displaystyle\\lim\_\{\\sigma\\to 0\}\\int\_\{0\}^\{1\}g\_\{\\rm hard,band\}\(\\theta\(t\)\)\\cdot\\dot\{\\theta\}\(t\)\\,dt=\\int\_\{0\}^\{1\}g\_\{\\rm path\}^\{h\}\\cdot\\dot\{\\theta\}\\,dt\+\\bigl\(2\\Phi\(\\tau\)\-1\\bigr\)\\sum\_\{k=1\}^\{r\}\\omega\_\{k\}\\,\\Delta\_\{e\_\{k\}\}^\{h\}\.\(A\.31\)Each jumpωkΔekh\\omega\_\{k\}\\Delta\_\{e\_\{k\}\}^\{h\}includes every later switch that changes its value as a consequence of the flip of eventeke\_\{k\}\. The limit in \(a\) needs no condition at the crossing times, and under the conditions of \(b\) its right side equals the right side of Eq\. \([A\.30](https://arxiv.org/html/2611.33716#A1.E30)\)\. The conditions of \(b\) are sufficient conditions\. The factor2Φ\(τ\)−12\\Phi\(\\tau\)\-1in Eq\. \([A\.31](https://arxiv.org/html/2611.33716#A1.E31)\) differs from11by2Φ\(−τ\)≤e−τ2/22\\Phi\(\-\\tau\)\\leq e^\{\-\\tau^\{2\}/2\}, by the Gaussian tail bound used in the proof of Proposition[A\.2](https://arxiv.org/html/2611.33716#Thmtheorem2a)\(b\), and is0\.999940\.99994atτ=4\\tau=4\. ###### Proof of Proposition[A\.5](https://arxiv.org/html/2611.33716#Thmtheorem2b)\. *Part \(a\)\.*For fixedσ\>0\\sigma\>0, Eq\. \([A\.2](https://arxiv.org/html/2611.33716#A1.E2)\) writesJσJ\_\{\\sigma\}as a finite sum of products of functions that are continuously differentiable on the open set, sot↦Jσ\(θ\(t\)\)t\\mapsto J\_\{\\sigma\}\(\\theta\(t\)\)is continuously differentiable with derivative∇θJσ\(θ\(t\)\)⋅θ˙\(t\)\\nabla\_\{\\theta\}J\_\{\\sigma\}\(\\theta\(t\)\)\\cdot\\dot\{\\theta\}\(t\)\. The fundamental theorem of calculus gives∫01∇θJσ⋅θ˙𝑑t=Jσ\(θ\(1\)\)−Jσ\(θ\(0\)\)\\int\_\{0\}^\{1\}\\nabla\_\{\\theta\}J\_\{\\sigma\}\\cdot\\dot\{\\theta\}\\,dt=J\_\{\\sigma\}\(\\theta\(1\)\)\-J\_\{\\sigma\}\(\\theta\(0\)\)for everyσ\\sigma, and applying Proposition[A\.2](https://arxiv.org/html/2611.33716#Thmtheorem2a)\(b\) at the two endpoints yields Eq\. \([A\.29](https://arxiv.org/html/2611.33716#A1.E29)\)\. *Part \(b\), crossing times\.*Lett∗t^\{\\ast\}be a time that is not a crossing time\. The induction in the proof of Proposition[A\.2](https://arxiv.org/html/2611.33716#Thmtheorem2a)\(c\), applied to the fixed\-history margins as continuous functions oftt, shows that the hard history is constant and every hard margin is nonzero forttneart∗t^\{\\ast\}\. The times that are not crossing times therefore form an open subset of\[0,1\]\[0,1\], and the hard history is constant on each of its intervals\. Now lett∗t^\{\\ast\}be a crossing time with eventee, and letβ\(1\)\\beta^\{\(1\)\}andβ\(0\)\\beta^\{\(0\)\}be the complete histories of the two hard continuations atθ\(t∗\)\\theta\(t^\{\\ast\}\)with eventeeforced on and forced off\. The hard\-switch trajectory atθ\(t∗\)\\theta\(t^\{\\ast\}\)isβ\(1\)\\beta^\{\(1\)\}, because the hard rule𝟏\[m≥0\]\\mathbf\{1\}\[m\\geq 0\]turns a switch with zero margin on\. The two histories share the switch values before eventee\. For these values, the margin of eventeeisψ\(t\)\\psi\(t\), which is continuously differentiable inttwithψ\(t∗\)=0\\psi\(t^\{\\ast\}\)=0andψ˙\(t∗\)=∇θpathmeh⋅θ˙\(t∗\)≠0\\dot\{\\psi\}\(t^\{\\ast\}\)=\\nabla\_\{\\theta\}^\{\\rm path\}m\_\{e\}^\{h\}\\cdot\\dot\{\\theta\}\(t^\{\\ast\}\)\\neq 0\. By the first and third conditions, every margin ofβ\(1\)\\beta^\{\(1\)\}and ofβ\(0\)\\beta^\{\(0\)\}other than that of eventeeis nonzero att∗t^\{\\ast\}\. By continuity there isδ\>0\\delta\>0such that, for\|t−t∗\|≤δ\|t\-t^\{\\ast\}\|\\leq\\delta, these margins keep their signs and\|ψ˙\(t\)\|≥\|ψ˙\(t∗\)\|/2\|\\dot\{\\psi\}\(t\)\|\\geq\|\\dot\{\\psi\}\(t^\{\\ast\}\)\|/2\. For suchtt, the hard rule reproduces the switch values before eventee, sets eventeeto𝟏\[ψ\(t\)≥0\]\\mathbf\{1\}\[\\psi\(t\)\\geq 0\], and then reproduces the later values of the corresponding continuation, so βh\(θ\(t\)\)=\{β\(1\),ψ\(t\)≥0,β\(0\),ψ\(t\)<0\.\\beta^\{h\}\(\\theta\(t\)\)=\\begin\{cases\}\\beta^\{\(1\)\},&\\psi\(t\)\\geq 0,\\\\ \\beta^\{\(0\)\},&\\psi\(t\)<0\.\\end\{cases\}\(A\.32\)Sinceψ\\psiis strictly monotone on this interval,t∗t^\{\\ast\}is the only crossing time in the interval\. The crossing times thus form a closed subset of\[0,1\]\[0,1\]whose points are all isolated, so this set is finite\. *Part \(b\), the hard loss\.*Between consecutive crossing times the hard history is a constantβ\\beta, soJhard\(θ\(t\)\)=Lθ\(t\)\(β\)J\_\{\\rm hard\}\(\\theta\(t\)\)=L\_\{\\theta\(t\)\}\(\\beta\)is continuously differentiable with derivativegpathh⋅θ˙g\_\{\\rm path\}^\{h\}\\cdot\\dot\{\\theta\}and has limits at both ends of the interval\. Neartkt\_\{k\}, writeψk\\psi\_\{k\},β\(1\)\\beta^\{\(1\)\}, andβ\(0\)\\beta^\{\(0\)\}for the objects of the previous step and letΛk\(t\)=Lθ\(t\)\(β\(1\)\)−Lθ\(t\)\(β\(0\)\)\\Lambda\_\{k\}\(t\)=L\_\{\\theta\(t\)\}\(\\beta^\{\(1\)\}\)\-L\_\{\\theta\(t\)\}\(\\beta^\{\(0\)\}\), which is continuous intt\. By the previous step, for\|t−tk\|≤δ\|t\-t\_\{k\}\|\\leq\\deltathe hard continuations atθ\(t\)\\theta\(t\)that start at eventeke\_\{k\}with its switch forced on and forced off reproduceβ\(1\)\\beta^\{\(1\)\}andβ\(0\)\\beta^\{\(0\)\}\. The two histories share the loss accumulated before the state update of eventeke\_\{k\}, soΛk\(t\)\\Lambda\_\{k\}\(t\)is the difference of their later losses, which equalsΔekh\\Delta\_\{e\_\{k\}\}^\{h\}atθ\(t\)\\theta\(t\)\. By Eq\. \([A\.32](https://arxiv.org/html/2611.33716#A1.E32)\),Jhard\(θ\(t\)\)J\_\{\\rm hard\}\(\\theta\(t\)\)equalsLθ\(t\)\(β\(1\)\)L\_\{\\theta\(t\)\}\(\\beta^\{\(1\)\}\)whereψk\(t\)≥0\\psi\_\{k\}\(t\)\\geq 0andLθ\(t\)\(β\(0\)\)L\_\{\\theta\(t\)\}\(\\beta^\{\(0\)\}\)whereψk\(t\)<0\\psi\_\{k\}\(t\)<0\. The sign ofψk\\psi\_\{k\}changes from−ωk\-\\omega\_\{k\}toωk\\omega\_\{k\}attkt\_\{k\}\. The limit from the right minus the limit from the left is thereforeωkΛk\(tk\)=ωkΔekh\\omega\_\{k\}\\Lambda\_\{k\}\(t\_\{k\}\)=\\omega\_\{k\}\\Delta\_\{e\_\{k\}\}^\{h\}\. Applying the fundamental theorem of calculus on each interval between crossing times and adding the jumps gives Eq\. \([A\.30](https://arxiv.org/html/2611.33716#A1.E30)\)\. *Part \(b\), the band integral\.*The integrandghard,band⋅θ˙g\_\{\\rm hard,band\}\\cdot\\dot\{\\theta\}is bounded and measurable intt, because it is built from finitely many fixed\-history losses, margins, and their gradients, all continuous along the path, and the histories are selected by the signs of finitely many continuous margins\. Shrinkδ\\deltaso that the intervalsUk=\[tk−δ,tk\+δ\]U\_\{k\}=\[t\_\{k\}\-\\delta,t\_\{k\}\+\\delta\]are disjoint, lie in\(0,1\)\(0,1\), and satisfy the two previous steps\. The rest of\[0,1\]\[0,1\]is covered by finitely many closed intervals without crossing times, on each of which the hard history is constant and the hard margins are continuous and nonzero, so their absolute values have a positive minimum\. OnUkU\_\{k\}, the margins ofβ\(1\)\\beta^\{\(1\)\}andβ\(0\)\\beta^\{\(0\)\}other than that ofeke\_\{k\}also have a positive minimum absolute value, andψk\(tk±δ\)≠0\\psi\_\{k\}\(t\_\{k\}\\pm\\delta\)\\neq 0\. Takeσ\\sigmaso small thatτσ\\tau\\sigmalies below all of these values\. The band is then empty outside the intervalsUkU\_\{k\}, while onUkU\_\{k\}it can contain onlyeke\_\{k\}, which requires\|ψk\(t\)\|<τσ\|\\psi\_\{k\}\(t\)\|<\\tau\\sigma\. Ifeke\_\{k\}is not eligible atθ\(t\)\\theta\(t\), its two continuations coincide andΛk\(t\)=0\\Lambda\_\{k\}\(t\)=0\. Because the switch values beforeeke\_\{k\}are constant onUkU\_\{k\}, we have∇θpathmekh⋅θ˙=ψ˙k\\nabla\_\{\\theta\}^\{\\rm path\}m\_\{e\_\{k\}\}^\{h\}\\cdot\\dot\{\\theta\}=\\dot\{\\psi\}\_\{k\}on this interval\. In every case ∫01\(ghard,band−gpathh\)⋅θ˙dt=∑k=1r∫Uk𝟏\[\|ψk\|<τσ\]κσ\(ψk\)Λkψ˙kdt\.\\displaystyle\\int\_\{0\}^\{1\}\\bigl\(g\_\{\\rm hard,band\}\-g\_\{\\rm path\}^\{h\}\\bigr\)\\cdot\\dot\{\\theta\}\\,dt=\\sum\_\{k=1\}^\{r\}\\int\_\{U\_\{k\}\}\\mathbf\{1\}\[\|\\psi\_\{k\}\|<\\tau\\sigma\]\\,\\kappa\_\{\\sigma\}\(\\psi\_\{k\}\)\\,\\Lambda\_\{k\}\\,\\dot\{\\psi\}\_\{k\}\\,dt\.OnUkU\_\{k\},ψk\\psi\_\{k\}is strictly monotone and its range contains\[−τσ,τσ\]\[\-\\tau\\sigma,\\tau\\sigma\]\. The substitutionz=ψk\(t\)/σz=\\psi\_\{k\}\(t\)/\\sigma, withκσ\(σz\)=ϕ\(z\)/σ\\kappa\_\{\\sigma\}\(\\sigma z\)=\\phi\(z\)/\\sigmaanddz=ψ˙kdt/σdz=\\dot\{\\psi\}\_\{k\}\\,dt/\\sigma, turns thekk\-th integral into ωk∫−ττϕ\(z\)Λk\(ψk−1\(σz\)\)𝑑z,\\omega\_\{k\}\\int\_\{\-\\tau\}^\{\\tau\}\\phi\(z\)\\,\\Lambda\_\{k\}\\bigl\(\\psi\_\{k\}^\{\-1\}\(\\sigma z\)\\bigr\)\\,dz,where the factorωk\\omega\_\{k\}accounts for the direction in whichzzruns\. Asσ→0\\sigma\\to 0,ψk−1\(σz\)→tk\\psi\_\{k\}^\{\-1\}\(\\sigma z\)\\to t\_\{k\}uniformly for\|z\|≤τ\|z\|\\leq\\tauandΛk\\Lambda\_\{k\}is continuous, so this expression tends toωkΛk\(tk\)∫−ττϕ\(z\)𝑑z=\(2Φ\(τ\)−1\)ωkΔekh\\omega\_\{k\}\\Lambda\_\{k\}\(t\_\{k\}\)\\int\_\{\-\\tau\}^\{\\tau\}\\phi\(z\)\\,dz=\(2\\Phi\(\\tau\)\-1\)\\,\\omega\_\{k\}\\Delta\_\{e\_\{k\}\}^\{h\}\. Since the integral ofgpathh⋅θ˙g\_\{\\rm path\}^\{h\}\\cdot\\dot\{\\theta\}does not depend onσ\\sigma, summing overkkgives Eq\. \([A\.31](https://arxiv.org/html/2611.33716#A1.E31)\)\. ∎ ## Appendix BExperimental details This appendix describes the three simulators, the configurations ofEventFlipand of each baseline, and the training and evaluation protocol behind every result in Section[4](https://arxiv.org/html/2611.33716#S4)\. Table B\.1:Switch properties of the three simulators\.The first two rows follow from the model equations\. The third row gives the number of switches in the threshold band\|m\|<4σ\|m\|<4\\sigmaper training window atσ=0\.02\\sigma=0\.02\(in the units of Appendix[B\.4](https://arxiv.org/html/2611.33716#A2.SS4)\), reported as a range over the untrained and the trained closure\.Table[B\.1](https://arxiv.org/html/2611.33716#A2.T1)lists the switch properties behind the choice of scenarios\. On the power grid, the closure cannot change the loss while the switches are held fixed, so the path gradient is zero\. On the detonation wave, the closure acts mostly through this fixed\-switch route, and training with the jump term alone reaches only 4\.3 to 4\.4% \(Table[2](https://arxiv.org/html/2611.33716#S4.T2)\)\. On cortical spreading depolarization, the switch has no physical intermediate state, and hundreds of switches lie near their thresholds in one training window\. ### B\.1 Power\-grid cascade ##### Network and cascade model\. The simulator runs DC power flow on the IEEE 118\-bus system from MATPOWER\([Zimmerman et al\., 2010](https://arxiv.org/html/2611.33716#bib.bib66)\), which has 118 buses and 186 branches \(including 11 transformers\)\. The nominal ratingcnomc\_\{\\rm nom\}of each line is the rateA value of the PGLib\-OPF casepglib\_opf\_case118\_ieee\([Babaeinejadsarookolaee et al\., 2019](https://arxiv.org/html/2611.33716#bib.bib2)\)\. In each generation, the simulator splits the in\-service lines into islands and balances each island, shedding load proportionally when generation is short and reducing generation proportionally when it exceeds the load\. It then solves the DC power flow and opens every in\-service line whose loading reaches its rating\. Opened lines stay open, and the cascade stops at the first generation without a trip\([Soltan et al\., 2014](https://arxiv.org/html/2611.33716#bib.bib51);[Bernstein et al\., 2014](https://arxiv.org/html/2611.33716#bib.bib8)\)\. Each line carries the switchb=𝟏\[m≥0\]b=\\mathbf\{1\}\[m\\geq 0\]with marginm=\|f\|/cθ−1m=\|f\|/c\_\{\\theta\}\-1, whereffis the line flow andcθc\_\{\\theta\}is the rating predicted by the closure\. Once the topology is fixed, flows and shed load do not depend on the closure, so the path gradient with switches held fixed is zero\. Reference cascades run for at most 10 generations\. ##### Cases\. Bus loads are multiplied by independent lognormal factors with log\-standard deviation 0\.1 and rescaled to a total ofsstimes the base load, withssuniform in\[0\.65,0\.75\]\[0\.65,0\.75\]\. The simulator uses a preventive security\-constrained dispatch that keeps every line flow within\|f\|≤ucnom\|f\|\\leq u\\,c\_\{\\rm nom\}both in the intact network and after every single\-line outage that does not split the network, withuuuniform in\[0\.95,1\.0\]\[0\.95,1\.0\]\. Among such dispatches, it selects the one closest inL1L^\{1\}distance to proportional dispatch\. The operator knows only the nominal ratings, and cases without a secure dispatch are redrawn\. The initial outage removes two lines that do not split the network, drawn with probability proportional to the square of their nominal pre\-outage loading\. Weather conditions are divided into three regions\. The ambient temperature is a case\-wide value uniform in\[0,40\]∘\[0,40\]^\{\\circ\}C plus a regional term with standard deviation2∘2^\{\\circ\}C\. The wind speed isexp\(ln3\.5\+0\.5η\)exp\(0\.2ηr\)\\exp\(\\ln 3\.5\+0\.5\\eta\)\\exp\(0\.2\\eta\_\{r\}\), clipped to\[0\.3,12\]\[0\.3,12\]m/s, and the wind direction is uniform on\[0,2π\)\[0,2\\pi\)plus0\.35ηr0\.35\\eta\_\{r\}, whereη\\etaandηr\\eta\_\{r\}are case\-wide and regional standard normal variables, respectively\. ##### Reference ratings and data\. The reference rating of each line isc⋆=cnomexp\(g⋆\+ε\)c^\{\\star\}=c\_\{\\rm nom\}\\exp\(g^\{\\star\}\+\\varepsilon\), whereε∼𝒩\(0,0\.032\)\\varepsilon\\sim\\mathcal\{N\}\(0,0\.03^\{2\}\)is drawn independently for every line and case and cannot be represented by the closure\. The factorg⋆g^\{\\star\}is modeled after the IEEE Std 738 steady\-state heat balance\([IEEE, 2013](https://arxiv.org/html/2611.33716#bib.bib22)\), with current proportional toh\(veff\)\(Tmax−Ta\)\\sqrt\{h\(v\_\{\\rm eff\}\)\(T\_\{\\max\}\-T\_\{a\}\)\}andh=1\+1\.5veffh=1\+1\.5\\sqrt\{v\_\{\\rm eff\}\}for the effective wind speedveffv\_\{\\rm eff\}at the line\. The temperature limitTmaxT\_\{\\max\}is 100, 75, or 65∘C depending on the conductor class, andg⋆g^\{\\star\}is normalized so thatg⋆=0g^\{\\star\}=0for a standard conductor at 20∘C under a perpendicular wind of 2 m/s\. The 345 kV lines are further capped by the St\. Clair limit, an empirical bound on how heavily a long line may be loaded, expressed as a multiple of its surge impedance loading and computed with a surge impedance \(the characteristic impedance of the line\) of 285Ω\\Omega\. Aged conductors in the third of the three weather regions \(buses 68–112, 116, and 118\) are derated by 7\.7% \(0\.08 in log rating\), and transformers follow limits of 120, 110, or 98∘C on the hot\-spot temperature \(the temperature of the hottest point of the winding\) without wind cooling\. The training, validation, and test sets contain 4,000, 600, and 600 cases\. ##### Closure\. The closure predicts every rating ascθ=cnomexp\(MLPθ\(z\)\)c\_\{\\theta\}=c\_\{\\rm nom\}\\exp\(\\mathrm\{MLP\}\_\{\\theta\}\(z\)\)with one MLP shared by all lines and cases\. The 13 input featureszzof a line are a one\-hot voltage level \(3\), its length divided by 100 km, a one\-hot conductor class \(3\), a one\-hot region \(3\),\(Ta−20\)/10\(T\_\{a\}\-20\)/10,\(v−3\.5\)/2\.5\(v\-3\.5\)/2\.5, and\(v\|sinφ\|−2\)/2\(v\|\\sin\\varphi\|\-2\)/2, with ambient temperatureTaT\_\{a\}in∘C, wind speedvvin m/s, andφ\\varphithe angle between wind and line\. The MLP has layers13→32→32→113\\to 32\\to 32\\to 1with GELU activations and 1,537 parameters in total\. Its output layer is initialized to zero, so the untrained closure returns the nominal ratings\. ##### Window loss and metrics\. A training window starts from the reference topology at generationk0k\_\{0\}, advances three generations, and compares its stepj=0,1,2j=0,1,2with reference generationk0\+j\+1k\_\{0\}\+j\+1\. The step loss is the mean over lines of\(\(f−fref\)/cnom\)2\(\(f\-f\_\{\\rm ref\}\)/c\_\{\\rm nom\}\)^\{2\}plus the mean over buses of the squared shed\-load error normalized by the mean bus load of the case \(its total load divided by 118\)\. A window whose loss is not finite is assigned a loss of10410^\{4\}\. The main metric is the rollout loss, defined as the sum of the step losses over all generations of the cascade simulated from the initial outage and averaged over the 600 test cases, 96 of which cascade\. The three physical quantities are averaged over cases for each seed and then over seeds\. - •*Shed load\.*The absolute difference between the predicted and reference final shed load, divided by the total system load and expressed in percent\. - •*Tripped lines\.*The absolute difference in the number of lines that are in service after the initial outage and trip by the end of the cascade\. - •*Severe\-case AUC\.*A case is severe when its reference final shed load is at least 5% of the total load, which holds for 67 of the 600 test cases \(11\.2%\)\. The AUC scores cases by their predicted shed load\. ### B\.2 Detonation wave ##### Physical model and discretization\. The simulator solves the one\-dimensional reactive Euler equations for the densityρ\\rho, momentumρu\\rho u, total energyEE, and unburnt\-fuel mass fractionZZof an ideal gas withγ=1\.4\\gamma=1\.4, using Heaviside ignition kinetics\([Bao and Jin, 2000](https://arxiv.org/html/2611.33716#bib.bib5)\)\. With temperatureT=p/ρT=p/\\rho, every cell carries the switchb=𝟏\[T≥Tign\]b=\\mathbf\{1\}\[T\\geq T\_\{\\rm ign\}\]with marginm=T−Tignm=T\-T\_\{\\rm ign\}, and the reaction step integratesρZ←ρZexp\(−krΔtb\)\\rho Z\\leftarrow\\rho Z\\exp\(\-k\_\{r\}\\Delta t\\,b\)exactly over the time stepΔt\\Delta t\. The convective part uses HLLC fluxes withZZadvected as a passive scalar, MUSCL reconstruction of the primitive variables with the minmod limiter, and second\-order strong\-stability\-preserving Runge–Kutta time stepping\. In CGS units, the base rate iskr=0\.5825×1010k\_\{r\}=0\.5825\\times 10^\{10\}, the base heat release isq0=0\.5196×1010q\_\{0\}=0\.5196\\times 10^\{10\}, and the base ignition temperature isTign=0\.1155×1010T\_\{\\rm ign\}=0\.1155\\times 10^\{10\}\. The unburnt state has density1\.201×10−31\.201\\times 10^\{\-3\}and pressure8\.321×1058\.321\\times 10^\{5\}, the tube has length0\.050\.05, and the initial interface lies at0\.0050\.005\. ##### Grids and reference\. The coarse solver uses 200 cells\. The data store one state per interval in which the faster of the burnt\-state and von Neumann\-state wave speeds, enlarged by a factor of 1\.2, crosses half a coarse cell\. The von Neumann state is the shocked but still unburnt gas immediately behind the leading shock\. Each coarse step advances two stored intervals, so the coarse time step is twice the storage interval of the reference\. The reference solution uses the same scheme on a grid refined 128 times \(25,600 cells\) and is coarsened to the 200\-cell grid\. A case ends when the coarse\-grid front comes within 5 cells of the right boundary, so each case spans 526 to 582 stored steps \(263 to 291 coarse steps\)\. ##### Case distribution and data\. Each case independently and uniformly draws an overdrive factorf∈\[1\.0,1\.6\]f\\in\[1\.0,1\.6\]\(how far the initial detonation is driven beyond the Chapman–Jouguet state\), a heat\-release factorq0/q0base∈\[0\.8,1\.2\]q\_\{0\}/q\_\{0\}^\{\\rm base\}\\in\[0\.8,1\.2\], a rate factorkr/krbase=10uk\_\{r\}/k\_\{r\}^\{\\rm base\}=10^\{u\}withu∈\[0,log102\.5\]u\\in\[0,\\log\_\{10\}2\.5\], and an ignition\-temperature factorTign/Tignbase∈\[0\.70,0\.85\]T\_\{\\rm ign\}/T\_\{\\rm ign\}^\{\\rm base\}\\in\[0\.70,0\.85\]\. It also draws, independently and uniformly, a random perturbation of the initial fuel field with amplitude in\[0,0\.3\]\[0,0\.3\]and correlation length in\[10,20\]\[10,20\]coarse cells, represented by 64 Fourier modes\. The training, validation, and test sets contain 256, 32, and 256 cases drawn from this distribution with separate random seeds\. ##### Closure\. The closure adds a conservative correction to the numerical flux at every interface\. At each interface, its input consists of five features on the six surrounding cells \(three on each side\), namelyρ/ρ0\\rho/\\rho\_\{0\},u/DCJu/D\_\{\\rm CJ\},p/\(ρ0DCJ2\)p/\(\\rho\_\{0\}D\_\{\\rm CJ\}^\{2\}\),ZZ, andT/TignT/T\_\{\\rm ign\}, whereρ0\\rho\_\{0\}is the unburnt density andDCJD\_\{\\rm CJ\}is the Chapman–Jouguet speed of the case\. Its four outputs correct the fluxes ofρ\\rho,ρu\\rho u,EE, andρZ\\rho Zand are scaled by0\.01×\(ρ0DCJ,ρ0DCJ2,ρ0DCJ3,ρ0DCJ\)0\.01\\times\(\\rho\_\{0\}D\_\{\\rm CJ\},\\rho\_\{0\}D\_\{\\rm CJ\}^\{2\},\\rho\_\{0\}D\_\{\\rm CJ\}^\{3\},\\rho\_\{0\}D\_\{\\rm CJ\}\)\. The network consists of a convolution with kernel size 6 from 5 to 64 channels, two convolutions with kernel size 1 and 64 channels, and an output convolution with kernel size 1 to 4 channels, with GELU activations\. Its10,56410\{,\}564parameters are all trained\. The output layer is initialized to zero, so the untrained closure reproduces the coarse solver\. The closure affects the ignition switch only through the temperature\. ##### Window loss\. The step loss sums the mean squared errors ofρ\\rho,ρu\\rho u, andEE, each normalized by the standard deviation of that variable along the reference trajectory\. The window loss sums the step losses over the window\. A failed rollout receives a penalty of ten times the largest single\-step loss of the uncorrected solver on the validation windows\. ##### Metrics\. Evaluation rolls each case out with hard switches fromt=0t=0to its stored length\. The main metric is the relative error of the wave speed \(%\), fitted from the front trajectory within 20%–90% of the tube length\. Each seed reports the median over the 256 test cases, with a failed case counted as 100%\. At each stored time within the 20%–90% window used for the wave\-speed fit, the maximum pressure over the five cells behind the leading shock is compared with the reference, and the relative error is averaged over time\. Because the reference coarsened to 200 cells does not resolve the von Neumann spike \(the thin pressure peak right behind the leading shock\), the quantity compared is the post\-shock peak pressure on the coarse grid\. For this quantity, each seed takes the median over the 256 cases \(with a failed case counted as 100%\), and the medians are averaged across seeds\. ### B\.3 Cortical spreading depolarization ##### Physical model and discretization\. The simulator is a minimal threshold\-release model in the reaction–diffusion tradition of spreading depolarization, in which extracellular K\+diffuses through the tissue and a cell whose K\+concentration exceeds a threshold activates and then releases its own store\([Tuckwell and Miura, 1978](https://arxiv.org/html/2611.33716#bib.bib59)\)\. Each cell carries the K\+concentrationcc, a releasable storehh, a release activityaa, and an excitabilityrr, in nondimensional units where the coarse cell size and the coarse time step are one\. Over a time stepΔt\\Delta t, extracellular K\+first advances by explicit diffusion with harmonic\-mean face diffusivities, plus the divergence of the closure’s flux correction\. Each cell then evaluates the threshold switchb=𝟏\[m≥0\]b=\\mathbf\{1\}\[m\\geq 0\]with normalized marginm=\(c−cth\(1\+χ\(1−r\)\)\)/cthm=\(c\-c\_\{\\rm th\}\(1\+\\chi\(1\-r\)\)\)/c\_\{\\rm th\}, wherecthc\_\{\\rm th\}is the local release threshold\. The switch latches the release activity viaa←a\+\(1−a\)ba\\leftarrow a\+\(1\-a\)band sets the excitability tor←r\(1−b\)r\\leftarrow r\(1\-b\)\. Activated cells release their store gradually according toh←hexp\(−kaΔt\)h\\leftarrow h\\exp\(\-ka\\Delta t\), which depletes it exponentially\. The released K\+is added tocc, which then relaxes toward the resting concentrationcrestc\_\{\\rm rest\}with time constantTrestT\_\{\\rm rest\}\. We usek=0\.6k=0\.6,crest=0\.05c\_\{\\rm rest\}=0\.05,Trest=40T\_\{\\rm rest\}=40, andχ=20\\chi=20\. The activity does not decay and neitherrrnorhhrecovers, so a cell activates at most once and, after activation, releases its store at an exponentially decaying rate\. Cells in the infarct core have no switch and no store\. ##### Grids and reference\. The coarse solver uses a64×6464\\times 64grid withΔt=1\\Delta t=1and runs 160 steps per case\. The reference solves the same model with hard switches on a256×256256\\times 256grid with 16 substeps per coarse step and is block\-averaged to the coarse grid\. The activity and excitability of each block are averaged only over its releasing cells\. The coarse model uses the block mean of the fine diffusivity, the mean threshold over the releasing cells of the block, and a store equal to the fraction of releasing cells\. A coarse cell carries a switch when its block contains a releasing cell\. Every rollout starts from the block\-averaged reference state att=0t=0\. ##### Case distribution and data\. Lengths are given in coarse cells\. The fine\-grid diffusivity isDdiff=0\.12exp\(0\.6η1\+0\.3η2\)D\_\{\\rm diff\}=0\.12\\exp\(0\.6\\,\\eta\_\{1\}\+0\.3\\,\\eta\_\{2\}\), clipped to\[0\.02,0\.24\]\[0\.02,0\.24\], whereη1\\eta\_\{1\}andη2\\eta\_\{2\}are unit\-variance Gaussian random fields with Gaussian correlation functions of correlation length0\.3750\.375and88coarse cells, respectively, so thatη1\\eta\_\{1\}varies below the coarse grid scale\([Nicholson and Syková, 1998](https://arxiv.org/html/2611.33716#bib.bib39)\)\. The threshold iscth=c¯th\(1\+0\.1η3\)c\_\{\\rm th\}=\\bar\{c\}\_\{\\rm th\}\(1\+0\.1\\,\\eta\_\{3\}\), withc¯th\\bar\{c\}\_\{\\rm th\}uniform in\[0\.22,0\.30\]\[0\.22,0\.30\]andη3\\eta\_\{3\}a field of the same kind with correlation length44\. The lesion center is uniform in\[16,48\]2\[16,48\]^\{2\}\. Inside the penumbra \(a disc with radius uniform in\[10,18\]\[10,18\]\), the threshold is multiplied by 0\.7\. The infarct core is a concentric disc with radius uniform in\[3,7\]\[3,7\]\. The stimulus is a disc of radius 3 centered in a uniformly random direction from the lesion center at the penumbra radius plus a distance uniform in\[4,12\]\[4,12\], and its center is clamped to lie at least 4 cells from the boundary\. Releasing cells inside the stimulus start activated withc=1c=1,a=1a=1, andr=0r=0, whereas all other cells start at rest withc=crestc=c\_\{\\rm rest\},a=0a=0, andr=1r=1, withh=1h=1outside the core\. The training, validation, and test sets contain 128, 32, and 64 cases drawn successively from this distribution\. ##### Closure\. The closure adds a conservative correction to the K\+flux across every coarse face\. Its input on every coarse cell is the state\(c,h,a,r\)\(c,h,a,r\)and five static fields, namely the block\-mean diffusivity divided by 0\.2, the threshold divided by its mean over the case, the initial store multiplied by 4, the fraction of releasing cells in the block, and the coefficient of variation of the fine diffusivity within the block\. The network consists of three convolutions with kernel size 3, 24 channels, and GELU activations, followed by an output convolution with kernel size 3 and two channels, which give the corrections on thexxandyyfaces after scaling by 0\.05\. Its12,81812\{,\}818parameters are all trained\. The output layer is initialized to zero, so the untrained closure reproduces the uncorrected coarse model, which gives the activation\-time error of the untrained closure reported in Table[C\.3](https://arxiv.org/html/2611.33716#A3.T3)\. The flux correction compensates for variations of the diffusivity finer than the coarse grid\. ##### Window loss\. The step loss is the mean over coarse cells of\(\(c−cref\)/s\)2\(\(c\-c\_\{\\rm ref\}\)/s\)^\{2\}, wheressis the standard deviation of the reference K\+concentration over the training set\. The window loss sums the step losses over the window\. A state is invalid when it is not finite or whenccleaves\(−1,20\)\(\-1,20\)\. A failed rollout is frozen and receives, for every remaining step, a penalty of four times the largest single\-step loss of the uncorrected solver on 256 validation windows\. ##### Metrics\. Evaluation rolls each case out with hard switches fromt=0t=0for 160 steps\. The activation time of a coarse cell is the first step at which its activity rises through 0\.5, which for the reference corresponds to the step at which half of the releasing cells of the block have fired\. A cell that never activates is assigned step 161\. The activation\-time error of a case is the mean of\|tmodel−tref\|\|t\_\{\\rm model\}\-t\_\{\\rm ref\}\|over the cells with a switch that activate in the model or in the reference, divided by 160 and expressed in percent, with a failed case counted as 100%\. Each seed reports the median over the 64 test cases\. The four physical quantities are averaged over seeds\. - •*Activation mismatch\.*The percentage of cells with a switch that activate in only one of the model and the reference, with a failed case counted as 100%, averaged over the test cases\. - •*Relative error of the K\+field\.*The norm of the difference between the predicted and reference K\+concentrations over the whole rollout, divided by the norm of the change of the reference from its initial state, with a failed case counted as 1\. Each seed takes the median over the test cases\. - •*Penumbra arrival error\.*The absolute difference between the steps at which the first penumbra cell activates in the model and in the reference, divided by 160 and expressed in percent\. Each seed takes the median over the test cases\. The penumbra of a test case covers 190 to 957 coarse cells \(with a median of 446\), and the reference wave reaches the penumbra in all 64 test cases\. - •*Penumbra activation\-time error\.*The activation\-time error restricted to the cells of the penumbra, computed in the same way as the main metric\. ### B\.4 Configuration ofEventFlip Both variants use the threshold band\|me\|<τσ\|m\_\{e\}\|<\\tau\\sigmawithτ=4\\tau=4, and Table[B\.2](https://arxiv.org/html/2611.33716#A2.T2)lists the widthσ\\sigmaand the numberMMof flip branches per window in each scenario\. The width is in units of line loading on the power grid, ofTignT\_\{\\rm ign\}on the detonation wave, and of the local threshold on cortical spreading depolarization \(Appendix[B\.3](https://arxiv.org/html/2611.33716#A2.SS3)\)\. The flipped events are drawn with replacement from the proposalπe\\pi\_\{e\}of Eq\. \([6](https://arxiv.org/html/2611.33716#S3.E6)\) withλ=0\.05\\lambda=0\.05, and each event vector is weighted by1/\(Mπe\)1/\(M\\pi\_\{e\}\)\. On the detonation wave,σ\\sigmais constant within a case, so the kernel component is proportional toϕ\(me/σ\)\\phi\(m\_\{e\}/\\sigma\)\. Appendix[C\.9](https://arxiv.org/html/2611.33716#A3.SS9)compares this proposal with uniform sampling on the band, which raises the error on the detonation wave and on cortical spreading depolarization\. A flip branch restarts the simulator from the state before the sampled event, sets that switch to the opposite state, and runs to the end of the window\.EventFlip\-Randuses randomized switches in both the base trajectory and the branch, and the branch reuses the threshold noise of the base trajectory after the flipped event\.EventFlip\-Harduses hard switches in both the base trajectory and the branch, andσ\\sigmasets only the band and the kernel weights\. ### B\.5 Training and evaluation protocol Every method receives 750,000 generation solves on the power grid \(where a generation solve is one DC power\-flow solve of one case\) and 800,000 coarse solver steps on the detonation wave and on cortical spreading depolarization\. A case consists of one initial condition with its reference trajectory, and every executed case\-step counts toward the budget\. Flip branches, ensemble members, and perturbed rollouts all count, with each flip branch chargedK−neK\-n\_\{e\}steps from its restart stepnen\_\{e\}, whereKKis the window length\. Validation rollouts are not counted on any simulator\. ##### Training windows\. On the power grid, each window spans three generations as described in Appendix[B\.1](https://arxiv.org/html/2611.33716#A2.SS1)\. On the detonation wave, each window spans 32 coarse steps from a random start in a random training case\. All candidates within an update share its windows\. On cortical spreading depolarization, a window likewise covers 32 coarse steps and starts at a random step of a random training case\. Table[B\.2](https://arxiv.org/html/2611.33716#A2.T2)lists the number of windows per update\. Base trajectories and flip branches apply the same invalid\-state checks\. ##### Optimization\. EventFlip\-Rand,EventFlip\-Hard, Direct, Sigmoid, STE, AoBG, ES, RLOO, GRPO\-clip, PPO, and Closure\-RL update the closure with Adam at learning rate10−310^\{\-3\}, whereas CMA\-ES, SPSA, and EKI use their own update rules\. On cortical spreading depolarization, every Adam method uses learning rate3×10−33\\times 10^\{\-3\}\. Gradient\-norm clipping at 1\.0 is applied to every Adam method on the power grid and, in the other two scenarios, to the methods whose update contains a likelihood\-ratio estimate \(AoBG, RLOO, GRPO\-clip, PPO, Closure\-RL, and the ablation without flip branches in Appendix[C\.7](https://arxiv.org/html/2611.33716#A3.SS7)\)\. All other methods run without clipping\. ##### Checkpoints and evaluation\. On the power grid, each run scores the untrained closure and 40 checkpoints at evenly spaced points of the budget by the mean rollout loss on the 600 validation cases\. On the detonation wave and on cortical spreading depolarization, each run stores the untrained closure and a checkpoint whenever the forward step count passes a multiple of 25,000\. Each candidate is scored by the median error of the main metric on the 32 validation cases \(the wave\-speed error on the detonation wave and the activation\-time error on cortical spreading depolarization\)\. Each candidate is rolled out with hard switches fromt=0t=0, with a failed case counted as 100%\. Configurations are selected on validation data\. Each run keeps the candidate with the lowest validation score, freezes it, and evaluates it once on the test set\. Every metric reported in this appendix comes from these frozen checkpoints on the same test set\. ##### Hardware\. Each run uses one NVIDIA A100\-SXM4\-80GB GPU\. Solvers and closures run in double precision on the power grid and the detonation wave and in single precision on cortical spreading depolarization\. ### B\.6 Baselines The twelve baselines form two groups\. The four gradient\-based baselines are direct differentiation \(Direct\), sigmoid relaxation \(Sigmoid\), straight\-through estimation \(STE\), and theα\\alpha\-order batched gradient \(AoBG\)\([Suh et al\., 2022](https://arxiv.org/html/2611.33716#bib.bib54)\)\. The eight derivative\-free baselines are evolution strategies \(ES\), simultaneous perturbation stochastic approximation \(SPSA\), the covariance matrix adaptation evolution strategy \(CMA\-ES\), ensemble Kalman inversion \(EKI\), REINFORCE with a leave\-one\-out baseline \(RLOO\), clipping in the style of group relative policy optimization \(GRPO\-clip\), proximal policy optimization \(PPO\), and multi\-agent closure reinforcement learning \(Closure\-RL\)\([von Bassewitz et al\., 2024](https://arxiv.org/html/2611.33716#bib.bib62)\)\. Table[B\.2](https://arxiv.org/html/2611.33716#A2.T2)lists the configuration of each baseline in the three scenarios\. Perturbation scales marked as relative are multiples of the initial standard deviation of each weight tensor, and a tensor initialized to zero \(such as the output layer\) uses the same multiple as an absolute scale\. ES, SPSA, CMA\-ES, and EKI perturb the parameters of the closure and update them from the rollouts of the perturbed parameters\. The remaining settings are the same in all three scenarios\. Direct holds the hard switches constant in backpropagation\. Sigmoid replaces the switch bysigmoid\(m/w\)\\mathrm\{sigmoid\}\(m/w\)in the forward and backward pass, and STE keeps the hard forward pass and uses the derivative of this sigmoid in the backward pass\. ES uses antithetic Gaussian perturbations of the hard\-switch window loss\. SPSA uses the gain exponentsα=0\.602\\alpha=0\.602andγ=0\.101\\gamma=0\.101and calibrates its step size on the calibration pairs so that the root\-mean\-square parameter step equals the relative perturbation\. CMA\-ES is the separable variant\([Ros and Hansen, 2008](https://arxiv.org/html/2611.33716#bib.bib43)\)with a maximum step size of 1\.0, and on the detonation wave and cortical spreading depolarization its population is4\+⌊3lnd⌋4\+\\lfloor 3\\ln d\\rfloorforddparameters\. EKI updates the full network with 32 members, a relative initial spread of 0\.3, and inflation 1\.05, and resamples the ensemble every 10 updates\. GRPO\-clip clips the per\-dimension probability ratio atϵ=0\.2\\epsilon=0\.2and runs 4 epochs of 4 minibatches with a target KL of 0\.02\. PPO uses the same clipping with GAE atλGAE=0\.95\\lambda\_\{\\rm GAE\}=0\.95\([Schulman et al\., 2015](https://arxiv.org/html/2611.33716#bib.bib45)\)and a critic MLP with hidden layers\[32,32\]\[32,32\]trained by Adam at10−310^\{\-3\}\. Closure\-RL uses 4 rollouts per window, discount 0\.95, GAE atλGAE=0\.95\\lambda\_\{\\rm GAE\}=0\.95, clippingϵ=0\.2\\epsilon=0\.2, entropy coefficient 0\.05, 4 epochs of 4 minibatches, and a target KL of 0\.02, and trains its policy and critic by Adam\. The output noise of AoBG, RLOO, GRPO\-clip, and PPO is added to the log\-rating offset of every line on the power grid and to the closure outputs before scaling in the other two scenarios\. Among the gradient\-based baselines, AoBG\([Suh et al\., 2022](https://arxiv.org/html/2611.33716#bib.bib54)\)adds Gaussian noise to the closure output at every interface and every step and combines two estimates of the gradient of the expected window loss, each from its own group of noisy hard\-switch rollouts\. The first\-order estimate differentiates each rollout with every switch held constant, as direct differentiation does\. The zeroth\-order estimate multiplies the gradient of the log density of the noise by the window loss minus the loss of the noise\-free rollout\. The update isα\\alphatimes the first\-order estimate plus1−α1\-\\alphatimes the zeroth\-order estimate\. The weightα\\alphastarts from the inverse\-variance weight of the two sample means and is lowered, down to zero, so thatα\\alphatimes the distance between the two estimates plus a confidence radius of the zeroth\-order estimate stays below a thresholdγ\\gamma\. The thresholdγ\\gammais selected on validation data in each scenario and is 1\.35 on the power grid and∞\\inftyon the other two, whereα\\alphakeeps the inverse\-variance weight\. In our runs,α\\alphastays near one on the detonation wave and on cortical spreading depolarization and near zero on the power grid, where the first\-order estimate is zero\. WithSSsamples per group, each update costs2S\+12S\+1rollouts of each window,SSfor each estimate and one noise\-free rollout, all charged to the forward budget\. Among the derivative\-free baselines, RLOO, GRPO\-clip, and PPO add Gaussian noise to the closure output at every interface \(every line on the power grid and every face on cortical spreading depolarization\) and every step, and roll out the hard\-switch simulator with the noisy outputs\. Every action of one step is credited with the same return, the loss of the rollout from that step to the end of the window\. Closure\-RL\([von Bassewitz et al\., 2024](https://arxiv.org/html/2611.33716#bib.bib62)\), also derivative\-free, treats each interface of the detonation wave and each face of cortical spreading depolarization as an agent\. All agents share one fully convolutional Gaussian policy, whose mean is the closure output and whose standard deviation comes from a convolutional head on the closure features that is used only in training\. A separate fully convolutional critic gives one value per agent\. After every corrected step, the simulator also takes an uncorrected step from the same state, and the reward of a cell is the squared error of the uncorrected step minus that of the corrected step, both against the reference\. Each agent is trained by PPO with advantages computed by GAE from its own rewards\. We adapt two details to our simulators\. An agent sits between cells and receives the mean reward of its adjacent cells, and a failed rollout gives every cell a fixed negative reward set by the failure penalty of Appendix[B](https://arxiv.org/html/2611.33716#A2)\. The uncorrected steps are charged to the forward budget, so each rollout costs twice its number of steps\. Closure\-RL does not apply to the power grid\. There a rating changes the state only through a trip, and a trip changes the flows on the whole network, so no local error measures the effect of one rating\. Table B\.2:Configurations of all methods in the three scenarios\.The widthsσ\\sigmaandwware in units of line loading on the power grid, ofTignT\_\{\\rm ign\}on the detonation wave, and of the local threshold on cortical spreading depolarization\. SD denotes a standard deviation\. The first four baselines are gradient\-based and the others are derivative\-free\.MethodSettingPower\-gridcascadeDetonationwaveCortical spreadingdepolarizationEventFlip\-RandWidthσ\\sigma0\.020\.020\.02Flip branchesMM418Windows per update32816EventFlip\-HardWidthσ\\sigma0\.020\.020\.04Flip branchesMM418Windows per update32816Direct\([Um et al\., 2020](https://arxiv.org/html/2611.33716#bib.bib60);[Feng et al\., 2022](https://arxiv.org/html/2611.33716#bib.bib16)\)Windows per update32816Sigmoid\([Seo, 2026](https://arxiv.org/html/2611.33716#bib.bib47)\)Sigmoid widthww0\.0030\.0080\.01Windows per update32816STE\([Bengio et al\., 2013](https://arxiv.org/html/2611.33716#bib.bib7)\)Sigmoid widthww0\.10\.020\.01Windows per update32816AoBG\([Suh et al\., 2022](https://arxiv.org/html/2611.33716#bib.bib54)\)Thresholdγ\\gamma1\.35∞\\infty∞\\inftyNoise SD0\.10\.30\.3Samples per group844Windows per update8816ES\([Salimans et al\., 2017](https://arxiv.org/html/2611.33716#bib.bib44)\)Perturbation pairs4168Perturbation SD \(absolute\)0\.030\.010\.01Windows per update8816SPSA\([Spall, 1992](https://arxiv.org/html/2611.33716#bib.bib53)\)Relative perturbation3×10−33\\times 10^\{\-3\}3×10−33\\times 10^\{\-3\}10−210^\{\-2\}Calibration pairs1644Windows per update8816CMA\-ES\([Hansen and Ostermeier, 2001](https://arxiv.org/html/2611.33716#bib.bib21)\)Initial step size \(relative\)3×10−23\\times 10^\{\-2\}10−210^\{\-2\}3×10−23\\times 10^\{\-2\}Population263132Windows per update8816EKI\([Iglesias et al\., 2013](https://arxiv.org/html/2611.33716#bib.bib23)\)Observation\-noise SD0\.030\.30\.3Windows per update822RLOO\([Kool et al\., 2019](https://arxiv.org/html/2611.33716#bib.bib28)\)Noise SD0\.10\.30\.3Group size844Windows per update8816GRPO\-clip\([Shao et al\., 2024](https://arxiv.org/html/2611.33716#bib.bib48)\)Noise SD0\.10\.10\.1Group size444Windows per update8816PPO\([Schulman et al\., 2017](https://arxiv.org/html/2611.33716#bib.bib46)\)Noise SD0\.10\.030\.1Group size444Windows per update8816Closure\-RL\([von Bassewitz et al\., 2024](https://arxiv.org/html/2611.33716#bib.bib62)\)Initial policy SDn/a0\.030\.1Learning raten/a10−310^\{\-3\}3×10−33\\times 10^\{\-3\}Windows per updaten/a816 ## Appendix CAdditional results ### C\.1 Full results on the three simulators A  B  Figure C\.1:One test case on the detonation wave and on cortical spreading depolarization\.ADetonation wave\. \(a\) Pressure in space and time, with the reference front dashed\. \(b\) Test wave\-speed error of each method\. \(c\) Absolute pressure error against the reference, on a logarithmic color scale with errors below0\.3p00\.3\\,p\_\{0\}in white\.BCortical spreading depolarization\. \(a\) Tissue with the coarse\-grid diffusivity, the penumbra, the infarct core, and the stimulus\. \(b\) Reference K\+concentration at three steps\. \(c\) Activation time of each cell, with contour lines\. \(d\) Test activation\-time error of each method\. \(e\) Absolute activation\-time difference from the reference, with the color scale truncated at 6 steps\. Panels within A\(a\), A\(c\), B\(c\), and B\(e\) share one color scale\. In A\(b\) and B\(d\), bars are means over seeds 1–3 and dots are individual seeds\.Fig\.[C\.1](https://arxiv.org/html/2611.33716#A3.F1)shows one test case on each of the two field simulators, evaluated with the seed\-1 closure of each method\. In the detonation case, the front predicted by direct differentiation runs ahead of the reference front, and the closure trained by sigmoid relaxation produces a spurious wave behind the front\. In the cortical case, the activation\-time errors of direct differentiation accumulate in patches after the wave has passed the penumbra and the infarct core, while those ofEventFlip\-Randremain mostly within two time steps\. Table[C\.1](https://arxiv.org/html/2611.33716#A3.T1), Table[C\.2](https://arxiv.org/html/2611.33716#A3.T2), and Table[C\.3](https://arxiv.org/html/2611.33716#A3.T3)report the main metric of Table[1](https://arxiv.org/html/2611.33716#S4.T1)and the physical quantities for every method as means±\\pmstandard deviations over seeds 1–3\. Table C\.1:Comparison of all methods on the power\-grid cascade\.Means±\\pmstandard deviations over seeds 1–3\. The untrained closure has a rollout loss of 0\.181\. Higher AUC is better\. Rollout loss is the sum of the step losses over the cascade, and shed load and trip error are the absolute errors of the final shed load \(in percent of the total load\) and of the number of tripped lines\. AUC is the severe\-case AUC \(Appendix[B\.1](https://arxiv.org/html/2611.33716#A2.SS1)\)\. Bold and underlined values mark the best and second best\. The first four baselines are gradient\-based and the others are derivative\-free\.Table C\.2:Comparison of all methods on the detonation wave\.Means±\\pmstandard deviations over seeds 1–3\. The untrained closure has a wave\-speed error of 13\.569%\. Wave\-speed error is the relative error of the fitted wave speed, and peak pressure is the relative error of the post\-shock peak pressure \(Appendix[B\.2](https://arxiv.org/html/2611.33716#A2.SS2)\)\. Bold and underlined values mark the lowest and second\-lowest errors\. For the nine methods whose wave\-speed error stays within 10% of that of the untrained closure, the peak pressure is not reported \(–\)\. The first four baselines are gradient\-based and the others are derivative\-free\.Table C\.3:Comparison of all methods on cortical spreading depolarization\.Means±\\pmstandard deviations over seeds 1–3\. The untrained closure has an activation\-time error of 13\.465%\. Act\.\-time error is the activation\-time error, mismatch is the percentage of cells that activate in only one of the model and the reference, and K\+error is the relative error of the K\+field\. Penumbra arrival is the error of the step at which the first penumbra cell activates, and penumbra act\. time is the activation\-time error restricted to the penumbra \(Appendix[B\.3](https://arxiv.org/html/2611.33716#A2.SS3)\)\. Bold and underlined values mark the lowest and second\-lowest errors\. The first four baselines are gradient\-based and the others are derivative\-free\. ### C\.2 Budget curves Fig\.[3](https://arxiv.org/html/2611.33716#S4.F3)shows the test error of the plotted methods at each level of the forward budget\. Direct differentiation stalls early\. Its error does not decrease after the first budget level on any of the three simulators, and on the detonation wave all three seeds reach their validation\-best checkpoint within the first 100k steps\. The better of the two variants ofEventFlipreaches the full\-budget error of the strongest baseline at 100k of the 750k generation solves on the power grid and at 200k of the 800k coarse solver steps on the detonation wave\. On cortical spreading depolarization, PPO remains almost untrained\. Sigmoid relaxation and straight\-through estimation do not follow the gradient of the simulator there \(Appendix[C\.8](https://arxiv.org/html/2611.33716#A3.SS8)\) and remain at 13\.3% at every budget level\. ### C\.3 Power grid by case severity Table[C\.4](https://arxiv.org/html/2611.33716#A3.T4)splits the 600 test cases of the power grid by their reference outcome into 504 cases without a cascade, 29 cascades that shed less than 5% of the load, and 67 severe cases that shed at least 5%, as in the AUC of Table[C\.1](https://arxiv.org/html/2611.33716#A3.T1)\. When no line trips, all methods incur a loss below 0\.02\. On the 29 cascades that shed less than 5% of the load, the losses of all methods lie between 0\.13 and 0\.25\. In the 67 severe cases, early line trips redistribute power flows across the network and trigger multi\-generation islanding and load shedding\. On these severe cases,EventFlip\-Hardlowers the rollout loss by 38% relative to CMA\-ES and by more than half relative to sigmoid relaxation and direct differentiation\. The top row of Fig\.[1](https://arxiv.org/html/2611.33716#S0.F1)illustrates one of these severe cases, simulated with the trained seed\-1 closure of each method shown\. Table C\.4:Evaluation of the rollout loss by case severity on the power\-grid cascade\.Means over seeds 1–3 within each group of test cases\. Bold and underlined values mark the lowest and second\-lowest losses\. The first four baselines are gradient\-based and the others are derivative\-free\. ### C\.4 Trip history This section compares the predicted trip history with the reference history on the power grid \(Table[C\.5](https://arxiv.org/html/2611.33716#A3.T5)\)\. On the power grid, the path gradient is zero \(Appendix[B\.1](https://arxiv.org/html/2611.33716#A2.SS1)\), so direct differentiation keeps the untrained ratings and almost all of its error consists of missed trips \(Table[C\.5](https://arxiv.org/html/2611.33716#A3.T5)\)\. The reference cascades trip 1\.76 lines per case, and 96 of the 600 test cases cascade\. Direct differentiation misses 1\.612 trips per case, compared with 0\.505 forEventFlip\-Hard\. A reference trip counts as recovered when the line trips in the prediction \(in the same or another generation\)\. By this count,EventFlip\-Hardrecovers 71% of the reference trips and direct differentiation recovers 8\.5%\. For direct differentiation, 89% of its loss comes from cases with a missed trip\. Cases whose predicted trip history matches the reference exactly incur zero loss, so the loss comes entirely from wrong trips\. Per cascading case, direct differentiation misses 10\.07 trips andEventFlip\-Hard3\.16\. Table C\.5:Evaluation of the predicted trip history on the power\-grid cascade\.The loss is the rollout loss, the three trip columns count line trips per test case, and the last column gives the share of cases with an exact trip history, all as means over seeds 1–3\. Wrong\-generation trips occur in a different cascade generation from the reference\. Missed counts reference trips of lines that never trip in the prediction\. The missed, wrong\-generation, and correct trips sum to the 1\.76 reference trips per case\. ### C\.5 Learned line ratings Table[C\.6](https://arxiv.org/html/2611.33716#A3.T6)compares the ratings learned on the power grid with the reference ratings of Appendix[B\.1](https://arxiv.org/html/2611.33716#A2.SS1), which come from the IEEE 738 heat balance\. Because the closure is trained only on cascade trajectories, it never sees these reference ratings\. The error of a line in one test case ise=log\(cθ/cnom\)−g⋆e=\\log\(c\_\{\\theta\}/c\_\{\\rm nom\}\)\-g^\{\\star\}, which leaves out the scatterε\\varepsilonthat the closure cannot represent\. Each of the 600 test cases has 184 branches after its two initial outages, for a total of 110,400 pairs of a line and a test case\. On the 1,901 pairs whose peak loading reaches at least 0\.8,EventFlip\-Hardachieves a root\-mean\-square error of 0\.022 to 0\.028 in the logarithmic rating with a mean bias near zero, and the untrained closure has an error of 0\.211 with a bias of\+0\.131\+0\.131\. Averaged over seeds 1–3 on these pairs, the root\-mean\-square error is 0\.026 forEventFlip\-Hardand 0\.077 for CMA\-ES\. The closure maps the features of a line, including its conductor class, the wind speed, the ambient temperature, and the wind direction, to its rating\. The loss depends on the ratings only through which lines trip and when, so the cascades constrain the rating of a line only when its loading comes close to that rating\. The error is therefore lower on the heavily loaded pairs than over all pairs \(Table[C\.6](https://arxiv.org/html/2611.33716#A3.T6)\)\. Over all 110,400 pairs, the error still falls from 0\.186 for the untrained closure to 0\.046 to 0\.051 forEventFlip\-Hard\. The lightly loaded lines include the transformers, of which only 1 of the 6,564 pairs reaches a peak loading of 0\.8, and the 345 kV lines capped by the St\. Clair limit, which are never heavily loaded\. Table C\.6:Evaluation of the learned line ratings on the power\-grid cascade\.Root\-mean\-square error of the logarithmic rating against the reference rating for seeds 1, 2, and 3\. A pair is one line in one test case, and the second column keeps the 1,901 pairs with a peak loading of at least 0\.8\. ### C\.6 Shared and independent threshold noise InEventFlip\-Rand, each flip branch reuses the threshold noise of the base trajectory after the flipped switch, whereas redrawing the threshold noise independently setsCov\(Ge\(1\),Ge\(0\)∣He\)=0\\operatorname\{Cov\}\(G\_\{e\}\(1\),G\_\{e\}\(0\)\\mid H\_\{e\}\)=0in Eq\. \([A\.23](https://arxiv.org/html/2611.33716#A1.E23)\) while preserving the conditional expectation and forward cost\. Table[C\.7](https://arxiv.org/html/2611.33716#A3.T7)compares the two schemes at the untrained and trainedEventFlip\-Randclosures\. The table also reports training from scratch with each scheme for seeds 1–3\. On cortical spreading depolarization, the sampled 32\-step windows contain hundreds of band events on average\. Sharing the threshold noise reduces the minibatch jump\-term variance by 9–22 times and lowers the trained activation\-time error from 1\.101% to 0\.759%\. On the power\-grid cascade and the detonation wave, only a few switches per window enter the threshold band, and the two schemes give similar minibatch jump\-term variance and trained test error\. Sharing the threshold noise therefore pays off where many switches lie in the band\. Independent threshold noise changes the decisions of other near\-threshold switches along the wave front between the two rollouts, whereas under shared noise the switches unaffected by the flip take the same values in both\. Table C\.7:Ablation of shared and independent threshold noise inEventFlip\-Rand\.The variance ratio divides the variance of the single\-update minibatch jump\-term estimate under independent noise by that under shared noise\. Test errors in the metrics and units of Table[1](https://arxiv.org/html/2611.33716#S4.T1)are means over seeds 1–3\. ### C\.7 No flip branch This ablation keeps the randomized simulator,σ\\sigma, the threshold band, and the pathwise term ofEventFlip\-Randand runs no flip branch\. In addition to the pathwise term, the update follows the gradient of 1Nbatch∑e∈ℬτsg\(Ge−G¯e\)logp\(be\),\\frac\{1\}\{N\_\{\\rm batch\}\}\\sum\_\{e\\in\\mathcal\{B\}\_\{\\tau\}\}\\operatorname\{sg\}\\bigl\(G\_\{e\}\-\\bar\{G\}\_\{e\}\\bigr\)\\log p\(b\_\{e\}\),wheresg\(⋅\)\\operatorname\{sg\}\(\\cdot\)stops the gradient,NbatchN\_\{\\rm batch\}is the number of windows in the update, and the sum runs over the events in the threshold band of these windows\. HereGeG\_\{e\}is the downstream loss of the base trajectory after eventee\(the quantityGe\(be\)G\_\{e\}\(b\_\{e\}\)of Section[3\.2](https://arxiv.org/html/2611.33716#S3.SS2)\), andG¯e\\bar\{G\}\_\{e\}is the mean of the same quantity at the same step of the window over the other windows of the minibatch\. Finally,p\(be\)p\(b\_\{e\}\)is the probability of the sampled switch decision, equal toΦ\(me/σ\)\\Phi\(m\_\{e\}/\\sigma\)if the switch is on and1−Φ\(me/σ\)1\-\\Phi\(m\_\{e\}/\\sigma\)if it is off, differentiated through the margin along the base trajectory\. The number of windows per update and the learning rate are those ofEventFlip\-Rand\(Appendix[B\.5](https://arxiv.org/html/2611.33716#A2.SS5)\)\. Without flip branches, an update costs 96 generation solves on the power grid and 256 and 512 coarse solver steps on the detonation wave and cortical spreading depolarization, and each run uses the forward budget of Table[1](https://arxiv.org/html/2611.33716#S4.T1)\. Table[C\.8](https://arxiv.org/html/2611.33716#A3.T8)compares the variance of the two estimates of the jump term\. Table C\.8:Variance of the jump term without a flip branch\.Ratio of the variance of the minibatch jump\-term gradient without a flip branch to that ofEventFlip\-Randon a fixed batch of training windows with only the threshold noise redrawn\. Each variance is multiplied by the forward steps of one update\. The trained closure is the validation\-best checkpoint ofEventFlip\-Randfor seed 1\.Without a flip branch, the expectation of the jump\-term estimate is the same as with a flip branch, but the estimate now carries the differences in downstream loss between windows as well as the decisions of every switch near its threshold\. At five of the six checkpoints, the variance without a flip branch is 14 to 71 times that ofEventFlip\-Randat equal forward cost, and at the untrained closure on cortical spreading depolarization it reaches 4,681 times\. On the power grid, the variance without a flip branch at equal forward cost is 14\.1 and 68\.4 times that ofEventFlip\-Randat the untrained and trained closures, while its test error of 0\.064 is comparable to the 0\.072 ofEventFlip\-Rand\. Table C\.9:How far each gradient is from the measured change of the loss\.Each cell is the directional derivative that a method returns, divided by the derivative measured with finite differences on the simulator, given as the smallest to the largest value over the tested directions\. A value of 1 means that the gradient predicts the measured change of the loss exactly\. The two columns evaluate all methods on the same closure \(either the untrained closure or the seed\-1 closure ofEventFlip\-Rand\), and theEventFlip\-Randrows use the band estimator\.Table C\.10:Ablation of the proposal for the flip branches\.Test error of each seed in the metrics and units of Table[1](https://arxiv.org/html/2611.33716#S4.T1)\. Kernel weight, 5% uniform is the default proposal of Appendix[B\.4](https://arxiv.org/html/2611.33716#A2.SS4)\. ### C\.8 Gradient fidelity This section checks numerically that the estimator ofEventFlip\-Randis an unbiased estimate of the gradient of the smoothed objective, as Proposition[2](https://arxiv.org/html/2611.33716#Thmtheorem2)states, and that the band truncation of Proposition[A\.1](https://arxiv.org/html/2611.33716#Thmtheorem1a)removes a negligible part of it\. On each simulator, we evaluate the untrained closure and the seed\-1 closure ofEventFlip\-Randon the same 16 training windows without training, and take as the reference the directional derivative ofJσJ\_\{\\sigma\}computed by central differences with common random numbers\. We test eight unit directions, four random and four along the gradients of the band estimator ofEventFlip\-Rand, direct differentiation, sigmoid relaxation, and straight\-through estimation, and keep those on which the central differences at two step sizes agree\. The full\-support estimator covers every eligible event withM=64M=64, and the band estimator uses the configuration of the main tables\. Along the tested directions, the approximate 95% upper bound on the relative bias of the full\-support and band estimators ofEventFlip\-Randhas a median between 0\.08% and 5% of‖∇θJσ‖\\\|\\nabla\_\{\\theta\}J\_\{\\sigma\}\\\|at every checkpoint, consistent with Proposition[2](https://arxiv.org/html/2611.33716#Thmtheorem2)\. Table[C\.9](https://arxiv.org/html/2611.33716#A3.T9)reports the ratio of the returned to the measured directional derivative for every method\. Among the methods in Table[C\.9](https://arxiv.org/html/2611.33716#A3.T9), the gradient ofEventFlip\-Randis the only one whose ratio stays between 0\.34 and 1\.2 on all three simulators and both closures\. Direct differentiation returns zero on the power grid and mostly less than the measured derivative on the other two simulators, because it omits the jump term\. On the detonation wave, where sigmoid relaxation is the strongest baseline, the gradient of sigmoid relaxation lies between 0\.36 and 1\.1 of the measured derivative at the untrained closure and between 0\.028 and 0\.92 at the trained closure\. However, it falls to2×10−42\\times 10^\{\-4\}to2×10−32\\times 10^\{\-3\}of the measured derivative at the trained closure on the power grid and exceeds it by factors of10410^\{4\}to10710^\{7\}on cortical spreading depolarization\. The gradient of straight\-through estimation is within a factor of about 100 of the measured derivative only on the power grid and exceeds it by up to10510^\{5\}on the detonation wave and10710^\{7\}on cortical spreading depolarization\. These factors are consistent with sigmoid relaxation and straight\-through estimation staying at the error of the untrained closure on cortical spreading depolarization \(Table[1](https://arxiv.org/html/2611.33716#S4.T1)\)\. For sigmoid relaxation, whether a fractional switch is a usable stand\-in depends on the switch itself\. On the detonation wave, the switch is evaluated anew at every step, and a fractional value represents a cell burning at a reduced rate\. On cortical spreading depolarization the switch latches, and an activated cell raises its own threshold so that it cannot activate again\. Sigmoid relaxation differentiates this threshold feedback through a fractional switch at every step, whereas in the hard\-switch simulator the feedback has no further effect once the cell activates\. Straight\-through estimation differentiates a sigmoid that its forward pass never applies\. The truncation bias is measured by evaluating the sum over the events outside the band for each draw ofξ\\xi, which gives‖Rtail\(τ\)‖/‖∇θJσ‖\\\|R\_\{\\rm tail\}\(\\tau\)\\\|/\\\|\\nabla\_\{\\theta\}J\_\{\\sigma\}\\\|\. At the defaultτ=4\\tau=4, this ratio lies between2\.3×10−62\.3\\times 10^\{\-6\}and9\.7×10−49\.7\\times 10^\{\-4\}across the checkpoints\. Atτ=1\\tau=1, it lies between 0\.13 and 1\.07\. At the default band, the measured truncation bias is therefore negligible\. ### C\.9 Kernel\-weighted and uniform branch sampling The default proposal draws 95% of the branches by kernel weight and 5% uniformly on the band, with importance weights1/\(Mπe\)1/\(M\\pi\_\{e\}\)\. Table[C\.10](https://arxiv.org/html/2611.33716#A3.T10)compares it with uniform sampling on the band and, on cortical spreading depolarization, with sampling by kernel weight alone\. All three proposals give the same expected update and have the same forward cost\. On the power grid, a training window holds only 1\.0 to 1\.3 switches in the threshold band on average \(Table[B\.1](https://arxiv.org/html/2611.33716#A2.T1)\), so the two proposals mostly draw the same switch and the difference between them is smaller than the inter\-seed spread\. Allocating branches uniformly across the band raises the error by 21%–83% on the detonation wave and by 11%–17% on cortical spreading depolarization\. Uniform sampling places as many branches near the edges of the threshold band, where the sensitivityκσ\(me\)\\kappa\_\{\\sigma\}\(m\_\{e\}\)is smallest, as nearme=0m\_\{e\}=0, where it is largest\. Retaining the 5% uniform component prevents large importance weights near the band edges and reduces the error by 5%–11% relative to pure kernel sampling on cortical spreading depolarization\.
相似文章
聪明训练,事半功倍:基于切换信号引导的主动学习训练
本文提出HybridAL,一种主动学习方法,通过稳定信号动态切换重训练与微调,从而提升文本分类任务的效率与性能。
浅层思考,深层解决:控制循环动态以实现可靠的测试时深度
本文提出了一种控制神经网络中循环动态的方法,以实现可靠的测试时深度,分析了稳定、边际或漂移等动态机制,以提高算法任务如数独和进位传播的性能。
即插即用脉冲算子:突破脉冲Transformer中的非线性瓶颈
本文提出一种即插即用框架,通过LIF神经元的种群计算和轻量级位移缩放,实现Transformer非线性(如Softmax、SiLU、归一化)的脉冲友好近似,在无需微调的LLMs上准确率下降不到1%。
半群一致性作为学习型物理模拟器的诊断指标
提出将半群一致性作为评估学习型物理模拟器的诊断指标,展示了在使用ConvNet和FNO基线的热力学和伯格斯动力学中,归一化半群误差与展开退化相关。
一种全GPU工作流:构建高超声速流动物理仿真器
本文介绍了一种全GPU工作流,通过可微分求解器(JAX-Fluids)和基于残差的精化方法加速高超声速流动神经仿真器的数据生成与训练,提高训练分布之外的物理一致性和可靠性。