Skip to content

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

Closed
juenglin wants to merge 5 commits into
NVIDIA:mainfrom
juenglin:oom-early-reservation-workaround
Closed

"cuda.core tests: reserve driver-managed mempools up front"#2522
juenglin wants to merge 5 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
@juenglin
juenglin force-pushed the oom-early-reservation-workaround branch from 6971e4e to 51f6ff4 Compare August 6, 2026 20:09
@Andy-Jost
Andy-Jost enabled auto-merge (squash) August 7, 2026 17:13
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

@juenglin
juenglin force-pushed the oom-early-reservation-workaround branch from cfc0054 to 2574452 Compare August 7, 2026 22:59
@juenglin
juenglin disabled auto-merge August 7, 2026 23:15
@juenglin
juenglin enabled auto-merge (squash) August 11, 2026 03:05
@Andy-Jost

Copy link
Copy Markdown
Contributor

The two cancelled tests appear to be a real deadlock or other hang.

…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.
…ervations

The largest free range alone does not predict whether both driver pools fit:
what matters is how many pool-sized reservations the free holes can hold between
them, since a reservation must fit inside one hole but a hole twice the size
takes two. Report that count on every run, and the hole addresses only when a
reservation is refused, which also shows whether the layout is being randomized.

Windows only, via VirtualQuery in a module imported only on win32; the section
is omitted elsewhere. The report is now printed once, from the terminal summary.
It was there to work out why the reservations sometimes failed. Runs with
bottom-up randomization disabled answered that -- 12 of 12 sessions clean
against 7 of 12 with it on -- so the VirtualQuery walk, the hole-capacity
maths and their tests have served their purpose and go.

Keeps the reservations themselves, the cuMemAddressReserve measurement that
works on both platforms, and the single end-of-run report.
@juenglin
juenglin force-pushed the oom-early-reservation-workaround branch from 2574452 to 2c8b0b1 Compare August 11, 2026 17:13
@juenglin juenglin closed this Aug 13, 2026
auto-merge was automatically disabled August 13, 2026 16:13

Pull request was closed

github-actions Bot pushed a commit that referenced this pull request Aug 14, 2026
Removed preview folders for the following PRs:
- PR #2463
- PR #2474
- PR #2479
- PR #2522
- PR #2551
- PR #2601
- PR #2608
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

3 participants