Numba: speed up advanced indexing with non-scalar core dims - #2345
Open
ricardoV94 wants to merge 1 commit into
Open
Numba: speed up advanced indexing with non-scalar core dims#2345ricardoV94 wants to merge 1 commit into
ricardoV94 wants to merge 1 commit into
Conversation
vector_integer_advanced_indexing emitted one whole-subarray operation per index step (out_buffer[i] = basic_indexed_x[scalar_idxs], and the += form for scatters). Numba routes a subarray assignment through generic array machinery, and the += form materialises a temporary per step. Emit an explicit scalar loop nest over the trailing dimensions instead. The trailing rank is known at codegen time; the extents are not, so the nest reads them off the buffer at run time.
Member
Author
|
CC @velochy (one of four implicated PRs on the MRP model catch-up) |
Contributor
|
My guess is this will be huge for us. We have a lot of indexing in our main flows, not just for likerts but for our order models as well. Very possible this will end up halving our execution time on the latter, which would be a pretty big deal |
Contributor
|
pl_bestworst_repro.py LMK if you would like this to be in the pymc-examples as well |
Member
Author
|
let me first collect the changes and do a release, then we can check with other variants |
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.
vector_integer_advanced_indexing emitted one whole-subarray operation per index step (out_buffer[i] = basic_indexed_x[scalar_idxs], and the += form for scatters). Numba routes a subarray assignment through generic array machinery, and the += form materialises a temporary per step.
Emit an explicit scalar loop nest over the trailing dimensions instead.
Before:
After:
I was shocked that we were leaving so much on the floor tbh