Refactor Python CUDA IPC API#1002
Merged
haixuanTao merged 3 commits intodora-rs:mainfrom May 26, 2025
Merged
Conversation
Collaborator
|
Thanks for this investigation and this looks really cool! However, would it be possible to not depend on pickle as it would reduce GPU 0-copy to python only project. The idea behind using cuda ipc handle was to be able to read this in like C/C++ or Rust. |
Contributor
Author
I refactored the encoding part and now removed pickle. |
haixuanTao
approved these changes
May 14, 2025
Collaborator
haixuanTao
left a comment
There was a problem hiding this comment.
Looks good to me!
I think uint8 would be more resilient!
But thanks for everything!
| "source_info": json.dumps(source_info), | ||
| } | ||
| return pa.array(handle_buffer, type=pa.uint8()), metadata | ||
| return pa.array(handle, pa.int8()), metadata |
Collaborator
There was a problem hiding this comment.
This should be uint8 right?
Suggested change
| return pa.array(handle, pa.int8()), metadata | |
| return pa.array(handle, pa.uint8()), metadata |
Contributor
Author
There was a problem hiding this comment.
handle is actually a int8 array (ranged from -128 to 127), since its underlying c type is char
haixuanTao
approved these changes
May 26, 2025
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.
As noted in #978, the current Python CUDA IPC API fails when sending specific tensors.
My investigation suggests that
pyarrow.cuda(used bydora.cuda), is likely the source of this failure. During testing with two processes (sender and receiver), the receiver receivespyarrow.CudaBufferwith corrupted content, and it appears that there's nothing we can do about this.However, I found that the
numba.cudamodule is a suitable alternative for implementing CUDA IPC. As we already depend onnumba, no new dependencies are introduced. I have refactored the API to usenumba.cuda, and it has passed the tests proposed in #978.Example & docstrings are updated accordingly.
Note: this change is not backward compatible.