Numba: SIMD-friendly maximum/minimum - #2370
Open
ricardoV94 wants to merge 1 commit into
Open
Conversation
ricardoV94
force-pushed
the
slow_numba_max
branch
3 times, most recently
from
August 20, 2026 15:45
3824ebf to
9fc0f1f
Compare
jessegrabowski
approved these changes
Aug 20, 2026
jessegrabowski
left a comment
Member
There was a problem hiding this comment.
For the record it came up in maxpool layers here: pymc-devs/pytensor_ml#100
ricardoV94
force-pushed
the
slow_numba_max
branch
from
August 20, 2026 15:49
9fc0f1f to
650544a
Compare
Member
Author
Does it fix it on your end? |
ricardoV94
marked this pull request as ready for review
August 20, 2026 15:53
Member
|
I switched to a custom kernel for those layers so it was moot, I just raised the issue because i found it was slow. I'll re-try the naive path tonight and let you know |
Member
Author
If the layer is literally a max it's probably one of those you'd want to fuse with whatever produces it |
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.
Closes #2367
This PR goes from 5x to 1.1-1.3x slower than numpy on my machine. I don't think we can go below that because numba/llvm won't SIMD these operations automatically. Numpy has a SIMD dispatcher instead.
In my experience this is not super critical as max/min are usually fused in loops that are order of magnitude worse, usually exp in a stable softmax or logsumexp