Skip to content

refactor(cuda.core): untangle the cached IPC pointer import - #3549

Merged
rparolin merged 5 commits into
ipc-readability/2-pool-importfrom
ipc-readability/3-pointer-import
Nov 25, 2026
Merged

rparolin merged 5 commits into
ipc-readability/2-pool-importfrom
ipc-readability/3-pointer-import

Conversation

@rparolin

@rparolin rparolin commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Description

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

In deviceptr_import_ipc(), the cache's factory lambda wrote two loose outer variables that a third lambda reported from later, and the discard was written twice.

  • DiscardedIpcImport: one value for a failed discard. Made under the cache's mutex with the raw p_ call, reported after the mutex is released.
  • DeleteIpcPtrBox: the box's deleter, named, in place of a lambda in the constructor call.
  • resource != 0 is now holds_import().

Same driver calls under the same lock. The raw p_ calls keep their // raw: marks, which tests/test_rt_layout.py checks.

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 cache's factory lambda wrote two loose outer variables that a third
lambda later reported from, and the discard was written twice. A failed
discard is now one value, DiscardedIpcImport, made under the cache's
mutex and reported after it. The box's deleter is the named
DeleteIpcPtrBox, and "resource != 0" becomes holds_import().

Same driver calls under the same lock. 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:25
tests/test_rt_layout.py requires every raw p_ driver call to carry the
mark. The previous commit folded the marks into a block comment.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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 f721c5a and 7aa6964.

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 cached device memory imports when import setup or deallocation-stream recording fails. Cleanup failures are now reported, and unsuccessful imports are discarded before setup continues.
    • Cached imports are released and removed from the registry when their owning resource is destroyed, helping prevent stale cache entries.

The IPC import path adds a dedicated deleter for cached imports. When deallocation-stream setup fails or throws, it discards the import under the cache mutex and reports free failures after releasing the mutex.

Changes: IPC import cleanup

Layer / File(s) Summary
IPC import lifecycle and cleanup
cuda_core/cuda/core/_cpp/rt/memory.cpp
A dedicated deleter frees cached imports and releases their cache entries. If stream recording fails or throws, the import is discarded under the cache mutex, and any free failure is reported after unlocking.

Suggested reviewers: juenglin, andy-jost, mdboom

Change: Refactor

Merge Risk: Minimal · previous review 6d231

This refactor of the IPC import cleanup path is not expected to change behavior. No merge-blocking risks were identified.

Security architecture risk: Minimal · up to 6d231

The refactor preserves who can import CUDA IPC pointers, when the cache takes ownership, and how cleanup failures are handled. No new design-level risk was identified.

- [ ] 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 566ac1f and 6d23190.

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; 9 remain after this review.

…ointer-import

Signed-off-by: Rob Parolin <rparolin@nvidia.com>
…ointer-import

Signed-off-by: Rob Parolin <rparolin@nvidia.com>
@rparolin rparolin added the enhancement Any code-related improvements label Nov 24, 2026
…ointer-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.

@rparolin
rparolin merged commit c82dcdf into main Nov 25, 2026
127 of 129 checks passed
@rparolin
rparolin deleted the ipc-readability/3-pointer-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