Skip to content

Speed up compute_memodel_properties with one reused Cell - #106

Merged
eleftherioszisis merged 5 commits into
mainfrom
optimize/compute-memodel-properties-single-cell
Nov 18, 2026
Merged

eleftherioszisis merged 5 commits into
mainfrom
optimize/compute-memodel-properties-single-cell

Conversation

@eleftherioszisis

@eleftherioszisis eleftherioszisis commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Run RMP, Rin, and rheobase bisection for compute_memodel_properties in one IsolatedProcess on a single reused Cell (clear stims between probes) instead of forking and rebuilding per probe.
  • Search holding uses emodel_properties.holding_current (same as calculate_rheobase); returned holding_current stays cell.hypamp (or 0.0), matching main for non-v6 templates without getHypAmp.
  • Same single-Cell path for StochKv and deterministic templates; worker still disables cvode when the template contains StochKv. Unseeded MCellRan4 (e.g. cSTUT_7) matches main bit-for-bit; do not call re_init_rng between probes (that would enable randomness main never had).
  • Regression tests: v6 cADpyr_L2TPC goldens, v5 cSTUT_7 goldens, holding/path contract tests, in-process worker coverage.

Wall-clock (compute_memodel_properties, this machine)

Model Before (main) After (this branch) Speedup
Deterministic / cvode (cADpyr_L2TPC) 9.91 s 3.61 s ~2.7×
Stochastic StochKv3 (bIR_L23BP) 23.3 s 16.9 s ~1.4×
v5 StochKv (cSTUT_7, holding=-0.05) ~304 s ~124–220 s ~1.4–2.5×

Issue: https://github.com/openbraininstitute/prod-build-emodel/issues/231

Avoid spawning a process and rebuilding the cell for every SS/threshold probe; keep origin/main numerical results via a dedicated regression test.
IsolatedProcess workers are not measured by coverage; exercise the worker body directly and the missing-emodel_properties error path.
@codecov

codecov Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
bluecellulab/tools.py 99.04% <100.00%> (+3.26%) ⬆️
tests/test_tools.py 99.15% <100.00%> (+0.25%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

darshanmandge
darshanmandge previously approved these changes Nov 18, 2026

@darshanmandge darshanmandge left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks also for fixing the issues in an earlier PR commit for the legacy v5 template and RNG for Stochastic models.

One non-blocking request: since the StochKv fallback was dropped in 13fef25, please add a short comment in compute_memodel_properties_subprocess stating the assumption, e.g.

# The Cell is reused across probes. Stochastic channels must restart their RNG
# stream on each run (StochKv/StochKv3 do this for Random123 in INITIAL).
# Templates that seed with MCellRan4 Random objects, or older StochKv3 builds
# without nrnran123_setseq in INITIAL, would see different noise than main.

@eleftherioszisis

Copy link
Copy Markdown
Contributor Author

Added the RNG reuse assumption comment in compute_memodel_properties_subprocess as requested.

@darshanmandge darshanmandge left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

@eleftherioszisis
eleftherioszisis merged commit b7b989f into main Nov 18, 2026
9 checks passed
@eleftherioszisis
eleftherioszisis deleted the optimize/compute-memodel-properties-single-cell branch November 18, 2026 15:58
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.

2 participants