Skip to content

Commit 24fd7b0

Browse files
committed
Regenerate cuda.core stubs after main merge
1 parent 5830ba7 commit 24fd7b0

22 files changed

Lines changed: 467 additions & 60 deletions

‎cuda_core/cuda/core/_device.pyi‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,4 +1027,5 @@ class Device:
10271027
.. versionadded:: 1.1.0
10281028
"""
10291029
_tls = threading.local()
1030-
_lock = threading.Lock()
1030+
_lock = threading.Lock()
1031+
__all__ = ['Device']

‎cuda_core/cuda/core/_event.pyi‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ class IPCEventDescriptor:
180180

181181
def __reduce__(self) -> tuple[object, ...]:
182182
...
183+
__all__ = ['Event', 'EventOptions']
183184

184185
def _reduce_event(event: Event) -> tuple[object, ...]:
185186
...

‎cuda_core/cuda/core/_launch_config.pyi‎

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ class LaunchConfig:
1818
1919
Attributes
2020
----------
21-
grid : Union[tuple, int]
21+
grid : tuple | int
2222
Collection of threads that will execute a kernel function. When cluster
2323
is not specified, this represents the number of blocks, otherwise
2424
this represents the number of clusters.
25-
cluster : Union[tuple, int]
25+
cluster : tuple | int
2626
Group of blocks (Thread Block Cluster) that will execute on the same
2727
GPU Processing Cluster (GPC). Blocks within a cluster have access to
2828
distributed shared memory and can be explicitly synchronized.
29-
block : Union[tuple, int]
29+
block : tuple | int
3030
Group of threads (Thread Block) that will execute on the same
3131
streaming multiprocessor (SM). Threads within a thread blocks have
3232
access to shared memory and can be explicitly synchronized.
@@ -35,23 +35,29 @@ class LaunchConfig:
3535
(Default to size 0)
3636
is_cooperative : bool, optional
3737
Whether this config can be used to launch a cooperative kernel.
38+
programmatic_stream_serialization : bool, optional
39+
Whether to allow programmatic stream serialization (PDL). When True,
40+
the kernel may overlap with a previous kernel in the same stream that
41+
signals completion via programmatic means.
3842
"""
3943

40-
def __init__(self, grid: int | tuple[int, ...] | None=None, cluster: int | tuple[int, ...] | None=None, block: int | tuple[int, ...] | None=None, shmem_size: int | None=None, is_cooperative: bool=False) -> None:
44+
def __init__(self, grid: int | tuple[int, ...] | None=None, cluster: int | tuple[int, ...] | None=None, block: int | tuple[int, ...] | None=None, shmem_size: int | None=None, is_cooperative: bool=False, programmatic_stream_serialization: bool=False) -> None:
4145
"""Initialize LaunchConfig with validation.
4246
4347
Parameters
4448
----------
45-
grid : Union[tuple, int], optional
49+
grid : tuple | int, optional
4650
Grid dimensions (number of blocks or clusters if cluster is specified)
47-
cluster : Union[tuple, int], optional
51+
cluster : tuple | int, optional
4852
Cluster dimensions (Thread Block Cluster)
49-
block : Union[tuple, int], optional
53+
block : tuple | int, optional
5054
Block dimensions (threads per block)
5155
shmem_size : int, optional
5256
Dynamic shared memory size in bytes (default: 0)
5357
is_cooperative : bool, optional
5458
Whether to launch as cooperative kernel (default: False)
59+
programmatic_stream_serialization : bool, optional
60+
Whether to allow programmatic stream serialization / PDL (default: False)
5561
"""
5662

5763
def _identity(self) -> tuple[Any, ...]:
@@ -65,7 +71,8 @@ class LaunchConfig:
6571

6672
def __hash__(self) -> int:
6773
...
68-
_LAUNCH_CONFIG_ATTRS = ('grid', 'cluster', 'block', 'shmem_size', 'is_cooperative')
74+
_LAUNCH_CONFIG_ATTRS = ('grid', 'cluster', 'block', 'shmem_size', 'is_cooperative', 'programmatic_stream_serialization')
75+
__all__ = ['LaunchConfig']
6976

7077
def _to_native_launch_config(config: LaunchConfig) -> object:
7178
"""Convert LaunchConfig to native driver CUlaunchConfig.

‎cuda_core/cuda/core/_launcher.pyi‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ from cuda.core._stream import Stream
88
from cuda.core.graph import GraphBuilder
99
from cuda.core.typing import IsStreamType
1010

11+
__all__ = ['launch']
1112

1213
def launch(stream: Stream | GraphBuilder | IsStreamType, config: LaunchConfig, kernel: Kernel, *kernel_args) -> None:
1314
"""Launches a :obj:`~_module.Kernel`

‎cuda_core/cuda/core/_memory/_buffer.pyi‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,15 @@ class Buffer:
3939
...
4040

4141
@classmethod
42-
def _init(cls, ptr: DevicePointerType, size: int, mr: MemoryResource | None=None, ipc_descriptor: IPCBufferDescriptor | None=None, owner: object | None=None) -> Buffer:
42+
def _init(cls, ptr: DevicePointerType, size: int, mr: MemoryResource | None=None, ipc_descriptor: IPCBufferDescriptor | None=None, owner: object | None=None, *, stream: Stream | GraphBuilder | None=None) -> Buffer:
4343
"""Create a Buffer from a raw pointer.
4444
4545
When ``mr`` is provided, the buffer takes ownership: ``mr.deallocate()``
4646
is called when the buffer is closed or garbage collected. When ``owner``
4747
is provided, the owner is kept alive but no deallocation is performed.
48+
When ``mr`` is provided, a deallocation stream is recorded at creation
49+
(``stream`` if given, otherwise ``default_stream()``). Recording a
50+
default-stream token requires a CUDA context to be current.
4851
"""
4952

5053
@staticmethod
@@ -55,7 +58,7 @@ class Buffer:
5558
...
5659

5760
@staticmethod
58-
def from_handle(ptr: DevicePointerType, size: int, mr: MemoryResource | None=None, owner: object | None=None) -> Buffer:
61+
def from_handle(ptr: DevicePointerType, size: int, mr: MemoryResource | None=None, owner: object | None=None, *, stream: Stream | GraphBuilder | None=None) -> Buffer:
5962
"""Create a new :class:`Buffer` object from a pointer.
6063
6164
Parameters
@@ -72,6 +75,13 @@ class Buffer:
7275
An object holding external allocation that the ``ptr`` points to.
7376
The reference is kept as long as the buffer is alive.
7477
The ``owner`` and ``mr`` cannot be specified together.
78+
stream : :obj:`~_stream.Stream` | :obj:`~graph.GraphBuilder`, optional
79+
Keyword-only. The stream used to order the buffer's deallocation
80+
when ``mr`` owns the pointer. Defaults to ``default_stream()``.
81+
Recording a default-stream token requires a CUDA context to be
82+
current. If the buffer may be freed from a different host thread,
83+
pass a stream other than the per-thread default stream, which
84+
refers to a different stream on each thread.
7585
7686
Note
7787
----
@@ -264,7 +274,12 @@ class MemoryResource:
264274
stream : :obj:`~_stream.Stream` | :obj:`~graph.GraphBuilder`
265275
Keyword-only. The stream on which to perform the allocation
266276
asynchronously. Must be passed explicitly; pass
267-
``device.default_stream`` to use the default stream.
277+
``device.default_stream`` to use the default stream. For subclasses
278+
that support stream-ordered deallocation, this stream also orders
279+
the buffer's eventual deallocation, so if the buffer may be freed
280+
from a different host thread, prefer a stream other than the
281+
per-thread default stream, which refers to a different stream on
282+
each thread.
268283
269284
Returns
270285
-------
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_memory/_copy_attributes.pyx
2+
3+
from __future__ import annotations
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_memory/_copy_ops.pyx
2+
3+
from __future__ import annotations
4+
5+
from collections.abc import Sequence
6+
7+
from cuda.core._memory._buffer import Buffer
8+
from cuda.core._memory._copy_enums import CopyOptions
9+
from cuda.core._stream import Stream
10+
11+
_SINGLE_COPY_HINT = 'Buffer.copy_to / Buffer.copy_from'
12+
13+
def _normalize_copy_options(options: CopyOptions | Sequence[CopyOptions] | None, n: int) -> tuple[CopyOptions, ...]:
14+
"""Expand ``options`` to exactly one :class:`CopyOptions` per copy.
15+
16+
``None`` and a scalar broadcast; a sequence pairs by index and must
17+
already have length ``n``.
18+
19+
Internal, but deliberately importable: options are hints that change
20+
how the driver stages a transfer and never the bytes it produces, so
21+
this expansion (and the run encoding applied to it) is the only
22+
observable evidence that a scalar reached every copy.
23+
"""
24+
25+
def copy_batch(stream: Stream, srcs: Sequence[Buffer], dsts: Sequence[Buffer], *, options: CopyOptions | Sequence[CopyOptions] | None=None) -> None:
26+
"""Copy a batch of buffers asynchronously.
27+
28+
Source buffer and destination buffer sizes must match. For a single
29+
buffer, use :meth:`Buffer.copy_to` or :meth:`Buffer.copy_from`.
30+
31+
The driver provides no graph-node form of ``cuMemcpyBatchAsync``, so
32+
this cannot be captured into a graph. Both passing a
33+
:class:`~graph.GraphBuilder` and passing its underlying
34+
:attr:`~graph.GraphBuilder.stream` while capture is active are
35+
rejected. Build graph copies with
36+
:meth:`graph.GraphNode.memcpy` or per-buffer :meth:`Buffer.copy_to`.
37+
38+
Parameters
39+
----------
40+
stream : :class:`~_stream.Stream`
41+
Stream for the asynchronous copy. First positional and required
42+
(mirrors :func:`launch`). Does not accept a capturing stream
43+
(including a :class:`~graph.GraphBuilder`'s underlying stream); use
44+
:meth:`graph.GraphNode.memcpy` or per-buffer
45+
:meth:`Buffer.copy_to` to build copies into a graph.
46+
srcs : Sequence[:class:`Buffer`]
47+
Source buffers. Must be a sequence, not a single Buffer.
48+
dsts : Sequence[:class:`Buffer`]
49+
Destination buffers. Must match ``len(srcs)``.
50+
options : :class:`CopyOptions` | Sequence[:class:`CopyOptions`] | None
51+
Per-copy options. A single value applies to every copy; a
52+
sequence pairs by index and must match ``len(srcs)``. ``None``
53+
uses stream-ordered defaults.
54+
55+
Raises
56+
------
57+
ValueError
58+
If lengths or sizes mismatch.
59+
TypeError
60+
If a single Buffer is passed instead of a sequence, if a
61+
default-stream token (``LEGACY_DEFAULT_STREAM`` /
62+
``PER_THREAD_DEFAULT_STREAM``) is passed, or if the stream is
63+
currently in graph capture mode.
64+
65+
Notes
66+
-----
67+
Batching through ``cuMemcpyBatchAsync`` requires all three of:
68+
``cuda.core`` built against CUDA 13 headers, ``cuda.bindings`` 13.0 or
69+
newer, and a driver reporting CUDA 13.0 or newer
70+
(``cuDriverGetVersion() >= 13000``). ``cuda.bindings`` binds only the
71+
CUDA 13.0 revision of the entry point, so a driver that predates it is
72+
refused even where it implements the earlier CUDA 12.8 signature.
73+
74+
The driver may execute batch items concurrently and in any order.
75+
A batch must therefore not contain copies where the source range of
76+
one copy overlaps the destination range of another; such aliasing
77+
produces undefined results. Detecting overlaps at runtime is
78+
impractical; callers are responsible for ensuring no aliasing exists.
79+
80+
On pre-CUDA 13 installs the copies fall back to a Python-level loop
81+
over ``cuMemcpyAsync``, so the potential performance benefit of
82+
asynchronous batched copies is not realized. :class:`CopyOptions` are
83+
silently ignored on the fallback path.
84+
85+
"""

‎cuda_core/cuda/core/_memory/_ipc.pyi‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class IPCAllocationHandle:
8484
@property
8585
def uuid(self) -> uuid.UUID:
8686
...
87-
__all__ = ['IPCBufferDescriptor', 'IPCAllocationHandle']
87+
__all__ = []
8888

8989
def _reduce_allocation_handle(alloc_handle: IPCAllocationHandle) -> tuple[object, ...]:
9090
...

‎cuda_core/cuda/core/_memory/_managed_memory_ops.pyi‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ from cuda.core._memory._buffer import Buffer
1111
from cuda.core._stream import Stream
1212
from cuda.core._utils.cuda_utils import driver
1313

14+
_SINGLE_MANAGED_HINT = 'the ManagedBuffer instance method'
1415

1516
def discard_batch(stream: Stream | GraphBuilder, buffers: Sequence[Buffer]) -> None:
1617
"""Discard a batch of managed-memory ranges.

‎cuda_core/cuda/core/_memory/_pinned_memory_resource.pyi‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ from __future__ import annotations
55
import uuid
66
from dataclasses import dataclass
77

8+
from cuda.core._memory._buffer import Buffer
89
from cuda.core._memory._ipc import IPCAllocationHandle
910
from cuda.core._memory._memory_pool import _MemPool
11+
from cuda.core._stream import Stream
12+
from cuda.core.graph import GraphBuilder
1013

1114

1215
@dataclass
@@ -63,6 +66,14 @@ class PinnedMemoryResource(_MemPool):
6366
6467
Notes
6568
-----
69+
The device associated with ``stream`` must support host memory pools. If
70+
``numa_id`` is set or derived for IPC, it must support host NUMA memory pools.
71+
You can query these capabilities through
72+
``Device.properties.host_memory_pools_supported`` and
73+
``Device.properties.host_numa_memory_pools_supported``. If the required pool
74+
is unsupported and stream-ordered allocation is not needed, use
75+
:class:`LegacyPinnedMemoryResource`.
76+
6677
To create an IPC-Enabled memory resource (MR) that is capable of sharing
6778
allocations between processes, specify ``ipc_enabled=True`` in the initializer
6879
option. When IPC is enabled and ``numa_id`` is not specified, the NUMA node
@@ -76,6 +87,9 @@ class PinnedMemoryResource(_MemPool):
7687
def __init__(self, options: PinnedMemoryResourceOptions | dict[str, object] | None=None) -> None:
7788
...
7889

90+
def allocate(self, size: int, *, stream: Stream | GraphBuilder) -> Buffer:
91+
"""Allocate a host-pinned buffer asynchronously on the supplied stream."""
92+
7993
def __reduce__(self) -> tuple[object, ...]:
8094
...
8195

0 commit comments

Comments
 (0)