Fix is_managed reporting for pool-allocated managed memory#1924
Merged
cpcloud merged 4 commits intoNVIDIA:mainfrom Apr 16, 2026
Merged
Fix is_managed reporting for pool-allocated managed memory#1924cpcloud merged 4 commits intoNVIDIA:mainfrom
cpcloud merged 4 commits intoNVIDIA:mainfrom
Conversation
Pool-allocated managed memory via cuMemAllocFromPoolAsync (from a pool created with CU_MEM_ALLOCATION_TYPE_MANAGED) does not set CU_POINTER_ATTRIBUTE_IS_MANAGED=1. _query_memory_attrs therefore classified the allocation as pinned host memory, causing classify_dl_device to return kDLCUDAHost instead of kDLCUDAManaged. CCCL's make_tma_descriptor only accepts kDLCUDA or kDLCUDAManaged, so as_tensor_map() failed with "Device type must be kDLCUDA or kDLCUDAManaged" on managed buffers. Buffer.is_device_accessible / is_host_accessible already delegate to the memory resource when one is attached. Apply the same pattern to is_managed, and expose is_managed on the MemoryResource base (defaulting to False) with ManagedMemoryResource overriding it to True. Also ignore .claude/settings.local.json in .gitignore. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
The existing test_managed_buffer_dlpack_roundtrip_device_type uses a DummyUnifiedMemoryResource backed by cuMemAllocManaged, which sets CU_POINTER_ATTRIBUTE_IS_MANAGED and so never exercised the pool-allocated path that surfaced the bug. Add two targeted tests: - test_managed_memory_resource_buffer_dlpack_device_type: allocates from ManagedMemoryResource (cuMemAllocFromPoolAsync on a managed pool) and asserts is_managed and kDLCUDAManaged through Buffer and view. - test_non_managed_resources_report_not_managed: parametrized smoke test ensuring DeviceMemoryResource and PinnedMemoryResource still report is_managed=False so the new MemoryResource.is_managed default does not silently misclassify non-managed resources. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Previous fix unconditionally delegated Buffer.is_managed to _memory_resource.is_managed, which returns False for any MemoryResource subclass that does not opt in. That broke DummyUnifiedMemoryResource (and any user-defined MR wrapping cuMemAllocManaged) where the driver pointer attribute correctly reports IS_MANAGED=1 but the resource does not override is_managed. Query the driver first; only fall back to the memory resource when the driver does not report IS_MANAGED (the pool-allocated managed memory path). This keeps both old-style cuMemAllocManaged buffers and ManagedMemoryResource pool allocations correctly classified. Also rework the regression test parametrization to skip the pinned case when PinnedMemoryResource is unavailable (CUDA < 13.0), and pick up the ruff-format reflow of the helper call site. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Pick up cuda-nvrtc 13.2.78, libcufile 1.17.1.22, and other transitive package updates from conda-forge. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
rparolin
approved these changes
Apr 16, 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
Buffer.is_managednow returnsTruewhen either the driver pointer attribute says so or the owning memory resource advertises managed allocations. The driver signal takes precedence; the resource signal is only a fallback.is_managedon theMemoryResourcebase (defaultFalse);ManagedMemoryResourceoverrides it toTrue. Other subclasses inheritFalse.Why
ManagedMemoryResourceallocates viacuMemAllocFromPoolAsyncfrom a pool created withCU_MEM_ALLOCATION_TYPE_MANAGED. On some CUDA driver / hardware combinations,cuPointerGetAttributeson those allocations returnsIS_MANAGED=0andMEMORY_TYPE=CU_MEMORYTYPE_HOST._query_memory_attrstherefore setis_device_accessible=True, is_host_accessible=True, is_managed=False, andclassify_dl_devicereturnedkDLCUDAHost(3).CCCL's
make_tma_descriptor(libcudacxx/include/cuda/__tma/make_tma_descriptor.h) accepts onlykDLCUDAorkDLCUDAManaged, soStridedMemoryView.as_tensor_map()failed on aManagedMemoryResourcebuffer with:Surfaced in
TestTensorMapMultiDeviceValidation::test_from_tiled_accepts_managed_buffer_on_nonzero_deviceon NVIDIA B300 SXM6 AC.Caveat on the driver behavior
Reproducing the exact pre-fix
cuPointerGetAttributesvalues on RTX 5070 Ti / driver 13.2.0 showsIS_MANAGED=1andMEMORY_TYPE=DEVICEfor bothcuMemAllocManagedandcuMemAllocFromPoolAsyncfrom a managed pool — i.e. this configuration does not hit the bug. The fix is still sound: it is a no-op when the driver attributes are reported correctly, and it closes the gap when they aren't, without relying on driver-side quirks. The precise driver / CTK / hw combination that triggers the kDLCUDAHost classification on B300 is not reproduced in this PR; the failing test in the description comes from the reporter's B300 environment.🤖 Generated with Claude Code