Skip to content

Commit 47276b4

Browse files
committed
Add API docs for cuda.core.graph and fix stale docstring references
The _graph -> graph rename left behind broken Sphinx cross-references and the new graph types were missing from the API reference. Made-with: Cursor
1 parent d538fd1 commit 47276b4

File tree

7 files changed

+82
-31
lines changed

7 files changed

+82
-31
lines changed

cuda_core/cuda/core/_launcher.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def launch(stream: Stream | GraphBuilder | IsStreamT, config: LaunchConfig, kern
2626
2727
Parameters
2828
----------
29-
stream : :obj:`~_stream.Stream` | :obj:`~_graph.GraphBuilder`
29+
stream : :obj:`~_stream.Stream` | :obj:`~graph.GraphBuilder`
3030
The stream establishing the stream ordering semantic of a
3131
launch.
3232
config : :obj:`LaunchConfig`

cuda_core/cuda/core/_memory/_buffer.pyx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ cdef class Buffer:
182182
183183
Parameters
184184
----------
185-
stream : :obj:`~_stream.Stream` | :obj:`~_graph.GraphBuilder`, optional
185+
stream : :obj:`~_stream.Stream` | :obj:`~graph.GraphBuilder`, optional
186186
The stream object to use for asynchronous deallocation. If None,
187187
the deallocation stream stored in the handle is used.
188188
"""
@@ -206,7 +206,7 @@ cdef class Buffer:
206206
----------
207207
dst : :obj:`~_memory.Buffer`
208208
Source buffer to copy data from
209-
stream : :obj:`~_stream.Stream` | :obj:`~_graph.GraphBuilder`
209+
stream : :obj:`~_stream.Stream` | :obj:`~graph.GraphBuilder`
210210
Keyword argument specifying the stream for the
211211
asynchronous copy
212212

@@ -237,7 +237,7 @@ cdef class Buffer:
237237
----------
238238
src : :obj:`~_memory.Buffer`
239239
Source buffer to copy data from
240-
stream : :obj:`~_stream.Stream` | :obj:`~_graph.GraphBuilder`
240+
stream : :obj:`~_stream.Stream` | :obj:`~graph.GraphBuilder`
241241
Keyword argument specifying the stream for the
242242
asynchronous copy
243243
@@ -262,7 +262,7 @@ cdef class Buffer:
262262
value : int | :obj:`collections.abc.Buffer`
263263
- int: Must be in range [0, 256). Converted to 1 byte.
264264
- :obj:`collections.abc.Buffer`: Must be 1, 2, or 4 bytes.
265-
stream : :obj:`~_stream.Stream` | :obj:`~_graph.GraphBuilder`
265+
stream : :obj:`~_stream.Stream` | :obj:`~graph.GraphBuilder`
266266
Stream for the asynchronous fill operation.
267267
268268
Raises
@@ -496,7 +496,7 @@ cdef class MemoryResource:
496496
----------
497497
size : int
498498
The size of the buffer to allocate, in bytes.
499-
stream : :obj:`~_stream.Stream` | :obj:`~_graph.GraphBuilder`, optional
499+
stream : :obj:`~_stream.Stream` | :obj:`~graph.GraphBuilder`, optional
500500
The stream on which to perform the allocation asynchronously.
501501
If None, it is up to each memory resource implementation to decide
502502
and document the behavior.
@@ -518,7 +518,7 @@ cdef class MemoryResource:
518518
The pointer or handle to the buffer to deallocate.
519519
size : int
520520
The size of the buffer to deallocate, in bytes.
521-
stream : :obj:`~_stream.Stream` | :obj:`~_graph.GraphBuilder`, optional
521+
stream : :obj:`~_stream.Stream` | :obj:`~graph.GraphBuilder`, optional
522522
The stream on which to perform the deallocation asynchronously.
523523
If None, it is up to each memory resource implementation to decide
524524
and document the behavior.

cuda_core/cuda/core/_memory/_memory_pool.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ cdef class _MemPool(MemoryResource):
129129
----------
130130
size : int
131131
The size of the buffer to allocate, in bytes.
132-
stream : :obj:`~_stream.Stream` | :obj:`~_graph.GraphBuilder`, optional
132+
stream : :obj:`~_stream.Stream` | :obj:`~graph.GraphBuilder`, optional
133133
The stream on which to perform the allocation asynchronously.
134134
If None, an internal stream is used.
135135

@@ -153,7 +153,7 @@ cdef class _MemPool(MemoryResource):
153153
The pointer or handle to the buffer to deallocate.
154154
size : int
155155
The size of the buffer to deallocate, in bytes.
156-
stream : :obj:`~_stream.Stream` | :obj:`~_graph.GraphBuilder`, optional
156+
stream : :obj:`~_stream.Stream` | :obj:`~graph.GraphBuilder`, optional
157157
The stream on which to perform the deallocation asynchronously.
158158
If the buffer is deallocated without an explicit stream, the allocation stream
159159
is used.

cuda_core/cuda/core/graph/_graph_builder.pyx

Lines changed: 17 additions & 17 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+
"""Customizable options for :obj:`~graph.GraphBuilder.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+
"""Customizable options for :obj:`~graph.GraphBuilder.complete()`
123123

124124
Attributes
125125
----------
@@ -188,7 +188,7 @@ class GraphBuilder:
188188
them with a specified dependency tree. It speeds up the workflow by combining the
189189
driver activities associated with CUDA kernel launches and CUDA API calls.
190190
191-
Directly creating a :obj:`~_graph.GraphBuilder` is not supported due
191+
Directly creating a :obj:`~graph.GraphBuilder` is not supported due
192192
to ambiguity. New graph builders should instead be created through a
193193
:obj:`~_device.Device`, or a :obj:`~_stream.stream` object.
194194
@@ -326,16 +326,16 @@ class GraphBuilder:
326326
return self
327327

328328
def complete(self, options: GraphCompleteOptions | None = None) -> "Graph":
329-
"""Completes the graph builder and returns the built :obj:`~_graph.Graph` object.
329+
"""Completes the graph builder and returns the built :obj:`~graph.Graph` object.
330330

331331
Parameters
332332
----------
333-
options : :obj:`~_graph.GraphCompleteOptions`, optional
333+
options : :obj:`~graph.GraphCompleteOptions`, optional
334334
Customizable dataclass for the graph builder completion options.
335335

336336
Returns
337337
-------
338-
graph : :obj:`~_graph.Graph`
338+
graph : :obj:`~graph.Graph`
339339
The newly built graph.
340340

341341
"""
@@ -351,7 +351,7 @@ class GraphBuilder:
351351
----------
352352
path : str
353353
File path to use for writting debug DOT output
354-
options : :obj:`~_graph.GraphDebugPrintOptions`, optional
354+
options : :obj:`~graph.GraphDebugPrintOptions`, optional
355355
Customizable dataclass for the debug print options.
356356
357357
"""
@@ -373,7 +373,7 @@ class GraphBuilder:
373373

374374
Returns
375375
-------
376-
graph_builders : tuple[:obj:`~_graph.GraphBuilder`, ...]
376+
graph_builders : tuple[:obj:`~graph.GraphBuilder`, ...]
377377
A tuple of split graph builders. The first graph builder in the tuple
378378
is always the original graph builder.
379379

@@ -400,12 +400,12 @@ class GraphBuilder:
400400

401401
Parameters
402402
----------
403-
*graph_builders : :obj:`~_graph.GraphBuilder`
403+
*graph_builders : :obj:`~graph.GraphBuilder`
404404
The graph builders to join.
405405

406406
Returns
407407
-------
408-
graph_builder : :obj:`~_graph.GraphBuilder`
408+
graph_builder : :obj:`~graph.GraphBuilder`
409409
The newly joined graph builder.
410410

411411
"""
@@ -521,7 +521,7 @@ class GraphBuilder:
521521

522522
Returns
523523
-------
524-
graph_builder : :obj:`~_graph.GraphBuilder`
524+
graph_builder : :obj:`~graph.GraphBuilder`
525525
The newly created conditional graph builder.
526526

527527
"""
@@ -552,7 +552,7 @@ class GraphBuilder:
552552

553553
Returns
554554
-------
555-
graph_builders : tuple[:obj:`~_graph.GraphBuilder`, :obj:`~_graph.GraphBuilder`]
555+
graph_builders : tuple[:obj:`~graph.GraphBuilder`, :obj:`~graph.GraphBuilder`]
556556
A tuple of two new graph builders, one for the if branch and one for the else branch.
557557

558558
"""
@@ -586,7 +586,7 @@ class GraphBuilder:
586586

587587
Returns
588588
-------
589-
graph_builders : tuple[:obj:`~_graph.GraphBuilder`, ...]
589+
graph_builders : tuple[:obj:`~graph.GraphBuilder`, ...]
590590
A tuple of new graph builders, one for each branch.
591591

592592
"""
@@ -617,7 +617,7 @@ class GraphBuilder:
617617

618618
Returns
619619
-------
620-
graph_builder : :obj:`~_graph.GraphBuilder`
620+
graph_builder : :obj:`~graph.GraphBuilder`
621621
The newly created while loop graph builder.
622622

623623
"""
@@ -643,13 +643,13 @@ class GraphBuilder:
643643
self._mnff.close()
644644

645645
def add_child(self, child_graph: GraphBuilder):
646-
"""Adds the child :obj:`~_graph.GraphBuilder` builder into self.
646+
"""Adds the child :obj:`~graph.GraphBuilder` builder into self.
647647
648648
The child graph builder will be added as a child node to the parent graph builder.
649649
650650
Parameters
651651
----------
652-
child_graph : :obj:`~_graph.GraphBuilder`
652+
child_graph : :obj:`~graph.GraphBuilder`
653653
The child graph builder. Must have finished building.
654654
"""
655655
if not child_graph._building_ended:
@@ -743,7 +743,7 @@ class Graph:
743743
them with a specified dependency tree. It speeds up the workflow by combining the
744744
driver activities associated with CUDA kernel launches and CUDA API calls.
745745
746-
Graphs must be built using a :obj:`~_graph.GraphBuilder` object.
746+
Graphs must be built using a :obj:`~graph.GraphBuilder` object.
747747
748748
"""
749749

cuda_core/cuda/core/graph/_graph_def.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ cdef class GraphDef:
278278

279279
Parameters
280280
----------
281-
options : :obj:`~_graph.GraphCompleteOptions`, optional
281+
options : :obj:`~graph.GraphCompleteOptions`, optional
282282
Customizable dataclass for graph instantiation options.
283283

284284
Returns

cuda_core/docs/source/api.rst

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ CUDA runtime
2020
:toctree: generated/
2121

2222
Device
23-
Graph
24-
GraphBuilder
2523
launch
2624

2725
:template: autosummary/cyclass.rst
@@ -43,8 +41,6 @@ CUDA runtime
4341
PinnedMemoryResourceOptions
4442
ManagedMemoryResourceOptions
4543
EventOptions
46-
GraphCompleteOptions
47-
GraphDebugPrintOptions
4844
StreamOptions
4945
LaunchConfig
5046
VirtualMemoryResourceOptions
@@ -62,6 +58,52 @@ CUDA runtime
6258
on other non-blocking streams.
6359

6460

61+
CUDA graphs
62+
-----------
63+
64+
.. autosummary::
65+
:toctree: generated/
66+
67+
graph.Graph
68+
graph.GraphBuilder
69+
graph.GraphDef
70+
71+
:template: autosummary/cyclass.rst
72+
73+
graph.GraphNode
74+
graph.Condition
75+
76+
:template: dataclass.rst
77+
78+
graph.GraphAllocOptions
79+
graph.GraphCompleteOptions
80+
graph.GraphDebugPrintOptions
81+
82+
Node types
83+
``````````
84+
85+
.. autosummary::
86+
:toctree: generated/
87+
88+
:template: autosummary/cyclass.rst
89+
90+
graph.EmptyNode
91+
graph.KernelNode
92+
graph.AllocNode
93+
graph.FreeNode
94+
graph.MemsetNode
95+
graph.MemcpyNode
96+
graph.ChildGraphNode
97+
graph.EventRecordNode
98+
graph.EventWaitNode
99+
graph.HostCallbackNode
100+
graph.ConditionalNode
101+
graph.IfNode
102+
graph.IfElseNode
103+
graph.WhileNode
104+
graph.SwitchNode
105+
106+
65107
CUDA compilation toolchain
66108
--------------------------
67109

cuda_core/docs/source/api_private.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ CUDA runtime
3434
_memory._ipc.IPCBufferDescriptor
3535

3636

37+
CUDA graphs
38+
-----------
39+
40+
.. autosummary::
41+
:toctree: generated/
42+
43+
graph._adjacency_set_proxy.AdjacencySetProxy
44+
45+
3746
CUDA protocols
3847
--------------
3948

0 commit comments

Comments
 (0)