Skip to content

[FEA]: Settable memory pool attributes and trim() for pool-backed memory resources #3261

Open

Description

@srimanachanta

Is this a duplicate?

Area

cuda.core

Is your feature request related to a problem? Please describe.

DeviceMemoryResource, PinnedMemoryResource and ManagedMemoryResource expose attributes, but every field is read-only, and there is no way to trim a pool.

  • Measuring the peak memory of each phase of a computation needs used_mem_high and its documented reset (setting it to 0). Stream-ordered allocations don't go through CuPy's memory hooks, so the pool's watermark is the only source.
  • DeviceMemoryResource(device) without options raises the default pool's release_threshold to ULLONG_MAX, for every user of that pool in the process. A CUDA-accelerated simulation library I am developing, cuNIBS allocates temporaries with cudaMallocAsync from the default pool and relies on the pool returning unused memory at the next synchronization (_memory.py). cuda.core offers no way to set the threshold back.

Describe the solution you'd like

I opened #3236 with this change before opening an issue. I'll revise or close it depending on the outcome here.

Describe alternatives you've considered

Stop raising the default pool's release_threshold in DeviceMemoryResource(device). That would undo #771, which raised it because allocations from the default pool were slow with a threshold of 0.

Additional context

Open question: should setters work on a resource that wraps the device's default pool? A change there affects every user of that pool in the process. cuda.core already changes that pool's release_threshold implicitly. #3236 allows setters on it and documents the effect. Allowing setters only on owned pools would rule out the release_threshold case above. #2362 raises the same question for max_pool_size and process-global pool changes.

Activity

  1. added this to the cuda.core 1.3.0 milestone on Oct 28, 2026
  2. added
    featureNew feature or request
    cuda.coreEverything related to the cuda.core module
    P2Low priority - Nice to have
    on Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Low priority - Nice to havecuda.coreEverything related to the cuda.core modulefeatureNew feature or requesttriageNeeds the team's attention

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions