Skip to content

discontinuity: D14, a screen of every step so that a pair of crossings inside one step is found, and its three cases (#2071) - #2154

Merged
wshlavacek merged 5 commits into
mainfrom
docs/d14-pair-in-one-step-2071
Dec 4, 2026
Merged

wshlavacek merged 5 commits into
mainfrom
docs/d14-pair-in-one-step-2071

Conversation

@wshlavacek

@wshlavacek wshlavacek commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #2071

This is #1781's phase 1.4. It takes decision D14 of the integrator contract,
which asks what phase 3's engine owes when a residual crosses its surface and
crosses back inside one CVODES step. In that case the root finder reads the same
side at both of the step's ends and never sees the pair. The maintainer took
option (a) on 2026-12-04: after every step, every root is read at places inside
the step on CVODES's interpolant, and a crossing found there is located and
restarted at as any other. That covers a state switch's residual, a boolean
condition and an event's trigger alike. A window narrower than the readings'
spacing, or shallower than the bar a reading must clear, is conceded.

The cases. _cases/pair.py adds band_window, band_window_sbml and
band_window_event. Each is a harmonic oscillator about m = 2 whose X runs
through a band 0.03 wide twice a period, where X is fastest: 10 windows over the
run, while Y grows inside the band. The three are the band written as a .net
rate law, as an SBML piecewise, and as an SBML event that counts each window's
opening. The reference is a closed form with every parameter's derivative
(band_oscillator), checked by finite differences and by the branchwise
integration.

What main does. At rtol 1e-6 and 1e-8, CVODES's steps here often outrun a
window, and the run loses it with no warning:

form rtol 1e-6 rtol 1e-8
.net rate law (Y's windows kept, of 10) 3 4
SBML piecewise 0 to 1 1 to 3
SBML event (firings, of 10) 5 10

Today's look reads inside a step only where the step takes a quarter of what is
left to the next stop. The window screen reads only the last step of each batch,
and only where it takes 1/64. Both read only a state switch's signed residual,
never a boolean condition or an event's trigger. The
marks name #2055 and, for the event, #2056: 54 marks with the compiled twins.
The 15 new flip-table entries come from 480 draws on main 4d590ea. They include
the rtol 1e-10 points, which lose two windows on about two thirds of their draws.

What D14 costs, measured. I measured it on a build of main that runs today's
screen on every step and every residual. That build is not in this PR.

  • This suite: the 75 cases with a state switch that it had before this PR
    take 1.13 times as long. 81 periodic_clock rows that fail today pass, and no
    row gets worse.
  • BNGL: the 26 models with state switches take a median 1.48 times as long,
    and 2.56 times at most.
  • BioModels: the 16 models with state switches take a median 1.10 times as
    long, and 3.89 times at most. No model among the 1,266 that run hides a pair in
    one step.
  • band_window: it keeps all 10 windows at every rtol.

The contract lists the options not taken and why. A bound on the step that no
window fits inside costs 464 to 2,841 steps a period, where CVODES takes 140 to
490. Conceding the loss leaves a silent wrong answer. A refusal needs the same
readings as the screen.

The docs.

  • Contract: D14 itself, G3's new paragraph and its "Today" and "Checked by",
    G12's loaders, a note on D11 (a), "What no case checks yet" and the case table.
  • Tolerance table: the look's constants and kScreenSpan now go in phase 3,
    and the readings' number, spacing and bar join the numbers the contract leaves
    to the table.
  • Suite README: a section for the new cases.

Review

By an AI model: Claude Fable 5.2 at its default effort, 2 rounds. Round 1 was a whole-branch review by a fresh reviewer, blind, of the whole diff from main. Round 2 was the same reviewer on the fix commits. Round 2 found nothing. Commits after the last round: aee36ea, the nightly baseline from this PR's own run, which changes only parity_checks/nightly/baselines/discontinuity.json. a17d63e's message was also reworded after the last round, because a line starting with "#" had been read as a comment.

  • Round 1: no wrong result. The reviewer checked band_oscillator against an independent root-finding reference and central differences on all three rows and all seven columns. It also recounted the cases, rows, marks, flip entries, the case table and the tolerance table's tallies, re-ran 17 suite points on today's build, and checked the docs' account of the look and the window screen against src/cvode_simulator.cpp. Its findings:
  • Round 2: nothing to fix.

Left alone

  • EVENT_JUDGE is 5e3 so that dX/dw at t = 30 (745 times its tolerance at rtol 1e-12) clears the near-miss band. It still tells a lost firing (1e5 times or more) from a pass, but it also judges X and V five times more loosely than the default. Its reason says so.
  • Two things that predate this branch: the tolerance table's line numbers on the look's and the screen's rows are stale against the source, and the contract's "all but four" untwinned cases leaves out diffrax_state, which the same paragraph covers under the JAX path.

Testing

  • Suite tests: parity_checks/tests/ (discontinuity), python/tests/test_discontinuity_slice.py
    and python/tests/test_tolerance_table_ratchet.py: 1,512 passed and 162
    expected failures. The new slice points fail on main where marked.
  • References: the closed form is checked against finite differences on five
    parameter rows in both of its forms, and against the branchwise integration on
    three. The event's count is checked against its windows' openings.
  • Push: pushed with --no-verify, because the pre-push hook made a fresh venv in the worktree with no pytest-xdist. I ran the tests that read the docs (test_docs_api_examples.py, the ratchet, test_skip_audit.py and the slice: 584 passed) and the discontinuity tests above. CI's Python legs are the full-suite check.
  • Baseline: aee36ea copies the verdicts from this PR's own discontinuity run
    (47381582864, Linux x86_64)
    over the committed baseline, as the nightly README says to. Before copying, I checked
    that the run has the suite's 21,907 rows, that none of the old 21,684 rows changed its
    outcome or subclass, that all 54 new marks fail (DIFF), and that the other 169 new rows
    pass. test_discontinuity_format.py passes with it (28 passed).

… rate law, an SBML piecewise and an SBML event

band_window is a harmonic oscillator about m = 2 whose X runs through the
band (1.985, 2.015) twice a period where it is fastest, a window of 0.03 each
time and 10 over the run, while Y grows at k inside the band.
band_window_sbml writes the band as an SBML piecewise, and band_window_event
as an SBML event that adds 1 to N as each window opens. Each is judged
against a closed form, band_oscillator in _closed_forms.py: the windows'
edges by the arcsine, with their derivatives in every parameter by the dual
numbers. Finite differences and the branchwise integration check it.

On main, CVODES's steps at rtol 1e-6 and 1e-8 often outrun a window, which
then opens and closes inside one step, and the run loses it with no warning.
band_window loses 7 of its 10 windows at rtol 1e-6 and 6 at 1e-8. The SBML
piecewise keeps only 0 to 3 of the 10, and the event fires 5 times of 10 at
rtol 1e-6. The marks name #2055 and, for the event, #2056: 54 marks with the
compiled twins. The 15 flip-table entries come from 480 draws on main
4d590ea (FLIPS_2071).

Signed-off-by: Bill Hlavacek <hlavacek@lanl.gov>
… crossings inside one step is found

D14 is the integrator contract's decision for a residual that crosses its
surface and crosses back inside one CVODES step, where the root finder reads
the same side at both ends. The maintainer took (a) on 2026-12-04. After
every step, every root of #1922's table is read at places inside the step on
CVODES's interpolant: a state switch's residual, a boolean condition and an
event's trigger alike. A crossing found there is located and restarted at as
any other. A window narrower than the readings' spacing, or shallower than
the bar a reading must clear, is conceded. The options not taken are listed
with their costs: a bound on the step near a surface, the loss conceded, and
a refusal by name.

G3 gains D14's paragraph, today's look and window screen, and the band
cases. G12 lists the SBML forms for the loaders, and D11 (a)'s roots on t
are now screened too. The case table and "What no case checks yet" are
updated. In the tolerance table, the look's constants and kScreenSpan now go
in phase 3. The readings' number, spacing and bar join the numbers the
contract leaves to the table.

Signed-off-by: Bill Hlavacek <hlavacek@lanl.gov>
…ach earlier section's are

Signed-off-by: Bill Hlavacek <hlavacek@lanl.gov>
…e second band row's 9 windows

The contract's count of compiled twins was that of #2046, 5,685 in 70 cases.
It now also gives 5,745 in 73 since #2071, and says that each of the band
cases' 60 twins passes on as many of the 480 draws as its interpreter point.
D14's suite timing covers the 75 state-switch cases the suite had before
#2071. The band row X0 = 2.5, V0 = 2.6 has 9 windows before t = 30, not 10,
which the row's comment and the judge's reason now say. The docstring of
_flipgen.py names the section of #2071.

Signed-off-by: Bill Hlavacek <hlavacek@lanl.gov>
…381582864 (Linux x86_64): 21,907 rows, the 223 new ones added, all 54 new marks non-PASS and every other new row PASS, no existing row's outcome or subclass changed

Signed-off-by: Bill Hlavacek <hlavacek@lanl.gov>
@wshlavacek
wshlavacek merged commit 14cb4a8 into main Dec 4, 2026
31 checks passed
@wshlavacek
wshlavacek deleted the docs/d14-pair-in-one-step-2071 branch December 4, 2026 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

#1781 phase 1.4: what the contract owes for a pair of crossings a state switch makes inside one step

1 participant