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
fix(cuda.core): report the exporter's NUMA node on imported pinned pools - #3530
An imported PinnedMemoryResource reported numa_id == 0 when the driver cannot report the pool's location (a CUDA 12 build or a driver before 13.2); #3516 fixed the case where it can. Now the exporter's node travels with the pickle, and PinnedMemoryResource.from_allocation_handle takes an optional numa_id for raw handles. If the handle's resource is already registered in the process with an unknown node, the argument becomes its node. A negative numa_id, or one that differs from the pool's known node (reported by the driver or by a resource already registered for the handle), raises ValueError.
If the node comes from neither the driver nor the argument, the import still succeeds, but the numa_id property raises RuntimeError instead of returning 0, and pickling the resource sends no node. This is a behavior change called out in the release note.
Tested with a CUDA 13.5 build; the no-location-query paths are covered by patching driver_version in the child process. A CUDA 12 build and a multi-node NUMA host were not tested.
An imported PinnedMemoryResource reported numa_id 0 whenever the driver
could not report the pool's location (a CUDA 12 build or a driver before
13.2). Unpickling a resource now carries the exporter's node, and
PinnedMemoryResource.from_allocation_handle accepts an optional numa_id
for a raw allocation handle. An import whose node is unknown still reports
0 and does not pass it on when pickled.
from_allocation_handle raises ValueError for a negative numa_id, and for
one that differs from the pool's known node, whether the driver reported
it or the resource was already registered in the process.
ClosesNVIDIA#3508.
Signed-off-by: Ralf Juengling <rjuengling@nvidia.com>
… is unknown
An imported pool whose node neither the driver nor the caller reports no
longer reports 0. The numa_id property raises RuntimeError instead, as
NVIDIA#3508 now specifies.
…tests
Close imported resources through an ExitStack, as the other children in
test_ipc_pool_kind.py do, by letting import_pool_resource and
enter_imported_pool pass numa_id. Reuse _without_location_query in
child_import_without_location_query, and explain why the pickle tests
send the reducer's output instead of the resource.
Cover the reducer output and the import from it in one pickle test, drop the
unknown-node assertion that test_import_uses_given_numa_id already makes, and
test a single negative numa_id.
Imported pinned memory resources can retain the exporting pool’s NUMA node through transfer or pickling. If the node can’t be detected automatically, you can provide it when importing an allocation handle or supply it for an existing import.
Behavior Changes
Accessing an unknown NUMA node now raises an error instead of returning 0. Invalid node values, including negative or out-of-range values, and values that conflict with a known node are rejected.
Imported pinned memory resources can obtain their NUMA node from the driver or an optional import argument. Pickling carries a known node to the importing process. If the node remains unknown, accessing numa_id raises RuntimeError instead of returning 0.
The resource tracks whether its NUMA node is known. The import API and property document node sources, validation, and behavior when the node is unknown.
Import and pickle behavior cuda_core/cuda/core/_memory/_pinned_memory_resource.pyx
Imports record a node reported by the driver or supplied by the caller. Negative or conflicting supplied nodes raise ValueError. Pickling includes the node when known; accessing numa_id raises RuntimeError when it is unknown.
Import validation and release notes cuda_core/tests/helpers/memory.py, cuda_core/tests/conftest.py, cuda_core/tests/memory_ipc/test_ipc_pool_kind.py, cuda_core/docs/source/release/1.4.0-notes.rst
Test helpers pass an optional node to pinned-resource imports. IPC tests cover driver lookup, caller-supplied nodes, unknown nodes, conflicts, concurrency, and pickling. Release notes describe the behavior.
Assessment against linked issues
Objective
Addressed
Explanation
Preserve the exporter’s NUMA node through pickling and accept an optional node for raw-handle imports [3508]
✅
Reject negative or conflicting node values, and leave an unavailable node unknown rather than reporting 0 [3508]
✅
Document node sources and behavior when the node is unknown [3508]
✅
Possibly related issues
NVIDIA/cuda-python#3615 — The PR implements the pinned-resource node conflict and unknown-node behavior discussed in this issue.
Possibly related PRs
NVIDIA/cuda-python#3516 — Both PRs change imported pinned-pool NUMA handling. This PR validates the supplied node against the driver-reported node and carries known nodes through pickling.
Suggested reviewers:leofang, mdboom, jpascucci-nv
Change: Bug fix · Severity of issue fixed: Medium
Merge Risk: Minimal · up to fde04
Imported pinned memory resources now take their NUMA node from the driver, the pickle payload, or an optional numa_id argument. When none of these supplies it, reading numa_id raises RuntimeError instead of returning 0. No concrete merge-blocking defect remains in the reviewed changes. The CUDA 12 build and multi-node hosts remain untested, as the author states.
Security architecture risk: Low · up to fde04
The change improves NUMA reporting without granting additional memory access. The main compatibility risk is that an updated process can send a pinned-memory resource that an older process cannot reconstruct, which matters if communicating processes are upgraded or rolled back separately.
Retained concerns
Trivial · reliability · observed: This PR breaks pinned-pool reconstruction from a new sender to an old receiver: the old reconstruction method accepts only the allocation handle, but the new sender always supplies a second argument, even when it is None. If peers are upgraded or rolled back independently, affected transfers fail until compatible peers are paired.
inferred — A caller or pickle sender can supply an unverified node when the receiver has no driver or registered value to compare against. That value can become visible to other users of the same wrapper in the receiving process and travel with a subsequent export of that resource; the inspected import path does not use it to grant additional access.
Trust Boundaries and Controls
observed — The import keeps the existing handle-open, registered-type, and driver pool-kind checks where available. NUMA validation checks representability and agreement with known metadata; it does not authenticate a caller-supplied node when no independent value is available.
Resilience and Maintainability Implications
observed — A fresh import that fails node validation exits before registry publication or the device-access grant. The temporary import uses the existing shared pool and file-descriptor ownership model; this PR does not add a separate cleanup path.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.
…nknown node
A second import of a registered handle, given a numa_id, now sets the node of
a resource whose first import had none, instead of leaving numa_id raising.
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.
Check and set the node of a registered import in one critical section, and
read it under the same critical section in numa_id and the pickle reducer, so
that concurrent imports naming different nodes cannot both succeed on a
free-threaded build. The reducer no longer sends a negative node, which
from_allocation_handle rejects.
The reason will be displayed to describe this comment to others. Learn more.
Reviewed at commit 1f0258c: three low-priority issues (codex GPT-6.2-Sol ultra):
P3 · Fractional NUMA IDs are silently truncated. On both CUDA builds, from_allocation_handle(..., numa_id=1.75) accepted the value and reported node 1. On CUDA 13 it also passed validation against the driver-reported node 1. Normalize once with operator.index() and a checked integer conversion before importing the pool. Validation · Conversion
P3 · The fallback pickle test bypasses multiprocessing reconstruction. It calls the reducer directly and manually imports its arguments. I verified a real Pipe round trip with the location query disabled. Both builds recovered node 1, and both reported the node as unknown when I removed the serialized metadata. That round trip would cover the public behavior directly. Fallback pickle test · Saved probe
P3 · The rejected-import test can miss its cleanup warning. The first import stays alive while the conflicting import is rejected. The two imports share a native pool owner, which releases the driver references when the first import closes, after warning capture ends. Close the first import before testing rejection to exercise cleanup inside the capture. Test · Shared owner
…uma_id tests
from_allocation_handle normalizes numa_id with operator.index and bounds it by
INT_MAX before importing the pool, so a float is no longer truncated. The
pickle test now sends the resource through a multiprocessing Pipe, the
rejected-import test closes the first import so that its cleanup is checked,
the pinned IPC pool is a shared fixture, and the tests assert exception types
instead of messages.
The reason will be displayed to describe this comment to others. Learn more.
Architecture findings (1)
Advisory architecture findings (1)
Trivial — This PR breaks pinned-pool reconstruction from a new sender to an old receiver: the old reconstruction method accepts only the allocation handle, but the new sender always supplies a second argument, even when it is None. If peers are upgraded or rolled back independently, affected transfers fail until compatible peers are paired.
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.
This branch has not been deployed
No deployments
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
bugSomething isn't workingcuda.coreEverything related to the cuda.core module
3 participants
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.
Description
closes #3508
An imported
PinnedMemoryResourcereportednuma_id == 0when the driver cannot report the pool's location (a CUDA 12 build or a driver before 13.2); #3516 fixed the case where it can. Now the exporter's node travels with the pickle, andPinnedMemoryResource.from_allocation_handletakes an optionalnuma_idfor raw handles. If the handle's resource is already registered in the process with an unknown node, the argument becomes its node. A negativenuma_id, or one that differs from the pool's known node (reported by the driver or by a resource already registered for the handle), raisesValueError.If the node comes from neither the driver nor the argument, the import still succeeds, but the
numa_idproperty raisesRuntimeErrorinstead of returning 0, and pickling the resource sends no node. This is a behavior change called out in the release note.Tested with a CUDA 13.5 build; the no-location-query paths are covered by patching
driver_versionin the child process. A CUDA 12 build and a multi-node NUMA host were not tested.Checklist