Skip to content

cuda.core: add graph definition node updates#2395

Draft
Andy-Jost wants to merge 12 commits into
NVIDIA:mainfrom
Andy-Jost:graph-definition-node-updates
Draft

cuda.core: add graph definition node updates#2395
Andy-Jost wants to merge 12 commits into
NVIDIA:mainfrom
Andy-Jost:graph-definition-node-updates

Conversation

@Andy-Jost

@Andy-Jost Andy-Jost commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Add subclass-specific update() methods for mutable graph definition nodes. The new API supports kernel, memcpy, memset, child-graph, event-record, event-wait, and host-callback nodes while leaving inspection properties read-only.

Updates replace one complete CUDA parameter structure through cuGraphNodeSetParams. Optional keyword arguments preserve existing values where coherent, coupled values such as kernels and arguments are replaced together, and existing executable graphs continue using their previous parameters and retained resources. This feature requires CUDA driver and cuda.bindings versions 12.2 or newer.

Changes

  • Add a shared graph-definition node update path with version checks, zero-initialized generic parameters, and failure-aware attachment prepare/commit handling.
  • Add update() methods for KernelNode, MemcpyNode, MemsetNode, ChildGraphNode, EventRecordNode, EventWaitNode, and HostCallbackNode.
  • Make partial kernel, memcpy, and memset updates keyword-only; changing a kernel requires explicitly supplying its arguments, including args=() for a no-argument kernel.
  • Preserve or replace retained kernels, arguments, buffers, explicit pointer owners, events, callbacks, and user data in step with the corresponding CUDA parameter update.
  • Stage, rekey, and publish replacement child-graph hierarchy metadata while invalidating views backed by the old embedded clone.
  • Add extensible parameterized behavior/failure tests, focused child-hierarchy lifetime tests, public API documentation, and release notes.

Review guide

  1. Review cuda_core/cuda/core/graph/_subclasses.pyx and _subclasses.pyi for the public update signatures and node-specific parameter construction.
  2. Review _set_definition_node_params for the common CUDA 12.2 gate and attachment transaction ordering.
  3. Review resource_handles.cpp/.hpp for staged child-hierarchy metadata replacement and shared clone/rekey primitives.
  4. Review test_graph_node_update.py for old-versus-new executable behavior and failure preservation, then test_graph_definition_lifetime.py for child-view invalidation and attachment lifetime coverage.

Related Work

@Andy-Jost Andy-Jost added this to the cuda.core 1.2.0 milestone Jul 20, 2026
@Andy-Jost Andy-Jost added P0 High priority - Must do! feature New feature or request cuda.core Everything related to the cuda.core module labels Jul 20, 2026
@Andy-Jost Andy-Jost self-assigned this Jul 20, 2026
@copy-pr-bot

copy-pr-bot Bot commented Jul 20, 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.

@Andy-Jost

Copy link
Copy Markdown
Contributor Author

/ok to test

@github-actions

Copy link
Copy Markdown

@Andy-Jost
Andy-Jost force-pushed the graph-definition-node-updates branch from 4ce2862 to fffa9fd Compare July 22, 2026 23:04

@mdboom mdboom 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.

The general organization and approach looks fine to me.

One small suggestion (that I can't really evaluate because I don't deeply understand the use cases).

Comment on lines +388 to +397
def update(
self,
dst: Buffer | int | None = None,
value=None,
width: int | None = None,
height: int | None = None,
pitch: int | None = None,
*,
dst_owner=None,
) -> None:

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.

One minor point (which really hinges on how we expect these update methods to be used).

If the idea is that users will most often be updating a subset of these values, it might be clearer to make them all kwarg only (i.e. put the *, at the beginning).

It's a minor point, but something we won't be able to change after the API freezes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good suggestion. I think kw-only is the better option here.

@Andy-Jost
Andy-Jost force-pushed the graph-definition-node-updates branch from 3ba7dda to 6bafe1a Compare July 23, 2026 22:04
Andy-Jost added 12 commits July 23, 2026 15:21
Use the generic node setter with failure-atomic attachment replacement, establishing the shared path for definition-level parameter mutation.
Extend definition-level mutation to event waits and both Python and ctypes host callbacks while preserving old executable state and attachment ownership.
Report unsupported driver or binding versions before preparing mutation attachments or calling the generic node setter.
Allow partial memset parameter replacement while preserving graph-owned destination lifetimes and previously instantiated graph behavior.
Support partial copy parameter replacement while preserving independent source and destination ownership across graph instantiations.
Support independent launch configuration and argument replacement while requiring explicit arguments when changing kernels.
Replace embedded child hierarchies while preserving attachment metadata, invalidating stale views, and keeping existing executables independent.
Describe supported mutation methods, CUDA 12.2 requirements, and executable graph behavior in the API and release notes.
Use type-erased shared ownership for prepared child updates so extension loading does not depend on a hidden C++ deleter symbol.
Reflect shared ownership for the opaque child update transaction in the generated stub.
Make memcpy and memset mutation calls explicit and unambiguous before the public API freezes.
@Andy-Jost
Andy-Jost force-pushed the graph-definition-node-updates branch from 6bafe1a to 84bcfab Compare July 23, 2026 22:22
@Andy-Jost

Copy link
Copy Markdown
Contributor Author

/ok to test

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 feature New feature or request P0 High priority - Must do!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cuda.core: add atomic update methods for graph definition nodes

2 participants