Skip to content

Add check and agent guidance about uncapped mempools - #2514

Open
juenglin wants to merge 2 commits into
NVIDIA:mainfrom
juenglin:more-oom-mitigations
Open

Add check and agent guidance about uncapped mempools#2514
juenglin wants to merge 2 commits into
NVIDIA:mainfrom
juenglin:more-oom-mitigations

Conversation

@juenglin

@juenglin juenglin commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #2484, which right-sized seven memory pools that reserved an
address-space window scaling with device memory while holding at most 1 KiB.
This PR adds the guidance and the automated check to keep new pools from
reintroducing the problem.

cuda_core/tests/AGENTS.md (new) documents the rule: a pool created without
max_size reserves roughly 1x device memory of address space regardless of
what the test allocates, and the whole suite shares one process, so those
reservations accumulate. It also spells out a distinction that is easy to get
backwards: DeviceMemoryResource(dev) with no options does not create a
pool — it wraps the device's default mempool and costs nothing — so adding
max_size to such a call converts a free wrapper into a new pool and makes
things worse. Managed pools are documented as exempt, since cuMemPoolCreate
requires maxSize == 0 for them.

A new pre-commit check check_mempool_hygiene enforces it. It statically parses
every .py under tests/ and fails on DeviceMemoryResourceOptions /
PinnedMemoryResourceOptions constructions that omit max_size, including the
dict-literal options form. The check is static rather than runtime so it also
covers pools in tests that skip on the current platform. Deliberate exceptions
opt out with a # uncapped-pool-ok: <reason> comment.

Applying the check surfaced three call sites, all in test_memory.py and all
inside pytest.raises where validation rejects the arguments before a pool is
created; those are annotated. test_multiprocessing_warning.py was hardcoding
2097152 in four places and now uses the suite-standard POOL_SIZE constant.
No production code changes; test-suite hygiene only.

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 5, 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.

@github-actions github-actions Bot added the cuda.core Everything related to the cuda.core module label Aug 5, 2026
@juenglin juenglin added P1 Medium priority - Should do test Improvements or additions to tests labels Aug 5, 2026
@juenglin juenglin self-assigned this Aug 5, 2026
@juenglin juenglin added this to the cuda.core 1.2.0 milestone Aug 5, 2026
@juenglin

juenglin commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

Comment thread cuda_core/tests/AGENTS.md Outdated
Comment thread cuda_core/tests/AGENTS.md Outdated
Comment thread ci/tools/check_mempool_hygiene.py
Review feedback on NVIDIA#2514:
- Move the uncapped-pool check out of the live test suite into a
  check-mempool-hygiene pre-commit hook. The rule is about source text and
  needs no GPU, so a hook catches it earlier and for free. Its tests move to
  ci/tools/tests, alongside the other check scripts'.
- Add helpers/constants.py and route the eleven ad-hoc POOL_SIZE definitions
  through it.
- Qualify "device memory" as installed/physical where the doc explains what an
  uncapped pool reserves.
@github-actions github-actions Bot added the CI/CD CI/CD infrastructure label Aug 5, 2026
@juenglin

juenglin commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test

@juenglin
juenglin marked this pull request as ready for review August 5, 2026 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI/CD CI/CD infrastructure cuda.core Everything related to the cuda.core module P1 Medium priority - Should do test Improvements or additions to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants