Add cupy backend - #188
Closed
lm-cyber wants to merge 4 commits into
Closed
Conversation
Owner
|
Thanks so much for putting this together! This looks like a nice implementation, and I can see it being valuable for GPU users. That said, I'm hesitant to take on cupy as a new dependency for the core library. I'm not very familiar with it myself, and since I expect to keep adding features down the line, I'm worried about introducing something I might inadvertently break later. Would you be open to releasing this as a separate fork instead, something like |
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.
Summary
Add an explicit, opt-in CuPy backend for BM25 retrieval and top-k selection.
This PR introduces
backend="cupy"for GPU retrieval andbackend_selection="cupy"for GPU top-k selection, while keepingbackend="auto"unchanged: it still selects Numba when available and otherwise fallsback to NumPy.
What changed
bm25s.cupywith CuPy top-k selection and retrieval utilities.BM25.retrieve(...).backend_selection="cupy"in the existing selection API.0is preserved instead of being dropped as falsy.Notes
CuPy is intentionally not selected automatically because users need a CuPy package matching their CUDA runtime, for example
cupy-cuda12x. Users must explicitly choosebackend="cupy"orbackend_selection="cupy".Testing
Ran locally: