-
Notifications
You must be signed in to change notification settings - Fork 143
[Java] Uniform toHost/toDevice to work across all CuVSMatrix classes #1328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rapids-bot
merged 7 commits into
rapidsai:branch-25.10
from
ldematte:java/seamless-matrix-type-change
Sep 17, 2025
Merged
[Java] Uniform toHost/toDevice to work across all CuVSMatrix classes #1328
rapids-bot
merged 7 commits into
rapidsai:branch-25.10
from
ldematte:java/seamless-matrix-type-change
Sep 17, 2025
Conversation
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
…ss-matrix-type-change
Contributor
|
/ok to test f92be71 |
mythrocks
reviewed
Sep 16, 2025
Contributor
|
/ok to test 71fead2 |
mythrocks
reviewed
Sep 17, 2025
java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSDeviceMatrix.java
Outdated
Show resolved
Hide resolved
…e/cuvs into java/seamless-matrix-type-change
…ss-matrix-type-change
Contributor
|
/ok to test fc01ca2 |
mythrocks
approved these changes
Sep 17, 2025
Contributor
mythrocks
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for making the fix.
This PR makes a good change. 👍
Contributor
|
/merge |
Contributor
Author
Thank you! :) |
rapids-bot bot
pushed a commit
that referenced
this pull request
Sep 24, 2025
…1361) This PR extract an internal interface that is used as a base to implement all internal CuVSMatrix types; the interface introduces commonly used field accessors like `memorySegment()` and `toTensor()` that we do not want/could not appear on the public interface (e.g. because they expose or require Panama types or internal types). The new interface is implemented by all concrete matrix types, closing a gap that we had in #1328 (which I realized while working on separate PRs like #1283) Follow-up of #1328 Authors: - Lorenzo Dematté (https://github.com/ldematte) Approvers: - Ben Frederickson (https://github.com/benfred) URL: #1361
enp1s0
pushed a commit
to enp1s0/cuvs
that referenced
this pull request
Oct 22, 2025
…apidsai#1361) This PR extract an internal interface that is used as a base to implement all internal CuVSMatrix types; the interface introduces commonly used field accessors like `memorySegment()` and `toTensor()` that we do not want/could not appear on the public interface (e.g. because they expose or require Panama types or internal types). The new interface is implemented by all concrete matrix types, closing a gap that we had in rapidsai#1328 (which I realized while working on separate PRs like rapidsai#1283) Follow-up of rapidsai#1328 Authors: - Lorenzo Dematté (https://github.com/ldematte) Approvers: - Ben Frederickson (https://github.com/benfred) URL: rapidsai#1361
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
This PR moves
toHost/toDeviceoperations toCuVSMatrixin order to uniform them; implementations then do not need to worry or perform checks on the input type, but simply accept anyCuVSMatrixand then "request" the type they want or need (no ifs, custom cudaAlloc or cudaMemcpy operations needed):If the source matrix is a
CuVSHostMatrix, device memory will be allocated and data will be copied; if the source matrix is a already aCuVSDeviceMatrix, a (wrapped) reference to the original data is returned (very fast, no copies, no additional allocations).The wrapper is currently implemented to follow C++
weak_ptrsemantics: it delegates everything to the wrapped matrix, the only difference is onclose()(which is a no-op in the wrapper, as you'd expect). The lifecycle of the data follows the one of the original matrix, the "weak" delegate does not influence it in any way. This way the caller can handle it uniformly (e.g. with try-with-resources), without side effects on the original matrix (which lifecycle will be already handled by its owner).An alternative would be to give this C++
shared_ptrsemantics, making it reference counted. I think this would be more complex and not necessary, but let me know.