Skip to content

refactor(cuda.core): give the IPC pool owner's release a named deleter - #3548

Merged
rparolin merged 4 commits into
ipc-readability/1-registry-statesfrom
ipc-readability/2-pool-import
Nov 25, 2026
Merged

rparolin merged 4 commits into
ipc-readability/1-registry-statesfrom
ipc-readability/2-pool-import

Conversation

@rparolin

@rparolin rparolin commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Readability follow-up to #3511. Part 2 of 4 (stack: #3547 → #3548 → #3549 → #3552). No behavior change.

The deleter of an imported IPC pool was a 35-line lambda inside the shared_ptr constructor. It is now named steps, read top to bottom:

  • delete_ipc_pool_box(): the deleter. Releases only if the box owns_pool().
  • release_owned_ipc_pool(): revoke access, destroy imports, wake waiting importers, then report.
  • destroy_imports() / report_failed_destroys(): the loop and the failure report.

imports > 0 is now owns_pool(). Same driver calls in the same order. ipc_pool_registry moved up so the deleter can see it.

Testing

  • Top of the stack: the full cuda_core test suite passes on an RTX 5880 Ada (cu13), except test_object_code_load_rdc*, which cannot build its fixture on my machine (system nvcc rejects the environment's gcc).
  • clang-tidy clean, pre-commit clean.
  • No new tests: the existing tests cover this path.

PLC Local Security Evidence (Advisory)

Local advisory checks only, run over the whole stack. Not release-gate results.

Check Status Tool Details
Secrets SKIP Pulse Secret Scanner registry login failed locally; the repo trufflehog pre-commit hook passed
SAST PASS Semgrep 0 findings (local advisory)
Dependencies N/A - no manifests or lockfiles changed
License N/A - no dependencies changed
Container N/A - no container changed

Checklist

  • I have read the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

🤖 Generated with Claude Code

The deleter of an imported pool was a 35-line lambda inside the
shared_ptr constructor. Split it into named steps: destroy_imports(),
report_failed_destroys(), release_owned_ipc_pool() and the deleter
delete_ipc_pool_box(). "imports > 0" becomes owns_pool().

Same driver calls in the same order. No behavior change.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Rob Parolin <rparolin@nvidia.com>
@rparolin
rparolin added this pull request to stack #3550 November 24, 2026 16:14
@copy-pr-bot

copy-pr-bot Bot commented Nov 24, 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 Nov 24, 2026
@rparolin rparolin added this to the cuda.core 1.4.0 milestone Nov 24, 2026
@rparolin rparolin self-assigned this Nov 24, 2026
@rparolin
rparolin marked this pull request as ready for review November 24, 2026 16:28
…/2-pool-import

Signed-off-by: Rob Parolin <rparolin@nvidia.com>
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between cd6579f and 9ed2aed.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Improved cleanup of shared CUDA memory pools when they are imported by multiple processes. Cleanup now releases registered pool state even if destroying an import fails, and reports the first failure afterward.
    • Corrected ownership tracking for imported pools.

IPC pool cleanup now runs only for owning boxes. The release path attempts destruction for every driver import, tracks failures, updates the live-owned count, releases the registry entry, and reports the first destroy failure afterward. The import path uses a named box deleter and records whether it became owner.

Changes: IPC pool ownership and cleanup

Layer / File(s) Summary
Ownership detection and deleter wiring
cuda_core/cuda/core/_cpp/rt/memory.cpp
IPC pool boxes expose an ownership check. The import path uses a named deleter and records whether the imported handle became the owner.
Owner cleanup and failure handling
cuda_core/cuda/core/_cpp/rt/memory.cpp
The cleanup path attempts to destroy every driver import, decrements the live-owned count, releases the registry entry, and reports the first destroy failure.

Possibly related PRs

  • NVIDIA/cuda-python#3511: Introduced shared ownership for repeat IPC pool imports and the release behavior that this change refactors.

Suggested reviewers: juenglin, andy-jost, rwgk

Change: Refactor

Merge Risk: Minimal · previous review a1bba

This is a readability refactor of the imported IPC pool's release path, and no behavior change was found. No concrete merge-blocking risk remains. The existing IPC tests cover the release path.

Security architecture risk: Minimal · up to a1bba

The refactor preserves who can import a GPU memory pool, which owner cleans it up, and when waiting importers can proceed. No new or worsened risk was identified in the changed path.

Finishing Touches

Fix failing CI checks

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 5224ba6 and a1bba26.

Files selected for processing: 1

  • cuda_core/cuda/core/_cpp/rt/memory.cpp

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.

…/2-pool-import

Signed-off-by: Rob Parolin <rparolin@nvidia.com>
@rparolin rparolin added the enhancement Any code-related improvements label Nov 24, 2026
…/2-pool-import

Signed-off-by: Rob Parolin <rparolin@nvidia.com>
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor
Doc Preview CI
Preview removed because the pull request was closed or merged.

@juenglin juenglin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice!

@rparolin
rparolin merged commit c55e8ba into main Nov 25, 2026
128 of 131 checks passed
@rparolin
rparolin deleted the ipc-readability/2-pool-import branch November 25, 2026 22:33
github-actions Bot pushed a commit that referenced this pull request Nov 26, 2026
Removed preview folders for the following PRs:
- PR #3521
- PR #3526
- PR #3547
- PR #3548
- PR #3549
- PR #3552
- PR #3589
- PR #3590
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 enhancement Any code-related improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants