Skip to content

Compare sensitivity timings only with timings of the same quantity (#61) - #68

Merged
wshlavacek merged 1 commit into
lanl:mainfrom
Montana:fix/61-sens-like-for-like
Dec 1, 2026
Merged

wshlavacek merged 1 commit into
lanl:mainfrom
Montana:fix/61-sens-like-for-like

Conversation

@Montana

@Montana Montana commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #61.

What

The sens-sbml and sens-net timing summaries now compare BNGsim's sensitivity solve only with engines that computed the same derivatives. Plain solves and log-likelihood gradients each get a table of their own, and every timing.csv row says what it computed.

Why

Each sensitivity timing also times what is not a sensitivity solve: a plain solve (bngsim_ode, roadrunner, run_network), the unit of a finite-difference gradient, and a log-likelihood gradient (amici_adjoint, bngsim_gradient). All of them sat in one table, and the derived speedups divided one by the other:

before after
sens-sbml, covid19_italy_interventions_giordano2020 (43 parameters) roadrunner 0.0031: BNGsim "328x slower", against a plain solve roadrunner_central_fd 0.26: 3.8x slower, against RoadRunner's central-difference gradient
sens-net, atf2_phosphoswitch_kirsch2020 (auto, 21 parameters) run_network 0.68: BNGsim slower run_network_central_fd 29: BNGsim 29x faster
sens-net, amici_adjoint divided by BNGsim's sensitivity matrix divided by bngsim_gradient, BNGsim's gradient of the same log-likelihood

fd_baselines, the like-for-like number, was in every job record, but bench publish never used it.

Changes

timing.csv has three new columns (docs/published_format.md):

  • quantity: what the engine computed. In a sens suite it is sensitivities, llh_gradient or plain_solve. Every other suite's engines compute the suite's own output, named by its capability (ode, steady_state, psa, ssa, nf). A pivot on engine and quantity cannot mix them.
  • derived_from, parameters: set on a new row per plain solve, the central finite-difference gradient it gives. That row's time is 2N times the plain solve's, its interval is the plain solve's scaled by 2N, and its pre-sim is the plain solve's. The rows are named roadrunner_central_fd, run_network_central_fd and bngsim_ode_central_fd. They are computed, not measured, and the role says so.

Note

The issue suggests the names fd_roadrunner and run_network_fd. Those are the correctness references, and they do more work: steps h and h/2 (4N solves) at the tighter fd_rtol/fd_atol. A timing row under the same name would read as their cost, understated at least twofold. So the rows are named apart, and the README and docs/published_format.md say which is which.

The table of what each engine computes is bench.gather.SENS_QUANTITIES. bench publish refuses a sens engine it does not list, so a new engine has to say what it computes before it is published beside the others.

The snapshot README has one timing table per quantity where a suite timed more than one, BNGsim's own first: forward sensitivities, then the log-likelihood gradient, then one plain solve. Each table's speedups divide by BNGsim's engine of that quantity (bngsim, bngsim_gradient, bngsim_ode). A finite-difference row reads roadrunner_central_fd (2 × 43 roadrunner solves). A member with no gradient timed is absent from the gradient table, which says so; its reason, if any, is in the first table. The READMEs of the suites that time one quantity are byte for byte unchanged.

The roles and pre-sim costs of sens rows. timing.csv read these through the general _presim, which knows only bngsim and the references. So bngsim_simultaneous, bngsim_ode and bngsim_gradient had no role and no pre-sim cost, and the role was the one thing that told a plain solve apart. They are now read through _sens_presim, as bench gather already did. As in gather, amici_adjoint and bngsim_gradient show the pre-sim of the build they run on (AMICI's, BNGsim's).

Committed snapshots are rebuilt, not rerun. publish.snapshot_tables rebuilds a snapshot's correctness.csv and timing.csv from its own manifest.json and job records. bench publish --index now writes them, as it writes the READMEs, and the existing guard (test_every_committed_summary_is_what_the_committed_data_generates) checks them. Before any change, it reproduced all 16 committed CSVs byte for byte. Every number here comes from the job records already committed; no suite was rerun. The publisher is not part of a job's definition, so no snapshot becomes out of date because of this.

bench gather's local report had the same mix: its sens x amici column divided AMICI's sensitivities by every engine's time. It now divides by sensitivities only, and says so under the table.

Audit of the other suites

Each times one quantity. ode-net, ode-sbml and ode-antimony time trajectories; ss-sbml and ss-net, steady states (bngsim_integration and run_network reach the same steady state another way); psa-net, the same PSA at each @nc=N, divided by bngsim@nc=N; ssa-, ensembles; nf-xml-, network-free runs. Their CSVs gain only the three columns (quantity filled, the other two empty), and their READMEs do not change.

Not doing

  • Republishing on a new build. The snapshots are still bngsim 0.17.2, and Published results are out of date #60 still lists them as out of date for 0.18.0. A rerun would publish these tables with new numbers.
  • The forward-difference cost (N + 1 solves). It stays in the records' fd_baselines. The published row is central differences, the method the correctness check uses.
  • fd_baselines is computed (2N × the plain-solve median), not timed end to end. The row says so; timing a whole FD gradient would be a harness change.

Review

One round of an independent whole-branch review using Fable (high effort). It reran the arithmetic against every committed record: each fd_baselines.central_seconds is 2N times the plain-solve median. Measured rows are unchanged apart from the filled roles and pre-sim costs. Non-sens READMEs are byte-identical. snapshot_tables reproduces what publish() writes, withheld timings included. It found four issues, each fixed with a test:

  • the FD rows shared the correctness references' names (above);
  • a snapshot with no bngsim row rendered an empty section and took a derived row as BNGsim's base;
  • an @nc=N plain solve's FD row would have landed in the plain-solve table;
  • the gradient table's note named a bngsim_gradient that sens-sbml does not time.

Testing

  • tests/test_summary.py, 11 new tests:
    • each sens row's quantity, with the role and pre-sim read from the record;
    • a finite-difference row derived and labelled, its interval scaled;
    • no FD row without a timed plain solve;
    • an unknown sens engine refused;
    • every other suite's engines computing its own output;
    • the guard the issue asks for: no table of any committed README, nor its speedups, shows two quantities;
    • its negative control: rendered without quantity, as first published, both sens READMEs put all three quantities in one table, and the guard says so;
    • sens-sbml's sensitivities divided by roadrunner_central_fd, never by roadrunner or the correctness reference's name;
    • an @nc=N plain solve's FD row keeping its suffix and quantity;
    • a snapshot with no bngsim row getting no empty section, and no derived row as BNGsim's base.
  • tests/test_gather.py: x amici is blank for a plain solve.
  • 20 mutants, each a bug planted on purpose (mutate.py from bngsim-preflights): 20 killed. A first run's one survivor was an equivalent mutant: it removed a role lookup that _sens_presim already does, so the lookup was removed.
  • Unit suite (-m 'not integration and not network') in a uv environment without pixi: 1330 passed. It has the same 18 failures and 5 errors as main in that environment, all needing AMICI or BioNetGen. CI is the first full run.
  • ruff check on the changed files: no new findings.

@elyfmiller elyfmiller mentioned this pull request Dec 1, 2026
@wshlavacek
wshlavacek merged commit 4c11c7a into lanl:main Dec 1, 2026
2 checks passed
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.

sens-sbml and sens-net summaries time a plain solve beside BNGsim's sensitivity solve; compare only like with like

2 participants