Implement release threshold configuration for DeviceMemoryResource performance optimization - #875
Conversation
…rformance optimization Co-authored-by: leofang <5534781+leofang@users.noreply.github.com>
…ization Co-authored-by: leofang <5534781+leofang@users.noreply.github.com>
Co-authored-by: leofang <5534781+leofang@users.noreply.github.com>
DeviceMemoryResourceCo-authored-by: leofang <5534781+leofang@users.noreply.github.com>
|
@copilot please add a release note entry noting the performance optimization in device memory management. No need to be too explicit about what's the optimization we did in this PR. |
Co-authored-by: leofang <5534781+leofang@users.noreply.github.com>
Added release note entry for the DeviceMemoryResource performance optimization to the 0.X.Y release notes. (6a2c4f4) |
|
@copilot please apply the labels from the issue we're fixing to this PR, thanks |
I can see that issue #771 has the following labels: |
|
/ok to test 6a2c4f4 |
This comment has been minimized.
This comment has been minimized.
Co-authored-by: leofang <5534781+leofang@users.noreply.github.com>
…date release note Co-authored-by: kkraus14 <3665167+kkraus14@users.noreply.github.com>
|
/ok to test 2a8b536 |
| if not device.properties.memory_pools_supported: | ||
| pytest.skip("memory pools not supported") |
There was a problem hiding this comment.
Is it a (happy) coincidence or the copilot actually understands that this is legit code (accessing device properties without calling .set_current() is OK)? Too good to be true!!!
Co-authored-by: leofang <5534781+leofang@users.noreply.github.com>
leofang
left a comment
There was a problem hiding this comment.
Since Keith already approved, the CI was green, and the last commit was doc-only, let me admin-merge this. Thanks Keith & @copilot!
|
This PR implements a performance optimization for
DeviceMemoryResourceby configuring the memory pool release threshold, addressing slow allocation performance when there are no active allocations.Problem
As reported in issue #756, allocation via
DeviceMemoryResourcecan be very slow when there are no active allocations. This occurs because the default memory pool is configured with a release threshold of0, meaning memory is immediately released back to the OS when there are no active suballocations. Subsequent allocations then require expensive OS memory requests.Solution
This PR upstreams the workaround from CCCL to cuda-core by modifying
DeviceMemoryResource.__init__()to:cuMemPoolGetAttribute0xFFFFFFFFFFFFFFFF) usingcuMemPoolSetAttributeImplementation Details
DeviceMemoryResource.__init__()incuda_core/cuda/core/experimental/_memory.pyThe implementation follows the exact same pattern as the CCCL workaround, using identical CUDA driver APIs and constants.
Example Usage
The optimization is transparent to users and maintains full backward compatibility.
Fixes #771.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.