Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
82 changes: 44 additions & 38 deletions cuda_core/cuda/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,45 +69,51 @@ class _PatchedProperty(metaclass=_PatchedPropMeta):


from cuda.core import checkpoint, system, utils
from cuda.core._context import Context, ContextOptions
from cuda.core._device import Device
from cuda.core._device_resources import (
DeviceResources,
SMResource,
SMResourceOptions,
WorkqueueResource,
WorkqueueResourceOptions,
from cuda.core._context import *
from cuda.core._context import __all__ as _context_all
from cuda.core._device import *
from cuda.core._device import __all__ as _device_all
from cuda.core._device_resources import *
from cuda.core._device_resources import __all__ as _device_resources_all
from cuda.core._event import *
from cuda.core._event import __all__ as _event_all
from cuda.core._graphics import *
from cuda.core._graphics import __all__ as _graphics_all
from cuda.core._host import *
from cuda.core._host import __all__ as _host_all
from cuda.core._launch_config import *
from cuda.core._launch_config import __all__ as _launch_config_all
from cuda.core._launcher import *
from cuda.core._launcher import __all__ as _launcher_all
from cuda.core._linker import *
from cuda.core._linker import __all__ as _linker_all
from cuda.core._memory import *
from cuda.core._memory import __all__ as _memory_all
from cuda.core._module import *
from cuda.core._module import __all__ as _module_all
from cuda.core._program import *
from cuda.core._program import __all__ as _program_all
from cuda.core._stream import *
from cuda.core._stream import __all__ as _stream_all
from cuda.core._tensor_map import *
from cuda.core._tensor_map import __all__ as _tensor_map_all

__all__ = (
_context_all
+ _device_all
+ _device_resources_all
+ _event_all
+ _graphics_all
+ _host_all
+ _launch_config_all
+ _launcher_all
+ _linker_all
+ _memory_all
+ _module_all
+ _program_all
+ _stream_all
+ _tensor_map_all
)
from cuda.core._event import Event, EventOptions
from cuda.core._graphics import GraphicsResource
from cuda.core._host import Host
from cuda.core._launch_config import LaunchConfig
from cuda.core._launcher import launch
from cuda.core._linker import Linker, LinkerOptions
from cuda.core._memory import (
Buffer,
DeviceMemoryResource,
DeviceMemoryResourceOptions,
GraphMemoryResource,
LegacyPinnedMemoryResource,
ManagedBuffer,
ManagedMemoryResource,
ManagedMemoryResourceOptions,
MemoryResource,
PinnedMemoryResource,
PinnedMemoryResourceOptions,
VirtualMemoryResource,
VirtualMemoryResourceOptions,
)
from cuda.core._module import Kernel, ObjectCode
from cuda.core._program import Program, ProgramOptions
from cuda.core._stream import (
LEGACY_DEFAULT_STREAM,
PER_THREAD_DEFAULT_STREAM,
Stream,
StreamOptions,
)
from cuda.core._tensor_map import TensorMapDescriptor, TensorMapDescriptorOptions

# isort: split
# Texture/surface types live under the cuda.core.texture namespace (not the
Expand Down
3 changes: 2 additions & 1 deletion cuda_core/cuda/core/_device.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1023,4 +1023,5 @@ class Device:
.. versionadded:: 1.1.0
"""
_tls = threading.local()
_lock = threading.Lock()
_lock = threading.Lock()
__all__ = ['Device']
2 changes: 2 additions & 0 deletions cuda_core/cuda/core/_device.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ _tls = threading.local()
_lock = threading.Lock()
cdef bint _is_cuInit = False

__all__ = ['Device']


cdef class DeviceProperties:
"""
Expand Down
1 change: 1 addition & 0 deletions cuda_core/cuda/core/_event.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ class IPCEventDescriptor:

def __reduce__(self) -> tuple[object, ...]:
...
__all__ = ['Event', 'EventOptions']

def _reduce_event(event: Event) -> tuple[object, ...]:
...
2 changes: 2 additions & 0 deletions cuda_core/cuda/core/_event.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ if TYPE_CHECKING:
import cuda.bindings.driver # no-cython-lint
from cuda.core._device import Device

__all__ = ['Event', 'EventOptions']


@dataclass
cdef class EventOptions:
Expand Down
2 changes: 2 additions & 0 deletions cuda_core/cuda/core/_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import threading
from typing import ClassVar

__all__ = ["Host"]


class Host:
"""Host (CPU) location for managed-memory operations.
Expand Down
1 change: 1 addition & 0 deletions cuda_core/cuda/core/_launch_config.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class LaunchConfig:
def __hash__(self) -> int:
...
_LAUNCH_CONFIG_ATTRS = ('grid', 'cluster', 'block', 'shmem_size', 'is_cooperative')
__all__ = ['LaunchConfig']

def _to_native_launch_config(config: LaunchConfig) -> object:
"""Convert LaunchConfig to native driver CUlaunchConfig.
Expand Down
2 changes: 2 additions & 0 deletions cuda_core/cuda/core/_launch_config.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ from cuda.core._utils.cuda_utils import (

_LAUNCH_CONFIG_ATTRS = ('grid', 'cluster', 'block', 'shmem_size', 'is_cooperative')

__all__ = ['LaunchConfig']


cdef class LaunchConfig:
"""Customizable launch options.
Expand Down
1 change: 1 addition & 0 deletions cuda_core/cuda/core/_launcher.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ from cuda.core._stream import Stream
from cuda.core.graph import GraphBuilder
from cuda.core.typing import IsStreamType

__all__ = ['launch']

def launch(stream: Stream | GraphBuilder | IsStreamType, config: LaunchConfig, kernel: Kernel, *kernel_args) -> None:
"""Launches a :obj:`~_module.Kernel`
Expand Down
2 changes: 2 additions & 0 deletions cuda_core/cuda/core/_launcher.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ if TYPE_CHECKING:
from cuda.core.graph import GraphBuilder
from cuda.core.typing import IsStreamType

__all__ = ['launch']


def launch(
stream: Stream | GraphBuilder | IsStreamType,
Expand Down
25 changes: 23 additions & 2 deletions cuda_core/cuda/core/_memory/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
# 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

from ._buffer import *
from ._buffer import __all__ as _buffer_all
from ._device_memory_resource import *
from ._device_memory_resource import __all__ as _device_memory_resource_all
from ._graph_memory_resource import *
from ._graph_memory_resource import __all__ as _graph_memory_resource_all
from ._ipc import *
from ._ipc import __all__ as _ipc_all
from ._legacy import *
from ._managed_buffer import ManagedBuffer
from ._legacy import __all__ as _legacy_all
from ._managed_buffer import *
from ._managed_buffer import __all__ as _managed_buffer_all
from ._managed_memory_resource import *
from ._managed_memory_resource import __all__ as _managed_memory_resource_all
from ._pinned_memory_resource import *
from ._pinned_memory_resource import __all__ as _pinned_memory_resource_all
from ._virtual_memory_resource import *
from ._virtual_memory_resource import __all__ as _virtual_memory_resource_all

__all__ = (
_buffer_all
+ _device_memory_resource_all
+ _graph_memory_resource_all
+ _ipc_all
+ _legacy_all
+ _managed_buffer_all
+ _managed_memory_resource_all
+ _pinned_memory_resource_all
+ _virtual_memory_resource_all
)
2 changes: 2 additions & 0 deletions cuda_core/cuda/core/_memory/_managed_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
from cuda.core._stream import Stream
from cuda.core.graph import GraphBuilder

__all__ = ["ManagedBuffer"]


_INT_SIZE = 4

Expand Down
1 change: 1 addition & 0 deletions cuda_core/cuda/core/_stream.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ class Stream:
Newly created graph builder object.

"""
__all__ = ['LEGACY_DEFAULT_STREAM', 'PER_THREAD_DEFAULT_STREAM', 'Stream', 'StreamOptions']
LEGACY_DEFAULT_STREAM: Stream = Stream._legacy_default()
PER_THREAD_DEFAULT_STREAM: Stream = Stream._per_thread_default()

Expand Down
3 changes: 3 additions & 0 deletions cuda_core/cuda/core/_stream.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ if TYPE_CHECKING:
from cuda.core._device import Device
from cuda.core.graph import GraphBuilder

__all__ = ['LEGACY_DEFAULT_STREAM', 'PER_THREAD_DEFAULT_STREAM', 'Stream', 'StreamOptions']


@dataclass
cdef class StreamOptions:
"""Customizable :obj:`~_stream.Stream` options.
Expand Down
1 change: 1 addition & 0 deletions cuda_core/cuda/core/_tensor_map.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ class TensorMapDescriptor:

def __repr__(self) -> str:
...
__all__ = ['TensorMapDescriptor', 'TensorMapDescriptorOptions']
_TMA_DT_UINT8 = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_UINT8)
_TMA_DT_UINT16 = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_UINT16)
_TMA_DT_UINT32 = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_UINT32)
Expand Down
2 changes: 2 additions & 0 deletions cuda_core/cuda/core/_tensor_map.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ try:
except ImportError:
ml_bfloat16 = None

__all__ = ['TensorMapDescriptor', 'TensorMapDescriptorOptions']


class TensorMapDataType(enum.IntEnum):
"""Data types for tensor map descriptors.
Expand Down
12 changes: 12 additions & 0 deletions cuda_core/cuda/core/graph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@
#
# SPDX-License-Identifier: Apache-2.0

from . import _graph_builder, _graph_definition, _graph_node, _subclasses
from ._graph_builder import *
from ._graph_definition import *
from ._graph_node import *
from ._subclasses import *

# Aggregate the star-imported submodule exports so ``cuda.core.graph`` carries
# an explicit ``__all__`` derived from its parts (no manual list to drift).
__all__ = [
*_graph_builder.__all__,
*_graph_definition.__all__,
*_graph_node.__all__,
*_subclasses.__all__,
]

del _graph_builder, _graph_definition, _graph_node, _subclasses
3 changes: 2 additions & 1 deletion cuda_core/cuda/core/system/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@

__all__ = [
"CUDA_BINDINGS_NVML_IS_COMPATIBLE",
"get_driver_branch",
"get_kernel_mode_driver_version",
"get_num_devices",
"get_nvml_version",
"get_process_name",
"get_user_mode_driver_version",
]
Expand All @@ -40,7 +42,6 @@
from .exceptions import *
from .exceptions import __all__ as _exceptions_all

__all__.append("get_nvml_version")
__all__.extend(_device_all)
__all__.extend(_system_events_all)
__all__.extend(_exceptions_all)
8 changes: 8 additions & 0 deletions cuda_core/docs/source/api_nvml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,11 @@ Types

Device
NvlinkInfo

Constants
---------

.. autosummary::
:toctree: generated/

CUDA_BINDINGS_NVML_IS_COMPATIBLE
39 changes: 36 additions & 3 deletions cuda_core/docs/source/api_private.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ CUDA runtime

:template: autosummary/cyclass.rst

DeviceResources
_device.DeviceProperties
_device_resources.DeviceResources
_memory._ipc.IPCAllocationHandle
_memory._ipc.IPCBufferDescriptor
IPCAllocationHandle
IPCBufferDescriptor
_memory._managed_buffer.AccessedBySetProxy


Expand Down Expand Up @@ -125,3 +125,36 @@ NVML
system.typing.TemperatureThresholds
system.typing.ThermalController
system.typing.ThermalTarget

system.NvmlError
system.UninitializedError
system.InvalidArgumentError
system.NotSupportedError
system.NoPermissionError
system.AlreadyInitializedError
system.NotFoundError
system.InsufficientSizeError
system.InsufficientPowerError
system.DriverNotLoadedError
system.TimeoutError
system.IrqIssueError
system.LibraryNotFoundError
system.FunctionNotFoundError
system.CorruptedInforomError
system.GpuIsLostError
system.ResetRequiredError
system.OperatingSystemError
system.LibRmVersionMismatchError
system.InUseError
system.MemoryError
system.NoDataError
system.VgpuEccNotSupportedError
system.InsufficientResourcesError
system.FreqNotSupportedError
system.ArgumentVersionMismatchError
system.DeprecatedError
system.NotReadyError
system.GpuNotFoundError
system.InvalidStateError
system.ResetTypeNotSupportedError
system.UnknownError
1 change: 1 addition & 0 deletions cuda_core/pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pytest-randomly = "*"
pytest-repeat = "*"
pytest-rerunfailures = "*"
cloudpickle = "*"
docutils = "*"
psutil = "*"
pyglet = "*"

Expand Down
1 change: 1 addition & 0 deletions cuda_core/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ test = [
"pytest-timeout==2.4.0",
"cloudpickle==3.1.2",
"psutil==7.2.2",
"docutils==0.23",
# TODO: remove the Python 3.15 guard once 3.15 is officially supported
"cffi==2.0.0; python_version < '3.15'",
]
Expand Down
Loading
Loading