cuda.core: retain graph attachments with per-node user objects#2357
Draft
Andy-Jost wants to merge 14 commits into
Draft
cuda.core: retain graph attachments with per-node user objects#2357Andy-Jost wants to merge 14 commits into
Andy-Jost wants to merge 14 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. |
d95680d to
d7e8d3e
Compare
Contributor
Author
|
/ok to test |
d7e8d3e to
945672d
Compare
|
Contributor
Author
|
/ok to test |
1d399c7 to
a8a5879
Compare
Give each resource-bearing graph node an immutable CUDA user object so clones and executable graphs no longer share mutable attachment ownership. Prepare bundles before node creation and share non-owning metadata across child and conditional graph views.
Destroy the CUDA node before invalidating Python/C++ handles, then release only the source graph's attachment reference. Existing execs retain deleted-node owners while failed graph-memory deletions preserve the node and its metadata.
Store the non-standard-layout transaction box behind an opaque shared value instead of recovering it with offsetof. This removes the compiler warning while preserving rollback ownership.
Exercise clone, child-view, whole-update, and two-owner bundle behavior under per-node user objects. Also clean up raw graph handles in existing lifetime tests and update slot-table terminology.
Document the per-node CUDA user-object model, hierarchy-wide metadata, transaction lifecycle, struct responsibilities, and correctness invariants alongside the implementation.
Keep rollback ownership single-valued across allocation failures, make post-destroy metadata purging allocation-free, and clarify graph hierarchy synchronization.
Represent empty ownership as a tombstone transaction so successful node updates can release obsolete graph references without installing a replacement user object.
Remap managed attachment records into internal child-graph clones so deleting cloned nodes releases their graph-owned references without waiting for the entire parent graph to die.
Document why queue initialization is serialized and why pending-call scheduling may need a later retry.
Exercise subgraph deletion, in-flight launches, failed transactions, and independent executable references so attachment lifetime guarantees remain regression-tested.
a8a5879 to
c3fce2c
Compare
Keep each CUDA user object and its owners in one payload, and make prepared attachment handles own their transaction state directly.
Set a current device explicitly so the isolated probe remains valid on drivers that require a context for graph creation.
Keep the resource-handle guide focused on the general handle pattern and document deferred user-object cleanup with the graph attachment lifecycle.
Make graph attachments intrusive cleanup items so CUDA callbacks can queue each payload directly without a separate envelope allocation.
807cac8 to
6d7ae74
Compare
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.
Summary
Fix the graph attachment lifetime problem described in #2350. Replace the mutable graph-wide attachment table with one immutable CUDA user object per resource-bearing node. This lets CUDA propagate each node's owners independently to graph clones and executable graphs, preventing source-graph mutation or node-handle reuse from invalidating existing executions.
Changes
Review guide
Suggested review order:
GRAPH_ATTACHMENTS.md, then reviewresource_handles.cpp/.hpp. Focus on transactional prepare/commit/abandon, non-owning metadata, node deletion, updates, and graph hierarchy ownership._resource_handles.*andgraph/*.pyx. Each resource-bearing operation should prepare ownership before the driver call, commit only after success, and preserve prior ownership on failure.Most remaining changes are mechanical wiring, tests, or documentation around that ownership state machine.
Related Work