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

Speed up unit conversions #179

Merged
merged 2 commits into from
Oct 28, 2024
Merged

Speed up unit conversions #179

merged 2 commits into from
Oct 28, 2024

Conversation

jeremykubica
Copy link
Contributor

Do a single matrix multiply instead of carrying the units through the full computation.

@jeremykubica jeremykubica requested a review from hombit October 28, 2024 13:13
Copy link

github-actions bot commented Oct 28, 2024

Before [88bd226] After [600586a] Ratio Benchmark (Parameter)
11.0±1ms 9.57±0.5ms ~0.87 benchmarks.TimeSuite.time_evaluate_salt3_model
2.23±1ms 842±600μs ~0.38 benchmarks.TimeSuite.time_fnu_to_flam
121±2μs 125±2μs 1.04 benchmarks.TimeSuite.time_sample_x0_from_distmod
1.49±0.08ms 1.49±0.1ms 1.00 benchmarks.TimeSuite.time_apply_passbands
9.13±0.06ms 9.10±0.2ms 1.00 benchmarks.TimeSuite.time_load_passbands
15.7±0.5μs 15.7±0.2μs 1.00 benchmarks.TimeSuite.time_sample_x1_from_hostmass
4.66±1ms 4.61±0.3ms 0.99 benchmarks.TimeSuite.time_chained_evaluate
1.37±0.02s 1.36±0.01s 0.99 benchmarks.TimeSuite.time_make_x1_from_hostmass
28.8±0.5μs 28.2±0.3μs 0.98 benchmarks.TimeSuite.time_make_new_salt3_model
5.85±0.3ms 5.08±0.2ms 0.87 benchmarks.TimeSuite.time_evaluate_salt3_passbands

Click here to view all benchmarks.

Copy link
Contributor

@hombit hombit left a comment

Choose a reason for hiding this comment

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

Looks good, thank you. How much faster is this?

src/tdastro/astro_utils/unit_utils.py Outdated Show resolved Hide resolved
src/tdastro/astro_utils/unit_utils.py Outdated Show resolved Hide resolved
@jeremykubica
Copy link
Contributor Author

Running this function in test_snia.py takes about 50% of the time (with the asarray change as well).

@jeremykubica jeremykubica merged commit c13a733 into main Oct 28, 2024
5 checks passed
@jeremykubica jeremykubica deleted the speedup_unit_conversions branch October 28, 2024 15:02
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