Migrate from numba to Cython#133
Open
Cadair wants to merge 6 commits into
Open
Conversation
5adc401 to
9f7849d
Compare
Contributor
|
For a standard non-trivial PFSS extrapolation using the sample_data gong map i get a 50-100% increase in runtime with this cython implementation vs the current numba release unfortunately. I will try to reproduce the test speed up you saw and see if we can understand the difference. Timing test log for this PR with Cython : (.sunkit-magex-cython) (base) sbadman@si393685:~/1_RESEARCH/GIT_REPOS/sunkit-magex$ ipython
Python 3.13.14 (main, Jun 11 2026, 12:30:58) [GCC 11.4.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 9.14.1 -- An enhanced Interactive Python. Type '?' for help.
Tip: IPython supports combining unicode identifiers, eg F\vec<tab> will become F⃗, useful for physics equations. Play with \dot \ddot and others.
In [1]: import sunkit_magex; print(sunkit_magex.__version__)
...:
...: import sunpy.map
...: from sunkit_magex import pfss
...:
...: gong_fname = pfss.sample_data.get_gong_map()
...: gong_map = sunpy.map.Map(gong_fname)
...:
...: nrho = 35
...: rss = 2.5
...: pfss_in = pfss.Input(gong_map, nrho, rss)
1.1.1.dev31+g9ff89ff6b
In [2]: %%timeit
...: pfss_out = pfss.pfss(pfss_in)
...:
...:
1.61 s ± 679 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)And with sunkit_magex 1.1.0 with current Numba implementation (py312) sbadman@si393685:~$ ipython
Python 3.12.3 | packaged by conda-forge | (main, Apr 15 2024, 18:38:13) [GCC 12.3.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.25.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import sunkit_magex; print(sunkit_magex.__version__)
...:
...: import sunpy.map
...: from sunkit_magex import pfss
...:
...: gong_fname = pfss.sample_data.get_gong_map()
...: gong_map = sunpy.map.Map(gong_fname)
...:
...: nrho = 35
...: rss = 2.5
...: pfss_in = pfss.Input(gong_map, nrho, rss)
1.1.0
In [2]: %%timeit
...: pfss_out = pfss.pfss(pfss_in)
...:
...:
879 ms ± 87 ms per loop (mean ± std. dev. of 7 runs, 1 loop each) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #39
I'd like someone to verify the performance delta here, from the speed the test suite runs this seems to be a good chunk faster than numba.