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

MESMER-X: use params instead of distr #611

Merged
merged 3 commits into from
Feb 3, 2025

Conversation

mathause
Copy link
Member

@mathause mathause commented Feb 3, 2025

This avoids Expression.evaluate(...) in favor of Expression.evaluate_params(...), which leads to a approximately 2x-4x speedup of calibrating mesmer-x. Instead of adding many methods to Expression it calls the method on Expression.distr (e.g. Expression.distr.pdf(x, **params).

cc @l-pierini, @yquilcaille

Copy link

codecov bot commented Feb 3, 2025

Codecov Report

Attention: Patch coverage is 81.81818% with 8 lines in your changes missing coverage. Please review.

Project coverage is 80.46%. Comparing base (b46f590) to head (bf52404).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
mesmer/mesmer_x/train_l_distrib_mesmerx.py 80.00% 8 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #611   +/-   ##
=======================================
  Coverage   80.45%   80.46%           
=======================================
  Files          49       49           
  Lines        3080     3081    +1     
=======================================
+ Hits         2478     2479    +1     
  Misses        602      602           
Flag Coverage Δ
unittests 80.46% <81.81%> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mathause
Copy link
Member Author

mathause commented Feb 3, 2025

Speedup

py3.13 ubuntu-latest

Before (6m 38s total)

169.00s call   tests/integration/test_calibrate_mesmer_x.py::test_calibrate_mesmer_x[ssp585-tasmax-norm(loc=c1 + c2 * __tas__, scale=c3)-expr1_2ndfit-True-False]
85.83s call    tests/integration/test_calibrate_mesmer_x.py::test_calibrate_mesmer_x[ssp585-tasmax-norm(loc=c1 + c2 * __tas__, scale=c3)-expr1-False-False]
8.70s call     tests/unit/test_mesmer_x_first_guess.py::test_first_guess_truncnorm

After (3m 43s total)

56.41s call    tests/integration/test_calibrate_mesmer_x.py::test_calibrate_mesmer_x[ssp585-tasmax-norm(loc=c1 + c2 * __tas__, scale=c3)-expr1_2ndfit-True-False]
29.68s call    tests/integration/test_calibrate_mesmer_x.py::test_calibrate_mesmer_x[ssp585-tasmax-norm(loc=c1 + c2 * __tas__, scale=c3)-expr1-False-False]
2.75s call     tests/unit/test_mesmer_x_first_guess.py::test_first_guess_truncnorm

py3.13 windows-latest

Before (11m 40s)

229.83s call     tests/integration/test_calibrate_mesmer_x.py::test_calibrate_mesmer_x[ssp585-tasmax-norm(loc=c1 + c2 * __tas__, scale=c3)-expr1_2ndfit-True-False]
116.79s call     tests/integration/test_calibrate_mesmer_x.py::test_calibrate_mesmer_x[ssp585-tasmax-norm(loc=c1 + c2 * __tas__, scale=c3)-expr1-False-False]
11.97s call     tests/unit/test_mesmer_x_first_guess.py::test_first_guess_truncnorm

After (9m 52s)


75.44s call     tests/integration/test_calibrate_mesmer_x.py::test_calibrate_mesmer_x[ssp585-tasmax-norm(loc=c1 + c2 * __tas__, scale=c3)-expr1_2ndfit-True-False]
39.01s call     tests/integration/test_calibrate_mesmer_x.py::test_calibrate_mesmer_x[ssp585-tasmax-norm(loc=c1 + c2 * __tas__, scale=c3)-expr1-False-False]
3.44s call     tests/unit/test_mesmer_x_first_guess.py::test_first_guess_truncnorm

@mathause mathause merged commit e432849 into MESMER-group:main Feb 3, 2025
11 checks passed
@mathause mathause deleted the use_params_instead_distrib branch February 3, 2025 21:35
@mathause mathause mentioned this pull request Feb 4, 2025
3 tasks
@veni-vidi-vici-dormivi
Copy link
Collaborator

Really cool!!

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.

frozen distribution considerably slower
2 participants