fix(cuda.core): route pool-backed MR buffers through deallocate() - #2620
Open
atiaomar1978-hub wants to merge 4 commits into
Open
fix(cuda.core): route pool-backed MR buffers through deallocate()#2620atiaomar1978-hub wants to merge 4 commits into
atiaomar1978-hub wants to merge 4 commits into
Conversation
Pool-backed and graph memory resources now wrap raw allocations with MR-owned device pointer handles, matching Buffer.from_handle(mr=...). Subclasses can observe or customize teardown via deallocate(). Fixes NVIDIA#2615 Signed-off-by: Omar Atie <atiaomar1978-hub@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Use MR-owned handles only for Python subclasses so built-in pool/graph MRs retain nogil cuMemFreeAsync teardown during interpreter shutdown. Signed-off-by: Omar Atie <atiaomar1978-hub@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Author
|
Thanks for filing #2615 — this PR addresses the inconsistent deallocation paths. Approach
Tests added
Bugbot review: clean after the hybrid approach. Happy to adjust based on maintainer feedback. |
Document MemoryResource subclass teardown behavior and add a 1.2.0 release note for pool-backed MR deallocate consistency. Signed-off-by: Omar Atie <atiaomar1978-hub@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>
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 #2615
Pool-backed memory resources (
DeviceMemoryResource,PinnedMemoryResource,ManagedMemoryResource) andGraphMemoryResourcepreviously returned buffers whose C++ deleter calledcuMemFreeAsyncdirectly, bypassing Pythondeallocate()overrides.This change wraps raw pool/async allocations with MR-owned device pointer handles (the same path as
Buffer.from_handle(mr=...)), records the allocation stream at creation, and routes teardown throughMemoryResource.deallocate().Checklist
Test plan
pytest cuda_core/tests/test_memory.py -k "pool_backed_mr or dmr_deallocate_frees_pool_pointer or dmr_from_handle_deallocate"cuda.core