-
Notifications
You must be signed in to change notification settings - Fork 6k
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
[RFC][Ray Core] Support zero-copy Pytorch tensor in Ray #26229
Comments
Hi, I'm a bot from the Ray team :) To help human contributors to focus on more relevant issues, I will automatically add the stale label to issues that have had no activity for more than 4 months. If there is no further activity in the 14 days, the issue will be closed!
You can always ask for help on our discussion forum or Ray's public slack channel. |
It'll benefit us a lot if ray support this issue. |
I'd also like this very much |
+1 to supporting this. |
Any progress on this feature? |
This issue seems to be quite old but still very relevant. I found a workaround and I thought it might help others. array_np = np.zeros((23,40))
obj_ref = ray.put(array_np)
array_np = ray.get(obj_ref)
array_torch = torch.from_numpy(array_np) Explanation
array_np, array_np_2= ray.get([obj_ref]*2)
array_torch, array_torch_2 = torch.from_numpy(array_np), torch.from_numpy(array_np_2)
array_torch.data_ptr() == array_torch_2.data_ptr()
|
Description
Previous work by @suquark that is reverted: #12344
Currently Ray support zero-copy for numpy arrays, but not Pytorch Tensor. This seems to be a feature asked by multiple folks we interacted with from Pytorch team in TorchX and PyTorch Geometric, etc. Similarly we encounter needs within Ray libraries down the road such as AIR (training data ingest) and Serve (ModelMesh, cc: @sihanwang41 ).
From our chat with Yaroslav:
As I chatted with @suquark , previous implementation is less ideal as we need to import torch, register a custom serializer and suppress warnings from pytorch since when we deserialize pytorch tensor as immutable objects, pytorch would raise a warning say torch tensor cannot be readonly
Our suggestion approach is to enable "numpy read-only" for Pytorch tensors and make Ray-Pytorch fast interoperability cleaner, related issues in Pytorch github are:
pytorch/pytorch#32868
pytorch/pytorch#44027
A bigger related RFC in pytorch is TensorStore: pytorch/pytorch#64932
cc: @yaroslavvb @msaroufim
Use case
AIR training data ingest
Ray Serve
The text was updated successfully, but these errors were encountered: