Skip to content

smooth pulses: read a bump call's argument for a clock before inlining every rate law - #1444

Merged
wshlavacek merged 2 commits into
mainfrom
fix/1286-pulse-check-cost
Nov 1, 2026
Merged

wshlavacek merged 2 commits into
mainfrom
fix/1286-pulse-check-cost

Conversation

@wshlavacek

Copy link
Copy Markdown
Collaborator

#1383's search for smooth pulses in time (#1286) made bngsim slow on any model whose rate laws call exp, cosh or tanh, on every run. Most such calls have nothing to do with time: a Boltzmann factor, a rate of a voltage. The search inlined every rate law and parsed each one that holds such a call, before asking whether any of them involves a clock.

model search per run, before after
MODEL1006230090 over 7 minutes (killed) 8 ms
MODEL1006230049 21 s under 20 ms

It found no pulse in any of them. On the nightly's runners that pushed MODEL1006230049, 053 and 077 out of their budget in the path-agreement check. #1401's run 41313484937 timed all three out in the locale check, which main before #1383 passed in 1,350–1,456 s. The slowdown never shipped: #1286's changelog fragment is still unreleased, so this adds none.

The fix

A pulse's argument has the clock as its only symbol once the parameter values are put in. The search now reads the function texts first. For each call's argument, it follows the functions and derived parameters it names and asks two things: does the argument reach a clock (time(), or a counter fed at a constant rate), and does it reach any other species or observable? Only an argument that reaches a clock and nothing else can be a pulse. If no argument passes, nothing is inlined or parsed. Otherwise the search runs exactly as before.

Checks

  • Tests. Four new cases fail without the change: a Boltzmann factor, a pulse of the state, the clock reached only beside the state (as pH_cy does in MODEL1006230049), and _e^ of no clock. Two more confirm that a pulse reached through another function is still found, in time() and in a counter. ode: stop on the centre of a smooth bump of the clock in a rate law (#1286) #1383's existing 30 tests pass unchanged.

  • Every pulse ode: stop on the centre of a smooth bump of the clock in a rate law (#1286) #1383's tests find is still found. I ran those tests and test_net_state_switch_stepping.py with a guard that asserted the check never skips a search that finds a stop. 75 searches ran: all 44 that found a stop were kept, and the 27 skipped found none.

  • Corpus sweep, all 1,319 BioModels SBML files. For every model the check skips, the old full search was run too.

    models
    no exp/cosh/tanh call at all (untouched) 1,109
    searched as before 86
    skipped, and the full search finds no pulse 91
    skipped, full search past 300 s (MODEL1006230090) 1
    load error (unrelated) 32

    None skipped had a pulse. MODEL1006230090 has no clock at all: no function calls time(), and no counter. The check costs at most 8 ms per model.

#1286)

#1383's stop search inlined every rate law and parsed each that calls
exp, cosh or tanh, on every run of any model that spells one. Most such
calls are no bump of a clock: a Boltzmann factor, a rate of a voltage.
MODEL1006230049 took 21 s a run for no stop, and MODEL1006230090 over
7 minutes, which timed the three large CellML models out of the
nightly's path-agreement check.

A bump's argument has the clock as its one symbol once the parameter
values are put in. The texts now say first whether any call's argument
reaches a clock (time() or a counter), through the functions and
derived parameters it names, and reaches no other species or
observable. Where none does, nothing is inlined or parsed. The four
models are answered in under 20 ms.
@wshlavacek
wshlavacek merged commit f64a2bf into main Nov 1, 2026
14 checks passed
@wshlavacek
wshlavacek deleted the fix/1286-pulse-check-cost branch November 1, 2026 18:27
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.

1 participant