Skip to content

Commit 22a3724

Browse files
committed
Update docstrings, api.rst structure, and release notes
- Rename "Memory" section to "Memory management" in api.rst - Add introductory paragraph under "Node types" subsection - Update node docstrings to concise noun phrases - Update graph API class docstrings (GraphBuilder, Graph, etc.) - Revise release notes highlights and new features sections - Fix test_registry_cleanup import path (cuda.core._graph -> cuda.core.graph) Made-with: Cursor
1 parent aec93bf commit 22a3724

File tree

7 files changed

+65
-52
lines changed

7 files changed

+65
-52
lines changed

cuda_core/cuda/core/graph/_graph_builder.pyx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ from cuda.core._utils.cuda_utils import (
2323

2424
@dataclass
2525
class GraphDebugPrintOptions:
26-
"""Customizable options for :obj:`~graph.GraphBuilder.debug_dot_print()`
26+
"""Options for debug_dot_print().
2727
2828
Attributes
2929
----------
@@ -119,7 +119,7 @@ class GraphDebugPrintOptions:
119119

120120
@dataclass
121121
class GraphCompleteOptions:
122-
"""Customizable options for :obj:`~graph.GraphBuilder.complete()`
122+
"""Options for graph instantiation.
123123

124124
Attributes
125125
----------
@@ -182,7 +182,7 @@ def _instantiate_graph(h_graph, options: GraphCompleteOptions | None = None) ->
182182

183183

184184
class GraphBuilder:
185-
"""Represents a graph under construction.
185+
"""A graph under construction by stream capture.
186186
187187
A graph groups a set of CUDA kernels and other CUDA operations together and executes
188188
them with a specified dependency tree. It speeds up the workflow by combining the
@@ -737,7 +737,7 @@ class GraphBuilder:
737737

738738

739739
class Graph:
740-
"""Represents an executable graph.
740+
"""An executable graph.
741741
742742
A graph groups a set of CUDA kernels and other CUDA operations together and executes
743743
them with a specified dependency tree. It speeds up the workflow by combining the

cuda_core/cuda/core/graph/_graph_def.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ from cuda.core._utils.cuda_utils import driver, handle_return
3030

3131

3232
cdef class Condition:
33-
"""Wraps a CUgraphConditionalHandle.
33+
"""A condition variable for conditional graph nodes.
3434
3535
Created by :meth:`GraphDef.create_condition` and passed to
3636
conditional-node builder methods (``if_cond``, ``if_else``,
@@ -92,7 +92,7 @@ class GraphAllocOptions:
9292
9393
9494
cdef class GraphDef:
95-
"""Represents a CUDA graph definition (CUgraph).
95+
"""A graph definition.
9696

9797
A GraphDef is used to construct a graph explicitly by adding nodes
9898
and specifying dependencies. Once construction is complete, call

cuda_core/cuda/core/graph/_graph_node.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ cdef inline GraphNode _registered(GraphNode n):
7373

7474

7575
cdef class GraphNode:
76-
"""Base class for all graph nodes.
76+
"""A node in a graph definition.
7777
7878
Nodes are created by calling builder methods on GraphDef (for
7979
entry-point nodes with no dependencies) or on other Nodes (for

cuda_core/cuda/core/graph/_subclasses.pyx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ cdef bint _check_node_get_params():
4949

5050

5151
cdef class EmptyNode(GraphNode):
52-
"""A synchronization / join node with no operation."""
52+
"""An empty (synchronization) node."""
5353

5454
@staticmethod
5555
cdef EmptyNode _create_impl(GraphNodeHandle h_node):
@@ -247,7 +247,7 @@ cdef class AllocNode(GraphNode):
247247

248248

249249
cdef class FreeNode(GraphNode):
250-
"""A memory free node.
250+
"""A memory deallocation node.
251251
252252
Properties
253253
----------
@@ -283,7 +283,7 @@ cdef class FreeNode(GraphNode):
283283

284284

285285
cdef class MemsetNode(GraphNode):
286-
"""A memory set node.
286+
"""A memset node.
287287
288288
Properties
289289
----------
@@ -364,7 +364,7 @@ cdef class MemsetNode(GraphNode):
364364

365365

366366
cdef class MemcpyNode(GraphNode):
367-
"""A memory copy node.
367+
"""A memcpy node.
368368
369369
Properties
370370
----------
@@ -437,7 +437,7 @@ cdef class MemcpyNode(GraphNode):
437437

438438

439439
cdef class ChildGraphNode(GraphNode):
440-
"""A child graph (sub-graph) node.
440+
"""A child graph node.
441441
442442
Properties
443443
----------
@@ -602,7 +602,7 @@ cdef class HostCallbackNode(GraphNode):
602602

603603

604604
cdef class ConditionalNode(GraphNode):
605-
"""Base class for conditional graph nodes.
605+
"""Base class for conditional nodes.
606606
607607
When created via builder methods (if_cond, if_else, while_loop, switch),
608608
a specific subclass (IfNode, IfElseNode, WhileNode, SwitchNode) is
@@ -707,7 +707,7 @@ cdef class ConditionalNode(GraphNode):
707707

708708

709709
cdef class IfNode(ConditionalNode):
710-
"""An if-conditional node (1 branch, executes when condition is non-zero)."""
710+
"""An if-conditional node."""
711711

712712
def __repr__(self) -> str:
713713
return (f"<IfNode handle=0x{as_intptr(self._h_node):x}"
@@ -720,7 +720,7 @@ cdef class IfNode(ConditionalNode):
720720

721721

722722
cdef class IfElseNode(ConditionalNode):
723-
"""An if-else conditional node (2 branches)."""
723+
"""An if-else conditional node."""
724724

725725
def __repr__(self) -> str:
726726
return (f"<IfElseNode handle=0x{as_intptr(self._h_node):x}"
@@ -738,7 +738,7 @@ cdef class IfElseNode(ConditionalNode):
738738

739739

740740
cdef class WhileNode(ConditionalNode):
741-
"""A while-loop conditional node (1 branch, repeats while condition is non-zero)."""
741+
"""A while-loop conditional node."""
742742

743743
def __repr__(self) -> str:
744744
return (f"<WhileNode handle=0x{as_intptr(self._h_node):x}"
@@ -751,7 +751,7 @@ cdef class WhileNode(ConditionalNode):
751751

752752

753753
cdef class SwitchNode(ConditionalNode):
754-
"""A switch conditional node (N branches, selected by condition value)."""
754+
"""A switch conditional node."""
755755

756756
def __repr__(self) -> str:
757757
return (f"<SwitchNode handle=0x{as_intptr(self._h_node):x}"

cuda_core/docs/source/api.rst

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ be considered stable and will follow semantic versioning with appropriate
1313
deprecation periods for breaking changes.
1414

1515

16-
CUDA runtime
17-
------------
16+
Devices and execution
17+
---------------------
1818

1919
.. autosummary::
2020
:toctree: generated/
@@ -24,26 +24,14 @@ CUDA runtime
2424

2525
:template: autosummary/cyclass.rst
2626

27-
Buffer
2827
Stream
2928
Event
30-
MemoryResource
31-
DeviceMemoryResource
32-
GraphMemoryResource
33-
PinnedMemoryResource
34-
ManagedMemoryResource
35-
LegacyPinnedMemoryResource
36-
VirtualMemoryResource
3729

3830
:template: dataclass.rst
3931

40-
DeviceMemoryResourceOptions
41-
PinnedMemoryResourceOptions
42-
ManagedMemoryResourceOptions
43-
EventOptions
4432
StreamOptions
33+
EventOptions
4534
LaunchConfig
46-
VirtualMemoryResourceOptions
4735

4836
.. data:: LEGACY_DEFAULT_STREAM
4937

@@ -58,9 +46,42 @@ CUDA runtime
5846
on other non-blocking streams.
5947

6048

49+
Memory management
50+
-----------------
51+
52+
.. autosummary::
53+
:toctree: generated/
54+
55+
:template: autosummary/cyclass.rst
56+
57+
Buffer
58+
MemoryResource
59+
DeviceMemoryResource
60+
GraphMemoryResource
61+
PinnedMemoryResource
62+
ManagedMemoryResource
63+
LegacyPinnedMemoryResource
64+
VirtualMemoryResource
65+
66+
:template: dataclass.rst
67+
68+
DeviceMemoryResourceOptions
69+
PinnedMemoryResourceOptions
70+
ManagedMemoryResourceOptions
71+
VirtualMemoryResourceOptions
72+
73+
6174
CUDA graphs
6275
-----------
6376

77+
A CUDA graph captures a set of GPU operations and their dependencies,
78+
allowing them to be defined once and launched repeatedly with minimal
79+
CPU overhead. Graphs can be constructed in two ways:
80+
:class:`~graph.GraphBuilder` captures operations from a stream, while
81+
:class:`~graph.GraphDef` builds a graph explicitly by adding nodes and
82+
edges. Both produce an executable :class:`~graph.Graph` that can be
83+
launched on a :class:`Stream`.
84+
6485
.. autosummary::
6586
:toctree: generated/
6687

@@ -82,6 +103,10 @@ CUDA graphs
82103
Node types
83104
``````````
84105

106+
Every graph node is a subclass of :class:`~graph.GraphNode`, which
107+
provides the common interface (dependencies, successors, destruction).
108+
Each subclass exposes attributes unique to its operation type.
109+
85110
.. autosummary::
86111
:toctree: generated/
87112

cuda_core/docs/source/release/0.7.x-notes.rst

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,14 @@
1010
Highlights
1111
----------
1212

13-
- Introduced :class:`~graph.GraphDef`, an explicit graph construction API. Graphs
14-
can now be built node-by-node (kernel launches, memset, memcpy, memory
15-
allocation/free, child graphs, event record/wait, host callbacks, and
16-
conditionals) with full control over topology. Nodes expose mutable
17-
:attr:`~graph.GraphNode.pred` and :attr:`~graph.GraphNode.succ` adjacency sets
18-
for edge manipulation, and individual nodes can be destroyed with
19-
:meth:`~graph.GraphNode.destroy`. A ``GraphDef`` can be instantiated into an
20-
executable :class:`Graph` or used to update an existing one in place.
13+
- Introduced support for explicit graph construction. CUDA graphs can now be
14+
built programmatically by adding nodes and edges, and their topology can be
15+
modified after construction.
2116

2217

2318
Breaking Changes
2419
----------------
2520

26-
- The internal ``cuda.core._graph`` package has been renamed to the public
27-
:mod:`cuda.core.graph`. Code that imported from ``cuda.core._graph`` must
28-
update its import paths.
29-
3021
- Building ``cuda.core`` from source now requires ``cuda-bindings`` >= 12.9.0, due to Cython-level
3122
dependencies on the NVVM and nvJitLink bindings (``cynvvm``, ``cynvjitlink``). Pre-built wheels
3223
are unaffected. The previous minimum was 12.8.0.
@@ -35,13 +26,10 @@ Breaking Changes
3526
New features
3627
------------
3728

38-
- Added the :mod:`cuda.core.graph` public module containing :class:`~graph.GraphDef`,
39-
:class:`~graph.GraphNode`, :class:`~graph.Condition`, :class:`~graph.GraphAllocOptions`,
40-
and typed node subclasses (:class:`~graph.KernelNode`, :class:`~graph.MemsetNode`,
41-
:class:`~graph.MemcpyNode`, :class:`~graph.AllocNode`, :class:`~graph.FreeNode`,
42-
:class:`~graph.EmptyNode`, :class:`~graph.ChildGraphNode`,
43-
:class:`~graph.EventRecordNode`, :class:`~graph.EventWaitNode`,
44-
:class:`~graph.HostCallbackNode`, and conditional node types).
29+
- Added the :mod:`cuda.core.graph` public module containing
30+
:class:`~graph.GraphDef` for explicit graph construction, typed node
31+
subclasses, and supporting types. :class:`~graph.GraphBuilder` (stream
32+
capture) also moves into this module.
4533

4634
- Added ``preferred_location_type`` option to :class:`ManagedMemoryResourceOptions`
4735
for explicit control over the preferred location kind (``"device"``,

cuda_core/tests/graph/test_graphdef.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ def test_registry_cleanup(init_cuda):
729729
"""Node registry entries are removed on destroy() and graph teardown."""
730730
import gc
731731

732-
from cuda.core._graph._graph_def._graph_node import _node_registry
732+
from cuda.core.graph._graph_node import _node_registry
733733

734734
def registered(node):
735735
return any(v is node for v in _node_registry.values())

0 commit comments

Comments
 (0)