cuda.core: add graph definition node updates#2395
Conversation
|
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. |
|
/ok to test |
|
4ce2862 to
fffa9fd
Compare
mdboom
left a comment
There was a problem hiding this comment.
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).
| 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: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Good suggestion. I think kw-only is the better option here.
3ba7dda to
6bafe1a
Compare
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.
6bafe1a to
84bcfab
Compare
|
/ok to test |
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 andcuda.bindingsversions 12.2 or newer.Changes
update()methods forKernelNode,MemcpyNode,MemsetNode,ChildGraphNode,EventRecordNode,EventWaitNode, andHostCallbackNode.args=()for a no-argument kernel.Review guide
cuda_core/cuda/core/graph/_subclasses.pyxand_subclasses.pyifor the public update signatures and node-specific parameter construction._set_definition_node_paramsfor the common CUDA 12.2 gate and attachment transaction ordering.resource_handles.cpp/.hppfor staged child-hierarchy metadata replacement and shared clone/rekey primitives.test_graph_node_update.pyfor old-versus-new executable behavior and failure preservation, thentest_graph_definition_lifetime.pyfor child-view invalidation and attachment lifetime coverage.Related Work