Repository navigation
[core][rdt] Implement receive side memory pool - #64487
Conversation
Signed-off-by: Joshua Lee <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request implements receiver-side memory pool management for NIXL RDT optimization, enabling incoming tensors to be read directly into a pre-registered pool and automatically freed via weakref finalizers. The review feedback highlights several critical issues: a deduplication collision and OOM risk when forwarding existing pool-backed views, potential alignment errors during tensor viewing due to unaligned block offsets, crashes when handling empty (0-sized) tensors, and a memory leak where pool blocks are not immediately freed if a transfer fails.
Signed-off-by: Joshua Lee <[email protected]>
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |
|
This pull request has been automatically closed because there has been no more activity in the 14 days Please feel free to reopen or open a new pull request if you'd still like this to be addressed. Again, you can always ask for help on our discussion forum or Ray's public slack channel. Thanks again for your contribution! |
Signed-off-by: Joshua Lee <[email protected]>
Signed-off-by: Joshua Lee <[email protected]>
Signed-off-by: Joshua Lee <[email protected]>
Signed-off-by: Joshua Lee <[email protected]>
Signed-off-by: Joshua Lee <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 82f292b. Configure here.
Signed-off-by: Joshua Lee <[email protected]>
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |
|
This pull request has been automatically closed because there has been no more activity in the 14 days Please feel free to reopen or open a new pull request if you'd still like this to be addressed. Again, you can always ask for help on our discussion forum or Ray's public slack channel. Thanks again for your contribution! |
Resolves the conflict in NixlTensorTransport._cleanup_transfer with ray-project#67389, which made it defer while the thread holds the cache lock and serialized handle releases with the remote agent locks. The receive pool blocks are carried through the deferred cleanup and freed after the rest of it, as before. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Joshua Lee <[email protected]>
Two follow-ups to merging ray-project#67389 into the receive pool: - When garbage collection cleans up a fetch request while _finish_transfers still polls its handle, the handle's release waits for the polling to end. Its pool blocks now wait with it, so the next receive can't take a block that the transfer may still write into. - The pool's lock is not reentrant, and garbage collection can run a fetch request's cleanup on a thread that holds it, which would then wait for the pool's lock itself, or for the cache lock or an agent lock whose holder waits for the pool's lock. Every pool call now runs with those cleanups deferred, as the cache lock already did. Also adds a test that a receive failing after it took its buffers from the pool returns them without deregistering anything, and that the pool still receives afterwards. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Joshua Lee <[email protected]>
NIXL can't find a zero-length descriptor inside a registered region (NIXL_ERR_NOT_FOUND), so an object holding an empty tensor failed to transfer once the receiver had a memory pool, while it works without one. Such an object now uses the per-transfer buffers instead. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Joshua Lee <[email protected]>
|
Merged master and pushed two more fixes:
The weakref, alignment and pool-backed-view bot threads from July are about code the copy-out design replaced. |

Follows up on #61573 with the receive side of the NIXL memory pool.
When the receiver has registered a pool with
register_nixl_memory_pooland passes no target buffers,ray.getreads the incoming tensors into regions of the pool, which is registered with NIXL once, instead of registering new buffers for every transfer. Once the transfer lands, the tensors are copied out into ordinary tensors on the source's device type, and the regions go straight back to the pool. The tensors you get are independent of the pool, so the pool size bounds how much data can be in flight at once, not how much received data you can hold. An earlier version of this PR tied blocks to the returned tensors withweakref, which broke when a view outlived the tensor, so it copies out instead.MemoryPoolManager.allocate_regions,copy_out_and_freeandfree_blocksmake up the receive-side allocator. Regions start on_MAX_ALIGNMENT, so the sender's packed layout decodes in place. The pool now has a lock, since sends and receives use it from both the main and_ray_systemthreads._finish_transfers([core][rdt] nixl: don't remove a remote agent while transfers on it are in flight #67389) to stop polling the handle.__del__can't deadlock on the pool's lock.NIXL_ERR_NOT_FOUND).Not a duplicate: this is the receive-side follow-up to #61573. Searching open PRs for the NIXL memory pool turns up #68142 (pool statistics, which touches the same files but not the receive path) and nothing else on the receive side.
Tests (4x T4, UCX with
UCX_TLS=^gdr_copy, Ray nightly 2b3daa8 with this branch'spython/ray/experimentalandpython/ray/testslinked in):pytest python/ray/tests/rdt/test_rdt_nixl.py python/ray/tests/rdt/test_nixl_agent_lock.py python/ray/tests/rdt/test_nixl_memory_pool.py: 95 passed, 1 skipped (test_nixl_borrow_after_abort, skipped on master).pytest python/ray/tests/rdt/test_nixl_backend_selection.py python/ray/tests/rdt/test_rdt_custom.py python/ray/tests/rdt/test_rdt_gloo.py(with the two unit files above): 101 passed, 1 skipped.AI assistance (Claude Code) was used for this PR.
🤖 Generated with Claude Code