feat: Make ak.combinations faster on GPU by using cp.searchsorted to compute output list indexes#3795
Merged
ianna merged 1 commit intoscikit-hep:mainfrom Jan 11, 2026
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files🚀 New features to boost your workflow:
|
ak.combinations faster on GPU by using cp.searchsorted to compute output list indexesak.combinations faster on GPU by using cp.searchsorted to compute output list indexes
|
The documentation preview is ready to be viewed at http://preview.awkward-array.org.s3-website.us-east-1.amazonaws.com/PR3795 |
ianna
approved these changes
Jan 11, 2026
Member
ianna
left a comment
There was a problem hiding this comment.
@shwina - Thanks for this contribution — the performance improvement is genuinely impressive. Moving the list‑index computation from a Python loop to a vectorized cp.searchsorted call is exactly the kind of backend‑aware optimization that pays off at scale. The benchmark numbers you included make the impact very clear.
What looks great
- Massive speedup: reducing runtime from ~2.16s → ~0.0015s for the provided workload is a transformative improvement for GPU users.
Thank you! 🙏
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.
By far the bottleneck in
ak.combinationsfor the GPU is the Python loop for computing the output list indexes. This can be done in a vectorized fashion usingcp.searchsorted. As written, this does multiplememsetoperations in a loop which can be slow.The improvement is massive.
Before:
After:
Benchmarking script used: