Skip to content
Merged
Prev Previous commit
Next Next commit
Address code review feedback: move skip logic, add docstring note, up…
…date release note

Co-authored-by: kkraus14 <[email protected]>
  • Loading branch information
Copilot and kkraus14 committed Aug 21, 2025
commit 2a8b536136ad762c77cd9fcb068e05f44af0bb31
7 changes: 7 additions & 0 deletions cuda_core/cuda/core/experimental/_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,13 @@ class DeviceMemoryResource(MemoryResource):
Device ordinal for which a memory resource is constructed. The mempool that is
set to *current* on ``device_id`` is used. If no mempool is set to current yet,
the driver would use the *default* mempool on the device.

Notes
-----
During initialization, this class automatically configures the memory pool's release
threshold for improved performance. If the current threshold is 0 (default), it is
set to the maximum value to prevent immediate memory release when there are no active
allocations, which can cause performance degradation.
Comment thread
leofang marked this conversation as resolved.
Resolved
"""

__slots__ = ("_dev_id",)
Expand Down
2 changes: 1 addition & 1 deletion cuda_core/docs/source/release/0.X.Y-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ None.
Fixes and enhancements
----------------------

- Improved :class:`DeviceMemoryResource` allocation performance when there are no active allocations (addresses issue #771).
- Improved :class:`DeviceMemoryResource` allocation performance when there are no active allocations by setting a higher release threshold (addresses issue #771).
- Fix :class:`LaunchConfig` grid unit conversion when cluster is set (addresses issue #867).
3 changes: 2 additions & 1 deletion cuda_core/tests/test_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,15 @@ def test_buffer_dunder_dlpack_device_failure():
buffer.__dlpack_device__()


@pytest.mark.skipif(not Device().properties.memory_pools_supported, reason="memory pools not supported")
def test_device_memory_resource_initialization():
Comment thread
leofang marked this conversation as resolved.
Resolved
"""Test that DeviceMemoryResource can be initialized successfully.

This test verifies that the DeviceMemoryResource initializes properly,
including the release threshold configuration for performance optimization.
"""
device = Device()
if not device.properties.memory_pools_supported:
pytest.skip("memory pools not supported")
Comment on lines +269 to +270

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!!!

device.set_current()

# This should succeed and configure the memory pool release threshold
Expand Down