-
Notifications
You must be signed in to change notification settings - Fork 10
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
Allow the numba cache to be used, for development #441
Conversation
I ran into the same issues as you here-- the bulk of stuff is still being compiled on import. I think pulling all the EP stuff into a low-level extension is the way to go. |
Can we do this while keeping it in python (I presume not)? Or are you thinking of writing the low-level e.g. in rust? |
It may be possible to build the extension with numba, but I think it'd be stabler and easier to maintain a C or rust extension. |
I could make the edits to the scipy special functions on this branch if you'd like @hyanwong ? |
Yes, why not. Thank you. |
Do you want me to have a go at swapping in math.lgamma for the script version, @nspope ? |
Sure, sorry to drop the ball on this. Where I'm thinking is, https://github.com/tskit-dev/tsdate/blob/240593d01a1a77561dadebee82cfb5fae67f83bc/tsdate/hypergeo.py#L72C17-L74C26 the _gammaln_f8 should be changed to math.lgamma -- hopefully that's enough to make more functions cache-able? |
No problem,. I'll give it a whirl. Thanks for the pointer. |
OK, with the new commits and the math.lgamma function this now seems to work, and cuts import down from 29 seconds (with I put |
Aha. I spotted some more functions I could mark to cache. Now down to 5 secs for import. |
I guess this is good to go, at least for the time being. To enable the caching (e.g. for development), you need to explicitly set |
I don't think there's a good reason for the choice of name, I agree with your preference for |
a3ac756
to
c58a15d
Compare
@nspope - I'm happy to merge this. Loading time for the library is now down to 2.5s on my laptop with |
Uses math.lgamma to allow numba caching. Copied from SGKIT. Fixes tskit-dev#438
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks @hyanwong !
Copied from SGKIT. Fixes #438