Repository navigation
[core][rdt] nixl: raise when a cached registration is smaller than the tensor - #66777
Merged
Sparks0219 merged 1 commit intoOct 8, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request adds size tracking to the NIXL tensor registration cache and raises a ValueError if a tensor's size exceeds its registered size. It also updates the documentation for register_nixl_memory to explain this behavior. The review feedback points out a critical issue where raising a ValueError mid-loop can cause a permanent memory registration leak due to partially incremented reference counts, and suggests pre-validating the tensor sizes to avoid this state corruption.
…e tensor Fixes ray-project#65701. `NixlTensorTransport` caches NIXL registrations by `storage.data_ptr()`. If a registered storage is freed without `deregister_nixl_memory` and a larger storage is allocated at the same address, the cache hits and skips re-registration. NIXL then only knows the old, smaller extent, and later transfers fail with `NIXL_ERR_NOT_FOUND`. `deregister_nixl_memory` leaves the lifecycle of registered memory to the user, so instead of silently re-registering, raise a clear error when the new storage is larger than the cached registration. A smaller or equal size still fits inside the registered region and remains a cache hit. ## Changes - `nixl_tensor_transport.py`: store the registered size in `TensorDesc` and raise `ValueError` in `_add_tensor_descs` on a cache hit when the storage's `nbytes()` exceeds it. - `util.py`: document the error and that pre-registered buffers should be allocated at their full size up front. Signed-off-by: BatshevaBlack <[email protected]>
BatshevaBlack
force-pushed
the
fix-nixl-register-size-mismatch
branch
from
October 6, 2026 11:43
a150173 to
dcbc42f
Compare
Sparks0219
approved these changes
Oct 8, 2026
Sparks0219
left a comment
Contributor
There was a problem hiding this comment.
LGTM, thanks for the contribution! 🚢
Sparks0219
enabled auto-merge (squash)
October 8, 2026 08:20
sai-miduthuri
added a commit
that referenced
this pull request
Oct 21, 2026
…67212) Cherry-pick of #66772 (master commit 36384df) onto `releases/2.60.0`. ## Why `//python/ray/tests:rdt/test_rdt_nixl` fails in the `:ray: core: multi gpu tests` and `:ray: core: multi gpu cu130 tests` jobs in all 11 `releases/2.60.0` postmerge builds so far, including build 20362 for the current branch head. In each one, `test_nixl_cross_device_fetch` fails with `NIXL_ERR_NOT_FOUND`. The cause is #65205 (sender-side memory pool), which this branch has. Since then, a fetch into target buffers labels the receiver's buffers with the sender's device type, so a CPU buffer is described to NIXL as CUDA, and vice versa. #66772 gives the local and remote descriptor lists their own memory types. It also rejects target buffers that mix device types, and tests that. On master, the test failed in every release-automation postmerge build that ran it, from the branch point through build 20195. It has passed in all 34 since build 20205, the first to include #66772. ## Cherry-pick details Applied cleanly with `git cherry-pick -x`. The change is identical to the master commit: - Same 2 files, 28 insertions and 3 deletions, and the same `git patch-id --stable`. - The diff text matches except for the three `nixl_tensor_transport.py` hunk headers. They start 2 lines earlier here, because this branch doesn't have the 2 lines #66777 added above them on master. No prerequisite commits are missing: - On master, only #66777 (raise when a cached registration is smaller than the tensor) touched `python/ray/experimental/rdt/` or `python/ray/tests/rdt/` between the branch cut and #66772. It changes the NIXL registration cache and adds a docstring note in `util.py`; #66772 neither touches nor uses either change. - After the pick, `test_rdt_nixl.py` is identical to master at 36384df, and `nixl_tensor_transport.py` differs only by #66777's lines. - On this branch, no commit after the cut touched those directories. Not a duplicate: this branch doesn't contain #66772, and no PR against `releases/2.60.0` references it. ## Testing | Command | Result | |---|---| | `pre-commit run --files python/ray/experimental/rdt/nixl_tensor_transport.py python/ray/tests/rdt/test_rdt_nixl.py` | Passed (ruff, black, pydoclint, docstyle, import order, and the other applicable hooks) | I couldn't run `test_rdt_nixl` locally because it needs GPUs and NIXL. In CI it runs in the `:ray: core: multi gpu tests` and `:ray: core: multi gpu cu130 tests` jobs. On premerge and microcheck, those jobs wait on the "run multi gpu tests" block step. AI assistance was used to prepare this cherry-pick. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Joshua Lee <[email protected]> Signed-off-by: Sai Miduthuri <[email protected]> Co-authored-by: Joshua Lee <[email protected]>
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.
Fixes #65701.
NixlTensorTransportcaches NIXL registrations bystorage.data_ptr(). If a registered storage is freed withoutderegister_nixl_memoryand a larger storage is allocated at the same address, the cache hits and skips re-registration. NIXL then only knows the old, smaller extent, and later transfers fail withNIXL_ERR_NOT_FOUND.deregister_nixl_memoryleaves the lifecycle of registered memory to the user, so instead of silently re-registering, raise a clear error when the new storage is larger than the cached registration. A smaller or equal size still fits inside the registered region and remains a cache hit.Changes
nixl_tensor_transport.py: store the registered size inTensorDescand raiseValueErrorin_add_tensor_descson a cache hit when the storage'snbytes()exceeds it.util.py: document the error and that pre-registered buffers should be allocated at their full size up front.Duplicate check
No open PR references #65701 or addresses this change.