Skip to content

[core][gpu-objects] Support ray.get on the driver process for GPU objects - #53902

Merged
jjyao merged 7 commits into
ray-project:masterfrom
kevin85421:20250616-devbox1-tmux1-ray1
Jun 19, 2025
Merged

jjyao merged 7 commits into
ray-project:masterfrom
kevin85421:20250616-devbox1-tmux1-ray1

Conversation

@kevin85421

@kevin85421 kevin85421 commented Jun 17, 2025 •

Copy link
Copy Markdown
Member

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

Signed-off-by: kaihsun <[email protected]>
@kevin85421 kevin85421 added the go add ONLY when ready to merge, run all tests label Jun 17, 2025
@kevin85421
kevin85421 marked this pull request as ready for review June 18, 2025 03:31
Copilot AI review requested due to automatic review settings June 18, 2025 03:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_data to detect driver-managed GPU objects and trigger a fetch.
  • Augmented GPUObjectManager with an is_driver check, an obj_id→ObjectRef mapping, and a fetch_gpu_object helper.

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_objects is ambiguous. It might be clearer to rename it to should_handle_gpu_object or is_gpu_object_relevant to better reflect its boolean purpose.
        enable_gpu_objects = gpu_object_manager.has_gpu_object(

python/ray/_private/gpu_object_manager.py:185

  • The symbol util is not imported in this file, so util.__ray_fetch_gpu_object__ will raise a NameError. Add import ray._private.gpu_object_manager_util as util or reference the function directly.
        tensors = ray.get(

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(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • serialization.py: The object will be immediately removed by remove_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 <[email protected]>
Signed-off-by: Kai-Hsun Chen <[email protected]>
Signed-off-by: kaihsun <[email protected]>
Signed-off-by: kaihsun <[email protected]>
@kevin85421

Copy link
Copy Markdown
Member Author

cc @jjyao @stephanie-wang @edoakes would you mind merging this PR? Thanks!

@jjyao
jjyao merged commit addab25 into ray-project:master Jun 19, 2025
minerharry pushed a commit to minerharry/ray that referenced this pull request Jun 27, 2025
…bjects (ray-project#53902)

Signed-off-by: kaihsun <[email protected]>
Signed-off-by: Kai-Hsun Chen <[email protected]>
Co-authored-by: Stephanie Wang <[email protected]>
elliot-barn pushed a commit that referenced this pull request Jul 2, 2025
…bjects (#53902)

Signed-off-by: kaihsun <[email protected]>
Signed-off-by: Kai-Hsun Chen <[email protected]>
Co-authored-by: Stephanie Wang <[email protected]>
Signed-off-by: elliot-barn <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[core][gpu-objects] Driver tries to get the data from in-actor store

6 participants