Repository navigation
Improve performance of several Ops in sparse numba - #2505
Merged
tomicapretto merged 4 commits intoOct 19, 2026
Merged
Conversation
Member
|
Amazing results, I'll see if they reproduce on my machine, and check if compile time didn't get too much worse |
Contributor
Author
|
You'll need the benchmark scripts (codex generated but I think they're OK) |
Member
|
@tomicapretto My bot butler confirmed the speedups on my machine, both your scripts or using regular pytensor.function. Compile times are not meaningfully affected. Only thing is that SpSum’s cache version was not bumped. Happy to approve after that |
tomicapretto
force-pushed
the
sparse-numba-perf-improvements
branch
from
October 18, 2026 21:26
9d77ed1 to
5555b2f
Compare
Contributor
Author
|
Done, thanks for the review! |
ricardoV94
reviewed
Oct 18, 2026
| return x.sum(axis) | ||
|
|
||
| return perform | ||
| return perform, 2 |
Member
There was a problem hiding this comment.
It's a bit more readable if you assign cache_version=2 and then return the named variable.
Contributor
Author
There was a problem hiding this comment.
Done, thanks. Will merge once CI is green.
ricardoV94
approved these changes
Oct 18, 2026
tomicapretto
force-pushed
the
sparse-numba-perf-improvements
branch
from
October 19, 2026 11:32
5555b2f to
0f3a5ad
Compare
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.
Description
I incorporate some lessons from work on #2469 and this comment to improve the performance of previously existing sparse ops in numba
What I did (update)
From largest to lowest impact:
np.dot(...).arr.astypeon entire arrays, which would allocate an entire new vector. Instead, doto_type(scalar).np.emptyinstead ofnp.zeroswhen possible, which is when we do set all values of the new array.Checklist
Type of change
Benchmarks
Sparse-dense dot product
Details
Sparse-sparse dot product
Details
Sparse-dense dot gradient
Details
Sparse-dense multiply
Details
Sparse-dense vector dot
Details
Structured sparse-dense dot product gradient
Details
Dense-sparse dot product
Details
Sparse X.sum()
Details