You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
RDT: register_nixl_memory cache false-hits on a resized/recycled pointer, skipping registration of the new extent #65701
P1Issue that should be fixed within a few weekscommunity-backlogcoreIssues that should be addressed in Ray CoreenhancementRequest for new feature and/or capabilitygood-first-issueGreat starter issue for someone just starting to contribute to Raystability
register_nixl_memory's cache is keyed on the storage's data_ptr(). If a tensor's storage is freed and a later allocation reuses the same address but with a larger size, the cache sees a hit on the pointer and skips re-registration.
NIXL still only has the old, smaller extent [P, P+S1) registered. A subsequent transfer of that tensor will fail with NIXL_ERR_NOT_FOUND, since NIXL requires the full transfer range to be covered by a single registered region.
Use case
On register_nixl_memory(tensor), when the cache has a hit on data_ptr(), also compare the previously-registered size against the current storage's nbytes():
Sizes match → current behavior (cache hit, skip registration).
Sizes differ → deregister the old registration and register the new extent as if fresh.
Add a docstring/comment on register_nixl_memory making explicit that resizing a preregistered buffer in place is inefficient and user should prefer allocating a big buffer size.
I reproduced the bug on current master with a CPU-only fake NIXL agent: registering a storage at pointer 0x1000 with 16 bytes and then a recycled storage at the same pointer with 32 bytes performs only the first registration and never deregisters the stale extent.
My plan is to:
retain the registered storage size alongside each traditional cached descriptor;
preserve the existing cache-hit/reference-count behavior when pointer and size both match;
when the pointer matches but the size differs, deregister the stale descriptor, advance the agent metadata version, and register the current extent as a fresh entry;
add CPU-only unit coverage for same-size hits, resized/recycled-pointer replacement, and the re-registration failure state;
document that in-place resizing of preregistered buffers is inefficient and that allocating the maximum required size up front is preferred.
I checked open PRs by issue number and by register_nixl_memory, NIXL registration cache, recycled pointer, and extent terms; I found no overlapping implementation. This investigation and the proposed patch are AI-assisted, and I will include the required disclosure and exact local test results in any PR.
I reviewed the proposed fix and would like to implement the cache-entry size tracking and re-registration path for recycled pointers, together with CPU-only unit tests covering:
cache hit when pointer and storage size are unchanged;
recycled pointer with a larger storage size;
deregistration of the stale extent before re-registration;
re-registration failure handling.
I also plan to add the requested documentation about avoiding in-place resizing of preregistered buffers.
I noticed @binaydhakal has also expressed interest. If this is still available, could you please confirm whether there is a particular scope you'd like me to take, or whether I should coordinate with @binaydhakal?
@binaydhakal@namviet157 thanks for offering to contribute
It would be great if you can prepose a PR with the points mentioned above and share it here so we can review
I'm a bit hesitant to have us handle this case since we did introduce deregister_nixl_memory to have the user specifically handle the lifecycle of the registered memory since it's beyond ray's purview. If the tensor's storage is freed, that would mean that the python ref count for that tensor hit 0 and was returned to torch and the user forgot to call deregister_nixl_memory. Perhaps to keep this simple, maybe we could just raise an error on the case where the we try to register a region with the same storage ptr repeatedly? What do you think @BatshevaBlack
Keep the cache as (pointer → size) - no weak_ref/storage-identity tracking.
When register_nixl_memory is called on a pointer already in the cache but with a different size, raise an error
instead of silently deregister+reregister.
Keep the docstring comment noting that resizing a preregistered buffer isn't free, so the guidance to allocate max size in advance still applies.
Apply the same ptr+size check to _tensor_memory_registered (pool eligibility) for consistency.
P1Issue that should be fixed within a few weekscommunity-backlogcoreIssues that should be addressed in Ray CoreenhancementRequest for new feature and/or capabilitygood-first-issueGreat starter issue for someone just starting to contribute to Raystability
Activity
binaydhakal commentedon Aug 24, 2026
I'd like to work on this.
I reproduced the bug on current
masterwith a CPU-only fake NIXL agent: registering a storage at pointer0x1000with 16 bytes and then a recycled storage at the same pointer with 32 bytes performs only the first registration and never deregisters the stale extent.My plan is to:
I checked open PRs by issue number and by
register_nixl_memory, NIXL registration cache, recycled pointer, and extent terms; I found no overlapping implementation. This investigation and the proposed patch are AI-assisted, and I will include the required disclosure and exact local test results in any PR.namviet157 commentedon Aug 27, 2026
Hi @BatshevaBlack,
I'd like to work on this issue as well.
I reviewed the proposed fix and would like to implement the cache-entry size tracking and re-registration path for recycled pointers, together with CPU-only unit tests covering:
I also plan to add the requested documentation about avoiding in-place resizing of preregistered buffers.
I noticed @binaydhakal has also expressed interest. If this is still available, could you please confirm whether there is a particular scope you'd like me to take, or whether I should coordinate with @binaydhakal?
Thanks!
BatshevaBlack commentedon Aug 30, 2026
@binaydhakal @namviet157 thanks for offering to contribute
It would be great if you can prepose a PR with the points mentioned above and share it here so we can review
Sparks0219 commentedon Sep 4, 2026
I'm a bit hesitant to have us handle this case since we did introduce deregister_nixl_memory to have the user specifically handle the lifecycle of the registered memory since it's beyond ray's purview. If the tensor's storage is freed, that would mean that the python ref count for that tensor hit 0 and was returned to torch and the user forgot to call deregister_nixl_memory. Perhaps to keep this simple, maybe we could just raise an error on the case where the we try to register a region with the same storage ptr repeatedly? What do you think @BatshevaBlack
BatshevaBlack commentedon Sep 7, 2026
@Sparks0219 Yes, you're right - this is simpler and more correct approach. Let's go with this.
@namviet157 if you don't mind changing this to:
instead of silently deregister+reregister.
thanks!
BatshevaBlack commentedon Oct 6, 2026
@Sparks0219 I opened a minimal PR solving this issue, can you take a look at this?
Thanks!
[core][rdt] nixl: raise when a cached registration is smaller than th…
[core][rdt] nixl: raise when a cached registration is smaller than th…