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

Numba decorators #23

Open
mrava87 opened this issue Jan 8, 2019 · 7 comments
Open

Numba decorators #23

mrava87 opened this issue Jan 8, 2019 · 7 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@mrava87
Copy link
Collaborator

mrava87 commented Jan 8, 2019

Some of the main linear operators may get a speed-up by simply adding numba <http://numba.pydata.org>_ @jit decorators to _matvec and _rmatvec methods.

Others, such as FirstDerivative may be suited to stencil decorator.

Note: it may be enough to simply add numba to dependencies as it is a fairly common library but to keep dependencies to a minimum it may be better to implement private functions such as _matvec_serial and _matvec_numba and try importingnumba, always falling back to by _matvec_serial if that is not available in the python environment of the user.

@mrava87 mrava87 added the enhancement New feature or request label Jan 8, 2019
@mrava87
Copy link
Collaborator Author

mrava87 commented Mar 15, 2019

Done for Spread operator (forward and adjoint). Follow that structure for future operator optimization

@AhmedA1559
Copy link

Is this still a goal for some of the other operators?

@mrava87 mrava87 added the good first issue Good for newcomers label Aug 5, 2022
@mrava87
Copy link
Collaborator Author

mrava87 commented Aug 5, 2022

Yes, as long as they show performance improvements over pure NumPy ones this is always welcome.

@AhmedA1559, do you have something specific in mind?

@AhmedA1559
Copy link

Yes, as long as they show performance improvements over pure NumPy ones this is always welcome.

@AhmedA1559, do you have something specific in mind?

Yes. I was thinking of implementing Numba decorators for some of the dunder methods in the LinearOperator base class at first, if they yielded performance benefits with it.

@mrava87
Copy link
Collaborator Author

mrava87 commented Aug 5, 2022

Sounds good. My reccomandation is that anything that simply calls NumPy/Scipy routines will likely not yield much benefit. In cases where writing a for...loop is the only way to go, then Numba may help.

Please make sure to always compare pre and after Numba decoration as we will only accept to include changes where the performance gain is evident :)

@dikwickley
Copy link
Contributor

@mrava87 do we still need to add this? I would like to work on this if it is still relevant.

@mrava87
Copy link
Collaborator Author

mrava87 commented Feb 16, 2023

Yes, still relevant. Read the comments above and do some digging of what methods you think may benefit from adding Numba decorators (which likely means you need to reimplement the matvec/rmatvec in a form that is Numba friendly more than Numpy friendly - eg with numpy you want to avoid for..loops as much as possible, with Numba you want them to allow Numba to parallelize if you use prange...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants