Fix PinnedMemoryResource IPC NUMA ID derivation#1699
Open
Andy-Jost wants to merge 3 commits intoNVIDIA:mainfrom
Open
Fix PinnedMemoryResource IPC NUMA ID derivation#1699Andy-Jost wants to merge 3 commits intoNVIDIA:mainfrom
Andy-Jost wants to merge 3 commits intoNVIDIA:mainfrom
Conversation
…ce-specific concerns Move _dev_id, device_id, and peer_accessible_by from _MemPool into DeviceMemoryResource. Eliminate _MemPoolOptions and refactor pool initialization into freestanding cdef functions (MP_init_create_pool, MP_init_current_pool, MP_raise_release_threshold) for cross-module visibility. Extract __init__ bodies into inline cdef helpers (_DMR_init, _PMR_init, _MMR_init) for consistency and shorter class definitions. Implements device_id as -1 for PinnedMemoryResource and ManagedMemoryResource since they are not device-bound. Made-with: Cursor
…IDIA#1603) PinnedMemoryResource(ipc_enabled=True) hardcoded host NUMA ID 0, causing failures on multi-NUMA systems where the active device is attached to a different NUMA node. Now derives the NUMA ID from the current device's host_numa_id attribute, and adds an explicit numa_id option for manual override. Removes the _check_numa_nodes warning machinery in favor of proper NUMA node selection. Made-with: Cursor
Contributor
Contributor
Author
|
/ok to test e55a26b |
|
leofang
reviewed
Feb 27, 2026
Comment on lines
+69
to
+72
| @property | ||
| def device_id(self) -> int: | ||
| """Return -1. Managed memory migrates automatically and is not tied to a specific device.""" | ||
| return -1 |
Member
There was a problem hiding this comment.
Q: Wouldn't this be a breaking change? In the old implementation, device_id was used to initialize _MemPool. _dev_id, which is used to back .device_id, but the new implementation returns .device_id = -1 unconditionally. I understand we meant to say the pages are migratable (not pinned), but maybe there is a better way to restore the capability of querying the preferred location?
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.
Summary
PinnedMemoryResource(ipc_enabled=True)hardcoded host NUMA ID0, causing failures on multi-NUMA systems when the active device is on a different NUMA nodenuma_idoption toPinnedMemoryResourceOptionsfor explicit NUMA node selection_MemPoolhierarchy to separate shared pool machinery from device-specific concernsChanges
Bugfix (
_pinned_memory_resource.pyx):ipc_enabled=Trueandnuma_idis not specified, derives the NUMA node from the current device'shost_numa_idattribute (requires active CUDA context)numa_id: int | None = NonetoPinnedMemoryResourceOptionsnuma_idproperty toPinnedMemoryResource_check_numa_nodeswarning machinery in favor of proper NUMA node selectionRefactor (
_MemPoolhierarchy):_dev_id,device_id, andpeer_accessible_byfrom_MemPoolintoDeviceMemoryResource_MemPoolOptions; pool initialization refactored into freestandingcdeffunctions (MP_init_create_pool,MP_init_current_pool,MP_raise_release_threshold)__init__bodies into inlinecdefhelpers (_DMR_init,_PMR_init,_MMR_init)device_idas-1forPinnedMemoryResourceandManagedMemoryResourceTest Coverage
numa_idbehavior matrix: default without IPC, default with IPC, explicit NUMA ID, negative NUMA ID errornuma_idvaluesMade with Cursor