cuda.core: Add conditional retry when default mempool reservation fails with OOM - #2474
Draft
juenglin wants to merge 4 commits into
Draft
cuda.core: Add conditional retry when default mempool reservation fails with OOM#2474juenglin wants to merge 4 commits into
juenglin wants to merge 4 commits into
Conversation
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. |
Contributor
Author
|
/ok to test |
|
Contributor
Author
|
/ok to test |
Contributor
Author
|
/ok to test |
Contributor
Author
|
/ok to test |
Contributor
Author
|
/ok to test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses #2381
Device.memory_resourcecould fail withCUDA_ERROR_OUT_OF_MEMORYon a device withample free memory. A memory pool's virtual address reservation is only returned when
the pool is torn down, and
cuMemPoolDestroywaits on the stream-orderedcuMemFreeAsynccalls for the pool's outstanding allocations. While those frees sitqueued behind unfinished work, the address space is recoverable but not yet
recovered — enough to fail the next pool lookup wherever address space is scarce.
get_device_mempoolnow drains the context once and retries:CUDA_ERROR_OUT_OF_MEMORY; every other status returns unchanged.cuCtxSynchronizea single thread-local error slot, so reporting the drain's failure instead would
misattribute why the pool was unavailable.
Scope and cost
get_device_mempooltakes adevice_id. When that device is not current, the retryretires unrelated work and will not recover the target pool. It then falls back to
reporting the original OOM, so this is a missed recovery rather than a wrong result.
it exists the lookup cannot fail. A retry that succeeds therefore costs one
synchronize per device per process, not one per allocation. A retry that fails can
recur, so a run that stays exhausted pays one drain per attempt — cheap on an idle
GPU, but not free.
cuMemPoolCreate(used bypinned, managed, and options-based resources) and
cuGraphAddMemAllocNodecan failthe same way and are unchanged.
Testing
cuda_core/tests/test_mempool_oom_retry.pyreproduces the failure and verifies recoveryin a single run: it exhausts the address space, blocks the deallocation stream on an
event behind a slow kernel, drops the pools, asserts the un-retried lookup still fails,
then asserts the retried one succeeds and actually blocked. It runs in a spawned child
process because the default pool is created lazily — once it exists the lookup cannot
fail, so a process that already touched it could not reproduce this. Confirmed to fail
against
mainfor the right reason. It skips on machines whose address space is toolarge to exhaust.
Checklist