Skip to content

"cuda.core tests: reserve driver-managed mempools up front" - #2522

Open
juenglin wants to merge 2 commits into
NVIDIA:mainfrom
juenglin:oom-early-reservation-workaround
Open

"cuda.core tests: reserve driver-managed mempools up front"#2522
juenglin wants to merge 2 commits into
NVIDIA:mainfrom
juenglin:oom-early-reservation-workaround

Conversation

@juenglin

@juenglin juenglin commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

closes #2381

Root cause and measurements are in this comment; in short, the driver's default memory pool and graph memory pool each permanently reserve ~2x installed device memory of virtual address space, and neither can be capped or released.

A session-scoped autouse fixture now takes both reservations up front, so they land back to back in a nearly empty address space instead of whenever test order happens to trigger them. This does not reduce the footprint; it just makes the big reservations deterministic. If either reservation is refused the session aborts with an explanation, rather than cascading ~194 identical OOM failures that say nothing about the cause.

Available address space is reported before and after via cuMemAddressReserve rather than an OS query, so it behaves the same on Windows and Linux. Devices without mempool support are skipped, not failed. Escape hatches: CUDA_CORE_TEST_SKIP_EARLY_RESERVATION=1 disables the fixture (use as the control when measuring whether it helps or is still needed).

The fixture can be removed once either driver-side improvement lands:

  1. the per-pool reservation is no longer ~2x device memory, or becomes cappable
    (cuGraphAddMemAllocNode currently accepts poolProps.maxSize but ignores it); or
  2. the per-process address-space budget stops being the binding constraint, which the
    fixture's own remaining headroom: N more pool-sized reservations line reports —
    an N comfortably above 1 means ordering can no longer matter on that machine.

Checklist

  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@copy-pr-bot

copy-pr-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@juenglin juenglin self-assigned this Aug 6, 2026
@juenglin juenglin added P0 High priority - Must do! test Improvements or additions to tests cuda.core Everything related to the cuda.core module labels Aug 6, 2026
@juenglin juenglin added this to the cuda.core 1.2.0 milestone Aug 6, 2026
@juenglin

juenglin commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test

@juenglin
juenglin requested a review from Andy-Jost August 6, 2026 18:47
@juenglin
juenglin marked this pull request as ready for review August 6, 2026 20:07
…sion start

The driver's default memory pool and graph memory pool each permanently reserve
roughly twice the installed device memory of virtual address space, and neither
can be capped or released. On a large-memory GPU with a bounded per-process
address space, whether the second reservation still finds a contiguous range
depends on how fragmented the space has become by the time some test needs it,
which is what makes the failures in NVIDIA#2381 intermittent. Measurements and
documentation references:
NVIDIA#2381 (comment)

Take both reservations up front in a session-scoped autouse fixture so they land
back to back in a nearly empty address space. This does not reduce the
footprint; it makes the outcome deterministic. If either is refused the session
aborts with an explanation, since every later test needing that pool would fail
the same way and a cascade of identical OOM errors says nothing about the cause.

Available address space is reported before and after via cuMemAddressReserve
rather than an OS query, so the measurement behaves the same on Windows and
Linux.

CUDA_CORE_TEST_SKIP_EARLY_RESERVATION=1 disables the fixture;
CUDA_CORE_TEST_FORCE_RESERVATION_FAILURE=1 exercises the abort path.
…orted

Both driver-managed pools require mempool support, so on a device without it
there is nothing to reserve and nothing to pre-empt. Reporting a failed
reservation there would abort the session, when the correct behaviour is to
carry on: the tests that need pools already skip themselves via
Device.properties.memory_pools_supported, and the rest still run.
@juenglin
juenglin force-pushed the oom-early-reservation-workaround branch from 6971e4e to 51f6ff4 Compare August 6, 2026 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda.core Everything related to the cuda.core module P0 High priority - Must do! test Improvements or additions to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Intermittent CUDA_ERROR_OUT_OF_MEMORY cascade in cuda_core test suite

2 participants