[core][gpu-objects] Support ray.get on the driver process for GPU objects#53902
Merged
jjyao merged 7 commits intoray-project:masterfrom Jun 19, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR enables the driver process to use ray.get on GPU-backed object references by fetching tensors through the object store rather than out-of-band transfers.
- Added a new end-to-end test covering driver-side GPU object fetch.
- Extended
_deserialize_pickle5_datato detect driver-managed GPU objects and trigger a fetch. - Augmented
GPUObjectManagerwith anis_drivercheck, anobj_id→ObjectRefmapping, and afetch_gpu_objecthelper.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| python/ray/tests/test_gpu_objects_gloo.py | Added test_fetch_gpu_object_to_driver covering single, multiple, and mixed CPU/GPU cases. |
| python/ray/_private/serialization.py | Updated deserialization to call fetch_gpu_object when the driver process owns the object. |
| python/ray/_private/gpu_object_manager_util.py | Introduced __ray_fetch_gpu_object__ to pull tensors via the object store. |
| python/ray/_private/gpu_object_manager.py | Added gpu_object_id_to_obj_ref mapping, is_driver, and fetch_gpu_object. |
Comments suppressed due to low confidence (2)
python/ray/_private/serialization.py:280
- [nitpick] The variable name
enable_gpu_objectsis ambiguous. It might be clearer to rename it toshould_handle_gpu_objectoris_gpu_object_relevantto better reflect its boolean purpose.
enable_gpu_objects = gpu_object_manager.has_gpu_object(
python/ray/_private/gpu_object_manager.py:185
- The symbol
utilis not imported in this file, soutil.__ray_fetch_gpu_object__will raise a NameError. Addimport ray._private.gpu_object_manager_util as utilor reference the function directly.
tensors = ray.get(
stephanie-wang
requested changes
Jun 18, 2025
| obj_ref = self.gpu_object_id_to_obj_ref[obj_id] | ||
| gpu_object_meta = self.gpu_object_refs[obj_ref] | ||
| src_actor = gpu_object_meta.src_actor | ||
| tensors = ray.get( |
Contributor
There was a problem hiding this comment.
Instead of caching the raw tensors (which will occupy memory and can cause OOM), let's cache the ObjectRef returned by ray_fetch_gpu_object.
Member
Author
There was a problem hiding this comment.
-
serialization.py: The object will be immediately removed byremove_gpu_object.if enable_gpu_objects: if gpu_object_manager.is_driver(object_id): gpu_object_manager.fetch_gpu_object(object_id) tensors = gpu_object_manager.get_gpu_object(object_id) ctx.reset_out_of_band_tensors(tensors) # TODO(kevin85421): The current garbage collection implementation for the in-actor object store # is naive. We garbage collect each object after it is consumed once. gpu_object_manager.remove_gpu_object(object_id)
Co-authored-by: Stephanie Wang <swang@cs.berkeley.edu> Signed-off-by: Kai-Hsun Chen <kaihsun@apache.org>
stephanie-wang
approved these changes
Jun 19, 2025
Member
Author
|
cc @jjyao @stephanie-wang @edoakes would you mind merging this PR? Thanks! |
minerharry
pushed a commit
to minerharry/ray
that referenced
this pull request
Jun 27, 2025
…bjects (ray-project#53902) Signed-off-by: kaihsun <kaihsun@anyscale.com> Signed-off-by: Kai-Hsun Chen <kaihsun@apache.org> Co-authored-by: Stephanie Wang <swang@cs.berkeley.edu>
elliot-barn
pushed a commit
that referenced
this pull request
Jul 2, 2025
…bjects (#53902) Signed-off-by: kaihsun <kaihsun@anyscale.com> Signed-off-by: Kai-Hsun Chen <kaihsun@apache.org> Co-authored-by: Stephanie Wang <swang@cs.berkeley.edu> Signed-off-by: elliot-barn <elliot.barnwell@anyscale.com>
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.
Why are these changes needed?
If an object ID exists in
gpu_object_ref, it means that the driver is attempting to fetch the GPU objects. In that case, tensors will not be transferred out of band. Instead, we need to transfer the tensors via object store.Related issue number
Closes #51272
Checks
git commit -s) in this PR.scripts/format.shto lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/under thecorresponding
.rstfile.