Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
dc92437
Reorganize graph test files for clarity
Andy-Jost Mar 31, 2026
281ed82
Enhance Graph.update() and add whole-graph update tests
Andy-Jost Mar 31, 2026
7854b76
Add AdjacencySet proxy for pred/succ and GraphNode.remove()
Andy-Jost Mar 31, 2026
5fbd288
Add edge mutation support and MutableSet interface for GraphNode adja…
Andy-Jost Apr 2, 2026
aa84e26
Use requires_module mark for numpy version checks in mutation tests
Andy-Jost Apr 2, 2026
b27dd93
Fix empty-graph return type: return set() instead of () for nodes/edges
Andy-Jost Apr 2, 2026
8554d30
Rename AdjacencySet to AdjacencySetProxy, add bulk ops and safety guards
Andy-Jost Apr 2, 2026
9813c20
Add destroy() method with handle invalidation, remove GRAPH_NODE_SENT…
Andy-Jost Apr 2, 2026
6411881
Add GraphNode identity cache for stable Python object round-trips
Andy-Jost Apr 2, 2026
7a3dbb4
Purge node cache on destroy to prevent stale identity lookups
Andy-Jost Apr 2, 2026
cc81e99
Make graph API public: rename _graph to cuda.core.graph
Andy-Jost Apr 2, 2026
fc6b98b
Add 0.7.x release notes for GraphDef and cuda.core.graph module
Andy-Jost Apr 2, 2026
91b3b4e
Skip NULL nodes in graph_node_registry to fix sentinel identity colli…
Andy-Jost Apr 2, 2026
1b7743d
Unregister destroyed nodes from C++ graph_node_registry
Andy-Jost Apr 3, 2026
84f0b30
Add dedicated test for node identity preservation through round-trips
Andy-Jost Apr 3, 2026
64d6c2d
Merge branch 'main' into graph-node-identity
Andy-Jost Apr 3, 2026
d538fd1
Merge branch 'graph-node-identity' into graph-public-api
Andy-Jost Apr 3, 2026
47276b4
Add API docs for cuda.core.graph and fix stale docstring references
Andy-Jost Apr 3, 2026
6b36e47
Add handle= to all GraphNode subclass __repr__ for debugging
Andy-Jost Apr 3, 2026
a40be9a
Merge branch 'main' into graph-node-identity
Andy-Jost Apr 3, 2026
729af49
Rename _node_cache/_cached to _node_registry/_registered
Andy-Jost Apr 3, 2026
42131b6
Fix unregister_handle and rename invalidate_graph_node_handle
Andy-Jost Apr 3, 2026
9766e54
Merge branch 'graph-node-identity' into graph-node-repr
Andy-Jost Apr 3, 2026
15d0036
Add cheap containment test and early type check for AdjacencySetProxy
Andy-Jost Apr 3, 2026
347693f
Add GraphDef.empty(), stack-buffer query optimization, and registry test
Andy-Jost Apr 3, 2026
641a089
Document the two-level handle and object registry design
Andy-Jost Apr 3, 2026
8370687
Fix import formatting in test_registry_cleanup
Andy-Jost Apr 3, 2026
36527da
Merge origin/main into graph-node-repr
Andy-Jost Apr 3, 2026
f779f30
Optimize GraphDef.nodes() and edges() to try a single driver call
Andy-Jost Apr 3, 2026
aec93bf
Merge branch 'graph-node-repr' into graph-public-api
Andy-Jost Apr 3, 2026
22a3724
Update docstrings, api.rst structure, and release notes
Andy-Jost Apr 4, 2026
f3704be
Merge origin/main into graph-public-api
Andy-Jost Apr 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions cuda_core/cuda/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0

Expand Down Expand Up @@ -31,12 +31,6 @@
from cuda.core import system, utils
from cuda.core._device import Device
from cuda.core._event import Event, EventOptions
from cuda.core._graph import (
Graph,
GraphBuilder,
GraphCompleteOptions,
GraphDebugPrintOptions,
)
from cuda.core._graphics import GraphicsResource
from cuda.core._launch_config import LaunchConfig
from cuda.core._launcher import launch
Expand Down Expand Up @@ -69,3 +63,12 @@
StreamOptions,
)
from cuda.core._tensor_map import TensorMapDescriptor, TensorMapDescriptorOptions
from cuda.core.graph import (
Condition,
Graph,
GraphAllocOptions,
GraphBuilder,
GraphCompleteOptions,
GraphDebugPrintOptions,
GraphDef,
)
11 changes: 6 additions & 5 deletions cuda_core/cuda/core/_device.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0

Expand All @@ -24,7 +24,6 @@ from cuda.core._resource_handles cimport (
as_cu,
)

from cuda.core._graph import GraphBuilder
from cuda.core._stream import IsStreamT, Stream, StreamOptions
from cuda.core._utils.clear_error_support import assert_type
from cuda.core._utils.cuda_utils import (
Expand Down Expand Up @@ -1363,15 +1362,17 @@ class Device:
self._check_context_initialized()
handle_return(runtime.cudaDeviceSynchronize())

def create_graph_builder(self) -> GraphBuilder:
"""Create a new :obj:`~_graph.GraphBuilder` object.
def create_graph_builder(self) -> "GraphBuilder":
"""Create a new :obj:`~graph.GraphBuilder` object.

Returns
-------
:obj:`~_graph.GraphBuilder`
:obj:`~graph.GraphBuilder`
Newly created graph builder object.

"""
from cuda.core.graph._graph_builder import GraphBuilder

self._check_context_initialized()
return GraphBuilder._init(stream=self.create_stream(), is_stream_owner=True)

Expand Down
19 changes: 0 additions & 19 deletions cuda_core/cuda/core/_graph/__init__.py

This file was deleted.

51 changes: 0 additions & 51 deletions cuda_core/cuda/core/_graph/_graph_def/__init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion cuda_core/cuda/core/_launcher.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def launch(stream: Stream | GraphBuilder | IsStreamT, config: LaunchConfig, kern
Parameters
----------
stream : :obj:`~_stream.Stream` | :obj:`~_graph.GraphBuilder`
stream : :obj:`~_stream.Stream` | :obj:`~graph.GraphBuilder`
The stream establishing the stream ordering semantic of a
launch.
config : :obj:`LaunchConfig`
Expand Down
12 changes: 6 additions & 6 deletions cuda_core/cuda/core/_memory/_buffer.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ cdef class Buffer:

Parameters
----------
stream : :obj:`~_stream.Stream` | :obj:`~_graph.GraphBuilder`, optional
stream : :obj:`~_stream.Stream` | :obj:`~graph.GraphBuilder`, optional
The stream object to use for asynchronous deallocation. If None,
the deallocation stream stored in the handle is used.
"""
Expand All @@ -206,7 +206,7 @@ cdef class Buffer:
----------
dst : :obj:`~_memory.Buffer`
Source buffer to copy data from
stream : :obj:`~_stream.Stream` | :obj:`~_graph.GraphBuilder`
stream : :obj:`~_stream.Stream` | :obj:`~graph.GraphBuilder`
Keyword argument specifying the stream for the
asynchronous copy

Expand Down Expand Up @@ -237,7 +237,7 @@ cdef class Buffer:
----------
src : :obj:`~_memory.Buffer`
Source buffer to copy data from
stream : :obj:`~_stream.Stream` | :obj:`~_graph.GraphBuilder`
stream : :obj:`~_stream.Stream` | :obj:`~graph.GraphBuilder`
Keyword argument specifying the stream for the
asynchronous copy

Expand All @@ -262,7 +262,7 @@ cdef class Buffer:
value : int | :obj:`collections.abc.Buffer`
- int: Must be in range [0, 256). Converted to 1 byte.
- :obj:`collections.abc.Buffer`: Must be 1, 2, or 4 bytes.
stream : :obj:`~_stream.Stream` | :obj:`~_graph.GraphBuilder`
stream : :obj:`~_stream.Stream` | :obj:`~graph.GraphBuilder`
Stream for the asynchronous fill operation.

Raises
Expand Down Expand Up @@ -496,7 +496,7 @@ cdef class MemoryResource:
----------
size : int
The size of the buffer to allocate, in bytes.
stream : :obj:`~_stream.Stream` | :obj:`~_graph.GraphBuilder`, optional
stream : :obj:`~_stream.Stream` | :obj:`~graph.GraphBuilder`, optional
The stream on which to perform the allocation asynchronously.
If None, it is up to each memory resource implementation to decide
and document the behavior.
Expand All @@ -518,7 +518,7 @@ cdef class MemoryResource:
The pointer or handle to the buffer to deallocate.
size : int
The size of the buffer to deallocate, in bytes.
stream : :obj:`~_stream.Stream` | :obj:`~_graph.GraphBuilder`, optional
stream : :obj:`~_stream.Stream` | :obj:`~graph.GraphBuilder`, optional
The stream on which to perform the deallocation asynchronously.
If None, it is up to each memory resource implementation to decide
and document the behavior.
Expand Down
4 changes: 2 additions & 2 deletions cuda_core/cuda/core/_memory/_memory_pool.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ cdef class _MemPool(MemoryResource):
----------
size : int
The size of the buffer to allocate, in bytes.
stream : :obj:`~_stream.Stream` | :obj:`~_graph.GraphBuilder`, optional
stream : :obj:`~_stream.Stream` | :obj:`~graph.GraphBuilder`, optional
The stream on which to perform the allocation asynchronously.
If None, an internal stream is used.

Expand All @@ -153,7 +153,7 @@ cdef class _MemPool(MemoryResource):
The pointer or handle to the buffer to deallocate.
size : int
The size of the buffer to deallocate, in bytes.
stream : :obj:`~_stream.Stream` | :obj:`~_graph.GraphBuilder`, optional
stream : :obj:`~_stream.Stream` | :obj:`~graph.GraphBuilder`, optional
The stream on which to perform the deallocation asynchronously.
If the buffer is deallocated without an explicit stream, the allocation stream
is used.
Expand Down
11 changes: 7 additions & 4 deletions cuda_core/cuda/core/_stream.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ from cuda.core._resource_handles cimport (
as_py,
)

from cuda.core._graph import GraphBuilder


@dataclass
Expand Down Expand Up @@ -354,17 +353,19 @@ cdef class Stream:

return Stream._init(obj=_stream_holder())

def create_graph_builder(self) -> GraphBuilder:
"""Create a new :obj:`~_graph.GraphBuilder` object.
def create_graph_builder(self) -> "GraphBuilder":
"""Create a new :obj:`~graph.GraphBuilder` object.

The new graph builder will be associated with this stream.

Returns
-------
:obj:`~_graph.GraphBuilder`
:obj:`~graph.GraphBuilder`
Newly created graph builder object.

"""
from cuda.core.graph._graph_builder import GraphBuilder

return GraphBuilder._init(stream=self, is_stream_owner=False)


Expand Down Expand Up @@ -466,6 +467,8 @@ cdef cydriver.CUstream _handle_from_stream_protocol(obj) except*:
# Helper for API functions that accept either Stream or GraphBuilder. Performs
# needed checks and returns the relevant stream.
cdef Stream Stream_accept(arg, bint allow_stream_protocol=False):
from cuda.core.graph._graph_builder import GraphBuilder

if isinstance(arg, Stream):
return <Stream>(arg)
elif isinstance(arg, GraphBuilder):
Expand Down
14 changes: 7 additions & 7 deletions cuda_core/cuda/core/experimental/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0

Expand Down Expand Up @@ -46,12 +46,6 @@ def _warn_deprecated():

from cuda.core._device import Device
from cuda.core._event import Event, EventOptions
from cuda.core._graph import (
Graph,
GraphBuilder,
GraphCompleteOptions,
GraphDebugPrintOptions,
)
from cuda.core._launch_config import LaunchConfig
from cuda.core._launcher import launch
from cuda.core._layout import _StridedLayout
Expand All @@ -73,3 +67,9 @@ def _warn_deprecated():
from cuda.core._module import Kernel, ObjectCode
from cuda.core._program import Program, ProgramOptions
from cuda.core._stream import Stream, StreamOptions
from cuda.core.graph import (
Graph,
GraphBuilder,
GraphCompleteOptions,
GraphDebugPrintOptions,
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#
# SPDX-License-Identifier: Apache-2.0

from cuda.core._graph._graph_def._graph_def cimport Condition, GraphDef
from cuda.core._graph._graph_def._graph_node cimport GraphNode
from cuda.core._graph._graph_def._subclasses cimport (
from cuda.core.graph._graph_def cimport Condition, GraphDef
from cuda.core.graph._graph_node cimport GraphNode
from cuda.core.graph._subclasses cimport (
AllocNode,
ChildGraphNode,
ConditionalNode,
Expand Down
33 changes: 33 additions & 0 deletions cuda_core/cuda/core/graph/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0

from cuda.core.graph._graph_builder import (
Graph,
GraphBuilder,
GraphCompleteOptions,
GraphDebugPrintOptions,
)
from cuda.core.graph._graph_def import (
Condition,
GraphAllocOptions,
GraphDef,
)
from cuda.core.graph._graph_node import GraphNode
from cuda.core.graph._subclasses import (
AllocNode,
ChildGraphNode,
ConditionalNode,
EmptyNode,
EventRecordNode,
EventWaitNode,
FreeNode,
HostCallbackNode,
IfElseNode,
IfNode,
KernelNode,
MemcpyNode,
MemsetNode,
SwitchNode,
WhileNode,
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from libc.stddef cimport size_t
from libcpp.vector cimport vector
from cuda.bindings cimport cydriver
from cuda.core._graph._graph_def._graph_node cimport GraphNode
from cuda.core.graph._graph_node cimport GraphNode
from cuda.core._resource_handles cimport (
GraphHandle,
GraphNodeHandle,
Expand Down
Loading
Loading