Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exploit stoichiometric matrix in pysb import #1761

Merged
merged 9 commits into from
Apr 5, 2022
Merged

Conversation

FFroehlich
Copy link
Member

@FFroehlich FFroehlich commented Apr 4, 2022

Exploits stoichiometric matrix to compute dxdotdx_explicit, dxdotdp_explicit and dxdotdw as sparse matrix multiplication with derivatives of the flux vector that can be computed efficiently.

@FFroehlich FFroehlich added python PySB PySB import related performance labels Apr 4, 2022
@FFroehlich FFroehlich requested a review from dweindl April 4, 2022 22:49
@codecov
Copy link

codecov bot commented Apr 4, 2022

Codecov Report

Merging #1761 (eecfa99) into develop (707ec6c) will increase coverage by 0.23%.
The diff coverage is 98.41%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1761      +/-   ##
===========================================
+ Coverage    77.77%   78.00%   +0.23%     
===========================================
  Files           74       74              
  Lines        12033    12096      +63     
===========================================
+ Hits          9359     9436      +77     
+ Misses        2674     2660      -14     
Flag Coverage Δ
cpp 75.05% <ø> (+0.17%) ⬆️
petab 59.61% <87.30%> (+0.43%) ⬆️
python 68.69% <96.82%> (+0.45%) ⬆️
sbmlsuite 86.36% <11.11%> (-0.45%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
python/amici/pysb_import.py 94.59% <98.14%> (+0.68%) ⬆️
python/amici/ode_export.py 92.51% <100.00%> (+0.20%) ⬆️
src/sundials_matrix_wrapper.cpp 80.08% <0.00%> (-0.45%) ⬇️
src/solver_cvodes.cpp 70.43% <0.00%> (+0.16%) ⬆️
src/amici.cpp 73.13% <0.00%> (+5.22%) ⬆️
src/exception.cpp 81.08% <0.00%> (+5.40%) ⬆️
src/spline.cpp 71.57% <0.00%> (+6.31%) ⬆️

@FFroehlich
Copy link
Member Author

Ran two quick tests with smaller models. Looks like its faster even for small models and improvement increases with model size.

nx = 50 (1.8 fold improvement)

new:

2022-04-04 18:52:33.544 - amici.ode_export - INFO - Finished generating cpp code                    (1.59E+01s)

old:

2022-04-04 18:54:37.827 - amici.ode_export - INFO - Finished generating cpp code                    (2.94E+01s)

nx = 93 (2.1 fold improvement)
new:

2022-04-04 19:00:46.940 - amici.ode_export - INFO - Finished generating cpp code                    (5.59E+01s)

old:

2022-04-04 18:57:21.643 - amici.ode_export - INFO - Finished generating cpp code                    (1.17E+02s)

@FFroehlich
Copy link
Member Author

FFroehlich commented Apr 5, 2022

For model with ~8k species, processing via stoichiometric matrix completes in ~7min where dxdotdw alone needs >20min and dxdotdx computation has been running for >18h.

FFroehlich and others added 2 commits April 4, 2022 21:33
* Steady State Sensitivity modes

* integrationOnly and integrateIfNewtonFails in forward sensitivity case

* turn off newton method in case integrationOnly and forward sensitivity

* python tests

* Apply suggestions from code review

Co-authored-by: Fabian Fröhlich <[email protected]>

* turn off newtin in findSteadyState

* fix test_compare_conservation_laws_sbml

* take preequilibration into account

* fix test_compare_conservation_laws_sbml

* quick notebook fix

Co-authored-by: Fabian Fröhlich <[email protected]>
Copy link
Member

@dweindl dweindl left a comment

Choose a reason for hiding this comment

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

Nice!

python/amici/pysb_import.py Outdated Show resolved Hide resolved
python/amici/pysb_import.py Outdated Show resolved Hide resolved
@sonarqubecloud
Copy link

sonarqubecloud bot commented Apr 5, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

96.8% 96.8% Coverage
0.0% 0.0% Duplication

@FFroehlich FFroehlich merged commit e4aaa0d into develop Apr 5, 2022
@FFroehlich FFroehlich deleted the speedup_pysb_sm branch April 5, 2022 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance PySB PySB import related python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants