Conversation
Contributor
|
Andy-Jost
force-pushed
the
ajost/issue-2877
branch
from
September 16, 2026 21:12
9e7578d to
bd6b7d1
Compare
Contributor
Contributor
Author
|
/ok to test bd6b7d1 |
This was referenced Sep 16, 2026
Andy-Jost
force-pushed
the
ajost/issue-2877
branch
from
September 17, 2026 17:27
bd6b7d1 to
23599fb
Compare
Contributor
Author
|
/ok to test 23599fb |
The slow path of VirtualMemoryResource.modify_allocation unmapped the old VA range, remapped the physical memory into the new range, freed the old reservation by hand and then reset the old buffer's handle with Buffer._clear(). That reset runs the handle's deleter, which calls mr.deallocate() on the range that was just freed. The failing cuMemRetainAllocationHandle is reported as a CUDAWarning since NVIDIA#2759 and was silently swallowed before. Map the old physical memory into the new range as a second mapping instead, which the VMM APIs allow (virtual aliasing), and then close the old buffer. Closing runs deallocate() on a range that is still mapped, so the old range is unmapped, its reservation freed and its handle reference released through the normal path. The remap-on-rollback undo step, which swallowed its own errors, is no longer needed because the old mapping is never removed before the transaction commits. Issue NVIDIA#2877 Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
The slow-path regression test fills the buffer with cuMemsetD8 and grows it at once. Memset is asynchronous with respect to the host, and on WDDM the batched kernel can still be pending when the grow unmaps the old range, so it faults with a sticky CUDA_ERROR_ILLEGAL_ADDRESS that took every later test in the job down with it. Synchronize before the grow. Issue NVIDIA#2877 Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Andy-Jost
force-pushed
the
ajost/issue-2877
branch
from
September 17, 2026 23:14
23599fb to
0fb501c
Compare
This was referenced Sep 17, 2026
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
Fixes #2877. The slow path of
VirtualMemoryResource.modify_allocation()unmapped the old VA range, remapped the physical memory into the new range, freed the old reservation by hand, and then reset the old buffer's handle withBuffer._clear(). That reset runs the handle's deleter, which callsmr.deallocate()on the range that was just freed; since #2759 the failingcuMemRetainAllocationHandleis reported as aCUDAWarning(visible in CI ontest_vmm_allocator_grow_allocation), and before that it was silently swallowed.Changes
_virtual_memory_resource.py: the slow path maps the old physical memory into the new range as a second mapping (virtual aliasing, which the VMM APIs support) and then closes the old buffer. Closing runsdeallocate()on a range that is still mapped, so the old range is unmapped, its reservation freed, and its handle reference released through the normal path. The remap-on-rollback undo step, which swallowed its own errors, is gone: the old mapping is never removed before the transaction commits, so a failure leaves the old buffer untouched.tests/test_memory.py: forces the slow path by reserving the address range right after the buffer, grows it underassert_no_cuda_warning(), and checks that the old buffer is closed and the old contents are readable through the new mapping.Related Work
🤖 Generated with Claude Code