fix(cuda.core): order VMM unmaps on the stream - #2889
aryanputta wants to merge 5 commits into
Conversation
Signed-off-by: Aryan <aryansputta@gmail.com>
Andy-Jost
left a comment
There was a problem hiding this comment.
Thanks for the PR. VMM work is consolidated under #2906, and this PR is on the list to land for cuda.core 1.3.0. Before review:
#2886 is a real gap, and the sync is the right fix for device-located buffers. One regression to fix first: host-located resources record no deallocation stream (is_device_accessible is False), so the deleter passes an unbound default stream, and .sync() raises when no context is current. The callback then reports a CUDAWarning and skips unmap and address-free, which leaks. Guard the sync on self.is_device_accessible.
For the test, drop the monkeypatch and add a driver test that allocates and closes one buffer from a device-located resource and one from a host-located resource with an explicit stream, asserting no CUDAWarning. Rebase on main (#2235 has merged; deallocate() no longer retains or releases a handle) and add a 1.3.0 release note.
Please keep discussion of the overall plan on #2906.
|
Changed:
Local validation passed: Ruff, Python syntax compilation, and |
Andy-Jost
left a comment
There was a problem hiding this comment.
Thanks for the rework. The device-side guard and sync are right, and the real-driver test is the right shape. Three things block this as it stands:
- The merge with
mainreintroduced the leak that #2235 fixed.deallocate()now callscuMemRetainAllocationHandle(ptr)and never releases the handle it gets back, so every close leaves the physical allocation with one extra reference and it is never freed. Drop that call: onmain, the mapping alone owns the allocation andcuMemUnmapfrees it. - The release-note edit removed an existing entry. The bullet for #2876 (the
Programdestructor fix) was replaced instead of a new bullet being added. Restore it and add the new bullet after it, citing #2886 rather than this PR. - The host case of the new test cannot pass on a GPU.
VirtualMemoryResourceOptions(location_type="host")keeps the defaultposix_fdhandle type, which the driver rejects for host memory, soallocate()fails before the test reachesclose(). Passhandle_type=Nonefor the host case. The test also needs@pytest.mark.thread_unsafe(reason=...), becauseassert_no_cuda_warningcaptures process-global warnings.
#2917 (the redesign from #2906) fixes #2886 in the new implementation and removes the file this PR edits, so these changes would not survive a rebase once it lands. Unless this needs to land first, we suggest closing this PR as superseded when #2917 merges.
Summary
Fixes #2886.
VirtualMemoryResource.deallocate() now synchronizes a supplied stream before calling cuMemUnmap. This preserves the stream-ordering contract documented by Buffer.close() and matches the synchronous resource implementations.
Changes
Validation
The branch is DCO signed and contains only the issue-focused changes.