Skip to content
This repository was archived by the owner on Jan 21, 2026. It is now read-only.

[Feat]: Add RayStorageClient to support the RDT feature of Ray - #108

Open
Evelynn-V wants to merge 17 commits into
devfrom
RDT
Open

Evelynn-V wants to merge 17 commits into
devfrom
RDT

Conversation

@Evelynn-V

@Evelynn-V Evelynn-V commented Nov 17, 2025 •

Copy link
Copy Markdown
Contributor

Summary

Implemented the class RayStorageClient and tested on the cpu using object_store (requires using NIXL on GPUs further testing)

Change

  1. Added transfer_queue/storage/clients/ray_storage_clients.py : Added classes RayStorageClient and RayGpuObjectRefStorage, encapsulating the invocation of the NIXL transport interface used in Ray.

  2. Add p2p tests: tests/test_ray_p2p.py .

Testing

  • Test RayStorageClient on CPU (Requires installing ray >= 2.50):

    python tests/test_ray_p2p.py

Related Links

TODO

  • Test the transfer of data using NIXL on GPUs with IB and without gdrcopy
  • Test the transfer of data using NIXL on GPUs with gdrcopy
  • Test the transfer of data using NIXL on GPUs with cuda_ipc

Summary by CodeRabbit

  • New Features

    • Added Ray-based GPU-aware storage client for efficient tensor handling and retrieval
    • Enabled concurrent tensor storage and management across multiple clients
  • Tests

    • Introduced comprehensive test suite covering storage operations and concurrent access scenarios

@coderabbitai

coderabbitai Bot commented Nov 17, 2025

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands and usage tips.

if key in self.storage_dict:
del self.storage_dict[key]

@StorageClientFactory.register("RAY")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
@StorageClientFactory.register("RAY")
@StorageClientFactory.register("RayStorageClient")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

except ValueError:
self.storage_actor = RayObjectRefStorage.options(
name="RayObjectRefStorage",
lifetime="detached",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

will this actor still exist even after the current training task ends, and interferes with new training tasks?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe we don't need to explicitly define lifetime="detached", since there always are som client that holds its reference

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It was found during the test that it did cause interference. It has now been removed.

if isinstance(v, torch.Tensor) and v.is_cuda and self.use_gpu:
# GPU Tensor → use NIXL
ref = ray.put(v, _tensor_transport="nixl")
else:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what if this is a gpu tensor while self.use_gpu=False? maybe we need a more fine-grained if-else?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It has been modified. The current logic is that as long as the input is tensors, NIXL will be used, regardless of the device. Thus, RDT can be used in both CPUs and GPUs.

def __init__(self):
self.storage_dict = {}

def put_gpu_obj_ref(self, keys: list[str], gpu_obj_refs: list[ray.ObjectRef]):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
def put_gpu_obj_ref(self, keys: list[str], gpu_obj_refs: list[ray.ObjectRef]):
def put_obj_ref(self, keys: list[str], gpu_obj_refs: list[ray.ObjectRef]):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

for key, gpu_obj_ref in zip(keys, gpu_obj_refs):
self.storage_dict[key] = gpu_obj_ref

def get_gpu_obj_ref(self, keys: list[str]) -> list[ray.ObjectRef]:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
def get_gpu_obj_ref(self, keys: list[str]) -> list[ray.ObjectRef]:
def get_obj_ref(self, keys: list[str]) -> list[ray.ObjectRef]:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

obj_refs = [self.storage_dict.get(key, None) for key in keys]
return obj_refs

def clear_gpu_obj_ref(self, keys: list[str]):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
def clear_gpu_obj_ref(self, keys: list[str]):
def clear_obj_ref(self, keys: list[str]):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

if not isinstance(keys, list):
raise ValueError(f"keys must be a list, but got {type(keys)}")

gpu_obj_refs = ray.get(self.storage_actor.get_gpu_obj_ref.remote(keys))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

see above comments; we need to change the name

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment thread transfer_queue/storage/managers/base.py Outdated
await self.notify_data_update(list(data.keys()), metadata.global_indexes, per_field_dtypes, per_field_shapes)
# await self.notify_data_update(list(data.keys()), metadata.global_indexes, per_field_dtypes, per_field_shapes)
await self.notify_data_update(
partition_id=metadata.samples[0].partition_id if metadata.samples else "unknown",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we'd better tackle metadata.samples == None at the beginning

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This part of the code has been modified by other PRs and has been updated.

from transfer_queue.storage.managers.base import KVStorageManager
from transfer_queue.storage.managers.factory import TransferQueueStorageManagerFactory

@TransferQueueStorageManagerFactory.register("RAY")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
@TransferQueueStorageManagerFactory.register("RAY")
@TransferQueueStorageManagerFactory.register("RayKVStorageManager")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

from transfer_queue.storage.managers.factory import TransferQueueStorageManagerFactory

@TransferQueueStorageManagerFactory.register("RAY")
class RayKVStorageManager(KVStorageManager):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why we need a dedicated RayKVStorageManager, rather than using KVStorageManager?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We hope the KVStorageManager acts as a general class for all KV based storage backend

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

RayKVStorageManager has been removed and replaced with KVStorageManager.

@0oshowero0 0oshowero0 mentioned this pull request Dec 31, 2025
9 of 22 tasks
Comment thread transfer_queue/storage/managers/base.py Outdated
from transfer_queue.storage.managers.factory import TransferQueueStorageManagerFactory # noqa: E402


@TransferQueueStorageManagerFactory.register("KV")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
@TransferQueueStorageManagerFactory.register("KV")
@TransferQueueStorageManagerFactory.register("KVStorageManager")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants