Restore v0.3.x MemoryResource behaviors + MR minor follow-ups#1388
Merged
leofang merged 5 commits intoNVIDIA:mainfrom Dec 17, 2025
Merged
Restore v0.3.x MemoryResource behaviors + MR minor follow-ups#1388leofang merged 5 commits intoNVIDIA:mainfrom
MemoryResource behaviors + MR minor follow-ups#1388leofang merged 5 commits intoNVIDIA:mainfrom
Conversation
Contributor
leofang
commented
Dec 16, 2025
Andy-Jost
approved these changes
Dec 16, 2025
| ) | ||
|
|
||
| _numa_warning_shown = True | ||
| _numa_warning_shown = True |
Contributor
There was a problem hiding this comment.
nit: it's possible for an error to leak from the above code causing this flag to not be set. I suspect you'd rather attempt lines 47... only once, no matter what happens.
kkraus14
approved these changes
Dec 16, 2025
Member
Author
|
/ok to test a0871e5 |
This comment has been minimized.
This comment has been minimized.
|
2 tasks
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.
Description
closes #1359
This PR attempts to partially restore the v0.3.x behavior, where initializing a
MemoryResourceinstance would raiseTypeError. We cannot actually do this because it is now acdef class, so we do lose some protection, but at least we can raise the same exception when attempting to access the 5 methods/attributes.This PR also addresses a few review comments from #1364.
Below is LLM-generated PR description: This pull request refactors the memory resource interface and its implementations to improve error handling and code clarity, while also making minor improvements to thread safety and test coverage. The most important changes are summarized below.
MemoryResource interface changes
abcmodule and replaced abstract methods in theMemoryResourceclass with concrete methods that raiseTypeErrorif not implemented by subclasses, ensuring clearer error messages when methods are not overridden. [1] [2] [3] [4]is_device_accessible,is_host_accessible,device_id) toMemoryResource, each raisingTypeErrorto enforce implementation in subclasses.Memory resource implementation cleanup
is_ipc_enabled,is_mapped, anduuidproperties from individual memory resource classes (DeviceMemoryResource,ManagedMemoryResource,PinnedMemoryResource) to their shared base class_MemPool, reducing code duplication and centralizing IPC-related logic. [1] [2] [3] [4]Thread safety and platform checks
PinnedMemoryResourceby introducing a threading lock to prevent race conditions when checking and setting the_numa_warning_shownflag. [1] [2] [3]Test improvements
MemoryResourcedirectly raises aTypeError, verifying the new error handling behavior.ccx_system.get_num_devices()instead of directly accessingccx_system.num_devices, improving API usage consistency. [1] [2] [3] [4]Minor improvements
nogilfor the_MP_deallocateCython function to allow for better concurrency.Checklist