Skip to content

fix(cuda.core): clear peer access on recycled pools - #2859

Open
aryanputta wants to merge 1 commit into
NVIDIA:mainfrom
aryanputta:fix/mempool-peer-access-2807
Open

aryanputta wants to merge 1 commit into
NVIDIA:mainfrom
aryanputta:fix/mempool-peer-access-2807

Conversation

@aryanputta

Copy link
Copy Markdown
Contributor

Fixes #2807

Summary

Clear peer access from an owned memory pool before destroying it without including the pool's owning device in the cuMemPoolSetAccess descriptor list.

CUDA rejects a batch that contains the owning device with CUDA_ERROR_INVALID_DEVICE. Because the call's return value was ignored, peer access could remain on a recycled pool handle and affect the next pool that received the same handle. The cleanup call now excludes the owner and uses the existing warning-on-failure wrapper so cleanup failures are visible.

Validation

  • Added two-device regression coverage for recycled owned pools.
  • Kept the cleanup path noexcept and best effort.
  • Used C++17-compatible descriptor initialization.
  • Full CUDA integration coverage requires an NVIDIA runner.

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 Sep 14, 2026

Copy link
Copy Markdown
Contributor

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

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 Sep 14, 2026
@aryanputta
aryanputta force-pushed the fix/mempool-peer-access-2807 branch from 44eac39 to 47fca25 Compare September 14, 2026 22:58

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 44eac392c7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

return {};
}
return wrap_mempool_owned(pool);
return wrap_mempool_owned(pool, -1);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve the owner when wrapping imported device pools

On a multi-GPU host, closing an IPC-imported DeviceMemoryResource passes -1 here, so clear_mempool_peer_access excludes no ordinal and includes the pool's owning device in the descriptor batch. CUDA rejects that entire batch, causing the new warning wrapper to write an error during normal teardown while leaving peer access uncleared for a recycled handle. DeviceMemoryResource.from_allocation_handle already receives the associated device ID, so the import path needs to preserve it for device-backed pools.

Useful? React with 👍 / 👎.

assert DMR_mempool_get_access(mr, peer.device_id) == ""


def test_owned_mempool_recycled_peer_access_is_cleared(mempool_device_x2):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Mark the new test as agent-authored

This Codex-authored test is added without the required provenance decorator. Add @pytest.mark.agent_authored(model="gpt-5.6-sol") immediately above the function so authorship-based test selection and later review-state updates remain reliable.

AGENTS.md reference: AGENTS.md:L122-L131

Useful? React with 👍 / 👎.

Fixes NVIDIA#2807

Signed-off-by: Aryan Putta <aryansputta@gmail.com>
@aryanputta
aryanputta force-pushed the fix/mempool-peer-access-2807 branch from c103103 to 52d973e Compare September 14, 2026 23:10
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

clear_mempool_peer_access() never takes effect: nvbug 5698116 workaround has been a no-op since #1368

1 participant