Fix adjoint sensitivities for events that are both state-triggered and state-updating - #3258
Draft
dweindl wants to merge 3 commits into
Draft
Fix adjoint sensitivities for events that are both state-triggered and state-updating#3258dweindl wants to merge 3 commits into
dweindl wants to merge 3 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3258 +/- ##
==========================================
+ Coverage 78.52% 78.53% +0.01%
==========================================
Files 318 318
Lines 22199 22205 +6
Branches 1490 1490
==========================================
+ Hits 17432 17439 +7
+ Misses 4759 4758 -1
Partials 8 8
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
dweindl
force-pushed
the
fix-asa-event-trigger-time-sensitivity
branch
from
September 9, 2026 16:06
c4a55d8 to
8cddbcd
Compare
Add fiddy-based finite differences sensitivity checks to the SBML semantic test suite. Splits the single forward-only sensitivity check into three independent nodes per case (forward/adjoint/consistency), generalizes the retry scaffold, fixes cross-test-node model-parameter contamination, and skips known-affected cases (events/piecewise, zero-state models) with adjoint/forward distinguished where relevant. Disables fiddy's function-call caching by default (pure overhead here, source of a flaky CI failure). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…d state-updating deltaxB/deltaqB embed dtaudx/dtaudp (trigger-time-sensitivity terms), but these were evaluated at whatever state the generated function happens to be called with -- in practice the post-event state. That's the wrong side of the discontinuity: the equivalent forward-mode quantity (stau) is deliberately computed pre-event. Fix: eliminate w via its own algebraic definition, then substitute x -> x_old. Verified via direct FSA-vs-ASA comparison (bypassing FD entirely) on a 72-case corpus of affected SBML semantic test suite models: divergence for the affected parameter previously ranged from ~0.001% up to ~1% relative (worst observed: FSA=0.16456 vs ASA=0.16303); after the fix, it drops to ~1e-13-3e-11 relative (floating-point noise) with zero regressions. Corpus (SBML semantic test suite case IDs), for future reference/test cases: - Explicit SBML events (state-triggered and state-updating): 00026, 00041, 00074, 00619, 00620, 00621, 00634, 00635, 00636, 00646, 00647, 00648, 00652, 00653, 00654, 00679, 00680, 00681, 00689, 00700, 00707, 00723, 00736, 00743, 00744, 00745, 00746, 00747, 00749, 00750, 00751, 00752, 00753, 00754, 00755, 00756, 00789, 00790, 00791, 00845, 00846, 00847, 00883, 00884, 00945, 00946, 00947, 00948, 01045, 01046, 01047, 01071, 01072, 01073, 01094, 01106 - Piecewise reaction-rate laws (no explicit <event>, but AMICI hits the same code path via an internal root): 00191, 00192, 00193, 00194, 00198, 00199, 00200, 00201, 00270, 00272, 00273, 00274, 00276, 00277, 00278, 00279 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
dweindl
force-pushed
the
fix-asa-event-trigger-time-sensitivity
branch
from
September 9, 2026 20:28
583959f to
8a7efac
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
deltaxB/deltaqB embed dtaudx/dtaudp (trigger-time-sensitivity terms), but these were evaluated at whatever state the generated function happens to be called with -- in practice the post-event state. That's the wrong side of the discontinuity: the equivalent forward-mode quantity (stau) is deliberately computed pre-event. Fix: eliminate w via its own algebraic definition, then substitute x -> x_old.
Verified via direct FSA-vs-ASA comparison (bypassing FD entirely) on a 72-case corpus of affected SBML semantic test suite models: divergence for the affected parameter previously ranged from ~0.001% up to ~1% relative (worst observed: FSA=0.16456 vs ASA=0.16303); after the fix, it drops to ~1e-13-3e-11 relative (floating-point noise) with zero regressions.
Corpus (SBML semantic test suite case IDs), for future reference/test cases:
Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com
Fixes #3257. Maybe #18 too, to be confirmed.
Tests will be implemented as part of #3251 and #3253.