diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 62220467b71..25352f42c64 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -83,12 +83,12 @@ repos: - id: stubgen-pyx-cuda-core name: Generate .pyi stubs for cuda_core - entry: python ./toolshed/run_stubgen_pyx.py + entry: python -X utf8 -m stubgen_pyx cuda_core/cuda --continue-on-error --include-private language: python files: ^cuda_core/cuda/.*\.(pyx|pxd)$ pass_filenames: false additional_dependencies: - - stubgen-pyx==0.2.6 + - stubgen-pyx==0.2.19 - Cython==3.2.9 # Link checking for authored documentation files diff --git a/cuda_core/cuda/core/_context.pyi b/cuda_core/cuda/core/_context.pyi index afbc130882e..4adccfcbcfb 100644 --- a/cuda_core/cuda/core/_context.pyi +++ b/cuda_core/cuda/core/_context.pyi @@ -1,6 +1,4 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_context.pyx - -from __future__ import annotations +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_context.pyx from collections.abc import Sequence from dataclasses import dataclass @@ -10,6 +8,8 @@ from cuda.core._device_resources import (DeviceResources, SMResource, WorkqueueResource) from cuda.core._stream import Stream +__all__ = ['Context', 'ContextOptions'] +DeviceResourcesType = Sequence[SMResource | WorkqueueResource] class Context: """CUDA context wrapper. @@ -17,25 +17,15 @@ class Context: Context objects represent CUDA contexts and cannot be instantiated directly. Use Device or Stream APIs to obtain context objects. """ - - def close(self): - """Release this context wrapper's underlying CUDA handles.""" - - def __init__(self, *args, **kwargs) -> None: - ... - + def __init__(self, *args, **kwargs) -> None: ... @property def handle(self) -> cuda.bindings.driver.CUcontext | None: """Return the underlying CUcontext handle.""" - @property - def _handle(self) -> cuda.bindings.driver.CUcontext | None: - ... - + def _handle(self) -> cuda.bindings.driver.CUcontext | None: ... @property def is_green(self) -> bool: """True if this context was created from device resources.""" - @property def resources(self) -> DeviceResources: """Query the hardware resources provisioned for this context. @@ -46,8 +36,7 @@ class Context: Raises :class:`RuntimeError` if the context has been closed. """ - - def create_stream(self, options: object=None) -> Stream: + def create_stream(self, options: object | None=None) -> Stream: """Create a new stream bound to this green context. This method is only available on green contexts. For primary @@ -63,15 +52,11 @@ class Context: :obj:`~_stream.Stream` Newly created stream object. """ - - def __eq__(self, other: object) -> bool: - ... - - def __hash__(self) -> int: - ... - - def __repr__(self) -> str: - ... + def close(self): + """Release this context wrapper's underlying CUDA handles.""" + def __eq__(self, other: object) -> bool: ... + def __hash__(self) -> int: ... + def __repr__(self) -> str: ... @dataclass class ContextOptions: @@ -83,5 +68,3 @@ class ContextOptions: Device resources used to create a green context. """ resources: DeviceResourcesType -__all__ = ['Context', 'ContextOptions'] -DeviceResourcesType = Sequence[SMResource | WorkqueueResource] \ No newline at end of file diff --git a/cuda_core/cuda/core/_device.pyi b/cuda_core/cuda/core/_device.pyi index e83aef8a8d0..825d7dd8cbc 100644 --- a/cuda_core/cuda/core/_device.pyi +++ b/cuda_core/cuda/core/_device.pyi @@ -1,8 +1,4 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_device.pyx - -from __future__ import annotations - -import threading +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_device.pyx import cuda.core.system from cuda.core._context import Context, ContextOptions @@ -17,6 +13,7 @@ from cuda.core.texture import (MipmappedArray, MipmappedArrayOptions, ResourceDescriptor, SurfaceObject, TextureObject, TextureObjectOptions) +__all__ = ['Device'] class DeviceProperties: """ @@ -24,588 +21,441 @@ class DeviceProperties: Attributes are read-only and provide information about the device. """ - - def __init__(self, *args, **kwargs) -> None: - ... - + def __init__(self, *args, **kwargs) -> None: ... @classmethod - def _init(cls, handle: int) -> DeviceProperties: - ... - + def _init(cls, handle: int) -> DeviceProperties: ... @property def max_threads_per_block(self) -> int: """int: Maximum number of threads per block.""" - @property def max_block_dim_x(self) -> int: """int: Maximum block dimension X.""" - @property def max_block_dim_y(self) -> int: """int: Maximum block dimension Y.""" - @property def max_block_dim_z(self) -> int: """int: Maximum block dimension Z.""" - @property def max_grid_dim_x(self) -> int: """int: Maximum grid dimension X.""" - @property def max_grid_dim_y(self) -> int: """int: Maximum grid dimension Y.""" - @property def max_grid_dim_z(self) -> int: """int: Maximum grid dimension Z.""" - @property def max_shared_memory_per_block(self) -> int: """int: Maximum shared memory available per block in bytes.""" - @property def total_constant_memory(self) -> int: """int: Memory available on device for constant variables in a CUDA C kernel in bytes.""" - @property def warp_size(self) -> int: """int: Warp size in threads.""" - @property def max_pitch(self) -> int: """int: Maximum pitch in bytes allowed by memory copies.""" - @property def maximum_texture1d_width(self) -> int: """int: Maximum 1D texture width.""" - @property def maximum_texture1d_linear_width(self) -> int: """int: Maximum width for a 1D texture bound to linear memory.""" - @property def maximum_texture1d_mipmapped_width(self) -> int: """int: Maximum mipmapped 1D texture width.""" - @property def maximum_texture2d_width(self) -> int: """int: Maximum 2D texture width.""" - @property def maximum_texture2d_height(self) -> int: """int: Maximum 2D texture height.""" - @property def maximum_texture2d_linear_width(self) -> int: """int: Maximum width for a 2D texture bound to linear memory.""" - @property def maximum_texture2d_linear_height(self) -> int: """int: Maximum height for a 2D texture bound to linear memory.""" - @property def maximum_texture2d_linear_pitch(self) -> int: """int: Maximum pitch in bytes for a 2D texture bound to linear memory.""" - @property def maximum_texture2d_mipmapped_width(self) -> int: """int: Maximum mipmapped 2D texture width.""" - @property def maximum_texture2d_mipmapped_height(self) -> int: """int: Maximum mipmapped 2D texture height.""" - @property def maximum_texture3d_width(self) -> int: """int: Maximum 3D texture width.""" - @property def maximum_texture3d_height(self) -> int: """int: Maximum 3D texture height.""" - @property def maximum_texture3d_depth(self) -> int: """int: Maximum 3D texture depth.""" - @property def maximum_texture3d_width_alternate(self) -> int: """int: Alternate maximum 3D texture width, 0 if no alternate maximum 3D texture size is supported.""" - @property def maximum_texture3d_height_alternate(self) -> int: """int: Alternate maximum 3D texture height, 0 if no alternate maximum 3D texture size is supported.""" - @property def maximum_texture3d_depth_alternate(self) -> int: """int: Alternate maximum 3D texture depth, 0 if no alternate maximum 3D texture size is supported.""" - @property def maximum_texturecubemap_width(self) -> int: """int: Maximum cubemap texture width or height.""" - @property def maximum_texture1d_layered_width(self) -> int: """int: Maximum 1D layered texture width.""" - @property def maximum_texture1d_layered_layers(self) -> int: """int: Maximum layers in a 1D layered texture.""" - @property def maximum_texture2d_layered_width(self) -> int: """int: Maximum 2D layered texture width.""" - @property def maximum_texture2d_layered_height(self) -> int: """int: Maximum 2D layered texture height.""" - @property def maximum_texture2d_layered_layers(self) -> int: """int: Maximum layers in a 2D layered texture.""" - @property def maximum_texturecubemap_layered_width(self) -> int: """int: Maximum cubemap layered texture width or height.""" - @property def maximum_texturecubemap_layered_layers(self) -> int: """int: Maximum layers in a cubemap layered texture.""" - @property def maximum_surface1d_width(self) -> int: """int: Maximum 1D surface width.""" - @property def maximum_surface2d_width(self) -> int: """int: Maximum 2D surface width.""" - @property def maximum_surface2d_height(self) -> int: """int: Maximum 2D surface height.""" - @property def maximum_surface3d_width(self) -> int: """int: Maximum 3D surface width.""" - @property def maximum_surface3d_height(self) -> int: """int: Maximum 3D surface height.""" - @property def maximum_surface3d_depth(self) -> int: """int: Maximum 3D surface depth.""" - @property def maximum_surface1d_layered_width(self) -> int: """int: Maximum 1D layered surface width.""" - @property def maximum_surface1d_layered_layers(self) -> int: """int: Maximum layers in a 1D layered surface.""" - @property def maximum_surface2d_layered_width(self) -> int: """int: Maximum 2D layered surface width.""" - @property def maximum_surface2d_layered_height(self) -> int: """int: Maximum 2D layered surface height.""" - @property def maximum_surface2d_layered_layers(self) -> int: """int: Maximum layers in a 2D layered surface.""" - @property def maximum_surfacecubemap_width(self) -> int: """int: Maximum cubemap surface width.""" - @property def maximum_surfacecubemap_layered_width(self) -> int: """int: Maximum cubemap layered surface width.""" - @property def maximum_surfacecubemap_layered_layers(self) -> int: """int: Maximum layers in a cubemap layered surface.""" - @property def max_registers_per_block(self) -> int: """int: Maximum number of 32-bit registers available to a thread block.""" - @property def clock_rate(self) -> int: """int: Typical clock frequency in kilohertz.""" - @property def texture_alignment(self) -> int: """int: Alignment requirement for textures.""" - @property def texture_pitch_alignment(self) -> int: """int: Pitch alignment requirement for textures.""" - @property def gpu_overlap(self) -> bool: """bool: Device can possibly copy memory and execute a kernel concurrently. Deprecated. Use :attr:`~DeviceProperties.async_engine_count` instead.""" - @property def multiprocessor_count(self) -> int: """int: Number of multiprocessors on device.""" - @property def kernel_exec_timeout(self) -> bool: """bool: Specifies whether there is a run time limit on kernels.""" - @property def integrated(self) -> bool: """bool: Device is integrated with host memory.""" - @property def can_map_host_memory(self) -> bool: """bool: Device can map host memory into CUDA address space.""" - @property def compute_mode(self) -> int: """int: Compute mode (See CUcomputemode for details).""" - @property def concurrent_kernels(self) -> bool: """bool: Device can possibly execute multiple kernels concurrently.""" - @property def ecc_enabled(self) -> bool: """bool: Device has ECC support enabled.""" - @property def pci_bus_id(self) -> int: """int: PCI bus ID of the device.""" - @property def pci_device_id(self) -> int: """int: PCI device ID of the device.""" - @property def pci_domain_id(self) -> int: """int: PCI domain ID of the device.""" - @property def tcc_driver(self) -> bool: """bool: Device is using TCC driver model.""" - @property def memory_clock_rate(self) -> int: """int: Peak memory clock frequency in kilohertz.""" - @property def global_memory_bus_width(self) -> int: """int: Global memory bus width in bits.""" - @property def l2_cache_size(self) -> int: """int: Size of L2 cache in bytes.""" - @property def max_threads_per_multiprocessor(self) -> int: """int: Maximum resident threads per multiprocessor.""" - @property def unified_addressing(self) -> bool: """bool: Device shares a unified address space with the host.""" - @property def compute_capability_major(self) -> int: """int: Major compute capability version number.""" - @property def compute_capability_minor(self) -> int: """int: Minor compute capability version number.""" - @property def global_l1_cache_supported(self) -> bool: """bool: Device supports caching globals in L1.""" - @property def local_l1_cache_supported(self) -> bool: """bool: Device supports caching locals in L1.""" - @property def max_shared_memory_per_multiprocessor(self) -> int: """int: Maximum shared memory available per multiprocessor in bytes.""" - @property def max_registers_per_multiprocessor(self) -> int: """int: Maximum number of 32-bit registers available per multiprocessor.""" - @property def managed_memory(self) -> bool: """bool: Device can allocate managed memory on this system.""" - @property def multi_gpu_board(self) -> bool: """bool: Device is on a multi-GPU board.""" - @property def multi_gpu_board_group_id(self) -> int: """int: Unique id for a group of devices on the same multi-GPU board.""" - @property def host_native_atomic_supported(self) -> bool: """bool: Link between the device and the host supports all native atomic operations.""" - @property def single_to_double_precision_perf_ratio(self) -> int: """int: Ratio of single precision performance (in floating-point operations per second) to double precision performance.""" - @property def pageable_memory_access(self) -> bool: """bool: Device supports coherently accessing pageable memory without calling cudaHostRegister on it.""" - @property def concurrent_managed_access(self) -> bool: """bool: Device can coherently access managed memory concurrently with the CPU.""" - @property def compute_preemption_supported(self) -> bool: """bool: Device supports compute preemption.""" - @property def can_use_host_pointer_for_registered_mem(self) -> bool: """bool: Device can access host registered memory at the same virtual address as the CPU.""" - @property def cooperative_launch(self) -> bool: """bool: Device supports launching cooperative kernels via cuLaunchCooperativeKernel.""" - @property def max_shared_memory_per_block_optin(self) -> int: """int: Maximum optin shared memory per block.""" - @property def pageable_memory_access_uses_host_page_tables(self) -> bool: """bool: Device accesses pageable memory via the host's page tables.""" - @property def direct_managed_mem_access_from_host(self) -> bool: """bool: The host can directly access managed memory on the device without migration.""" - @property def virtual_memory_management_supported(self) -> bool: """bool: Device supports virtual memory management APIs like cuMemAddressReserve, cuMemCreate, cuMemMap and related APIs.""" - @property def handle_type_posix_file_descriptor_supported(self) -> bool: """bool: Device supports exporting memory to a posix file descriptor with cuMemExportToShareableHandle, if requested via cuMemCreate.""" - @property def handle_type_win32_handle_supported(self) -> bool: """bool: Device supports exporting memory to a Win32 NT handle with cuMemExportToShareableHandle, if requested via cuMemCreate.""" - @property def handle_type_win32_kmt_handle_supported(self) -> bool: """bool: Device supports exporting memory to a Win32 KMT handle with cuMemExportToShareableHandle, if requested via cuMemCreate.""" - @property def max_blocks_per_multiprocessor(self) -> int: """int: Maximum number of blocks per multiprocessor.""" - @property def generic_compression_supported(self) -> bool: """bool: Device supports compression of memory.""" - @property def max_persisting_l2_cache_size(self) -> int: """int: Maximum L2 persisting lines capacity setting in bytes.""" - @property def max_access_policy_window_size(self) -> int: """int: Maximum value of CUaccessPolicyWindow.num_bytes.""" - @property def gpu_direct_rdma_with_cuda_vmm_supported(self) -> bool: """bool: Device supports specifying the GPUDirect RDMA flag with cuMemCreate.""" - @property def reserved_shared_memory_per_block(self) -> int: """int: Shared memory reserved by CUDA driver per block in bytes.""" - @property def sparse_cuda_array_supported(self) -> bool: """bool: Device supports sparse CUDA arrays and sparse CUDA mipmapped arrays.""" - @property def read_only_host_register_supported(self) -> bool: """bool: True if device supports using the cuMemHostRegister flag CU_MEMHOSTREGISTER_READ_ONLY to register memory that must be mapped as read-only to the GPU, False if not.""" - @property def memory_pools_supported(self) -> bool: """bool: Device supports using the cuMemAllocAsync and cuMemPool family of APIs.""" - @property def gpu_direct_rdma_supported(self) -> bool: """bool: Device supports GPUDirect RDMA APIs, like nvidia_p2p_get_pages (see https://docs.nvidia.com/cuda/gpudirect-rdma for more information).""" - @property def gpu_direct_rdma_flush_writes_options(self) -> int: """int: The returned attribute shall be interpreted as a bitmask, where the individual bits are described by the CUflushGPUDirectRDMAWritesOptions enum.""" - @property def gpu_direct_rdma_writes_ordering(self) -> int: """int: GPUDirect RDMA writes to the device do not need to be flushed for consumers within the scope indicated by the returned attribute. See CUGPUDirectRDMAWritesOrdering for the numerical values returned here.""" - @property def mempool_supported_handle_types(self) -> int: """int: Handle types supported with mempool based IPC.""" - @property def deferred_mapping_cuda_array_supported(self) -> bool: """bool: Device supports deferred mapping CUDA arrays and CUDA mipmapped arrays.""" - @property def numa_config(self) -> int: """int: NUMA configuration of a device: value is of type CUdeviceNumaConfig enum.""" - @property def numa_id(self) -> int: """int: NUMA node ID of the GPU memory.""" - @property def multicast_supported(self) -> bool: """bool: Device supports switch multicast and reduction operations.""" - @property def surface_alignment(self) -> int: """int: Surface alignment requirement in bytes.""" - @property def async_engine_count(self) -> int: """int: Number of asynchronous engines.""" - @property def can_tex2d_gather(self) -> bool: """bool: True if device supports 2D texture gather operations, False if not.""" - @property def maximum_texture2d_gather_width(self) -> int: """int: Maximum 2D texture gather width.""" - @property def maximum_texture2d_gather_height(self) -> int: """int: Maximum 2D texture gather height.""" - @property def stream_priorities_supported(self) -> bool: """bool: True if device supports stream priorities, False if not.""" - @property def can_flush_remote_writes(self) -> bool: """bool: The CU_STREAM_WAIT_VALUE_FLUSH flag and the CU_STREAM_MEM_OP_FLUSH_REMOTE_WRITES MemOp are supported on the device. See Stream Memory Operations for additional details.""" - @property def host_register_supported(self) -> bool: """bool: Device supports host memory registration via cudaHostRegister.""" - @property def timeline_semaphore_interop_supported(self) -> bool: """bool: External timeline semaphore interop is supported on the device.""" - @property def cluster_launch(self) -> bool: """bool: Indicates device supports cluster launch.""" - @property def can_use_64_bit_stream_mem_ops(self) -> bool: """bool: 64-bit operations are supported in cuStreamBatchMemOp and related MemOp APIs.""" - @property def can_use_stream_wait_value_nor(self) -> bool: """bool: CU_STREAM_WAIT_VALUE_NOR is supported by MemOp APIs.""" - @property def dma_buf_supported(self) -> bool: """bool: Device supports buffer sharing with dma_buf mechanism.""" - @property def ipc_event_supported(self) -> bool: """bool: Device supports IPC Events.""" - @property def mem_sync_domain_count(self) -> int: """int: Number of memory domains the device supports.""" - @property def tensor_map_access_supported(self) -> bool: """bool: Device supports accessing memory using Tensor Map.""" - @property def handle_type_fabric_supported(self) -> bool: """bool: Device supports exporting memory to a fabric handle with cuMemExportToShareableHandle() or requested with cuMemCreate().""" - @property def unified_function_pointers(self) -> bool: """bool: Device supports unified function pointers.""" - @property def mps_enabled(self) -> bool: """bool: Indicates if contexts created on this device will be shared via MPS.""" - @property def host_numa_id(self) -> int: """int: NUMA ID of the host node closest to the device. Returns -1 when system does not support NUMA.""" - @property def d3d12_cig_supported(self) -> bool: """bool: Device supports CIG with D3D12.""" - @property def mem_decompress_algorithm_mask(self) -> int: """int: The returned value shall be interpreted as a bitmask, where the individual bits are described by the CUmemDecompressAlgorithm enum.""" - @property def mem_decompress_maximum_length(self) -> int: """int: The returned value is the maximum length in bytes of a single decompress operation that is allowed.""" - @property def vulkan_cig_supported(self) -> bool: """bool: Device supports CIG with Vulkan.""" - @property def gpu_pci_device_id(self) -> int: """int: The combined 16-bit PCI device ID and 16-bit PCI vendor ID. Returns 0 if the driver does not support this query. """ - @property def gpu_pci_subsystem_id(self) -> int: """int: The combined 16-bit PCI subsystem ID and 16-bit PCI subsystem vendor ID. Returns 0 if the driver does not support this query. """ - @property def host_numa_virtual_memory_management_supported(self) -> bool: """bool: Device supports HOST_NUMA location with the virtual memory management APIs like cuMemCreate, cuMemMap and related APIs.""" - @property def host_numa_memory_pools_supported(self) -> bool: """bool: Device supports HOST_NUMA location with the cuMemAllocAsync and cuMemPool family of APIs.""" - @property def host_numa_multinode_ipc_supported(self) -> bool: """bool: Device supports HOST_NUMA location IPC between nodes in a multi-node system.""" - @property def host_memory_pools_supported(self) -> bool: """bool: Device supports HOST location with the cuMemAllocAsync and cuMemPool family of APIs.""" - @property def host_virtual_memory_management_supported(self) -> bool: """bool: Device supports HOST location with the virtual memory management APIs like cuMemCreate, cuMemMap and related APIs.""" - @property def host_alloc_dma_buf_supported(self) -> bool: """bool: Device supports page-locked host memory buffer sharing with dma_buf mechanism.""" - @property def only_partial_host_native_atomic_supported(self) -> bool: """bool: Link between the device and the host supports only some native atomic operations.""" @@ -638,12 +488,8 @@ class Device: """ __slots__ = ('_device_id', '_memory_resource', '_has_inited', '_properties', '_resources', '_uuid', '_context', '__weakref__') - def __new__(cls, device_id: Device | int | None=None) -> Device: - ... - - def _check_context_initialized(self) -> None: - ... - + def __new__(cls, device_id: Device | int | None=None) -> Device: ... + def _check_context_initialized(self) -> None: ... @classmethod def get_all_devices(cls) -> tuple[Device, ...]: """ @@ -654,8 +500,7 @@ class Device: tuple of Device A tuple containing instances of available devices. """ - - def to_system_device(self) -> 'cuda.core.system.Device': + def to_system_device(self) -> cuda.core.system.Device: """ Get the corresponding :class:`cuda.core.system.Device` (which is used for NVIDIA Management Library (NVML) access) for this @@ -668,15 +513,12 @@ class Device: cuda.core.system.Device The corresponding system-level device instance used for NVML access. """ - @property def device_id(self) -> int: """Return device ordinal.""" - @property def pci_bus_id(self) -> str: """Return a PCI Bus Id string for this device.""" - def can_access_peer(self, peer: Device | int) -> bool: """Check if this device can access memory from the specified peer device. @@ -688,7 +530,6 @@ class Device: peer : Device | int The peer device to check accessibility to. Can be a :obj:`~_device.Device` object or device ID. """ - @property def uuid(self) -> str: """Return a UUID for the device. @@ -705,27 +546,21 @@ class Device: The UUID is cached after first access to avoid repeated CUDA API calls. """ - @property def name(self) -> str: """Return the device name.""" - @property def properties(self) -> DeviceProperties: """Return a :obj:`~_device.DeviceProperties` class with information about the device.""" - @property def resources(self) -> DeviceResources: """Return the hardware resource query namespace for this device.""" - @property def compute_capability(self) -> ComputeCapability: """Return a named tuple with 2 fields: major and minor.""" - @property def arch(self) -> str: """Return compute capability as a string (e.g., '75' for CC 7.5).""" - @property def context(self) -> Context: """Return the :obj:`~_context.Context` associated with this device. @@ -735,15 +570,11 @@ class Device: Device must be initialized. """ - @property def memory_resource(self) -> MemoryResource: """Return :obj:`~_memory.MemoryResource` associated with this device.""" - @memory_resource.setter - def memory_resource(self, mr: MemoryResource) -> None: - ... - + def memory_resource(self, mr: MemoryResource) -> None: ... @property def default_stream(self) -> Stream: """Return default CUDA :obj:`~_stream.Stream` associated with this device. @@ -755,22 +586,12 @@ class Device: the legacy stream. """ - def __int__(self) -> int: """Return device_id.""" - - def __repr__(self) -> str: - ... - - def __hash__(self) -> int: - ... - - def __eq__(self, other: object) -> bool: - ... - - def __reduce__(self) -> tuple[object, ...]: - ... - + def __repr__(self) -> str: ... + def __hash__(self) -> int: ... + def __eq__(self, other: object) -> bool: ... + def __reduce__(self) -> tuple[object, ...]: ... def set_current(self, ctx: Context | None=None) -> Context | None: """Set device to be used for GPU executions. @@ -801,7 +622,6 @@ class Device: >>> # ... do work on device 0 ... """ - def create_context(self, options: ContextOptions | None=None) -> Context: """Create a new :obj:`~_context.Context` object. @@ -820,8 +640,7 @@ class Device: Newly created context object. """ - - def create_stream(self, obj: IsStreamType | None=None, options: object=None) -> Stream: + def create_stream(self, obj: IsStreamType | None=None, options: object | None=None) -> Stream: """Create a :obj:`~_stream.Stream` object. New stream objects can be created in two different ways: @@ -849,7 +668,6 @@ class Device: Newly created stream object. """ - def create_event(self, options: EventOptions | None=None) -> Event: """Create an :obj:`~_event.Event` object without recording it to a :obj:`~_stream.Stream`. @@ -868,7 +686,6 @@ class Device: Newly created event object. """ - def allocate(self, size: int, *, stream: Stream | GraphBuilder) -> Buffer: """Allocate device memory from a specified stream. @@ -894,7 +711,6 @@ class Device: Newly created buffer object. """ - def sync(self) -> None: """Synchronize the device. @@ -903,7 +719,6 @@ class Device: Device must be initialized. """ - def create_graph_builder(self) -> GraphBuilder: """Create a new :obj:`~graph.GraphBuilder` object. @@ -913,7 +728,6 @@ class Device: Newly created graph builder object. """ - def create_opaque_array(self, options: OpaqueArrayOptions) -> OpaqueArray: """Create an :obj:`~cuda.core.texture.OpaqueArray` on the current device. @@ -938,7 +752,6 @@ class Device: .. versionadded:: 1.1.0 """ - def create_mipmapped_array(self, options: MipmappedArrayOptions) -> MipmappedArray: """Create a :obj:`~cuda.core.texture.MipmappedArray` on the current device. @@ -963,7 +776,6 @@ class Device: .. versionadded:: 1.1.0 """ - def create_texture_object(self, *, resource: ResourceDescriptor, options: TextureObjectOptions | None=None) -> TextureObject: """Create a :obj:`~cuda.core.texture.TextureObject` on the current device. @@ -993,7 +805,6 @@ class Device: .. versionadded:: 1.1.0 """ - def create_surface_object(self, *, resource: ResourceDescriptor) -> SurfaceObject: """Create a :obj:`~cuda.core.texture.SurfaceObject` on the current device. @@ -1022,6 +833,3 @@ class Device: .. versionadded:: 1.1.0 """ -_tls = threading.local() -_lock = threading.Lock() -__all__ = ['Device'] \ No newline at end of file diff --git a/cuda_core/cuda/core/_device_resources.pyi b/cuda_core/cuda/core/_device_resources.pyi index 7514f5a2f43..a6837e837e9 100644 --- a/cuda_core/cuda/core/_device_resources.pyi +++ b/cuda_core/cuda/core/_device_resources.pyi @@ -1,6 +1,4 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_device_resources.pyx - -from __future__ import annotations +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_device_resources.pyx from collections.abc import Sequence as SequenceABC from dataclasses import dataclass @@ -8,6 +6,7 @@ from dataclasses import dataclass from cuda.core._device import Device from cuda.core.typing import WorkqueueSharingScopeType +__all__ = ['DeviceResources', 'SMResource', 'SMResourceOptions', 'WorkqueueResource', 'WorkqueueResourceOptions'] @dataclass class SMResourceOptions: @@ -61,8 +60,7 @@ class WorkqueueResourceOptions: sharing_scope: WorkqueueSharingScopeType | str | None = None concurrency_limit: int | None = None - def __post_init__(self): - ... + def __post_init__(self): ... class SMResource: """Represent an SM (streaming multiprocessor) resource partition. @@ -70,30 +68,22 @@ class SMResource: Instances are returned by :obj:`DeviceResources.sm` or :meth:`SMResource.split` and cannot be instantiated directly. """ - - def __init__(self, *args, **kwargs): - ... - + def __init__(self, *args, **kwargs): ... @property def handle(self) -> int: """Return the address of the underlying ``CUdevResource`` struct.""" - @property def sm_count(self) -> int: """Total SMs available in this resource.""" - @property def min_partition_size(self) -> int: """Minimum SM count required to create a partition.""" - @property def coscheduled_alignment(self) -> int: """Number of SMs guaranteed to be co-scheduled.""" - @property def flags(self) -> int: """Raw flags from the underlying SM resource.""" - def split(self, options: SMResourceOptions, *, dry_run: bool=False) -> tuple[list[SMResource], SMResource]: """Split this SM resource into groups and a remainder. @@ -120,14 +110,10 @@ class WorkqueueResource: Instances are returned by :obj:`DeviceResources.workqueue` and cannot be instantiated directly. """ - - def __init__(self, *args, **kwargs) -> None: - ... - + def __init__(self, *args, **kwargs) -> None: ... @property def handle(self) -> int: """Return the address of the underlying config ``CUdevResource`` struct.""" - @property def sharing_scope(self) -> WorkqueueSharingScopeType: """Current sharing scope of this workqueue resource. @@ -138,7 +124,6 @@ class WorkqueueResource: :meth:`configure` with :attr:`WorkqueueResourceOptions.sharing_scope`. """ - @property def concurrency_limit(self) -> int: """Current expected maximum concurrent stream-ordered workloads. @@ -149,11 +134,9 @@ class WorkqueueResource: via :meth:`configure` with :attr:`WorkqueueResourceOptions.concurrency_limit`. """ - @property def device(self) -> Device: """The :class:`~cuda.core.Device` this workqueue resource is available on.""" - def configure(self, options: WorkqueueResourceOptions) -> None: """Configure the workqueue resource in place. @@ -173,15 +156,10 @@ class DeviceResources: This class cannot be instantiated directly. """ - - def __init__(self, *args, **kwargs) -> None: - ... - + def __init__(self, *args, **kwargs) -> None: ... @property def sm(self) -> SMResource: """Return the :obj:`SMResource` for this device or context.""" - @property def workqueue(self) -> WorkqueueResource: """Return the :obj:`WorkqueueResource` for this device or context.""" -__all__ = ['DeviceResources', 'SMResource', 'SMResourceOptions', 'WorkqueueResource', 'WorkqueueResourceOptions'] \ No newline at end of file diff --git a/cuda_core/cuda/core/_dlpack.pyi b/cuda_core/cuda/core/_dlpack.pyi index 575d9ced8f5..37d65d9f0e4 100644 --- a/cuda_core/cuda/core/_dlpack.pyi +++ b/cuda_core/cuda/core/_dlpack.pyi @@ -1,11 +1,10 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_dlpack.pyx - -from __future__ import annotations +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_dlpack.pyx from enum import IntEnum +from typing import Any, Callable, TypeAlias, TypedDict -_DLDeviceType = int -DLDataTypeCode = int +_DLDeviceType: TypeAlias = int +DLDataTypeCode: TypeAlias = int class DLDeviceType(IntEnum): kDLCPU = 1 @@ -13,12 +12,56 @@ class DLDeviceType(IntEnum): kDLCUDAHost = 3 kDLCUDAManaged = 13 -def make_py_capsule(buf: object, versioned: bool) -> object: - ... +class DLDevice(TypedDict): + device_type: _DLDeviceType + device_id: int + +class DLDataType(TypedDict): + code: int + bits: int + lanes: int + +class DLTensor(TypedDict): + data: None + device: DLDevice + ndim: int + dtype: DLDataType + shape: int + strides: int + byte_offset: int + +class DLManagedTensor(TypedDict): + dl_tensor: DLTensor + manager_ctx: None + deleter: Callable[..., Any] + +class DLPackVersion(TypedDict): + major: int + minor: int + +class DLManagedTensorVersioned(TypedDict): + version: DLPackVersion + manager_ctx: None + deleter: Callable[..., Any] + flags: int + dl_tensor: DLTensor + +class DLPackExchangeAPIHeader(TypedDict): + version: DLPackVersion + prev_api: DLPackExchangeAPIHeader + +class DLPackExchangeAPI(TypedDict): + header: DLPackExchangeAPIHeader + managed_tensor_allocator: ... + managed_tensor_from_py_object_no_sync: ... + managed_tensor_to_py_object_no_sync: ... + dltensor_from_py_object_no_sync: ... + current_work_stream: ... def classify_dl_device(buf: object) -> tuple[int, int]: """Classify a buffer into a DLPack (device_type, device_id) pair. ``buf`` must expose ``is_device_accessible``, ``is_host_accessible``, ``is_managed``, and ``device_id`` attributes. - """ \ No newline at end of file + """ +def make_py_capsule(buf: object, versioned: bool) -> object: ... diff --git a/cuda_core/cuda/core/_event.pyi b/cuda_core/cuda/core/_event.pyi index 9391735b6ab..3fbb1b0b1b0 100644 --- a/cuda_core/cuda/core/_event.pyi +++ b/cuda_core/cuda/core/_event.pyi @@ -1,14 +1,13 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_event.pyx - -from __future__ import annotations +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_event.pyx from dataclasses import dataclass +from typing import Any import cuda.bindings.driver -import cython from cuda.core._context import Context from cuda.core._device import Device +__all__ = ['Event', 'EventOptions'] @dataclass class EventOptions: @@ -61,39 +60,22 @@ class Event: and they should instead be created through a :obj:`~_stream.Stream` object. """ - + def __init__(self, *args, **kwargs) -> None: ... def close(self): """Destroy the event. Releases the event handle. The underlying CUDA event is destroyed when the last reference is released. """ - - def __init__(self, *args, **kwargs) -> None: - ... - - def __isub__(self, other: object): - ... - - def __rsub__(self, other: object): - ... - - def __sub__(self, other: Event) -> float: - ... - - def __hash__(self) -> int: - ... - - def __eq__(self, other: object) -> bool: - ... - - def __repr__(self) -> str: - ... - + def __isub__(self, other: object): ... + def __rsub__(self, other: object): ... + def __sub__(self, other: Event) -> float: ... + def __hash__(self) -> int: ... + def __eq__(self, other: object) -> bool: ... + def __repr__(self) -> str: ... @property def ipc_descriptor(self) -> IPCEventDescriptor: """Descriptor for sharing this event with other processes.""" - @classmethod def from_ipc_descriptor(cls, ipc_descriptor: IPCEventDescriptor) -> Event: """Import an event that was exported from another process. @@ -110,21 +92,17 @@ class Event: A new event backed by the imported IPC handle. """ - @property def is_ipc_enabled(self) -> bool: """Return True if the event can be shared across process boundaries, otherwise False.""" - @property def is_timing_enabled(self) -> bool: """Return True if the event records timing data, otherwise False.""" - @property def is_blocking_sync(self) -> bool: """Return True if the event uses blocking synchronization (the CPU thread blocks on :meth:`sync` instead of busy-waiting), otherwise False. """ - def sync(self) -> None: """Synchronize until the event completes. @@ -134,11 +112,9 @@ class Event: thread busy-waits until the event has completed. """ - @property def is_done(self) -> bool: """Return True if all captured works have been completed, otherwise False.""" - @property def handle(self) -> cuda.bindings.driver.CUevent: """Return the underlying CUevent object. @@ -148,7 +124,6 @@ class Event: This handle is a Python object. To get the memory address of the underlying C handle, call ``int(Event.handle)``. """ - @property def device(self) -> Device: """Return the :obj:`~_device.Device` singleton associated with this event. @@ -160,27 +135,16 @@ class Event: context is set current after a event is created. """ - @property def context(self) -> Context: """Return the :obj:`~_context.Context` associated with this event.""" class IPCEventDescriptor: """Serializable object describing an event that can be shared between processes.""" - - def __init__(self, *arg, **kwargs) -> None: - ... - + def __init__(self, *arg, **kwargs) -> None: ... @staticmethod - def _init(reserved: bytes, is_blocking_sync: cython.bint) -> IPCEventDescriptor: - ... - - def __eq__(self, other: object) -> bool: - ... - - def __reduce__(self) -> tuple[object, ...]: - ... -__all__ = ['Event', 'EventOptions'] + def _init(reserved: bytes, is_blocking_sync: Any) -> IPCEventDescriptor: ... + def __eq__(self, other: object) -> bool: ... + def __reduce__(self) -> tuple[object, ...]: ... -def _reduce_event(event: Event) -> tuple[object, ...]: - ... \ No newline at end of file +def _reduce_event(event: Event) -> tuple[object, ...]: ... diff --git a/cuda_core/cuda/core/_graphics.pyi b/cuda_core/cuda/core/_graphics.pyi index b7022e5a18a..3ca77a137b6 100644 --- a/cuda_core/cuda/core/_graphics.pyi +++ b/cuda_core/cuda/core/_graphics.pyi @@ -1,6 +1,4 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_graphics.pyx - -from __future__ import annotations +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_graphics.pyx from typing import Sequence @@ -8,6 +6,8 @@ from cuda.bindings import cydriver from cuda.core._memory._buffer import Buffer from cuda.core._stream import Stream +__all__ = ['GraphicsResource'] +_REGISTER_FLAGS = {'none': cydriver.CU_GRAPHICS_REGISTER_FLAGS_NONE, 'read_only': cydriver.CU_GRAPHICS_REGISTER_FLAGS_READ_ONLY, 'write_discard': cydriver.CU_GRAPHICS_REGISTER_FLAGS_WRITE_DISCARD, 'surface_load_store': cydriver.CU_GRAPHICS_REGISTER_FLAGS_SURFACE_LDST, 'texture_gather': cydriver.CU_GRAPHICS_REGISTER_FLAGS_TEXTURE_GATHER} class GraphicsResource: """RAII wrapper for a CUDA graphics resource (``CUgraphicsResource``). @@ -48,23 +48,7 @@ class GraphicsResource: # ... launch kernels using buf.handle, buf.size ... pass """ - - def close(self, stream: object=None): - """Unregister this graphics resource from CUDA. - - If the resource is currently mapped, it is unmapped first. After - closing, the resource cannot be used again. - - Parameters - ---------- - stream : :class:`~cuda.core.Stream`, optional - Optional override for the stream used to close the currently - mapped buffer, if one exists. - """ - - def __init__(self) -> None: - ... - + def __init__(self) -> None: ... @classmethod def from_gl_buffer(cls, gl_buffer: int, *, flags: str | tuple[str, ...] | list[str] | None=None, stream: Stream | None=None) -> GraphicsResource: """Register an OpenGL buffer object for CUDA access. @@ -111,7 +95,6 @@ class GraphicsResource: ValueError If an unknown flag string is provided. """ - @classmethod def from_gl_image(cls, image: int, target: int, *, flags: str | tuple[str, ...] | list[str] | None=None) -> GraphicsResource: """Register an OpenGL texture or renderbuffer for CUDA access. @@ -142,10 +125,7 @@ class GraphicsResource: ValueError If an unknown flag string is provided. """ - - def _get_mapped_buffer(self) -> object: - ... - + def _get_mapped_buffer(self) -> object: ... def map(self, *, stream: Stream) -> Buffer: """Map this graphics resource for CUDA access. @@ -178,7 +158,6 @@ class GraphicsResource: CUDAError If the mapping fails. """ - def unmap(self, *, stream: Stream | None=None) -> None: """Unmap this graphics resource, releasing it back to the graphics API. @@ -198,29 +177,29 @@ class GraphicsResource: CUDAError If the unmapping fails. """ + def __enter__(self) -> object: ... + def __exit__(self, exc_type: type | None, exc_val: BaseException | None, exc_tb: object) -> bool: ... + def close(self, stream: object | None=None): + """Unregister this graphics resource from CUDA. - def __enter__(self) -> object: - ... - - def __exit__(self, exc_type: type | None, exc_val: BaseException | None, exc_tb: object) -> bool: - ... + If the resource is currently mapped, it is unmapped first. After + closing, the resource cannot be used again. + Parameters + ---------- + stream : :class:`~cuda.core.Stream`, optional + Optional override for the stream used to close the currently + mapped buffer, if one exists. + """ @property def is_mapped(self) -> bool: """Whether the resource is currently mapped for CUDA access.""" - @property def handle(self) -> int: """The raw ``CUgraphicsResource`` handle as a Python int.""" - @property def resource_handle(self) -> int: """Alias for :attr:`handle`.""" + def __repr__(self) -> str: ... - def __repr__(self) -> str: - ... -__all__ = ['GraphicsResource'] -_REGISTER_FLAGS = {'none': cydriver.CU_GRAPHICS_REGISTER_FLAGS_NONE, 'read_only': cydriver.CU_GRAPHICS_REGISTER_FLAGS_READ_ONLY, 'write_discard': cydriver.CU_GRAPHICS_REGISTER_FLAGS_WRITE_DISCARD, 'surface_load_store': cydriver.CU_GRAPHICS_REGISTER_FLAGS_SURFACE_LDST, 'texture_gather': cydriver.CU_GRAPHICS_REGISTER_FLAGS_TEXTURE_GATHER} - -def _parse_register_flags(flags: str | Sequence[str] | None) -> int: - ... \ No newline at end of file +def _parse_register_flags(flags: str | Sequence[str] | None) -> int: ... diff --git a/cuda_core/cuda/core/_kernel_arg_handler.pyi b/cuda_core/cuda/core/_kernel_arg_handler.pyi index 0ebd2c0d0b6..918548ef40c 100644 --- a/cuda_core/cuda/core/_kernel_arg_handler.pyi +++ b/cuda_core/cuda/core/_kernel_arg_handler.pyi @@ -1,18 +1,15 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_kernel_arg_handler.pyx +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_kernel_arg_handler.pyx -from __future__ import annotations +from typing import Any, Sequence, TypeAlias, TypedDict -from typing import Any, Sequence - -from libcpp.complex import complex as cpp_complex +cpp_single_complex: TypeAlias = Any +cpp_double_complex: TypeAlias = Any +class __half_raw(TypedDict): + x: int class ParamHolder: + ptr: int - def __init__(self, kernel_args: Sequence[Any]) -> None: - ... - - def __dealloc__(self) -> None: - ... -cpp_single_complex = cpp_complex.complex -cpp_double_complex = cpp_complex.complex \ No newline at end of file + def __init__(self, kernel_args: Sequence[Any]) -> None: ... + def __dealloc__(self) -> None: ... diff --git a/cuda_core/cuda/core/_launch_config.pyi b/cuda_core/cuda/core/_launch_config.pyi index 47187fb03d6..a731f2999ff 100644 --- a/cuda_core/cuda/core/_launch_config.pyi +++ b/cuda_core/cuda/core/_launch_config.pyi @@ -1,9 +1,9 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_launch_config.pyx - -from __future__ import annotations +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_launch_config.pyx from typing import Any +_LAUNCH_CONFIG_ATTRS = ('grid', 'cluster', 'block', 'shmem_size', 'is_cooperative', 'programmatic_stream_serialization') +__all__ = ['LaunchConfig'] class LaunchConfig: """Customizable launch options. @@ -40,6 +40,12 @@ class LaunchConfig: the kernel may overlap with a previous kernel in the same stream that signals completion via programmatic means. """ + grid: tuple[Any, ...] + cluster: tuple[Any, ...] + block: tuple[Any, ...] + shmem_size: int + is_cooperative: bool + programmatic_stream_serialization: bool 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: """Initialize LaunchConfig with validation. @@ -59,20 +65,11 @@ class LaunchConfig: programmatic_stream_serialization : bool, optional Whether to allow programmatic stream serialization / PDL (default: False) """ - - def _identity(self) -> tuple[Any, ...]: - ... - + def _identity(self) -> tuple[Any, ...]: ... def __repr__(self) -> str: """Return string representation of LaunchConfig.""" - - def __eq__(self, other: object) -> bool: - ... - - def __hash__(self) -> int: - ... -_LAUNCH_CONFIG_ATTRS = ('grid', 'cluster', 'block', 'shmem_size', 'is_cooperative', 'programmatic_stream_serialization') -__all__ = ['LaunchConfig'] + def __eq__(self, other: object) -> bool: ... + def __hash__(self) -> int: ... def _to_native_launch_config(config: LaunchConfig) -> object: """Convert LaunchConfig to native driver CUlaunchConfig. @@ -86,4 +83,4 @@ def _to_native_launch_config(config: LaunchConfig) -> object: ------- driver.CUlaunchConfig Native CUDA driver launch configuration - """ \ No newline at end of file + """ diff --git a/cuda_core/cuda/core/_launcher.pyi b/cuda_core/cuda/core/_launcher.pyi index 27ed7e86da7..72ba7c6c623 100644 --- a/cuda_core/cuda/core/_launcher.pyi +++ b/cuda_core/cuda/core/_launcher.pyi @@ -1,6 +1,4 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_launcher.pyx - -from __future__ import annotations +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_launcher.pyx from cuda.core._launch_config import LaunchConfig from cuda.core._module import Kernel @@ -28,4 +26,4 @@ def launch(stream: Stream | GraphBuilder | IsStreamType, config: LaunchConfig, k Variable length argument list that is provided to the launching kernel. - """ \ No newline at end of file + """ diff --git a/cuda_core/cuda/core/_layout.pyi b/cuda_core/cuda/core/_layout.pyi index 1562a2bf76f..0483a78b6ad 100644 --- a/cuda_core/cuda/core/_layout.pyi +++ b/cuda_core/cuda/core/_layout.pyi @@ -1,14 +1,17 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_layout.pyx +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_layout.pyx -from __future__ import annotations +from typing import Any, TypeAlias, TypedDict -import cython -from libcpp import vector +OrderFlag: TypeAlias = int +Property: TypeAlias = int +extent_t: TypeAlias = int +stride_t: TypeAlias = int +axis_t: TypeAlias = int +axes_mask_t: TypeAlias = int +property_mask_t: TypeAlias = int +extents_strides_t: TypeAlias = Any +axis_vec_t: TypeAlias = Any -OrderFlag = int -Property = int - -@cython.final class _StridedLayout: """ A class describing the layout of a multi-dimensional tensor @@ -39,10 +42,10 @@ class _StridedLayout: The offset (as a number of elements, not bytes) of the element at index ``(0,) * ndim``. See also :attr:`slice_offset_in_bytes`. """ + itemsize: int + slice_offset: stride_t - def __init__(self: _StridedLayout, shape: tuple[int, ...], strides: tuple[int, ...] | None, itemsize: int, divide_strides: bool=False) -> None: - ... - + def __init__(self: _StridedLayout, shape: tuple[int, ...], strides: tuple[int, ...] | None, itemsize: int, divide_strides: bool=False) -> None: ... @classmethod def dense(cls, shape: tuple[int], itemsize: int, stride_order: str | tuple[int]='C') -> _StridedLayout: """ @@ -72,7 +75,6 @@ class _StridedLayout: assert _StridedLayout.dense((5, 3, 7), 1, (2, 0, 1)) == _StridedLayout((5, 3, 7), (3, 1, 15), 1) """ - @classmethod def dense_like(cls, other: _StridedLayout, stride_order: str | tuple[int]='K') -> _StridedLayout: """ @@ -109,13 +111,8 @@ class _StridedLayout: assert _StridedLayout.dense_like(layout, "C") == _StridedLayout((7, 5, 3), (15, 3, 1), 1) assert _StridedLayout.dense_like(layout, "F") == _StridedLayout((7, 5, 3), (1, 7, 35), 1) """ - - def __repr__(self: _StridedLayout) -> str: - ... - - def __eq__(self, other: object) -> bool: - ... - + def __repr__(self: _StridedLayout) -> str: ... + def __eq__(self, other: object) -> bool: ... @property def ndim(self: _StridedLayout) -> int: """ @@ -123,7 +120,6 @@ class _StridedLayout: :type: int """ - @property def shape(self: _StridedLayout) -> tuple[int, ...]: """ @@ -131,7 +127,6 @@ class _StridedLayout: :type: tuple[int] """ - @property def strides(self: _StridedLayout) -> tuple[int, ...] | None: """ @@ -141,7 +136,6 @@ class _StridedLayout: :type: tuple[int] | None """ - @property def strides_in_bytes(self: _StridedLayout) -> tuple[int, ...] | None: """ @@ -149,7 +143,6 @@ class _StridedLayout: :type: tuple[int] | None """ - @property def stride_order(self: _StridedLayout) -> tuple[int, ...]: """ @@ -168,7 +161,6 @@ class _StridedLayout: :type: tuple[int] """ - @property def volume(self: _StridedLayout) -> int: """ @@ -176,7 +168,6 @@ class _StridedLayout: :type: int """ - @property def is_unique(self: _StridedLayout) -> bool: """ @@ -196,7 +187,6 @@ class _StridedLayout: :type: bool """ - @property def is_contiguous_c(self: _StridedLayout) -> bool: """ @@ -216,7 +206,6 @@ class _StridedLayout: :type: bool """ - @property def is_contiguous_f(self: _StridedLayout) -> bool: """ @@ -236,7 +225,6 @@ class _StridedLayout: :type: bool """ - @property def is_contiguous_any(self: _StridedLayout) -> bool: """ @@ -275,7 +263,6 @@ class _StridedLayout: :type: bool """ - @property def is_dense(self: _StridedLayout) -> bool: """ @@ -287,7 +274,6 @@ class _StridedLayout: :type: bool """ - @property def offset_bounds(self: _StridedLayout) -> tuple[int, int]: """ @@ -316,7 +302,6 @@ class _StridedLayout: :type: tuple[int, int] """ - @property def min_offset(self: _StridedLayout) -> int: """ @@ -324,7 +309,6 @@ class _StridedLayout: :type: int """ - @property def max_offset(self: _StridedLayout) -> int: """ @@ -332,7 +316,6 @@ class _StridedLayout: :type: int """ - @property def slice_offset_in_bytes(self: _StridedLayout) -> int: """ @@ -345,7 +328,6 @@ class _StridedLayout: :type: int """ - def required_size_in_bytes(self: _StridedLayout) -> int: """ The memory allocation size (in bytes) needed so that @@ -378,13 +360,11 @@ class _StridedLayout: b_view = StridedMemoryView.from_buffer(mem, layout, a_view.dtype) return b_view """ - def flattened_axis_mask(self: _StridedLayout) -> axes_mask_t: """ A mask describing which axes of this layout are mergeable using the :meth:`flattened` method. """ - def to_dense(self: _StridedLayout, stride_order: object='K') -> _StridedLayout: """ Returns a dense layout with the same shape and itemsize, @@ -392,7 +372,6 @@ class _StridedLayout: See :meth:`dense_like` method documentation for details. """ - def reshaped(self: _StridedLayout, shape: tuple[int]) -> _StridedLayout: """ Returns a layout with the new shape, if the new shape is compatible @@ -415,13 +394,11 @@ class _StridedLayout: assert layout.permuted((2, 0, 1)).reshaped((4, 15,)) == _StridedLayout((4, 15), (1, 4), 1) # layout.permuted((2, 0, 1)).reshaped((20, 3)) -> error """ - def permuted(self: _StridedLayout, axis_order: tuple[int]) -> _StridedLayout: """ Returns a new layout where the shape and strides tuples are permuted according to the specified permutation of axes. """ - def flattened(self: _StridedLayout, start_axis: int=0, end_axis: int=-1, mask: int | None=None) -> _StridedLayout: """ Merges consecutive extents into a single extent (equal to the product of merged extents) @@ -465,7 +442,6 @@ class _StridedLayout: assert layout.flattened(mask=mask) == _StridedLayout((4, 15), (15, 1), 4) assert layout2.flattened(mask=mask) == _StridedLayout((4, 15), (1, 4), 4) """ - def squeezed(self: _StridedLayout) -> _StridedLayout: """ Returns a new layout where all the singleton dimensions (extents equal to 1) @@ -473,14 +449,12 @@ class _StridedLayout: the returned layout will be reduced to a 1-dim layout with shape (0,) and strides (0,). """ - def unsqueezed(self: _StridedLayout, axis: int | tuple[int]) -> _StridedLayout: """ Returns a new layout where the specified axis or axes are added as singleton extents. The ``axis`` can be either a single integer in range ``[0, ndim]`` or a tuple of unique integers in range ``[0, ndim + len(axis) - 1]``. """ - def broadcast_to(self: _StridedLayout, shape: tuple[int]) -> _StridedLayout: """ Returns a layout with the new shape, if the old shape can be @@ -494,7 +468,6 @@ class _StridedLayout: Strides of the added or modified extents are set to 0, the remaining ones are unchanged. If the shapes are not compatible, a ValueError is raised. """ - def repacked(self: _StridedLayout, itemsize: int, data_ptr: int=0, axis: int=-1, keep_dim: bool=True) -> _StridedLayout: """ Converts the layout to match the specified itemsize. @@ -546,13 +519,11 @@ class _StridedLayout: b = numpy.from_dlpack(complex_view) assert b.shape == (5, 3) """ - def max_compatible_itemsize(self: _StridedLayout, max_itemsize: int=16, data_ptr: int=0, axis: int=-1) -> int: """ Returns the maximum itemsize (but no greater than ``max_itemsize``) that can be used with the :meth:`repacked` method for the current layout. """ - def sliced(self: _StridedLayout, slices: int | slice | tuple[int | slice]) -> _StridedLayout: """ Returns a sliced layout. @@ -569,13 +540,10 @@ class _StridedLayout: any data access. """ + def __getitem__(self: _StridedLayout, slices: int | slice | tuple[int | slice]) -> _StridedLayout: ... - def __getitem__(self: _StridedLayout, slices: int | slice | tuple[int | slice]) -> _StridedLayout: - ... -extent_t = int -stride_t = int -axis_t = int -axes_mask_t = int -property_mask_t = int -extents_strides_t = vector.vector -axis_vec_t = vector.vector \ No newline at end of file +class BaseLayout(TypedDict): + _mem: extents_strides_t + shape: extent_t + strides: stride_t + ndim: int diff --git a/cuda_core/cuda/core/_linker.pyi b/cuda_core/cuda/core/_linker.pyi index 42b08313f78..a649bd69e10 100644 --- a/cuda_core/cuda/core/_linker.pyi +++ b/cuda_core/cuda/core/_linker.pyi @@ -1,4 +1,4 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_linker.pyx +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_linker.pyx """Linking machinery for combining object codes. @@ -6,8 +6,6 @@ This module provides :class:`Linker` for linking one or more :class:`~cuda.core.ObjectCode` objects, with :class:`LinkerOptions` for configuration. """ -from __future__ import annotations - from dataclasses import dataclass from typing import Union @@ -16,6 +14,15 @@ import cuda.bindings.nvjitlink from cuda.core._module import ObjectCode from cuda.core.typing import CompilerBackendType, ObjectCodeFormatType +_keep_driver_in_stub: cuda.bindings.driver.CUlinkState +_keep_nvjitlink_in_stub: cuda.bindings.nvjitlink.nvJitLinkHandle +__all__ = ['Linker', 'LinkerOptions'] +LinkerHandleT = Union['cuda.bindings.nvjitlink.nvJitLinkHandle', 'cuda.bindings.driver.CUlinkState'] +_driver = None +_inited = False +_use_nvjitlink_backend = None +_nvjitlink_input_types = None +_driver_input_types = None class Linker: """Represent a linking machinery to link one or more object codes into @@ -31,10 +38,7 @@ class Linker: options : :class:`LinkerOptions`, optional Options for the linker. If not provided, default options will be used. """ - - def __init__(self, options: LinkerOptions | None=None, *object_codes: ObjectCode): - ... - + def __init__(self, *object_codes: ObjectCode, options: LinkerOptions | None=None): ... def link(self, target_type: ObjectCodeFormatType | str) -> ObjectCode: """Link the provided object codes into a single output of the specified target type. @@ -53,7 +57,6 @@ class Linker: Ensure that input object codes were compiled with appropriate flags for linking (e.g., relocatable device code enabled). """ - def get_error_log(self) -> str: """Get the error log generated by the linker. @@ -62,7 +65,6 @@ class Linker: str The error log. """ - def get_info_log(self) -> str: """Get the info log generated by the linker. @@ -71,10 +73,8 @@ class Linker: str The info log. """ - def close(self) -> None: """Destroy this linker.""" - @property def handle(self) -> LinkerHandleT: """Return the underlying handle object. @@ -88,7 +88,6 @@ class Linker: This handle is a Python object. To get the memory address of the underlying C handle, call ``int(Linker.handle)``. """ - @classmethod def which_backend(cls) -> CompilerBackendType: """Return which linking backend will be used. @@ -201,15 +200,9 @@ class LinkerOptions: no_cache: bool | None = None numba_debug: bool | None = None - def __post_init__(self) -> None: - ... - - def _prepare_nvjitlink_options(self, as_bytes: bool=False) -> list[bytes] | list[str]: - ... - - def _prepare_driver_options(self) -> tuple[list[object], list[object]]: - ... - + def __post_init__(self) -> None: ... + def _prepare_nvjitlink_options(self, as_bytes: bool=False) -> list[bytes] | list[str]: ... + def _prepare_driver_options(self) -> tuple[list[object], list[object]]: ... def as_bytes(self, backend: str='nvjitlink') -> list[bytes]: """Convert linker options to bytes format for the nvjitlink backend. @@ -230,21 +223,8 @@ class LinkerOptions: RuntimeError If nvJitLink backend is not available. """ -_keep_driver_in_stub: 'cuda.bindings.driver.CUlinkState' -_keep_nvjitlink_in_stub: 'cuda.bindings.nvjitlink.nvJitLinkHandle' -__all__ = ['Linker', 'LinkerOptions'] -LinkerHandleT = Union['cuda.bindings.nvjitlink.nvJitLinkHandle', 'cuda.bindings.driver.CUlinkState'] -_driver = None -_inited = False -_use_nvjitlink_backend = None -_nvjitlink_input_types = None -_driver_input_types = None - -def _nvjitlink_has_version_symbol(nvjitlink) -> bool: - ... +def _nvjitlink_has_version_symbol(nvjitlink) -> bool: ... def _decide_nvjitlink_or_driver() -> bool: """Return True if falling back to the cuLink* driver APIs.""" - -def _lazy_init() -> None: - ... \ No newline at end of file +def _lazy_init() -> None: ... diff --git a/cuda_core/cuda/core/_memory/_buffer.pyi b/cuda_core/cuda/core/_memory/_buffer.pyi index b441754503c..f0ba484217e 100644 --- a/cuda_core/cuda/core/_memory/_buffer.pyi +++ b/cuda_core/cuda/core/_memory/_buffer.pyi @@ -1,8 +1,7 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_memory/_buffer.pyx +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_memory/_buffer.pyx -from __future__ import annotations +from typing import TypedDict -import cython from cuda.core._memory._copy_enums import CopyOptions from cuda.core._memory._device_memory_resource import DeviceMemoryResource from cuda.core._memory._ipc import IPCBufferDescriptor @@ -12,6 +11,7 @@ from cuda.core._utils.pycompat import BufferProtocol from cuda.core.graph import GraphBuilder from cuda.core.typing import DevicePointerType +__all__ = ['Buffer', 'MemoryResource'] class Buffer: """Represent a handle to allocated memory. @@ -29,16 +29,10 @@ class Buffer: by calling :meth:`from_ipc_descriptor` and therefore performs an IPC import. Do not unpickle buffers from untrusted sources. """ + _size: int - def __cinit__(self) -> None: - ... - - def _clear(self) -> None: - ... - - def __init__(self, *args, **kwargs) -> None: - ... - + def _clear(self) -> None: ... + def __init__(self, *args, **kwargs) -> None: ... @classmethod 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: """Create a Buffer from a raw pointer. @@ -50,14 +44,9 @@ class Buffer: (``stream`` if given, otherwise ``default_stream()``). Recording a default-stream token requires a CUDA context to be current. """ - @staticmethod - def _reduce_helper(mr, ipc_descriptor): - ... - - def __reduce__(self) -> tuple[object, ...]: - ... - + def _reduce_helper(mr, ipc_descriptor): ... + def __reduce__(self) -> tuple[object, ...]: ... @staticmethod def from_handle(ptr: DevicePointerType, size: int, mr: MemoryResource | None=None, owner: object | None=None, *, stream: Stream | GraphBuilder | None=None) -> Buffer: """Create a new :class:`Buffer` object from a pointer. @@ -90,7 +79,6 @@ class Buffer: non-owning reference. The pointer will NOT be freed when the :class:`Buffer` is closed or garbage collected. """ - @classmethod def from_ipc_descriptor(cls, mr: DeviceMemoryResource | PinnedMemoryResource, ipc_descriptor: IPCBufferDescriptor, *, stream: Stream) -> Buffer: """Import a buffer that was exported from another process. @@ -111,12 +99,9 @@ class Buffer: and must be treated as untrusted input unless the peer is known to be cooperating. """ - @property - @cython.critical_section def ipc_descriptor(self) -> IPCBufferDescriptor: """Descriptor for sharing this buffer with other processes.""" - def close(self, stream: Stream | GraphBuilder | None=None) -> None: """Deallocate this buffer asynchronously on the given stream. @@ -134,7 +119,6 @@ class Buffer: set_deallocation_stream Change the deallocation stream without closing the buffer. """ - def set_deallocation_stream(self, stream: Stream | GraphBuilder) -> None: """Change the stream that orders this buffer's eventual deallocation. @@ -164,13 +148,8 @@ class Buffer: Synchronizing concurrent mutation and destruction of the same buffer is the caller's responsibility. """ - - def __enter__(self): - ... - - def __exit__(self, exc_type, exc_val, exc_tb): - ... - + def __enter__(self): ... + def __exit__(self, exc_type, exc_val, exc_tb): ... def copy_to(self, dst: Buffer | None=None, *, stream: Stream | GraphBuilder, options: CopyOptions | None=None) -> Buffer: """Copy from this buffer to the dst buffer asynchronously on the given stream. @@ -210,7 +189,6 @@ class Buffer: back to a plain copy cannot honor that guarantee. """ - def copy_from(self, src: Buffer, *, stream: Stream | GraphBuilder, options: CopyOptions | None=None) -> None: """Copy from the src buffer to this buffer asynchronously on the given stream. @@ -244,7 +222,6 @@ class Buffer: cuda.bindings or the driver is older than CUDA 13.2: falling back to a plain copy cannot honor that guarantee. """ - def fill(self, value: int | BufferProtocol, *, stream: Stream | GraphBuilder) -> None: """Fill this buffer with a repeating byte pattern. @@ -267,23 +244,13 @@ class Buffer: If int value is outside [0, 256). """ - - def __dlpack__(self, *, stream: int | None=None, max_version: tuple[int, int] | None=None, dl_device: tuple[int, int] | None=None, copy: bool | None=None) -> object: - ... - - def __dlpack_device__(self) -> tuple[int, int]: - ... - - def __buffer__(self, flags: int, /) -> memoryview: - ... - - def __release_buffer__(self, buffer: memoryview, /) -> None: - ... - + def __dlpack__(self, *, stream: int | None=None, max_version: tuple[int, int] | None=None, dl_device: tuple[int, int] | None=None, copy: bool | None=None) -> object: ... + def __dlpack_device__(self) -> tuple[int, int]: ... + def __buffer__(self, flags: int, /) -> memoryview: ... + def __release_buffer__(self, buffer: memoryview, /) -> None: ... @property def device_id(self) -> int: """Return the device ordinal of this buffer.""" - @property def handle(self) -> int: """Return the buffer handle object. @@ -293,40 +260,27 @@ class Buffer: This handle is a Python object. To get the memory address of the underlying C handle, call ``int(Buffer.handle)``. """ - - def __eq__(self, other: object) -> bool: - ... - - def __hash__(self) -> int: - ... - - def __repr__(self) -> str: - ... - + def __eq__(self, other: object) -> bool: ... + def __hash__(self) -> int: ... + def __repr__(self) -> str: ... @property def is_device_accessible(self) -> bool: """Return True if this buffer can be accessed by the GPU, otherwise False.""" - @property def is_host_accessible(self) -> bool: """Return True if this buffer can be accessed by the CPU, otherwise False.""" - @property def is_managed(self) -> bool: """Return True if this buffer is CUDA managed (unified) memory, otherwise False.""" - @property def is_mapped(self) -> bool: """Return True if this buffer is mapped into the process via IPC.""" - @property def memory_resource(self) -> MemoryResource: """Return the memory resource associated with this buffer.""" - @property def size(self) -> int: """Return the memory size of this buffer.""" - @property def owner(self) -> object: """Return the object holding external allocation.""" @@ -342,7 +296,6 @@ class MemoryResource: buffer properties are retrieved simply by looking up the underlying memory resource's respective property.) """ - def allocate(self, size: int, *, stream: Stream | GraphBuilder) -> Buffer: """Allocate a buffer of the requested size. @@ -366,7 +319,6 @@ class MemoryResource: The allocated buffer object, which can be used for device or host operations depending on the resource's properties. """ - def deallocate(self, ptr: DevicePointerType, size: int, *, stream: Stream | GraphBuilder) -> None: """Deallocate a buffer previously allocated by this resource. @@ -381,20 +333,21 @@ class MemoryResource: asynchronously. Must be passed explicitly; pass ``device.default_stream`` to use the default stream. """ - @property def is_device_accessible(self) -> bool: """Whether buffers allocated by this resource are device-accessible.""" - @property def is_host_accessible(self) -> bool: """Whether buffers allocated by this resource are host-accessible.""" - @property def is_managed(self) -> bool: """Whether buffers allocated by this resource are CUDA managed (unified) memory.""" - @property def device_id(self) -> int: """Device ID associated with this memory resource, or -1 if not applicable.""" -__all__ = ['Buffer', 'MemoryResource'] \ No newline at end of file + +class _MemAttrs(TypedDict): + device_id: int + is_device_accessible: bool + is_host_accessible: bool + is_managed: bool diff --git a/cuda_core/cuda/core/_memory/_copy_attributes.pyi b/cuda_core/cuda/core/_memory/_copy_attributes.pyi index 0fceb058f53..93b9a97aa2b 100644 --- a/cuda_core/cuda/core/_memory/_copy_attributes.pyi +++ b/cuda_core/cuda/core/_memory/_copy_attributes.pyi @@ -1,3 +1 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_memory/_copy_attributes.pyx - -from __future__ import annotations \ No newline at end of file +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_memory/_copy_attributes.pyx diff --git a/cuda_core/cuda/core/_memory/_copy_ops.pyi b/cuda_core/cuda/core/_memory/_copy_ops.pyi index 9923f2a0042..f3439732230 100644 --- a/cuda_core/cuda/core/_memory/_copy_ops.pyi +++ b/cuda_core/cuda/core/_memory/_copy_ops.pyi @@ -1,6 +1,4 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_memory/_copy_ops.pyx - -from __future__ import annotations +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_memory/_copy_ops.pyx from collections.abc import Sequence @@ -21,7 +19,6 @@ def _normalize_copy_options(options: CopyOptions | Sequence[CopyOptions] | None, this expansion (and the run encoding applied to it) is the only observable evidence that a scalar reached every copy. """ - def copy_batch(stream: Stream, srcs: Sequence[Buffer], dsts: Sequence[Buffer], *, options: CopyOptions | Sequence[CopyOptions] | None=None) -> None: """Copy a batch of buffers asynchronously. @@ -93,4 +90,4 @@ def copy_batch(stream: Stream, srcs: Sequence[Buffer], dsts: Sequence[Buffer], * stream-ordered access would let a caller reuse the source buffer before the real read happens. - """ \ No newline at end of file + """ diff --git a/cuda_core/cuda/core/_memory/_device_memory_resource.pyi b/cuda_core/cuda/core/_memory/_device_memory_resource.pyi index efe845377c0..897e1d03302 100644 --- a/cuda_core/cuda/core/_memory/_device_memory_resource.pyi +++ b/cuda_core/cuda/core/_memory/_device_memory_resource.pyi @@ -1,6 +1,4 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_memory/_device_memory_resource.pyx - -from __future__ import annotations +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_memory/_device_memory_resource.pyx import uuid from dataclasses import dataclass @@ -10,6 +8,7 @@ from cuda.core._memory._ipc import IPCAllocationHandle from cuda.core._memory._memory_pool import _MemPool from cuda.core._memory._peer_access_utils import PeerAccessibleBySetProxy +__all__ = ['DeviceMemoryResource', 'DeviceMemoryResourceOptions'] @dataclass class DeviceMemoryResourceOptions: @@ -116,16 +115,8 @@ class DeviceMemoryResource(_MemPool): descriptors from trusted peers, and do not unpickle buffers from untrusted sources. """ - - def __cinit__(self, *args, **kwargs) -> None: - ... - - def __init__(self, device_id: Device | int, options: DeviceMemoryResourceOptions | None=None) -> None: - ... - - def __reduce__(self) -> tuple[object, ...]: - ... - + def __init__(self, device_id: Device | int, options: DeviceMemoryResourceOptions | None=None) -> None: ... + def __reduce__(self) -> tuple[object, ...]: ... @staticmethod def from_registry(uuid: uuid.UUID) -> DeviceMemoryResource: """ @@ -136,7 +127,6 @@ class DeviceMemoryResource(_MemPool): RuntimeError If no mapped memory resource is found in the registry. """ - def register(self, uuid: uuid.UUID) -> DeviceMemoryResource: """ Register a mapped memory resource. @@ -146,7 +136,6 @@ class DeviceMemoryResource(_MemPool): The registered mapped memory resource. If one was previously registered with the given key, it is returned. """ - @classmethod def from_allocation_handle(cls, device_id: Device | int, alloc_handle: int | IPCAllocationHandle) -> DeviceMemoryResource: """Create a device memory resource from an allocation handle. @@ -170,7 +159,6 @@ class DeviceMemoryResource(_MemPool): ------- A new device memory resource instance with the imported handle. """ - @property def allocation_handle(self) -> IPCAllocationHandle: """Shareable handle for this memory pool (requires IPC). @@ -178,11 +166,9 @@ class DeviceMemoryResource(_MemPool): The handle can be used to share the memory pool with other processes. The handle is cached in this `MemoryResource` and owned by it. """ - @property def device_id(self) -> int: """The associated device ordinal.""" - @property def peer_accessible_by(self) -> PeerAccessibleBySetProxy: """ @@ -202,19 +188,14 @@ class DeviceMemoryResource(_MemPool): >>> dmr.peer_accessible_by.add(2) # update access to include device 2 >>> dmr.peer_accessible_by = [] # revoke peer access """ - @peer_accessible_by.setter - def peer_accessible_by(self, devices) -> None: - ... - + def peer_accessible_by(self, devices) -> None: ... @property def is_device_accessible(self) -> bool: """Return True. This memory resource provides device-accessible buffers.""" - @property def is_host_accessible(self) -> bool: """Return False. This memory resource does not provide host-accessible buffers.""" -__all__ = ['DeviceMemoryResource', 'DeviceMemoryResourceOptions'] def DMR_mempool_get_access(dmr: DeviceMemoryResource, device_id: int) -> str: """ @@ -230,6 +211,4 @@ def DMR_mempool_get_access(dmr: DeviceMemoryResource, device_id: int) -> str: str Access permissions: "rw" for read-write, "r" for read-only, "" for no access. """ - -def _deep_reduce_device_memory_resource(mr) -> tuple[object, ...]: - ... \ No newline at end of file +def _deep_reduce_device_memory_resource(mr) -> tuple[object, ...]: ... diff --git a/cuda_core/cuda/core/_memory/_graph_memory_resource.pyi b/cuda_core/cuda/core/_memory/_graph_memory_resource.pyi index b34f968fdc9..5801490f8fb 100644 --- a/cuda_core/cuda/core/_memory/_graph_memory_resource.pyi +++ b/cuda_core/cuda/core/_memory/_graph_memory_resource.pyi @@ -1,6 +1,4 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_memory/_graph_memory_resource.pyx - -from __future__ import annotations +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_memory/_graph_memory_resource.pyx from cuda.core._device import Device from cuda.core._memory._buffer import Buffer, MemoryResource @@ -8,82 +6,59 @@ from cuda.core._stream import Stream from cuda.core.graph import GraphBuilder from cuda.core.typing import DevicePointerType +__all__ = ['GraphMemoryResource'] class GraphMemoryResourceAttributes: - - def __init__(self, *args, **kwargs) -> None: - ... - + def __init__(self, *args, **kwargs) -> None: ... @classmethod - def _init(cls, device_id: int) -> GraphMemoryResourceAttributes: - ... - - def __repr__(self) -> str: - ... - + def _init(cls, device_id: int) -> GraphMemoryResourceAttributes: ... + def __repr__(self) -> str: ... @property def reserved_mem_current(self) -> int: """Current amount of backing memory allocated.""" - @property def reserved_mem_high(self) -> int: """ High watermark of backing memory allocated. It can be set to zero to reset it to the current usage. """ - @reserved_mem_high.setter - def reserved_mem_high(self, value: int) -> None: - ... - + def reserved_mem_high(self, value: int) -> None: ... @property def used_mem_current(self) -> int: """Current amount of memory in use.""" - @property def used_mem_high(self) -> int: """ High watermark of memory in use. It can be set to zero to reset it to the current usage. """ - @used_mem_high.setter - def used_mem_high(self, value: int) -> None: - ... + def used_mem_high(self, value: int) -> None: ... class cyGraphMemoryResource(MemoryResource): - - def __cinit__(self, device_id: int) -> None: - ... - + def __init__(self, device_id: int) -> None: ... def allocate(self, size: int, *, stream: Stream | GraphBuilder) -> Buffer: """ Allocate a buffer of the requested size. See documentation for :obj:`~_memory.MemoryResource`. """ - def deallocate(self, ptr: DevicePointerType, size: int, *, stream: Stream | GraphBuilder) -> None: """ Deallocate a buffer of the requested size. See documentation for :obj:`~_memory.MemoryResource`. """ - def close(self) -> None: """No operation (provided for compatibility).""" - def trim(self) -> None: """Free unused memory that was cached on the specified device for use with graphs back to the OS.""" - @property def attributes(self) -> GraphMemoryResourceAttributes: """Asynchronous allocation attributes related to graphs.""" - @property def device_id(self) -> int: """The associated device ordinal.""" - @property def is_device_accessible(self) -> bool: """Return True. This memory resource provides device-accessible buffers.""" - @property def is_host_accessible(self) -> bool: """Return False. This memory resource does not provide host-accessible buffers.""" @@ -106,11 +81,6 @@ class GraphMemoryResource(cyGraphMemoryResource): device_id: int | Device Device or Device ordinal for which a graph memory resource is obtained. """ - - def __new__(cls, device_id: int | Device) -> GraphMemoryResource: - ... - + def __new__(cls, device_id: int | Device) -> GraphMemoryResource: ... @classmethod - def _create(cls, device_id: int) -> GraphMemoryResource: - ... -__all__ = ['GraphMemoryResource'] \ No newline at end of file + def _create(cls, device_id: int) -> GraphMemoryResource: ... diff --git a/cuda_core/cuda/core/_memory/_ipc.pyi b/cuda_core/cuda/core/_memory/_ipc.pyi index 7c707ab0418..d1b2324b8f4 100644 --- a/cuda_core/cuda/core/_memory/_ipc.pyi +++ b/cuda_core/cuda/core/_memory/_ipc.pyi @@ -1,41 +1,26 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_memory/_ipc.pyx - -from __future__ import annotations +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_memory/_ipc.pyx import uuid +__all__ = [] class IPCDataForBuffer: """Data members related to sharing memory buffers via IPC.""" - - def __cinit__(self, ipc_descriptor: IPCBufferDescriptor, is_mapped: bool) -> None: - ... - + def __init__(self, ipc_descriptor: IPCBufferDescriptor, is_mapped: bool) -> None: ... @property - def ipc_descriptor(self) -> IPCBufferDescriptor: - ... - + def ipc_descriptor(self) -> IPCBufferDescriptor: ... @property - def is_mapped(self) -> bool: - ... + def is_mapped(self) -> bool: ... class IPCDataForMR: """Data members related to sharing memory resources via IPC.""" - - def __cinit__(self, alloc_handle: IPCAllocationHandle, is_mapped: bool) -> None: - ... - + def __init__(self, alloc_handle: IPCAllocationHandle, is_mapped: bool) -> None: ... @property - def alloc_handle(self) -> IPCAllocationHandle: - ... - + def alloc_handle(self) -> IPCAllocationHandle: ... @property - def is_mapped(self) -> bool: - ... - + def is_mapped(self) -> bool: ... @property - def uuid(self) -> uuid.UUID | None: - ... + def uuid(self) -> uuid.UUID | None: ... class IPCBufferDescriptor: """Serializable object describing a buffer that can be shared between processes. @@ -46,48 +31,25 @@ class IPCBufferDescriptor: Receivers must treat them as untrusted and import only through :meth:`Buffer.from_ipc_descriptor`. """ - - def __init__(self, *arg, **kwargs) -> None: - ... - + def __init__(self, *arg, **kwargs) -> None: ... @staticmethod - def _init(reserved: bytes, size: int) -> IPCBufferDescriptor: - ... - - def __reduce__(self) -> tuple[object, ...]: - ... - + def _init(reserved: bytes, size: int) -> IPCBufferDescriptor: ... + def __reduce__(self) -> tuple[object, ...]: ... @property - def size(self) -> int: - ... + def size(self) -> int: ... class IPCAllocationHandle: """Shareable handle to an IPC-enabled device memory pool.""" - + def __init__(self, *arg, **kwargs) -> None: ... + @classmethod + def _init(cls, handle: int, uuid: uuid.UUID | None) -> IPCAllocationHandle: ... def close(self): """Close the handle.""" - - def __init__(self, *arg, **kwargs) -> None: - ... - - @classmethod - def _init(cls, handle: int, uuid: uuid.UUID | None) -> IPCAllocationHandle: - ... - - def __int__(self) -> int: - ... - + def __int__(self) -> int: ... @property - def handle(self) -> int: - ... - + def handle(self) -> int: ... @property - def uuid(self) -> uuid.UUID: - ... -__all__ = [] - -def _reduce_allocation_handle(alloc_handle: IPCAllocationHandle) -> tuple[object, ...]: - ... + def uuid(self) -> uuid.UUID: ... -def _reconstruct_allocation_handle(cls: type, df: object, uuid: uuid.UUID | None) -> IPCAllocationHandle: - ... \ No newline at end of file +def _reduce_allocation_handle(alloc_handle: IPCAllocationHandle) -> tuple[object, ...]: ... +def _reconstruct_allocation_handle(cls: type, df: object, uuid: uuid.UUID | None) -> IPCAllocationHandle: ... diff --git a/cuda_core/cuda/core/_memory/_location.pyi b/cuda_core/cuda/core/_memory/_location.pyi new file mode 100644 index 00000000000..fa1467c3432 --- /dev/null +++ b/cuda_core/cuda/core/_memory/_location.pyi @@ -0,0 +1 @@ +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_memory/_location.pxd diff --git a/cuda_core/cuda/core/_memory/_managed_memory_ops.pyi b/cuda_core/cuda/core/_memory/_managed_memory_ops.pyi index a72bc52827f..4523a39d728 100644 --- a/cuda_core/cuda/core/_memory/_managed_memory_ops.pyi +++ b/cuda_core/cuda/core/_memory/_managed_memory_ops.pyi @@ -1,6 +1,4 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_memory/_managed_memory_ops.pyx - -from __future__ import annotations +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_memory/_managed_memory_ops.pyx from collections.abc import Sequence @@ -34,17 +32,14 @@ def discard_batch(stream: Stream | GraphBuilder, buffers: Sequence[Buffer]) -> N NotImplementedError On a CUDA 12 build of ``cuda.core``. """ - def _do_single_discard_py(buf: Buffer, stream: Stream | GraphBuilder | None) -> None: """Internal: single-buffer discard for ManagedBuffer.discard().""" - def _advise_one(buf: Buffer, advice: driver.CUmem_advise, location: Device | Host | None) -> None: """Internal: apply managed-memory advice to a single buffer. Used by :class:`ManagedBuffer` property setters. Not part of the public API. """ - def prefetch_batch(stream: Stream | GraphBuilder, buffers: Sequence[Buffer], locations: Device | Host | Sequence[Device | Host]) -> None: """Prefetch a batch of managed-memory ranges to target locations. @@ -68,16 +63,12 @@ def prefetch_batch(stream: Stream | GraphBuilder, buffers: Sequence[Buffer], loc ``cuMemPrefetchAsync`` per buffer (no batched driver entry point on CUDA 12). CUDA 13 builds use ``cuMemPrefetchBatchAsync`` directly. """ - def _do_single_prefetch_py(buf: Buffer, location: Device | Host | None, stream: Stream | GraphBuilder | None) -> None: """Internal: single-buffer prefetch for ManagedBuffer.prefetch(). Uses cuMemPrefetchAsync (works on CUDA 12 and 13). """ - -def _read_preferred_location_v2(buf: Buffer) -> Device | Host | None: - ... - +def _read_preferred_location_v2(buf: Buffer) -> Device | Host | None: ... def discard_prefetch_batch(stream: Stream | GraphBuilder, buffers: Sequence[Buffer], locations: Device | Host | Sequence[Device | Host]) -> None: """Discard a batch of managed-memory ranges and prefetch them to target locations. @@ -100,7 +91,6 @@ def discard_prefetch_batch(stream: Stream | GraphBuilder, buffers: Sequence[Buff NotImplementedError On a CUDA 12 build of ``cuda.core``. """ - def _do_single_discard_prefetch_py(buf: Buffer, location: Device | Host | None, stream: Stream | GraphBuilder | None) -> None: """Internal: single-buffer discard+prefetch for - ManagedBuffer.discard_prefetch().""" \ No newline at end of file + ManagedBuffer.discard_prefetch().""" diff --git a/cuda_core/cuda/core/_memory/_managed_memory_resource.pyi b/cuda_core/cuda/core/_memory/_managed_memory_resource.pyi index 511c72252b4..44523ae0f53 100644 --- a/cuda_core/cuda/core/_memory/_managed_memory_resource.pyi +++ b/cuda_core/cuda/core/_memory/_managed_memory_resource.pyi @@ -1,6 +1,4 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_memory/_managed_memory_resource.pyx - -from __future__ import annotations +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_memory/_managed_memory_resource.pyx from dataclasses import dataclass @@ -10,6 +8,7 @@ from cuda.core._stream import Stream from cuda.core.graph import GraphBuilder from cuda.core.typing import ManagedMemoryLocationType +__all__ = ['ManagedMemoryResource', 'ManagedMemoryResourceOptions'] @dataclass class ManagedMemoryResourceOptions: @@ -76,10 +75,7 @@ class ManagedMemoryResource(_MemPool): IPC (Inter-Process Communication) is not currently supported for managed memory pools. """ - - def __init__(self, options: ManagedMemoryResourceOptions | None=None) -> None: - ... - + def __init__(self, options: ManagedMemoryResourceOptions | None=None) -> None: ... def allocate(self, size: int, *, stream: Stream | GraphBuilder) -> ManagedBuffer: """Allocate a managed-memory buffer of the requested size. @@ -101,11 +97,9 @@ class ManagedMemoryResource(_MemPool): and instance methods (``prefetch``, ``discard``, ``discard_prefetch``). """ - @property def device_id(self) -> int: """The preferred device ordinal, or -1 if the preferred location is not a device.""" - @property def preferred_location(self) -> tuple[ManagedMemoryLocationType, int | None] | None: """The preferred location for managed memory allocations. @@ -115,19 +109,15 @@ class ManagedMemoryResource(_MemPool): ``"host"``, or ``"host_numa"``, and *id* is the device ordinal, ``None`` (for ``"host"``), or the NUMA node ID, respectively. """ - @property def is_device_accessible(self) -> bool: """Return True. This memory resource provides device-accessible buffers.""" - @property def is_host_accessible(self) -> bool: """Return True. This memory resource provides host-accessible buffers.""" - @property def is_managed(self) -> bool: """Return True. This memory resource provides managed (unified) memory buffers.""" -__all__ = ['ManagedMemoryResource', 'ManagedMemoryResourceOptions'] def reset_concurrent_access_warning() -> None: - """Reset the concurrent access warning flag for testing purposes.""" \ No newline at end of file + """Reset the concurrent access warning flag for testing purposes.""" diff --git a/cuda_core/cuda/core/_memory/_memory_pool.pyi b/cuda_core/cuda/core/_memory/_memory_pool.pyi index 7f8c64aedda..70189ee5413 100644 --- a/cuda_core/cuda/core/_memory/_memory_pool.pyi +++ b/cuda_core/cuda/core/_memory/_memory_pool.pyi @@ -1,10 +1,7 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_memory/_memory_pool.pyx - -from __future__ import annotations +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_memory/_memory_pool.pyx import uuid -import cython from cuda.core._memory._buffer import Buffer, MemoryResource from cuda.core._stream import Stream from cuda.core.graph import GraphBuilder @@ -13,56 +10,40 @@ from cuda.core.typing import DevicePointerType class _MemPoolAttributes: """Provides access to memory pool attributes.""" - - def __init__(self, *args, **kwargs) -> None: - ... - - def __repr__(self) -> str: - ... - + def __init__(self, *args, **kwargs) -> None: ... + def __repr__(self) -> str: ... @property def reuse_follow_event_dependencies(self) -> bool: """Allow memory to be reused when there are event dependencies between streams.""" - @property def reuse_allow_opportunistic(self) -> bool: """Allow reuse of completed frees without dependencies.""" - @property def reuse_allow_internal_dependencies(self) -> bool: """Allow insertion of new stream dependencies for memory reuse.""" - @property def release_threshold(self) -> int: """Amount of reserved memory to hold before OS release.""" - @property def reserved_mem_current(self) -> int: """Current amount of backing memory allocated.""" - @property def reserved_mem_high(self) -> int: """High watermark of backing memory allocated.""" - @property def used_mem_current(self) -> int: """Current amount of memory in use.""" - @property def used_mem_high(self) -> int: """High watermark of memory in use.""" class _MemPool(MemoryResource): - - def __cinit__(self) -> None: - ... - + def __init__(self) -> None: ... def close(self) -> None: """ Close the memory resource and destroy the associated memory pool if owned. """ - def allocate(self, size: int, *, stream: Stream | GraphBuilder) -> Buffer: """Allocate a buffer of the requested size. @@ -81,7 +62,6 @@ class _MemPool(MemoryResource): The allocated buffer object, which is accessible on the device that this memory resource was created for. """ - def deallocate(self, ptr: DevicePointerType, size: int, *, stream: Stream | GraphBuilder) -> None: """Deallocate a buffer previously allocated by this resource. @@ -96,34 +76,27 @@ class _MemPool(MemoryResource): asynchronously. Must be passed explicitly; pass ``device.default_stream`` to use the default stream. """ - @property - @cython.critical_section def attributes(self) -> _MemPoolAttributes: """Memory pool attributes.""" - @property def handle(self) -> object: """Handle to the underlying memory pool.""" - @property def is_handle_owned(self) -> bool: """Whether the memory resource handle is owned. If False, ``close`` has no effect.""" - @property def is_ipc_enabled(self) -> bool: """Whether this memory resource has IPC enabled.""" - @property def is_mapped(self) -> bool: """ Whether this is a mapping of an IPC-enabled memory resource from another process. If True, allocation is not permitted. """ - @property def uuid(self) -> uuid.UUID | None: """ A universally unique identifier for this memory resource. Meaningful only for IPC-enabled memory resources. - """ \ No newline at end of file + """ diff --git a/cuda_core/cuda/core/_memory/_peer_access_utils.pyi b/cuda_core/cuda/core/_memory/_peer_access_utils.pyi index fa2b5c490a4..2c38debd2de 100644 --- a/cuda_core/cuda/core/_memory/_peer_access_utils.pyi +++ b/cuda_core/cuda/core/_memory/_peer_access_utils.pyi @@ -1,10 +1,8 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_memory/_peer_access_utils.pyx +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_memory/_peer_access_utils.pyx -from __future__ import annotations - -from collections.abc import Callable, Iterable, Iterator, Set +from collections.abc import Iterable, Iterator, Set from dataclasses import dataclass -from typing import Any +from typing import Any, Callable from cuda.core._device import Device from cuda.core._memory._device_memory_resource import DeviceMemoryResource @@ -35,60 +33,33 @@ class PeerAccessibleBySetProxy: is updated, so coalescing into a single driver call lets the toolkit handle the mappings in parallel. """ - __slots__ = ('_mr',) - - def __init__(self, mr: DeviceMemoryResource) -> None: - ... + __slots__ = '_mr' + def __init__(self, mr: DeviceMemoryResource) -> None: ... @classmethod - def _from_iterable(cls, it: Iterable[Device]) -> set[Device]: - ... - - def __contains__(self, value: object) -> bool: - ... - - def __iter__(self) -> Iterator[Device]: - ... - - def __len__(self) -> int: - ... - + def _from_iterable(cls, it: Iterable[Device]) -> set[Device]: ... + def __contains__(self, value: object) -> bool: ... + def __iter__(self) -> Iterator[Device]: ... + def __len__(self) -> int: ... def add(self, value: Device | int) -> None: """Grant peer access from ``value`` to allocations in this pool.""" - def discard(self, value: Device | int) -> None: """Revoke peer access from ``value`` to allocations in this pool.""" - def clear(self) -> None: """Revoke all peer access in a single driver call.""" - def update(self, *others: Iterable[Device | int]) -> None: """Grant peer access to every device in ``others`` in one driver call.""" - def difference_update(self, *others: Iterable[Device | int]) -> None: """Revoke peer access for every device in ``others`` in one driver call.""" - def intersection_update(self, *others: Iterable[Device | int]) -> None: """Restrict peer access to the intersection in a single driver call.""" - def symmetric_difference_update(self, other: Iterable[Device | int]) -> None: """Toggle peer access for every device in ``other`` in one driver call.""" - - def __ior__(self, other: Set[Any]) -> PeerAccessibleBySetProxy: - ... - - def __iand__(self, other: Set[Any]) -> PeerAccessibleBySetProxy: - ... - - def __isub__(self, other: Set[Any]) -> PeerAccessibleBySetProxy: - ... - - def __ixor__(self, other: Set[Any]) -> PeerAccessibleBySetProxy: - ... - - def __repr__(self) -> str: - ... - + def __ior__(self, other: Set[Any]) -> PeerAccessibleBySetProxy: ... + def __iand__(self, other: Set[Any]) -> PeerAccessibleBySetProxy: ... + def __isub__(self, other: Set[Any]) -> PeerAccessibleBySetProxy: ... + def __ixor__(self, other: Set[Any]) -> PeerAccessibleBySetProxy: ... + def __repr__(self) -> str: ... def _apply(self, additions, removals) -> None: """Compute the diff and issue a single ``cuMemPoolSetAccess``. @@ -98,24 +69,12 @@ class PeerAccessibleBySetProxy: removals bypass that check (revoking is always permitted). """ -def replace_peer_accessible_by(mr: DeviceMemoryResource, devices: object) -> None: - """Replace the full peer-access set in a single batched driver call. - - Backs the ``mr.peer_accessible_by = [...]`` setter. Uses the same planner - as the proxy's bulk ops; the only difference is that adds and removes are - derived from the symmetric difference between current driver state and the - requested target set. - """ - def normalize_peer_access_targets(owner_device_id: int, requested_devices: Iterable[object], *, resolve_device_id: Callable[[object], int]) -> tuple[int, ...]: """Return sorted, unique peer device IDs, excluding the owner device.""" - def plan_peer_access_update(owner_device_id: int, current_peer_ids: Iterable[int], requested_devices: Iterable[object], *, resolve_device_id: Callable[[object], int], can_access_peer: Callable[[int], bool]) -> PeerAccessPlan: """Compute the peer-access target state and add/remove deltas.""" - def _resolve_peer_device_id(value: Device | int | None) -> int: """Coerce ``Device | int`` into a device-ordinal int.""" - def _set_pool_access(mr: object, to_add: tuple[int, ...], to_remove: tuple[int, ...]) -> None: """Issue one ``cuMemPoolSetAccess`` for the given add/remove deltas. @@ -127,7 +86,6 @@ def _set_pool_access(mr: object, to_add: tuple[int, ...], to_remove: tuple[int, Preconditions: ``len(to_add) + len(to_remove) > 0`` (the caller is responsible for skipping empty diffs). """ - def _apply_peer_access_diff(mr: DeviceMemoryResource, to_add: Iterable[int], to_remove: Iterable[int]) -> None: """Apply a peer-access diff in at most one driver call. @@ -135,4 +93,12 @@ def _apply_peer_access_diff(mr: DeviceMemoryResource, to_add: Iterable[int], to_ ``peer_accessible_by`` setter routes through this function. Empty diffs short-circuit here so the driver-level helper :func:`_set_pool_access` is only invoked when there is actual work for ``cuMemPoolSetAccess`` to do. - """ \ No newline at end of file + """ +def replace_peer_accessible_by(mr: DeviceMemoryResource, devices: object) -> None: + """Replace the full peer-access set in a single batched driver call. + + Backs the ``mr.peer_accessible_by = [...]`` setter. Uses the same planner + as the proxy's bulk ops; the only difference is that adds and removes are + derived from the symmetric difference between current driver state and the + requested target set. + """ diff --git a/cuda_core/cuda/core/_memory/_pinned_memory_resource.pyi b/cuda_core/cuda/core/_memory/_pinned_memory_resource.pyi index a74920a987f..76a7010dbc4 100644 --- a/cuda_core/cuda/core/_memory/_pinned_memory_resource.pyi +++ b/cuda_core/cuda/core/_memory/_pinned_memory_resource.pyi @@ -1,6 +1,4 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_memory/_pinned_memory_resource.pyx - -from __future__ import annotations +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_memory/_pinned_memory_resource.pyx import uuid from dataclasses import dataclass @@ -11,6 +9,7 @@ from cuda.core._memory._memory_pool import _MemPool from cuda.core._stream import Stream from cuda.core.graph import GraphBuilder +__all__ = ['PinnedMemoryResource', 'PinnedMemoryResourceOptions'] @dataclass class PinnedMemoryResourceOptions: @@ -83,16 +82,10 @@ class PinnedMemoryResource(_MemPool): See :class:`DeviceMemoryResource` for more details on IPC usage patterns. """ - - def __init__(self, options: PinnedMemoryResourceOptions | None=None) -> None: - ... - + def __init__(self, options: PinnedMemoryResourceOptions | None=None) -> None: ... def allocate(self, size: int, *, stream: Stream | GraphBuilder) -> Buffer: """Allocate a host-pinned buffer asynchronously on the supplied stream.""" - - def __reduce__(self) -> tuple[object, ...]: - ... - + def __reduce__(self) -> tuple[object, ...]: ... @staticmethod def from_registry(uuid: uuid.UUID) -> PinnedMemoryResource: """ @@ -103,7 +96,6 @@ class PinnedMemoryResource(_MemPool): RuntimeError If no mapped memory resource is found in the registry. """ - def register(self, uuid: uuid.UUID) -> PinnedMemoryResource: """ Register a mapped memory resource. @@ -113,7 +105,6 @@ class PinnedMemoryResource(_MemPool): The registered mapped memory resource. If one was previously registered with the given key, it is returned. """ - @classmethod def from_allocation_handle(cls, alloc_handle: int | IPCAllocationHandle) -> PinnedMemoryResource: """Create a host-pinned memory resource from an allocation handle. @@ -132,7 +123,6 @@ class PinnedMemoryResource(_MemPool): ------- A new host-pinned memory resource instance with the imported handle. """ - @property def allocation_handle(self) -> IPCAllocationHandle: """Shareable handle for this memory pool (requires IPC). @@ -140,23 +130,17 @@ class PinnedMemoryResource(_MemPool): The handle can be used to share the memory pool with other processes. The handle is cached in this `MemoryResource` and owned by it. """ - @property def device_id(self) -> int: """Return -1. Pinned memory is host memory and is not associated with a specific device.""" - @property def numa_id(self) -> int: """The host NUMA node ID used for pool placement, or -1 for OS-managed placement.""" - @property def is_device_accessible(self) -> bool: """Return True. This memory resource provides device-accessible buffers.""" - @property def is_host_accessible(self) -> bool: """Return True. This memory resource provides host-accessible buffers.""" -__all__ = ['PinnedMemoryResource', 'PinnedMemoryResourceOptions'] -def _deep_reduce_pinned_memory_resource(mr: object) -> tuple[object, ...]: - ... \ No newline at end of file +def _deep_reduce_pinned_memory_resource(mr: object) -> tuple[object, ...]: ... diff --git a/cuda_core/cuda/core/_memory/_virtual_memory_resource.py b/cuda_core/cuda/core/_memory/_virtual_memory_resource.py index 7cd12f597a6..4a0ec1f6bf7 100644 --- a/cuda_core/cuda/core/_memory/_virtual_memory_resource.py +++ b/cuda_core/cuda/core/_memory/_virtual_memory_resource.py @@ -350,10 +350,9 @@ def _grow_allocation_fast_path( # All succeeded, cancel undo actions trans.commit() - # Update the buffer size (pointer stays the same) - # TODO: #2049 This is a real bug, accessing _size which doesn't exist. - # Fix bug and remove the "type: ignore[attr-defined]" comment. - buf._size = new_size # type: ignore[attr-defined] + # Update the buffer size (pointer stays the same). `Buffer.size` has + # no public setter, so this reaches into the private attribute. + buf._size = new_size return buf def _grow_allocation_slow_path( diff --git a/cuda_core/cuda/core/_memoryview.pyi b/cuda_core/cuda/core/_memoryview.pyi index e0ed0d3cf0d..e718be87140 100644 --- a/cuda_core/cuda/core/_memoryview.pyi +++ b/cuda_core/cuda/core/_memoryview.pyi @@ -1,10 +1,7 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_memoryview.pyx - -from __future__ import annotations +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_memoryview.pyx import functools -from collections.abc import Callable -from typing import Any +from typing import Any, Callable, TypedDict import numpy from cuda.core._layout import _StridedLayout @@ -13,6 +10,10 @@ from cuda.core._stream import Stream from ._dlpack import * +_SMV_DLPACK_EXCHANGE_API_CAPSULE = ... + +class PyTypeObject(TypedDict): + tp_dict: None class StridedMemoryView: """A class holding metadata of a strided dense array/tensor. @@ -70,10 +71,13 @@ class StridedMemoryView: it will be the Buffer instance passed to the method. """ + ptr: int + device_id: int + is_device_accessible: bool + readonly: bool + exporting_obj: object - def __init__(self, obj: object=None, stream_ptr: int | None=None) -> None: - ... - + def __init__(self, obj: object | None=None, stream_ptr: int | None=None) -> None: ... @classmethod def from_dlpack(cls, obj: object, stream_ptr: int | None=None) -> StridedMemoryView: """Create a view from an object supporting the `DLPack `_ protocol. @@ -86,7 +90,6 @@ class StridedMemoryView: stream_ptr : int, optional Stream pointer for synchronization. If ``None``, no synchronization is performed. """ - @classmethod def from_cuda_array_interface(cls, obj: object, stream_ptr: int | None=None) -> StridedMemoryView: """Create a view from an object supporting the `__cuda_array_interface__ `_ protocol. @@ -98,7 +101,6 @@ class StridedMemoryView: stream_ptr : int, optional Stream pointer for synchronization. If ``None``, no synchronization is performed. """ - @classmethod def from_array_interface(cls, obj: object) -> StridedMemoryView: """Create a view from an object supporting the `__array_interface__ `_ protocol. @@ -108,7 +110,6 @@ class StridedMemoryView: obj : object An object implementing the `__array_interface__ `_ protocol (e.g., a numpy array). """ - @classmethod def from_any_interface(cls, obj: object, stream_ptr: int | None=None) -> StridedMemoryView: """Create a view by automatically selecting the best available protocol. @@ -126,7 +127,6 @@ class StridedMemoryView: stream_ptr : int, optional Stream pointer for synchronization. If ``None``, no synchronization is performed. """ - @classmethod def from_buffer(cls, buffer: Buffer, shape: tuple[int, ...], strides: tuple[int, ...] | None=None, *, itemsize: int | None=None, dtype: numpy.dtype | None=None, is_readonly: bool=False) -> StridedMemoryView: """ @@ -155,17 +155,13 @@ class StridedMemoryView: is_readonly : bool, optional Whether the mark the view as readonly. """ - - def __dealloc__(self) -> None: - ... - + def __dealloc__(self) -> None: ... def view(self, layout: _StridedLayout | None=None, dtype: numpy.dtype | None=None) -> StridedMemoryView: """ Creates a new view with adjusted layout and dtype. Same as calling :meth:`from_buffer` with the current buffer. """ - - def as_tensor_map(self, box_dim: tuple[int, ...] | None=None, *, options: object=None, element_strides: tuple[int, ...] | None=None, data_type: object=None, interleave: object=None, swizzle: object=None, l2_promotion: object=None, oob_fill: object=None) -> object: + def as_tensor_map(self, box_dim: tuple[int, ...] | None=None, *, options: object | None=None, element_strides: tuple[int, ...] | None=None, data_type: object | None=None, interleave: object | None=None, swizzle: object | None=None, l2_promotion: object | None=None, oob_fill: object | None=None) -> object: """Create a tiled :obj:`TensorMapDescriptor` from this view. This is the public entry point for creating tiled tensor map @@ -173,8 +169,7 @@ class StridedMemoryView: individual keyword arguments directly, or provide bundled tiled options via ``options=``. """ - - def copy_from(self, other: StridedMemoryView, stream: Stream, allocator: object=None, blocking: bool | None=None) -> None: + def copy_from(self, other: StridedMemoryView, stream: Stream, allocator: object | None=None, blocking: bool | None=None) -> None: """ Copies the data from the other view into this view. @@ -202,43 +197,32 @@ class StridedMemoryView: * for device-to-device, it defaults to ``False`` (non-blocking), * for host-to-device or device-to-host, it defaults to ``True`` (blocking). """ - - def copy_to(self, other: StridedMemoryView, stream: Stream | None=None, allocator: object=None, blocking: bool | None=None) -> None: + def copy_to(self, other: StridedMemoryView, stream: Stream | None=None, allocator: object | None=None, blocking: bool | None=None) -> None: """ Copies the data from this view into the ``other`` view. For details, see :meth:`copy_from`. """ - - def __dlpack__(self, *, stream: int | None=None, max_version: tuple[int, int] | None=None, dl_device: tuple[int, int] | None=None, copy: bool | None=None) -> object: - ... - - def __dlpack_device__(self) -> tuple[int, int]: - ... - + def __dlpack__(self, *, stream: int | None=None, max_version: tuple[int, int] | None=None, dl_device: tuple[int, int] | None=None, copy: bool | None=None) -> object: ... + def __dlpack_device__(self) -> tuple[int, int]: ... @property def _layout(self) -> _StridedLayout: """ The layout of the tensor. For StridedMemoryView created from DLPack or CAI, the layout is inferred from the tensor object's metadata. """ - @property - def size(self) -> int: - ... - + def size(self) -> int: ... @property def shape(self) -> tuple[int, ...]: """ Shape of the tensor. """ - @property def strides(self) -> tuple[int, ...] | None: """ Strides of the tensor (in **counts**, not bytes). """ - @property def dtype(self) -> numpy.dtype | None: """ @@ -249,33 +233,21 @@ class StridedMemoryView: installed. If ``ml_dtypes`` is not available and such a tensor is encountered, a :obj:`NotImplementedError` will be raised. """ - - def __repr__(self) -> str: - ... + def __repr__(self) -> str: ... class _StridedMemoryViewProxy: + obj: object + has_dlpack: bool - def view(self, stream_ptr=None) -> StridedMemoryView: - ... - - def __init__(self, obj: object) -> None: - ... -_SMV_DLPACK_EXCHANGE_API_CAPSULE = ... - -def view_as_cai(obj, stream_ptr, view=None) -> StridedMemoryView: - ... - -def view_as_array_interface(obj, view=None) -> StridedMemoryView: - ... + def __init__(self, obj: object) -> None: ... + def view(self, stream_ptr=None) -> StridedMemoryView: ... @functools.lru_cache -def _typestr2dtype(typestr: str) -> numpy.dtype: - ... - +def _typestr2dtype(typestr: str) -> numpy.dtype: ... @functools.lru_cache -def _typestr2itemsize(typestr: str) -> int: - ... - +def _typestr2itemsize(typestr: str) -> int: ... +def view_as_cai(obj, stream_ptr, view=None) -> StridedMemoryView: ... +def view_as_array_interface(obj, view=None) -> StridedMemoryView: ... def args_viewable_as_strided_memory(arg_indices: tuple[int, ...]) -> Callable[[Callable[..., Any]], Callable[..., Any]]: """ Decorator to create proxy objects to :obj:`StridedMemoryView` for the @@ -304,4 +276,4 @@ def args_viewable_as_strided_memory(arg_indices: tuple[int, ...]) -> Callable[[C ---------- arg_indices : tuple The indices of the target positional arguments. - """ \ No newline at end of file + """ diff --git a/cuda_core/cuda/core/_module.pyi b/cuda_core/cuda/core/_module.pyi index e8604af012c..9fb502920ad 100644 --- a/cuda_core/cuda/core/_module.pyi +++ b/cuda_core/cuda/core/_module.pyi @@ -1,16 +1,15 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_module.pyx +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_module.pyx -from __future__ import annotations - -from collections import namedtuple from os import PathLike +from typing import Any -import cython from cuda.core._device import Device from cuda.core._launch_config import LaunchConfig from cuda.core._stream import Stream from cuda.core._utils.cuda_utils import driver +__all__ = ['Kernel', 'ObjectCode'] +CodeTypeT = bytes | bytearray | str class KernelAttributes: """Read-only view of a kernel's per-device attributes. @@ -22,10 +21,7 @@ class KernelAttributes: views share the underlying cache so a value queried through one view is visible through the others. """ - - def __init__(self, *args, **kwargs) -> None: - ... - + def __init__(self, *args, **kwargs) -> None: ... def __getitem__(self, device: Device | int) -> KernelAttributes: """Return a view of these attributes bound to a specific device. @@ -41,77 +37,61 @@ class KernelAttributes: A view bound to ``device`` that shares the underlying cache with this view. """ - @property def max_threads_per_block(self) -> int: """int : The maximum number of threads per block. This attribute is read-only.""" - @property def shared_size_bytes(self) -> int: """int : The size in bytes of statically-allocated shared memory required by this function. This attribute is read-only.""" - @property def const_size_bytes(self) -> int: """int : The size in bytes of user-allocated constant memory required by this function. This attribute is read-only.""" - @property def local_size_bytes(self) -> int: """int : The size in bytes of local memory used by each thread of this function. This attribute is read-only.""" - @property def num_regs(self) -> int: """int : The number of registers used by each thread of this function. This attribute is read-only.""" - @property def ptx_version(self) -> int: """int : The PTX virtual architecture version for which the function was compiled. This attribute is read-only.""" - @property def binary_version(self) -> int: """int : The binary architecture version for which the function was compiled. This attribute is read-only.""" - @property def cache_mode_ca(self) -> bool: """bool : Whether the function has been compiled with user specified option "-Xptxas --dlcm=ca" set. This attribute is read-only.""" - @property def max_dynamic_shared_size_bytes(self) -> int: """int : The maximum size in bytes of dynamically-allocated shared memory that can be used by this function.""" - @property def preferred_shared_memory_carveout(self) -> int: """int : The shared memory carveout preference, in percent of the total shared memory.""" - @property def cluster_size_must_be_set(self) -> bool: """bool : The kernel must launch with a valid cluster size specified. This attribute is read-only.""" - @property def required_cluster_width(self) -> int: """int : The required cluster width in blocks.""" - @property def required_cluster_height(self) -> int: """int : The required cluster height in blocks.""" - @property def required_cluster_depth(self) -> int: """int : The required cluster depth in blocks.""" - @property def non_portable_cluster_size_allowed(self) -> bool: """bool : Whether the function can be launched with non-portable cluster size.""" - @property def cluster_scheduling_policy_preference(self) -> int: """int : The block scheduling policy of a function.""" @@ -120,10 +100,7 @@ class KernelOccupancy: """This class offers methods to query occupancy metrics that help determine optimal launch parameters such as block size, grid size, and shared memory usage. """ - - def __init__(self, *args, **kwargs) -> None: - ... - + def __init__(self, *args, **kwargs) -> None: ... def max_active_blocks_per_multiprocessor(self, block_size: int, dynamic_shared_memory_size: int) -> int: """Occupancy of the kernel. @@ -149,8 +126,7 @@ class KernelOccupancy: theoretical multiprocessor utilization (occupancy). """ - - def max_potential_block_size(self, dynamic_shared_memory_needed: int | driver.CUoccupancyB2DSize, block_size_limit: int) -> MaxPotentialBlockSizeOccupancyResult: + def max_potential_block_size(self, dynamic_shared_memory_needed: int | driver.CUoccupancyB2DSize, block_size_limit: int) -> Any: """MaxPotentialBlockSizeOccupancyResult: Suggested launch configuration for reasonable occupancy. Returns the minimum grid size needed to achieve the maximum occupancy and @@ -180,7 +156,6 @@ class KernelOccupancy: Interpreter Lock may lead to deadlocks. """ - def available_dynamic_shared_memory_per_block(self, num_blocks_per_multiprocessor: int, block_size: int) -> int: """Dynamic shared memory available per block for given launch configuration. @@ -198,7 +173,6 @@ class KernelOccupancy: int Dynamic shared memory available per block for given launch configuration. """ - def max_potential_cluster_size(self, config: LaunchConfig, *, stream: Stream) -> int: """Maximum potential cluster size. @@ -218,7 +192,6 @@ class KernelOccupancy: int The maximum cluster size that can be launched for this kernel and launch configuration. """ - def max_active_clusters(self, config: LaunchConfig, *, stream: Stream) -> int: """Maximum number of active clusters on the target device. @@ -249,28 +222,19 @@ class Kernel: should instead be created through a :obj:`~_module.ObjectCode` object. """ - - def __init__(self, *args, **kwargs) -> None: - ... - + def __init__(self, *args, **kwargs) -> None: ... @property - @cython.critical_section def attributes(self) -> KernelAttributes: """Get the read-only attributes of this kernel.""" - @property def num_arguments(self) -> int: """int : The number of arguments of this function""" - @property - def arguments_info(self) -> list[ParamInfo]: + def arguments_info(self) -> list[Any]: """list[ParamInfo]: (offset, size) for each argument of this function""" - @property - @cython.critical_section def occupancy(self) -> KernelOccupancy: """Get the occupancy information for launching this kernel.""" - @property def handle(self) -> object: """Return the underlying kernel handle object. @@ -280,11 +244,8 @@ class Kernel: This handle is a Python object. To get the memory address of the underlying C handle, call ``int(Kernel.handle)``. """ - @property - def _handle(self) -> object: - ... - + def _handle(self) -> object: ... @staticmethod def from_handle(handle, mod: ObjectCode | None=None) -> Kernel: """Creates a new :obj:`Kernel` object from a kernel handle. @@ -299,15 +260,9 @@ class Kernel: library lifetime for foreign kernels not created by cuda.core. """ - - def __eq__(self, other: object) -> bool: - ... - - def __hash__(self) -> int: - ... - - def __repr__(self) -> str: - ... + def __eq__(self, other: object) -> bool: ... + def __hash__(self) -> int: ... + def __repr__(self) -> str: ... class ObjectCode: """Represent a compiled program to be loaded onto the device. @@ -322,21 +277,12 @@ class ObjectCode: from all other possible code types should be avoided in favor of compilation through :class:`~cuda.core.Program` """ - - def __init__(self, *args, **kwargs) -> None: - ... - + def __init__(self, *args, **kwargs) -> None: ... @classmethod - def _init(cls, module, code_type, *, name: str='', symbol_mapping: dict[str, str] | None=None) -> ObjectCode: - ... - + def _init(cls, module, code_type, *, name: str='', symbol_mapping: dict[str, str] | None=None) -> ObjectCode: ... @staticmethod - def _reduce_helper(module, code_type, name, symbol_mapping): - ... - - def __reduce__(self) -> tuple[object, ...]: - ... - + def _reduce_helper(module, code_type, name, symbol_mapping): ... + def __reduce__(self) -> tuple[object, ...]: ... @staticmethod def from_cubin(module: bytes | str | PathLike[str], *, name: str='', symbol_mapping: dict[str, str] | None=None) -> ObjectCode: """Create an :class:`ObjectCode` instance from an existing cubin. @@ -354,7 +300,6 @@ class ObjectCode: should be mapped to the mangled names before trying to retrieve them (default to no mappings). """ - @staticmethod def from_ptx(module: bytes | str | PathLike[str], *, name: str='', symbol_mapping: dict[str, str] | None=None) -> ObjectCode: """Create an :class:`ObjectCode` instance from an existing PTX. @@ -372,7 +317,6 @@ class ObjectCode: should be mapped to the mangled names before trying to retrieve them (default to no mappings). """ - @staticmethod def from_ltoir(module: bytes | str | PathLike[str], *, name: str='', symbol_mapping: dict[str, str] | None=None) -> ObjectCode: """Create an :class:`ObjectCode` instance from an existing LTOIR. @@ -390,7 +334,6 @@ class ObjectCode: should be mapped to the mangled names before trying to retrieve them (default to no mappings). """ - @staticmethod def from_fatbin(module: bytes | str | PathLike[str], *, name: str='', symbol_mapping: dict[str, str] | None=None) -> ObjectCode: """Create an :class:`ObjectCode` instance from an existing fatbin. @@ -408,7 +351,6 @@ class ObjectCode: should be mapped to the mangled names before trying to retrieve them (default to no mappings). """ - @staticmethod def from_object(module: bytes | str, *, name: str='', symbol_mapping: dict[str, str] | None=None) -> ObjectCode: """Create an :class:`ObjectCode` instance from an existing object code. @@ -425,7 +367,6 @@ class ObjectCode: should be mapped to the mangled names before trying to retrieve them (default to no mappings). """ - @staticmethod def from_library(module: bytes | str, *, name: str='', symbol_mapping: dict[str, str] | None=None) -> ObjectCode: """Create an :class:`ObjectCode` instance from an existing library. @@ -442,7 +383,6 @@ class ObjectCode: should be mapped to the mangled names before trying to retrieve them (default to no mappings). """ - def get_kernel(self, name: str | bytes) -> Kernel: """Return the :obj:`~_module.Kernel` of a specified name from this object code. @@ -457,7 +397,6 @@ class ObjectCode: Newly created kernel object. """ - def get_module(self) -> driver.CUmodule: """Return a context-dependent :obj:`~driver.CUmodule` for legacy interop. @@ -471,23 +410,18 @@ class ObjectCode: Module handle for the current CUDA context, suitable for legacy driver APIs that accept ``CUmodule``. """ - @property def code(self) -> CodeTypeT: """Return the underlying code object.""" - @property def name(self) -> str: """Return a human-readable name of this code object.""" - @property def code_type(self) -> str: """Return the type of the underlying code object.""" - @property def symbol_mapping(self) -> dict[str, str]: """Return a copy of the symbol mapping dictionary.""" - @property def handle(self) -> object: """Return the native, context-independent :obj:`~driver.CUlibrary` handle. @@ -500,16 +434,6 @@ class ObjectCode: This handle is a Python object. To get the memory address of the underlying C handle, call ``int(ObjectCode.handle)``. """ - - def __eq__(self, other: object) -> bool: - ... - - def __hash__(self) -> int: - ... - - def __repr__(self) -> str: - ... -__all__ = ['Kernel', 'ObjectCode'] -MaxPotentialBlockSizeOccupancyResult = namedtuple('MaxPotentialBlockSizeOccupancyResult', ('min_grid_size', 'max_block_size')) -ParamInfo = namedtuple('ParamInfo', ['offset', 'size']) -CodeTypeT = bytes | bytearray | str \ No newline at end of file + def __eq__(self, other: object) -> bool: ... + def __hash__(self) -> int: ... + def __repr__(self) -> str: ... diff --git a/cuda_core/cuda/core/_program.pyi b/cuda_core/cuda/core/_program.pyi index fd40aae069f..3e525597977 100644 --- a/cuda_core/cuda/core/_program.pyi +++ b/cuda_core/cuda/core/_program.pyi @@ -1,12 +1,10 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_program.pyx +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_program.pyx """Compilation machinery for CUDA programs. This module provides :class:`Program` for compiling source code into :class:`~cuda.core.ObjectCode`, with :class:`ProgramOptions` for configuration. """ -from __future__ import annotations - from dataclasses import dataclass from cuda.bindings import nvrtc @@ -16,6 +14,10 @@ from cuda.core.typing import (CompilerBackendType, ObjectCodeFormatType, PCHStatusType, SourceCodeType) from cuda.core.utils._program_cache import ProgramCacheResource +__all__ = ['Program', 'ProgramOptions'] +ProgramHandleT = nvrtc.nvrtcProgram | int | LinkerHandleT +_nvvm_module = None +_nvvm_import_attempted = False class Program: """Represent a compilation machinery to process programs into @@ -35,14 +37,10 @@ class Program: options : :class:`ProgramOptions`, optional Options to customize the compilation process. """ - - def __init__(self, code: str | bytes | bytearray, code_type: SourceCodeType | str, options: ProgramOptions | None=None): - ... - + def __init__(self, code: str | bytes | bytearray, code_type: SourceCodeType | str, options: ProgramOptions | None=None): ... def close(self) -> None: """Destroy this program.""" - - def compile(self, target_type: ObjectCodeFormatType | str, name_expressions: tuple[str, ...] | list[str]=..., logs: object=None, *, cache: ProgramCacheResource | None=None) -> ObjectCode: + def compile(self, target_type: ObjectCodeFormatType | str, name_expressions: tuple[str, ...] | list[str]=(), logs: object | None=None, *, cache: ProgramCacheResource | None=None) -> ObjectCode: """Compile the program to the specified target type. Parameters @@ -90,7 +88,6 @@ class Program: :class:`~cuda.core.ObjectCode` The compiled object code. """ - @property def pch_status(self) -> PCHStatusType | None: """PCH creation outcome from the most recent :meth:`compile` call. @@ -115,11 +112,9 @@ class Program: use the NVRTC backend. For PTX and NVVM programs this property always returns ``None``. """ - @property def backend(self) -> CompilerBackendType: """Return this Program instance's underlying :class:`CompilerBackendType`.""" - @property def handle(self) -> ProgramHandleT: """Return the underlying handle object. @@ -133,9 +128,7 @@ class Program: This handle is a Python object. To get the memory address of the underlying C handle, call ``int(Program.handle)``. """ - - def __repr__(self) -> str: - ... + def __repr__(self) -> str: ... @dataclass class ProgramOptions: @@ -374,15 +367,9 @@ class ProgramOptions: use_libdevice: bool | None = None numba_debug: bool | None = None - def __post_init__(self) -> None: - ... - - def _prepare_nvrtc_options(self) -> list[bytes]: - ... - - def _prepare_nvvm_options(self, as_bytes: bool=True) -> list[bytes] | list[str]: - ... - + def __post_init__(self) -> None: ... + def _prepare_nvrtc_options(self) -> list[bytes]: ... + def _prepare_nvvm_options(self, as_bytes: bool=True) -> list[bytes] | list[str]: ... def as_bytes(self, backend: CompilerBackendType | str, target_type: ObjectCodeFormatType | str | None=None) -> list[bytes]: """Convert program options to bytes format for the specified backend. @@ -415,30 +402,9 @@ class ProgramOptions: >>> options = ProgramOptions(arch="sm_80", debug=True) >>> nvrtc_options = options.as_bytes("nvrtc") """ - - def __repr__(self) -> str: - ... - + def __repr__(self) -> str: ... def _prepare_extra_sources_bytes(self) -> list[tuple[bytes, bytes]] | None: """Convert extra_sources to bytes format for NVVM.""" -__all__ = ['Program', 'ProgramOptions'] -ProgramHandleT = nvrtc.nvrtcProgram | int | LinkerHandleT -_nvvm_module = None -_nvvm_import_attempted = False - -def _can_load_generated_ptx() -> bool: - """Check if the driver can load PTX generated by the current NVRTC version.""" - -def _assert_single_dashed_nvvm_options(options: list[str]) -> None: - """Guard against emitting a double-dashed option to libNVVM. - - libNVVM's parser accepts only single-dashed options and rejects the - double-dashed spelling of every option with NVVM_ERROR_INVALID_OPTION - (see #2570). Every option on this path is generated from typed fields, so - a double dash can only mean a bug in ``cuda.core`` rather than bad user - input. Fail here, naming the option, instead of leaving the user with - libNVVM's opaque error. - """ def _program_compile_uncached(program, target_type, name_expressions, logs): """Run ``Program_compile`` without the cache wrapper. @@ -449,9 +415,19 @@ def _program_compile_uncached(program, target_type, name_expressions, logs): and its methods cannot be reassigned from Python, so the seam must live outside the class. """ - def _get_nvvm_module() -> object: """Get the NVVM module, importing it lazily with availability checks.""" - def _find_libdevice_path() -> object: - """Find libdevice*.bc for NVVM compilation using cuda.pathfinder.""" \ No newline at end of file + """Find libdevice*.bc for NVVM compilation using cuda.pathfinder.""" +def _can_load_generated_ptx() -> bool: + """Check if the driver can load PTX generated by the current NVRTC version.""" +def _assert_single_dashed_nvvm_options(options: list[str]) -> None: + """Guard against emitting a double-dashed option to libNVVM. + + libNVVM's parser accepts only single-dashed options and rejects the + double-dashed spelling of every option with NVVM_ERROR_INVALID_OPTION + (see #2570). Every option on this path is generated from typed fields, so + a double dash can only mean a bug in ``cuda.core`` rather than bad user + input. Fail here, naming the option, instead of leaving the user with + libNVVM's opaque error. + """ diff --git a/cuda_core/cuda/core/_resource_handles.pyi b/cuda_core/cuda/core/_resource_handles.pyi index f9b10d4db3d..457e2921047 100644 --- a/cuda_core/cuda/core/_resource_handles.pyi +++ b/cuda_core/cuda/core/_resource_handles.pyi @@ -1,31 +1,29 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_resource_handles.pyx +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_resource_handles.pyx -from __future__ import annotations +from typing import Any, TypeAlias -from libcpp.memory import shared_ptr, unique_ptr - -ContextHandle = shared_ptr -GreenCtxHandle = shared_ptr -StreamHandle = shared_ptr -EventHandle = shared_ptr -MemoryPoolHandle = shared_ptr -DevicePtrHandle = shared_ptr -LibraryHandle = shared_ptr -KernelHandle = shared_ptr -GraphHandle = shared_ptr -GraphExecHandle = shared_ptr -GraphNodeHandle = shared_ptr -GraphicsResourceHandle = shared_ptr -NvrtcProgramHandle = shared_ptr -NvvmProgramHandle = shared_ptr -NvJitLinkHandle = shared_ptr -CuLinkHandle = shared_ptr -FileDescriptorHandle = shared_ptr -OpaqueArrayHandle = shared_ptr -MipmappedArrayHandle = shared_ptr -TexObjectHandle = shared_ptr -SurfObjectHandle = shared_ptr -OpaqueHandle = shared_ptr -PreparedAttachment = unique_ptr -PreparedChildGraphUpdate = shared_ptr -PreparedExecAttachment = unique_ptr \ No newline at end of file +ContextHandle: TypeAlias = Any +GreenCtxHandle: TypeAlias = Any +StreamHandle: TypeAlias = Any +EventHandle: TypeAlias = Any +MemoryPoolHandle: TypeAlias = Any +DevicePtrHandle: TypeAlias = Any +LibraryHandle: TypeAlias = Any +KernelHandle: TypeAlias = Any +GraphHandle: TypeAlias = Any +GraphExecHandle: TypeAlias = Any +GraphNodeHandle: TypeAlias = Any +GraphicsResourceHandle: TypeAlias = Any +NvrtcProgramHandle: TypeAlias = Any +NvvmProgramHandle: TypeAlias = Any +NvJitLinkHandle: TypeAlias = Any +CuLinkHandle: TypeAlias = Any +FileDescriptorHandle: TypeAlias = Any +OpaqueArrayHandle: TypeAlias = Any +MipmappedArrayHandle: TypeAlias = Any +TexObjectHandle: TypeAlias = Any +SurfObjectHandle: TypeAlias = Any +OpaqueHandle: TypeAlias = Any +PreparedAttachment: TypeAlias = Any +PreparedChildGraphUpdate: TypeAlias = Any +PreparedExecAttachment: TypeAlias = Any diff --git a/cuda_core/cuda/core/_stream.pyi b/cuda_core/cuda/core/_stream.pyi index 99af5f9b15b..bee6efd9d31 100644 --- a/cuda_core/cuda/core/_stream.pyi +++ b/cuda_core/cuda/core/_stream.pyi @@ -1,18 +1,18 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_stream.pyx - -from __future__ import annotations +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_stream.pyx from dataclasses import dataclass -from typing import Protocol +from typing import Any, Protocol import cuda.bindings.driver -import cython from cuda.core._context import Context from cuda.core._device import Device from cuda.core._device_resources import DeviceResources from cuda.core._event import Event, EventOptions from cuda.core.graph import GraphBuilder +__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() @dataclass class StreamOptions: @@ -27,11 +27,10 @@ class StreamOptions: higher priority. (Default to lowest priority) """ - nonblocking: cython.bint = True + nonblocking: Any = True priority: int | None = None class IsStreamType(Protocol): - def __cuda_stream__(self) -> tuple[int, int]: """ For any Python object that is meant to be interpreted as a CUDA stream, the intent @@ -56,42 +55,27 @@ class Stream: object, or created directly through using an existing handle using Stream.from_handle(). """ - - def close(self): - """Destroy the stream. - - Releases the stream handle. For owned streams, this destroys the - underlying CUDA stream. For borrowed streams, this releases the - reference and allows the Python owner to be GC'd. - """ - - def __init__(self, *args, **kwargs) -> None: - ... - + def __init__(self, *args, **kwargs) -> None: ... @classmethod def _legacy_default(cls) -> Stream: """Return the legacy default stream (supports subclassing).""" - @classmethod def _per_thread_default(cls) -> Stream: """Return the per-thread default stream (supports subclassing).""" - @classmethod - def _init(cls, obj: IsStreamType | None=None, options: object=None, device_id: int | None=None, ctx: Context | None=None) -> Stream: - ... + def _init(cls, obj: IsStreamType | None=None, options: object | None=None, device_id: int | None=None, ctx: Context | None=None) -> Stream: ... + def close(self): + """Destroy the stream. + Releases the stream handle. For owned streams, this destroys the + underlying CUDA stream. For borrowed streams, this releases the + reference and allows the Python owner to be GC'd. + """ def __cuda_stream__(self) -> tuple[int, int]: """Return an instance of a __cuda_stream__ protocol.""" - - def __hash__(self) -> int: - ... - - def __eq__(self, other: object) -> bool: - ... - - def __repr__(self) -> str: - ... - + def __hash__(self) -> int: ... + def __eq__(self, other: object) -> bool: ... + def __repr__(self) -> str: ... @property def handle(self) -> cuda.bindings.driver.CUstream: """Return the underlying ``CUstream`` object. @@ -101,18 +85,14 @@ class Stream: This handle is a Python object. To get the memory address of the underlying C handle, call ``int(Stream.handle)``. """ - @property def is_nonblocking(self) -> bool: """Return True if this is a nonblocking stream, otherwise False.""" - @property def priority(self) -> int: """Return the stream priority.""" - def sync(self) -> None: """Synchronize the stream.""" - def record(self, event: Event | None=None, options: EventOptions | None=None) -> Event: """Record an event onto the stream. @@ -139,7 +119,6 @@ class Stream: associated with the current context at call time. """ - def wait(self, event_or_stream: Event | Stream) -> None: """Wait for a CUDA event or a CUDA stream. @@ -157,7 +136,6 @@ class Stream: streams. """ - @property def device(self) -> Device: """Return the :obj:`~_device.Device` singleton associated with this stream. @@ -174,7 +152,6 @@ class Stream: set current after the stream is created. """ - @property def context(self) -> Context: """Return the :obj:`~_context.Context` associated with this stream. @@ -187,7 +164,6 @@ class Stream: context at call time. """ - @property def resources(self) -> DeviceResources: """Query the hardware resources provisioned for this stream's context. @@ -204,7 +180,6 @@ class Stream: context at call time. """ - @staticmethod def from_handle(handle) -> Stream: """Create a new :obj:`~_stream.Stream` object from a foreign stream handle. @@ -229,7 +204,6 @@ class Stream: Newly created stream object. """ - def create_graph_builder(self) -> GraphBuilder: """Create a new :obj:`~graph.GraphBuilder` object. @@ -241,9 +215,6 @@ 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() def default_stream() -> Stream: """Return the default CUDA :obj:`~_stream.Stream`. @@ -255,6 +226,4 @@ def default_stream() -> Stream: the legacy stream. """ - -def Stream_accept(arg, allow_stream_protocol: bool=False) -> Stream: - ... \ No newline at end of file +def Stream_accept(arg, allow_stream_protocol: bool=False) -> Stream: ... diff --git a/cuda_core/cuda/core/_tensor_bridge.pyi b/cuda_core/cuda/core/_tensor_bridge.pyi index 22948d5b864..25c13c6458c 100644 --- a/cuda_core/cuda/core/_tensor_bridge.pyi +++ b/cuda_core/cuda/core/_tensor_bridge.pyi @@ -1,4 +1,4 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_tensor_bridge.pyx +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_tensor_bridge.pyx """Tensor bridge: extract PyTorch tensor metadata via the AOTI stable C ABI. @@ -46,13 +46,19 @@ Credit: Emilio Castillo (ecastillo@nvidia.com) – original tensor-bridge POC. ``torch._C`` has been re-opened with ``RTLD_GLOBAL`` *before* importing this module so that the AOTI symbols are visible. """ -from __future__ import annotations +from typing import TypeAlias, TypedDict import numpy from cuda.core._memoryview import StridedMemoryView -AOTITorchError = int +AOTITorchError: TypeAlias = int +class PyObject(TypedDict): ... + +class AtenTensorOpaque(TypedDict): ... + +def resolve_aoti_dtype(dtype_code: int) -> numpy.dtype: + """Python-callable wrapper around _get_aoti_dtype (for lazy resolution).""" def sync_torch_stream(device_index: int, consumer_s: int) -> int: """Establish stream ordering between PyTorch's current CUDA stream and the given consumer stream. @@ -61,10 +67,6 @@ def sync_torch_stream(device_index: int, consumer_s: int) -> int: the consumer stream wait on it. This is a no-op if both streams are the same. """ - -def resolve_aoti_dtype(dtype_code: int) -> numpy.dtype: - """Python-callable wrapper around _get_aoti_dtype (for lazy resolution).""" - def view_as_torch_tensor(obj: object, stream_ptr: object, view: StridedMemoryView | None=None) -> StridedMemoryView: """Create/populate a :class:`StridedMemoryView` from a ``torch.Tensor``. @@ -82,4 +84,4 @@ def view_as_torch_tensor(obj: object, stream_ptr: object, view: StridedMemoryVie view : StridedMemoryView, optional If provided, populate this existing view in-place. Otherwise a new instance is created. - """ \ No newline at end of file + """ diff --git a/cuda_core/cuda/core/_tensor_map.pyi b/cuda_core/cuda/core/_tensor_map.pyi index c6a18ad2399..2a3dc8a48a3 100644 --- a/cuda_core/cuda/core/_tensor_map.pyi +++ b/cuda_core/cuda/core/_tensor_map.pyi @@ -1,6 +1,4 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_tensor_map.pyx - -from __future__ import annotations +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_tensor_map.pyx from dataclasses import dataclass @@ -8,6 +6,22 @@ import numpy from cuda.bindings import cydriver from cuda.core._device import Device +__all__ = ['TensorMapDescriptor', 'TensorMapDescriptorOptions'] +_TMA_DT_UINT8: int = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_UINT8) +_TMA_DT_UINT16: int = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_UINT16) +_TMA_DT_UINT32: int = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_UINT32) +_TMA_DT_INT32: int = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_INT32) +_TMA_DT_UINT64: int = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_UINT64) +_TMA_DT_INT64: int = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_INT64) +_TMA_DT_FLOAT16: int = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_FLOAT16) +_TMA_DT_FLOAT32: int = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_FLOAT32) +_TMA_DT_FLOAT64: int = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_FLOAT64) +_TMA_DT_BFLOAT16: int = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_BFLOAT16) +_TMA_DT_FLOAT32_FTZ: int = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_FLOAT32_FTZ) +_TMA_DT_TFLOAT32: int = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_TFLOAT32) +_TMA_DT_TFLOAT32_FTZ: int = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_TFLOAT32_FTZ) +_NUMPY_DTYPE_TO_TMA = {numpy.dtype(numpy.uint8): _TMA_DT_UINT8, numpy.dtype(numpy.uint16): _TMA_DT_UINT16, numpy.dtype(numpy.uint32): _TMA_DT_UINT32, numpy.dtype(numpy.int32): _TMA_DT_INT32, numpy.dtype(numpy.uint64): _TMA_DT_UINT64, numpy.dtype(numpy.int64): _TMA_DT_INT64, numpy.dtype(numpy.float16): _TMA_DT_FLOAT16, numpy.dtype(numpy.float32): _TMA_DT_FLOAT32, numpy.dtype(numpy.float64): _TMA_DT_FLOAT64} +_TMA_DATA_TYPE_SIZE = {_TMA_DT_UINT8: 1, _TMA_DT_UINT16: 2, _TMA_DT_UINT32: 4, _TMA_DT_INT32: 4, _TMA_DT_UINT64: 8, _TMA_DT_INT64: 8, _TMA_DT_FLOAT16: 2, _TMA_DT_FLOAT32: 4, _TMA_DT_FLOAT64: 8, _TMA_DT_BFLOAT16: 2, _TMA_DT_FLOAT32_FTZ: 4, _TMA_DT_TFLOAT32: 4, _TMA_DT_TFLOAT32_FTZ: 4} class TensorMapDataType: """Data types for tensor map descriptors. @@ -105,8 +119,7 @@ class TensorMapDescriptorOptions: l2_promotion: TensorMapL2Promotion = TensorMapL2Promotion.NONE oob_fill: TensorMapOOBFill = TensorMapOOBFill.NONE - def __post_init__(self) -> None: - ... + def __post_init__(self) -> None: ... class TensorMapDescriptor: """Describes a TMA (Tensor Memory Accelerator) tensor map for Hopper+ GPUs. @@ -121,16 +134,12 @@ class TensorMapDescriptor: descriptors can be passed directly to :func:`~cuda.core.launch` as a kernel argument. """ - - def __init__(self): - ... - + def __init__(self): ... @property def device(self) -> Device | None: """Return the :obj:`~cuda.core.Device` associated with this descriptor.""" - @classmethod - def _from_tiled(cls, view, box_dim=None, *, options=None, element_strides=None, data_type=None, interleave=..., swizzle=..., l2_promotion=..., oob_fill=...): + def _from_tiled(cls, view, box_dim=None, *, options=None, element_strides=None, data_type=None, interleave=TensorMapInterleave.NONE, swizzle=TensorMapSwizzle.NONE, l2_promotion=TensorMapL2Promotion.NONE, oob_fill=TensorMapOOBFill.NONE): """Create a tiled TMA descriptor from a validated view. Parameters @@ -171,9 +180,8 @@ class TensorMapDescriptor: If the tensor rank is outside [1, 5], the pointer is not 16-byte aligned, or dimension/stride constraints are violated. """ - @classmethod - def _from_im2col(cls, view, pixel_box_lower_corner, pixel_box_upper_corner, channels_per_pixel, pixels_per_column, *, element_strides=None, data_type=None, interleave=..., swizzle=..., l2_promotion=..., oob_fill=...): + def _from_im2col(cls, view, pixel_box_lower_corner, pixel_box_upper_corner, channels_per_pixel, pixels_per_column, *, element_strides=None, data_type=None, interleave=TensorMapInterleave.NONE, swizzle=TensorMapSwizzle.NONE, l2_promotion=TensorMapL2Promotion.NONE, oob_fill=TensorMapOOBFill.NONE): """Create an im2col TMA descriptor from a validated view. Im2col layout is used for convolution-style data access patterns. @@ -219,9 +227,8 @@ class TensorMapDescriptor: If the tensor rank is outside [3, 5], the pointer is not 16-byte aligned, or other constraints are violated. """ - @classmethod - def _from_im2col_wide(cls, view, pixel_box_lower_corner_width, pixel_box_upper_corner_width, channels_per_pixel, pixels_per_column, *, element_strides=None, data_type=None, interleave=..., mode=..., swizzle=..., l2_promotion=..., oob_fill=...): + def _from_im2col_wide(cls, view, pixel_box_lower_corner_width, pixel_box_upper_corner_width, channels_per_pixel, pixels_per_column, *, element_strides=None, data_type=None, interleave=TensorMapInterleave.NONE, mode=TensorMapIm2ColWideMode.W, swizzle=TensorMapSwizzle.SWIZZLE_128B, l2_promotion=TensorMapL2Promotion.NONE, oob_fill=TensorMapOOBFill.NONE): """Create an im2col-wide TMA descriptor from a validated view. Im2col-wide layout loads elements exclusively along the W (width) @@ -267,7 +274,6 @@ class TensorMapDescriptor: If the tensor rank is outside [3, 5], the pointer is not 16-byte aligned, or other constraints are violated. """ - def replace_address(self, tensor: object) -> None: """Replace the global memory address in this tensor map descriptor. @@ -281,44 +287,16 @@ class TensorMapDescriptor: or a :obj:`~cuda.core.StridedMemoryView`. Must refer to device-accessible memory with a 16-byte-aligned pointer. """ + def __repr__(self) -> str: ... - 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) -_TMA_DT_INT32 = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_INT32) -_TMA_DT_UINT64 = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_UINT64) -_TMA_DT_INT64 = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_INT64) -_TMA_DT_FLOAT16 = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_FLOAT16) -_TMA_DT_FLOAT32 = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_FLOAT32) -_TMA_DT_FLOAT64 = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_FLOAT64) -_TMA_DT_BFLOAT16 = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_BFLOAT16) -_TMA_DT_FLOAT32_FTZ = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_FLOAT32_FTZ) -_TMA_DT_TFLOAT32 = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_TFLOAT32) -_TMA_DT_TFLOAT32_FTZ = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_TFLOAT32_FTZ) -_NUMPY_DTYPE_TO_TMA = {numpy.dtype(numpy.uint8): _TMA_DT_UINT8, numpy.dtype(numpy.uint16): _TMA_DT_UINT16, numpy.dtype(numpy.uint32): _TMA_DT_UINT32, numpy.dtype(numpy.int32): _TMA_DT_INT32, numpy.dtype(numpy.uint64): _TMA_DT_UINT64, numpy.dtype(numpy.int64): _TMA_DT_INT64, numpy.dtype(numpy.float16): _TMA_DT_FLOAT16, numpy.dtype(numpy.float32): _TMA_DT_FLOAT32, numpy.dtype(numpy.float64): _TMA_DT_FLOAT64} -_TMA_DATA_TYPE_SIZE = {_TMA_DT_UINT8: 1, _TMA_DT_UINT16: 2, _TMA_DT_UINT32: 4, _TMA_DT_INT32: 4, _TMA_DT_UINT64: 8, _TMA_DT_INT64: 8, _TMA_DT_FLOAT16: 2, _TMA_DT_FLOAT32: 4, _TMA_DT_FLOAT64: 8, _TMA_DT_BFLOAT16: 2, _TMA_DT_FLOAT32_FTZ: 4, _TMA_DT_TFLOAT32: 4, _TMA_DT_TFLOAT32_FTZ: 4} - -def _normalize_tensor_map_data_type(data_type): - ... - -def _normalize_tensor_map_sequence(name, values): - ... - -def _require_tensor_map_enum(name, value, enum_type): - ... - -def _coerce_tensor_map_descriptor_options(box_dim, options, *, element_strides, data_type, interleave, swizzle, l2_promotion, oob_fill): - ... - +def _normalize_tensor_map_data_type(data_type): ... +def _normalize_tensor_map_sequence(name, values): ... +def _require_tensor_map_enum(name, value, enum_type): ... +def _coerce_tensor_map_descriptor_options(box_dim, options, *, element_strides, data_type, interleave, swizzle, l2_promotion, oob_fill): ... def _resolve_data_type(view, data_type): """Resolve the TMA data type from an explicit value or the view's dtype.""" - def _get_validated_view(tensor): """Obtain a device-accessible StridedMemoryView with a 16-byte-aligned pointer.""" - def _require_view_device(view, expected_device_id, operation): """Ensure device-local tensors match the current CUDA device. @@ -326,12 +304,10 @@ def _require_view_device(view, expected_device_id, operation): ``kDLCUDAManaged`` with ``device_id=0`` regardless of the current device, so only true ``kDLCUDA`` tensors are rejected by device-id mismatch. """ - def _compute_byte_strides(shape, strides, elem_size): """Compute byte strides from element strides or C-contiguous fallback. Returns a tuple of byte strides in row-major order. """ - def _validate_element_strides(element_strides, rank): - """Validate or default element_strides to all-ones.""" \ No newline at end of file + """Validate or default element_strides to all-ones.""" diff --git a/cuda_core/cuda/core/_tensor_map.pyx b/cuda_core/cuda/core/_tensor_map.pyx index 46c2fa93152..3b8b54dd8f3 100644 --- a/cuda_core/cuda/core/_tensor_map.pyx +++ b/cuda_core/cuda/core/_tensor_map.pyx @@ -132,19 +132,19 @@ ELSE: W128 = 1 -_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) -_TMA_DT_INT32 = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_INT32) -_TMA_DT_UINT64 = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_UINT64) -_TMA_DT_INT64 = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_INT64) -_TMA_DT_FLOAT16 = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_FLOAT16) -_TMA_DT_FLOAT32 = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_FLOAT32) -_TMA_DT_FLOAT64 = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_FLOAT64) -_TMA_DT_BFLOAT16 = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_BFLOAT16) -_TMA_DT_FLOAT32_FTZ = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_FLOAT32_FTZ) -_TMA_DT_TFLOAT32 = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_TFLOAT32) -_TMA_DT_TFLOAT32_FTZ = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_TFLOAT32_FTZ) +_TMA_DT_UINT8: int = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_UINT8) +_TMA_DT_UINT16: int = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_UINT16) +_TMA_DT_UINT32: int = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_UINT32) +_TMA_DT_INT32: int = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_INT32) +_TMA_DT_UINT64: int = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_UINT64) +_TMA_DT_INT64: int = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_INT64) +_TMA_DT_FLOAT16: int = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_FLOAT16) +_TMA_DT_FLOAT32: int = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_FLOAT32) +_TMA_DT_FLOAT64: int = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_FLOAT64) +_TMA_DT_BFLOAT16: int = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_BFLOAT16) +_TMA_DT_FLOAT32_FTZ: int = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_FLOAT32_FTZ) +_TMA_DT_TFLOAT32: int = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_TFLOAT32) +_TMA_DT_TFLOAT32_FTZ: int = int(cydriver.CU_TENSOR_MAP_DATA_TYPE_TFLOAT32_FTZ) def _normalize_tensor_map_data_type(data_type): diff --git a/cuda_core/cuda/core/_utils/_weak_handles.pyi b/cuda_core/cuda/core/_utils/_weak_handles.pyi index 5b7913e008a..a795a180504 100644 --- a/cuda_core/cuda/core/_utils/_weak_handles.pyi +++ b/cuda_core/cuda/core/_utils/_weak_handles.pyi @@ -1,4 +1,4 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_utils/_weak_handles.pyx +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_utils/_weak_handles.pyx """Test-only weak handles for resource-handle lifetime checks. @@ -20,9 +20,6 @@ handle field (see ``*.pxd``), assigns to :ctype:`OpaqueHandle`, and extend the Python owners via ``make_opaque_py`` are not covered here -- use :class:`weakref.ref` on a weak-referenceable owner object in tests instead. """ -from __future__ import annotations - - class WeakHandle: """Non-owning weak handle for a resource's shared control block. @@ -30,13 +27,9 @@ class WeakHandle: falsy once the last strong reference is released. Obtain instances via :func:`weak_handle` rather than constructing directly. """ - - def __bool__(self): - ... - + def __bool__(self): ... def expired(self): """Return ``True`` once every strong owner of the handle is gone.""" - def use_count(self): """Number of strong owners currently sharing the handle.""" @@ -53,4 +46,4 @@ def weak_handle(obj): If ``obj`` is a :class:`~cuda.core.Buffer` with no active allocation. TypeError If ``obj`` is not a supported type. - """ \ No newline at end of file + """ diff --git a/cuda_core/cuda/core/_utils/_wsl_locale.pyi b/cuda_core/cuda/core/_utils/_wsl_locale.pyi index 267bdf244f0..790ae71b99d 100644 --- a/cuda_core/cuda/core/_utils/_wsl_locale.pyi +++ b/cuda_core/cuda/core/_utils/_wsl_locale.pyi @@ -1,7 +1,4 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_utils/_wsl_locale.pyx - -from __future__ import annotations - +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_utils/_wsl_locale.pyx class c_locale_guard: """Context manager that pins the calling thread to the "C" locale. @@ -9,12 +6,6 @@ class c_locale_guard: Uses POSIX newlocale/uselocale/freelocale so other threads' view of the locale is unaffected. Restores the previous thread locale on exit. """ - - def __cinit__(self) -> None: - ... - - def __enter__(self): - ... - - def __exit__(self, exc_type, exc_val, exc_tb): - ... \ No newline at end of file + def __init__(self) -> None: ... + def __enter__(self): ... + def __exit__(self, exc_type, exc_val, exc_tb): ... diff --git a/cuda_core/cuda/core/_utils/cuda_utils.pyi b/cuda_core/cuda/core/_utils/cuda_utils.pyi index 87067927724..545b9a9073c 100644 --- a/cuda_core/cuda/core/_utils/cuda_utils.pyi +++ b/cuda_core/cuda/core/_utils/cuda_utils.pyi @@ -1,21 +1,25 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_utils/cuda_utils.pyx +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_utils/cuda_utils.pyx -from __future__ import annotations - -from collections import namedtuple -from typing import Any, Callable +from typing import Any, Callable, NamedTuple from cuda.bindings import cydriver from cuda.bindings import driver as driver from cuda.bindings import nvrtc as nvrtc from cuda.bindings import runtime as runtime +_keep_driver_in_stub: driver.CUresult +_keep_nvrtc_in_stub: nvrtc.nvrtcResult +_keep_runtime_in_stub: runtime.cudaError_t +_fork_warning_checked = False + +class CUDAError(Exception): ... -class CUDAError(Exception): - ... +class NVRTCError(CUDAError): ... -class NVRTCError(CUDAError): - ... +class ComputeCapability(NamedTuple): + """A named tuple of (major, minor) CUDA compute capability version numbers.""" + major: int + minor: int class Transaction: """ @@ -35,81 +39,32 @@ class Transaction: append(fn, *args, **kwargs): Register an undo action to be called on rollback. commit(): Disarm all undo actions; nothing will be rolled back on exit. """ - - def __init__(self) -> None: - ... - - def __enter__(self): - ... - - def __exit__(self, exc_type, exc, tb): - ... - + def __init__(self) -> None: ... + def __enter__(self): ... + def __exit__(self, exc_type, exc, tb): ... def append(self, fn: Callable[..., Any], /, *args: Any, **kwargs) -> None: """ Register an undo action (runs if the with-block exits without commit()). Values are bound now via partial so late mutations don't bite you. """ - def commit(self) -> None: """ Disarm all undo actions. After this, exiting the with-block does nothing. """ -_keep_driver_in_stub: 'driver.CUresult' -_keep_nvrtc_in_stub: 'nvrtc.nvrtcResult' -_keep_runtime_in_stub: 'runtime.cudaError_t' -ComputeCapability = namedtuple('ComputeCapability', ('major', 'minor')) -_fork_warning_checked = False - -def _check_driver_error(error: cydriver.CUresult) -> int: - ... - -def _check_runtime_error(error) -> int: - ... - -def _check_nvrtc_error(error, handle=None) -> int: - ... +def cast_to_3_tuple(label: str, cfg: int | tuple[int, ...]) -> tuple[int, int, int]: ... +def _check_driver_error(error: cydriver.CUresult) -> int: ... +def _check_runtime_error(error) -> int: ... +def _check_nvrtc_error(error, handle=None) -> int: ... +def handle_return(result: tuple[Any, ...], handle: object | None=None) -> Any: ... def check_or_create_options(cls: type, options: object, options_description: str='', keep_none: bool=False) -> object: """ Create the specified options dataclass from a dictionary of options or None. """ - -def _parse_fill_value(value) -> tuple: - """Parse a fill/memset value into (raw_value, element_size). - - Parameters - ---------- - value : int or buffer-protocol object - - int: Must be in range [0, 256). Treated as 1-byte fill. - - bytes or buffer-protocol: Must be 1, 2, or 4 bytes. - - Returns - ------- - tuple of (int, int) - (raw_value, element_size) where element_size is 1, 2, or 4. - - Raises - ------ - OverflowError - If int value is outside [0, 256). - TypeError - If value is not an int and does not support the buffer protocol. - ValueError - If value byte length is not 1, 2, or 4. - """ - -def cast_to_3_tuple(label: str, cfg: int | tuple[int, ...]) -> tuple[int, int, int]: - ... - -def handle_return(result: tuple[Any, ...], handle: object=None) -> Any: - ... - def _handle_boolean_option(option: bool) -> str: """ Convert a boolean option to a string representation. """ - def precondition(checker: Callable[..., None], what: str='') -> Callable[..., Any]: """ A decorator that adds checks to ensure any preconditions are met. @@ -122,23 +77,42 @@ def precondition(checker: Callable[..., None], what: str='') -> Callable[..., An Returns: Callable: A decorator that creates the wrapping. """ - def is_sequence(obj: object) -> bool: """ Check if the given object is a sequence (list or tuple). """ - def is_nested_sequence(obj: object) -> bool: """ Check if the given object is a nested sequence (list or tuple with atleast one list or tuple element). """ - def reset_fork_warning() -> None: """Reset the fork warning check flag for testing purposes. This function is intended for use in tests to allow multiple test runs to check the warning behavior. """ +def _parse_fill_value(value) -> tuple[Any, ...]: + """Parse a fill/memset value into (raw_value, element_size). + Parameters + ---------- + value : int or buffer-protocol object + - int: Must be in range [0, 256). Treated as 1-byte fill. + - bytes or buffer-protocol: Must be 1, 2, or 4 bytes. + + Returns + ------- + tuple of (int, int) + (raw_value, element_size) where element_size is 1, 2, or 4. + + Raises + ------ + OverflowError + If int value is outside [0, 256). + TypeError + If value is not an int and does not support the buffer protocol. + ValueError + If value byte length is not 1, 2, or 4. + """ def check_multiprocessing_start_method() -> None: - """Check if multiprocessing start method is 'fork' and warn if so.""" \ No newline at end of file + """Check if multiprocessing start method is 'fork' and warn if so.""" diff --git a/cuda_core/cuda/core/_utils/cuda_utils.pyx b/cuda_core/cuda/core/_utils/cuda_utils.pyx index cf3415b3458..ce75746de56 100644 --- a/cuda_core/cuda/core/_utils/cuda_utils.pyx +++ b/cuda_core/cuda/core/_utils/cuda_utils.pyx @@ -7,10 +7,9 @@ from functools import partial import multiprocessing import platform import warnings -from collections import namedtuple from collections.abc import Sequence from contextlib import ExitStack -from typing import Any, Callable +from typing import Any, Callable, NamedTuple from cuda.bindings import driver as driver, nvrtc as nvrtc, runtime as runtime @@ -42,7 +41,10 @@ class NVRTCError(CUDAError): -ComputeCapability = namedtuple("ComputeCapability", ("major", "minor")) +class ComputeCapability(NamedTuple): + """A named tuple of (major, minor) CUDA compute capability version numbers.""" + major: int + minor: int def cast_to_3_tuple(label: str, cfg: int | tuple[int, ...]) -> tuple[int, int, int]: diff --git a/cuda_core/cuda/core/_utils/version.pyi b/cuda_core/cuda/core/_utils/version.pyi index a577e037bf7..021d86f1aec 100644 --- a/cuda_core/cuda/core/_utils/version.pyi +++ b/cuda_core/cuda/core/_utils/version.pyi @@ -1,6 +1,4 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/_utils/version.pyx - -from __future__ import annotations +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/_utils/version.pyx import functools @@ -12,11 +10,9 @@ def _parse_version_triple(version_str: str) -> tuple[int, int, int]: ``0b1`` or ``0rc1`` by extracting only the leading integer from each release segment. """ - @functools.cache def binding_version() -> tuple[int, int, int]: """Return the cuda-bindings version as a (major, minor, patch) triple.""" - @functools.cache def driver_version() -> tuple[int, int, int]: - """Return the CUDA driver version as a (major, minor, patch) triple.""" \ No newline at end of file + """Return the CUDA driver version as a (major, minor, patch) triple.""" diff --git a/cuda_core/cuda/core/graph/_adjacency_set_proxy.pyi b/cuda_core/cuda/core/graph/_adjacency_set_proxy.pyi index 742b3777b04..a434c6d8108 100644 --- a/cuda_core/cuda/core/graph/_adjacency_set_proxy.pyi +++ b/cuda_core/cuda/core/graph/_adjacency_set_proxy.pyi @@ -1,8 +1,6 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/graph/_adjacency_set_proxy.pyx +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/graph/_adjacency_set_proxy.pyx """Mutable-set proxy for graph node predecessors and successors.""" -from __future__ import annotations - from collections.abc import Iterator, Set from typing import Any @@ -12,47 +10,26 @@ from cuda.core.graph._graph_node import GraphNode class AdjacencySetProxy: """Mutable set proxy for a node's predecessors or successors. Mutations write through to the underlying CUDA graph.""" - __slots__ = ('_core',) - - def __init__(self, node: GraphNode, is_fwd: bool) -> None: - ... + __slots__ = '_core' + def __init__(self, node: GraphNode, is_fwd: bool) -> None: ... @classmethod - def _from_iterable(cls, it) -> set[GraphNode]: - ... - - def __contains__(self, x: object) -> bool: - ... - - def __iter__(self) -> Iterator[GraphNode]: - ... - - def __len__(self) -> int: - ... - - def add(self, value: GraphNode) -> None: - ... - - def discard(self, value: GraphNode) -> None: - ... - + def _from_iterable(cls, it) -> set[GraphNode]: ... + def __contains__(self, x: object) -> bool: ... + def __iter__(self) -> Iterator[GraphNode]: ... + def __len__(self) -> int: ... + def add(self, value: GraphNode) -> None: ... + def discard(self, value: GraphNode) -> None: ... def clear(self) -> None: """Remove all edges in a single driver call.""" - - def __isub__(self, it: Set[Any]) -> 'AdjacencySetProxy': + def __isub__(self, it: Set[Any]) -> AdjacencySetProxy: """Remove edges to all nodes in *it* in a single driver call.""" - def update(self, *others) -> None: """Add edges to multiple nodes at once.""" - - def __ior__(self, it: Set[Any]) -> 'AdjacencySetProxy': + def __ior__(self, it: Set[Any]) -> AdjacencySetProxy: """Add edges to all nodes in *it* in a single driver call.""" - - def __repr__(self) -> str: - ... + def __repr__(self) -> str: ... class _AdjacencySetCore: """Cythonized core implementing AdjacencySetProxy""" - - def __init__(self, node: GraphNode, is_fwd: bool): - ... \ No newline at end of file + def __init__(self, node: GraphNode, is_fwd: bool): ... diff --git a/cuda_core/cuda/core/graph/_graph_builder.pyi b/cuda_core/cuda/core/graph/_graph_builder.pyi index d238b419be1..1e286d3277b 100644 --- a/cuda_core/cuda/core/graph/_graph_builder.pyi +++ b/cuda_core/cuda/core/graph/_graph_builder.pyi @@ -1,8 +1,7 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/graph/_graph_builder.pyx - -from __future__ import annotations +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/graph/_graph_builder.pyx from dataclasses import dataclass +from typing import TypeAlias from cuda.core._stream import Stream from cuda.core._utils.cuda_utils import driver @@ -10,8 +9,9 @@ from cuda.core.graph._graph_definition import GraphCondition, GraphDefinition from cuda.core.graph._graph_node import GraphNode from cuda.core.graph._subclasses import ExecutableGraphNode -_BuilderKind = int -_CaptureState = int +_BuilderKind: TypeAlias = int +_CaptureState: TypeAlias = int +__all__ = ['Graph', 'GraphBuilder', 'GraphCompleteOptions', 'GraphDebugPrintOptions'] @dataclass class GraphDebugPrintOptions: @@ -121,28 +121,18 @@ class GraphBuilder: retains the operands it is given. """ - - def __init__(self): - ... - - def __dealloc__(self): - ... - + def __init__(self): ... + def __dealloc__(self): ... @staticmethod - def _init(stream: Stream): - ... - + def _init(stream: Stream): ... def close(self): """Destroy the graph builder.""" - @property def stream(self) -> Stream: """Returns the stream associated with the graph builder.""" - @property def is_join_required(self) -> bool: """Returns True if this graph builder must be joined before building is ended.""" - @property def graph_definition(self) -> GraphDefinition: """The captured graph as an explicit :class:`~graph.GraphDefinition`. @@ -189,7 +179,6 @@ class GraphBuilder: keeps working; only fresh access through this property is rejected once the builder is closed. """ - def begin_building(self, mode: str | None='relaxed') -> GraphBuilder: """Begins the building process. @@ -206,14 +195,11 @@ class GraphBuilder: Default set to use relaxed. """ - @property def is_building(self) -> bool: """Returns True if the graph builder is currently building.""" - def end_building(self) -> GraphBuilder: """Ends the building process.""" - def complete(self, options: GraphCompleteOptions | None=None) -> Graph: """Completes the graph builder and returns the built :obj:`~graph.Graph` object. @@ -228,7 +214,6 @@ class GraphBuilder: The newly built graph. """ - def debug_dot_print(self, path: str, options: GraphDebugPrintOptions | None=None) -> None: """Generates a DOT debug file for the graph builder. @@ -240,7 +225,6 @@ class GraphBuilder: Customizable dataclass for the debug print options. """ - def split(self, count: int) -> tuple[GraphBuilder, ...]: """Splits the original graph builder into multiple graph builders. @@ -259,7 +243,6 @@ class GraphBuilder: is always the original graph builder. """ - @staticmethod def join(*graph_builders: GraphBuilder) -> GraphBuilder: """Joins multiple graph builders into a single graph builder. @@ -277,13 +260,9 @@ class GraphBuilder: The newly joined graph builder. """ - def __cuda_stream__(self) -> tuple[int, int]: """Return an instance of a __cuda_stream__ protocol.""" - - def _get_conditional_context(self) -> driver.CUcontext: - ... - + def _get_conditional_context(self) -> driver.CUcontext: ... def create_condition(self, default_value: int | None=None) -> GraphCondition: """Create a condition variable for use with conditional nodes. @@ -303,7 +282,6 @@ class GraphBuilder: GraphCondition A condition variable for controlling conditional execution. """ - def if_then(self, condition: GraphCondition) -> GraphBuilder: """Adds an if condition branch and returns a new graph builder for it. @@ -324,7 +302,6 @@ class GraphBuilder: The newly created conditional graph builder. """ - def if_else(self, condition: GraphCondition) -> tuple[GraphBuilder, GraphBuilder]: """Adds an if-else condition branch and returns new graph builders for both branches. @@ -345,7 +322,6 @@ class GraphBuilder: A tuple of two new graph builders, one for the if branch and one for the else branch. """ - def switch(self, condition: GraphCondition, count: int) -> tuple[GraphBuilder, ...]: """Adds a switch condition branch and returns new graph builders for all cases. @@ -369,7 +345,6 @@ class GraphBuilder: A tuple of new graph builders, one for each branch. """ - def while_loop(self, condition: GraphCondition) -> GraphBuilder: """Adds a while loop and returns a new graph builder for it. @@ -390,7 +365,6 @@ class GraphBuilder: The newly created while loop graph builder. """ - def embed(self, child: GraphBuilder): """Embed a previously-built :obj:`~graph.GraphBuilder` as a child node. @@ -399,7 +373,6 @@ class GraphBuilder: child : :obj:`~graph.GraphBuilder` The child graph builder. Must have finished building. """ - def callback(self, fn, *, user_data=None) -> None: """Add a host callback to the graph during stream capture. @@ -454,13 +427,9 @@ class Graph: Graphs must be built using a :obj:`~graph.GraphBuilder` object. """ - - def __init__(self): - ... - + def __init__(self): ... def close(self) -> None: """Destroy the graph.""" - @property def handle(self) -> driver.CUgraphExec: """Return the underlying ``CUgraphExec`` object. @@ -471,7 +440,6 @@ class Graph: handle, call ``int()`` on the returned object. """ - def __getitem__(self, node: GraphNode) -> ExecutableGraphNode: """Return a view for updating *node* in this executable graph. @@ -480,8 +448,7 @@ class Graph: node's parameters for future launches. Kernel, memcpy, and memset views also support enabling and disabling the node. """ - - def update(self, source: 'GraphBuilder | GraphDefinition') -> None: + def update(self, source: GraphBuilder | GraphDefinition) -> None: """Update the graph using a new graph definition. The topology of the provided source must be identical to this graph. @@ -493,7 +460,6 @@ class Graph: finished building. """ - def upload(self, stream: Stream) -> None: """Uploads the graph in a stream. @@ -503,7 +469,6 @@ class Graph: The stream in which to upload the graph """ - def launch(self, stream: Stream) -> None: """Launches the graph in a stream. @@ -513,10 +478,7 @@ class Graph: The stream in which to launch the graph. """ -__all__ = ['Graph', 'GraphBuilder', 'GraphCompleteOptions', 'GraphDebugPrintOptions'] - -def _instantiate_graph(source, options: GraphCompleteOptions | None=None) -> Graph: - ... +def _instantiate_graph(source, options: GraphCompleteOptions | None=None) -> Graph: ... def _capture_callback_with_tail_failure_for_testing(gb: GraphBuilder, fn, *, user_data=None): - """Exercise anonymous attachment retention after node discovery fails.""" \ No newline at end of file + """Exercise anonymous attachment retention after node discovery fails.""" diff --git a/cuda_core/cuda/core/graph/_graph_definition.pyi b/cuda_core/cuda/core/graph/_graph_definition.pyi index 9780b53b586..dd915e555a4 100644 --- a/cuda_core/cuda/core/graph/_graph_definition.pyi +++ b/cuda_core/cuda/core/graph/_graph_definition.pyi @@ -1,8 +1,6 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/graph/_graph_definition.pyx +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/graph/_graph_definition.pyx """GraphDefinition: explicit CUDA graph definition.""" -from __future__ import annotations - from cuda.core._device import Device from cuda.core._event import Event from cuda.core._launch_config import LaunchConfig @@ -20,6 +18,7 @@ from cuda.core.graph._subclasses import (AllocNode, ChildGraphNode, EmptyNode, WhileNode) from cuda.core.typing import GraphMemoryType +__all__ = ['GraphCondition', 'GraphDefinition'] class GraphCondition: """A condition variable for conditional graph nodes. @@ -36,16 +35,9 @@ class GraphCondition: ``CUgraphConditionalHandle`` value so device code can update the condition. """ - - def __repr__(self) -> str: - ... - - def __eq__(self, other: object) -> bool: - ... - - def __hash__(self) -> int: - ... - + def __repr__(self) -> str: ... + def __eq__(self, other: object) -> bool: ... + def __hash__(self) -> int: ... @property def handle(self) -> driver.CUgraphConditionalHandle: """The raw CUgraphConditionalHandle as an int.""" @@ -63,47 +55,34 @@ class GraphDefinition: share underlying graph state. Mutations anywhere in that hierarchy must be externally synchronized. """ - def __init__(self): """Create a new empty graph definition.""" - - def __repr__(self) -> str: - ... - - def __eq__(self, other: object) -> bool: - ... - - def __hash__(self) -> int: - ... - + def __repr__(self) -> str: ... + def __eq__(self, other: object) -> bool: ... + def __hash__(self) -> int: ... @property def _entry(self) -> GraphNode: """Return the internal entry-point GraphNode (no dependencies).""" - - def allocate(self, size: int, *, device: Device | int | None=None, memory_type: GraphMemoryType=..., peer_access: list[Device | int] | None=None) -> AllocNode: + def allocate(self, size: int, *, device: Device | int | None=None, memory_type: GraphMemoryType=GraphMemoryType.DEVICE, peer_access: list[Device | int] | None=None) -> AllocNode: """Add an entry-point memory allocation node (no dependencies). See :meth:`GraphNode.allocate` for full documentation. """ - def deallocate(self, dptr: int) -> FreeNode: """Add an entry-point memory free node (no dependencies). See :meth:`GraphNode.deallocate` for full documentation. """ - def memset(self, dst: Buffer | int, value, width: int, height: int=1, pitch: int=0, *, dst_owner=None) -> MemsetNode: """Add an entry-point memset node (no dependencies). See :meth:`GraphNode.memset` for full documentation. """ - def launch(self, config: LaunchConfig, kernel: Kernel, *args) -> KernelNode: """Add an entry-point kernel launch node (no dependencies). See :meth:`GraphNode.launch` for full documentation. """ - def empty(self) -> EmptyNode: """Add an entry-point empty node (no dependencies). @@ -112,7 +91,6 @@ class GraphDefinition: EmptyNode A new EmptyNode with no dependencies. """ - def join(self, *nodes: GraphNode) -> EmptyNode: """Create an empty node that depends on all given nodes. @@ -126,37 +104,31 @@ class GraphDefinition: EmptyNode A new EmptyNode that depends on all input nodes. """ - def memcpy(self, dst: Buffer | int, src: Buffer | int, size: int, *, dst_owner=None, src_owner=None) -> MemcpyNode: """Add an entry-point memcpy node (no dependencies). See :meth:`GraphNode.memcpy` for full documentation. """ - def embed(self, child: GraphDefinition) -> ChildGraphNode: """Add an entry-point child graph node (no dependencies). See :meth:`GraphNode.embed` for full documentation. """ - def record(self, event: Event) -> EventRecordNode: """Add an entry-point event record node (no dependencies). See :meth:`GraphNode.record` for full documentation. """ - def wait(self, event: Event) -> EventWaitNode: """Add an entry-point event wait node (no dependencies). See :meth:`GraphNode.wait` for full documentation. """ - def callback(self, fn, *, user_data=None) -> HostCallbackNode: """Add an entry-point host callback node (no dependencies). See :meth:`GraphNode.callback` for full documentation. """ - def create_condition(self, default_value: int | None=None) -> GraphCondition: """Create a condition variable for use with conditional nodes. @@ -175,31 +147,26 @@ class GraphDefinition: GraphCondition A condition variable for controlling conditional execution. """ - def if_then(self, condition: GraphCondition) -> IfNode: """Add an entry-point if-conditional node (no dependencies). See :meth:`GraphNode.if_then` for full documentation. """ - def if_else(self, condition: GraphCondition) -> IfElseNode: """Add an entry-point if-else conditional node (no dependencies). See :meth:`GraphNode.if_else` for full documentation. """ - def while_loop(self, condition: GraphCondition) -> WhileNode: """Add an entry-point while-loop conditional node (no dependencies). See :meth:`GraphNode.while_loop` for full documentation. """ - def switch(self, condition: GraphCondition, count: int) -> SwitchNode: """Add an entry-point switch conditional node (no dependencies). See :meth:`GraphNode.switch` for full documentation. """ - def instantiate(self, options: GraphCompleteOptions | None=None) -> Graph: """Instantiate the graph definition into an executable Graph. @@ -213,7 +180,6 @@ class GraphDefinition: Graph An executable graph that can be launched on a stream. """ - def debug_dot_print(self, path: str, options: GraphDebugPrintOptions | None=None) -> None: """Write a GraphViz DOT representation of the graph to a file. @@ -224,7 +190,6 @@ class GraphDefinition: options : GraphDebugPrintOptions, optional Customizable options for the debug print. """ - def nodes(self) -> set[GraphNode]: """Return all nodes in the graph. @@ -233,7 +198,6 @@ class GraphDefinition: set of GraphNode All nodes in the graph. """ - def edges(self) -> set[tuple[GraphNode, GraphNode]]: """Return all edges in the graph as (from_node, to_node) pairs. @@ -243,8 +207,6 @@ class GraphDefinition: Each element is a (from_node, to_node) pair representing a dependency edge in the graph. """ - @property def handle(self) -> driver.CUgraph: """Return the underlying driver CUgraph handle.""" -__all__ = ['GraphCondition', 'GraphDefinition'] \ No newline at end of file diff --git a/cuda_core/cuda/core/graph/_graph_node.pyi b/cuda_core/cuda/core/graph/_graph_node.pyi index 0e3cac045d2..9c5d9c3a2e0 100644 --- a/cuda_core/cuda/core/graph/_graph_node.pyi +++ b/cuda_core/cuda/core/graph/_graph_node.pyi @@ -1,8 +1,6 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/graph/_graph_node.pyx +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/graph/_graph_node.pyx """GraphNode base class — factory, properties, and builder methods.""" -from __future__ import annotations - import weakref from collections.abc import Iterable @@ -21,6 +19,8 @@ from cuda.core.graph._subclasses import (AllocNode, ChildGraphNode, EmptyNode, SwitchNode, WhileNode) from cuda.core.typing import GraphMemoryType +__all__ = ['GraphNode'] +_node_registry: weakref.WeakValueDictionary[int, GraphNode] = weakref.WeakValueDictionary() class GraphNode: """A node in a graph definition. @@ -29,16 +29,9 @@ class GraphNode: entry-point nodes with no dependencies) or on other Nodes (for nodes that depend on a predecessor). """ - - def __repr__(self) -> str: - ... - - def __eq__(self, other: object) -> bool: - ... - - def __hash__(self) -> int: - ... - + def __repr__(self) -> str: ... + def __eq__(self, other: object) -> bool: ... + def __hash__(self) -> int: ... @property def type(self) -> driver.CUgraphNodeType | None: """Return the CUDA graph node type. @@ -48,25 +41,21 @@ class GraphNode: CUgraphNodeType or None The node type enum value, or None for the entry node. """ - @property def graph(self) -> GraphDefinition: """Return the GraphDefinition this node belongs to.""" - @property def handle(self) -> driver.CUgraphNode: """Return the underlying driver CUgraphNode handle. Returns None for the entry node. """ - @property def is_valid(self) -> bool: """Whether this node is valid (not destroyed). Returns ``False`` after :meth:`destroy` has been called. """ - def destroy(self) -> None: """Destroy this node and remove all its edges from the parent graph. @@ -74,23 +63,16 @@ class GraphNode: cannot be re-added to any graph. Safe to call on an already-destroyed node (no-op). """ - @property def pred(self) -> AdjacencySetProxy: """A mutable set-like view of this node's predecessors.""" - @pred.setter - def pred(self, value: Iterable[GraphNode]) -> None: - ... - + def pred(self, value: Iterable[GraphNode]) -> None: ... @property def succ(self) -> AdjacencySetProxy: """A mutable set-like view of this node's successors.""" - @succ.setter - def succ(self, value: Iterable[GraphNode]) -> None: - ... - + def succ(self, value: Iterable[GraphNode]) -> None: ... def launch(self, config: LaunchConfig, kernel: Kernel, *args) -> KernelNode: """Add a kernel launch node depending on this node. @@ -118,7 +100,6 @@ class GraphNode: KernelNode A new KernelNode representing the kernel launch. """ - def join(self, *nodes: GraphNode) -> EmptyNode: """Create an empty node that depends on this node and all given nodes. @@ -134,8 +115,7 @@ class GraphNode: EmptyNode A new EmptyNode that depends on all input nodes. """ - - def allocate(self, size: int, *, device: Device | int | None=None, memory_type: GraphMemoryType=..., peer_access: list[Device | int] | None=None) -> AllocNode: + def allocate(self, size: int, *, device: Device | int | None=None, memory_type: GraphMemoryType=GraphMemoryType.DEVICE, peer_access: list[Device | int] | None=None) -> AllocNode: """Add a memory allocation node depending on this node. Parameters @@ -174,7 +154,6 @@ class GraphNode: IPC (inter-process communication) is not supported for graph memory allocation nodes per CUDA documentation. """ - def deallocate(self, dptr: int) -> FreeNode: """Add a memory free node depending on this node. @@ -188,7 +167,6 @@ class GraphNode: FreeNode A new FreeNode representing the free operation. """ - def memset(self, dst: Buffer | int, value, width: int, height: int=1, pitch: int=0, *, dst_owner=None) -> MemsetNode: """Add a memset node depending on this node. @@ -230,7 +208,6 @@ class GraphNode: ValueError If ``dst_owner`` is given together with a :class:`Buffer` ``dst``. """ - def memcpy(self, dst: Buffer | int, src: Buffer | int, size: int, *, dst_owner=None, src_owner=None) -> MemcpyNode: """Add a memcpy node depending on this node. @@ -277,7 +254,6 @@ class GraphNode: If ``dst_owner`` or ``src_owner`` is given together with a :class:`Buffer` ``dst`` or ``src`` respectively. """ - def embed(self, child: GraphDefinition) -> ChildGraphNode: """Add a child graph node depending on this node. @@ -295,7 +271,6 @@ class GraphNode: ChildGraphNode A new ChildGraphNode representing the embedded sub-graph. """ - def record(self, event: Event) -> EventRecordNode: """Add an event record node depending on this node. @@ -309,7 +284,6 @@ class GraphNode: EventRecordNode A new EventRecordNode representing the event record operation. """ - def wait(self, event: Event) -> EventWaitNode: """Add an event wait node depending on this node. @@ -323,7 +297,6 @@ class GraphNode: EventWaitNode A new EventWaitNode representing the event wait operation. """ - def callback(self, fn, *, user_data=None) -> object: """Add a host callback node depending on this node. @@ -372,7 +345,6 @@ class GraphNode: ValueError If ``user_data`` is given for a Python callable. """ - def if_then(self, condition: GraphCondition) -> IfNode: """Add an if-conditional node depending on this node. @@ -389,7 +361,6 @@ class GraphNode: IfNode A new IfNode with one branch accessible via ``.then``. """ - def if_else(self, condition: GraphCondition) -> IfElseNode: """Add an if-else conditional node depending on this node. @@ -407,7 +378,6 @@ class GraphNode: A new IfElseNode with branches accessible via ``.then`` and ``.else_``. """ - def while_loop(self, condition: GraphCondition) -> WhileNode: """Add a while-loop conditional node depending on this node. @@ -424,7 +394,6 @@ class GraphNode: WhileNode A new WhileNode with body accessible via ``.body``. """ - def switch(self, condition: GraphCondition, count: int) -> SwitchNode: """Add a switch conditional node depending on this node. @@ -443,5 +412,3 @@ class GraphNode: SwitchNode A new SwitchNode with branches accessible via ``.branches``. """ -__all__ = ['GraphNode'] -_node_registry: weakref.WeakValueDictionary[int, GraphNode] = weakref.WeakValueDictionary() \ No newline at end of file diff --git a/cuda_core/cuda/core/graph/_host_callback.pyi b/cuda_core/cuda/core/graph/_host_callback.pyi index 1c642abf501..60674fcedc2 100644 --- a/cuda_core/cuda/core/graph/_host_callback.pyi +++ b/cuda_core/cuda/core/graph/_host_callback.pyi @@ -1,6 +1,4 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/graph/_host_callback.pyx - -from __future__ import annotations +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/graph/_host_callback.pyx import sys @@ -8,7 +6,6 @@ _CUHOSTFN_HINT = 'ctypes.CFUNCTYPE(None, ctypes.c_void_p)' if sys.platform != 'w def _cuhostfn_type_error(detail): """Build the rejection message for a non-conforming ctypes callback.""" - def _validate_ctypes_host_callback(fn): """Reject ctypes callbacks whose declared prototype is not CUhostFn. @@ -16,4 +13,4 @@ def _validate_ctypes_host_callback(fn): what CUDA calls through. A function pointer taken from a shared library keeps ctypes' defaults -- a ``c_int`` result and unspecified arguments -- until the caller declares otherwise, so it must be declared to be accepted. - """ \ No newline at end of file + """ diff --git a/cuda_core/cuda/core/graph/_subclasses.pyi b/cuda_core/cuda/core/graph/_subclasses.pyi index a68e500f7f2..7a46b2969b8 100644 --- a/cuda_core/cuda/core/graph/_subclasses.pyi +++ b/cuda_core/cuda/core/graph/_subclasses.pyi @@ -1,8 +1,6 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/graph/_subclasses.pyx +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/graph/_subclasses.pyx """GraphNode subclasses — EmptyNode through SwitchNode.""" -from __future__ import annotations - from cuda.core._event import Event from cuda.core._launch_config import LaunchConfig from cuda.core._memory._buffer import Buffer @@ -11,12 +9,11 @@ from cuda.core.graph._graph_definition import GraphCondition, GraphDefinition from cuda.core.graph._graph_node import GraphNode from cuda.core.typing import GraphConditionalType +__all__ = ['AllocNode', 'ChildGraphNode', 'ConditionalNode', 'EmptyNode', 'EventRecordNode', 'EventWaitNode', 'ExecutableChildGraphNode', 'ExecutableEventRecordNode', 'ExecutableEventWaitNode', 'ExecutableGraphNode', 'ExecutableHostCallbackNode', 'ExecutableKernelNode', 'ExecutableMemcpyNode', 'ExecutableMemsetNode', 'FreeNode', 'HostCallbackNode', 'IfElseNode', 'IfNode', 'KernelNode', 'MemcpyNode', 'MemsetNode', 'SwitchNode', 'WhileNode'] class EmptyNode(GraphNode): """An empty (synchronization) node.""" - - def __repr__(self) -> str: - ... + def __repr__(self) -> str: ... class KernelNode(GraphNode): """A kernel launch node. @@ -34,10 +31,7 @@ class KernelNode(GraphNode): config : LaunchConfig A LaunchConfig reconstructed from this node's parameters. """ - - def __repr__(self) -> str: - ... - + def __repr__(self) -> str: ... def update(self, *, config: LaunchConfig | None=None, kernel: Kernel | None=None, args=None) -> None: """Replace selected kernel launch parameters. @@ -52,23 +46,18 @@ class KernelNode(GraphNode): graph that retains it cannot be broken by Python's cyclic garbage collector. Use a weak reference to break such cycles. """ - @property def grid(self) -> tuple[int, int, int]: """Grid dimensions as a 3-tuple (gridDimX, gridDimY, gridDimZ).""" - @property def block(self) -> tuple[int, int, int]: """Block dimensions as a 3-tuple (blockDimX, blockDimY, blockDimZ).""" - @property def shmem_size(self) -> int: """Dynamic shared memory size in bytes.""" - @property def kernel(self) -> Kernel: """The Kernel object for this launch node.""" - @property def config(self) -> LaunchConfig: """A LaunchConfig reconstructed from this node's grid, block, and shmem_size. @@ -93,26 +82,19 @@ class AllocNode(GraphNode): peer_access : tuple of int Device IDs that have read-write access to this allocation. """ - - def __repr__(self) -> str: - ... - + def __repr__(self) -> str: ... @property def dptr(self) -> int: """The device pointer for the allocation.""" - @property def bytesize(self) -> int: """The number of bytes allocated.""" - @property def device_id(self) -> int: """The device on which the allocation was made.""" - @property def memory_type(self) -> str: """The type of memory: ``"device"``, ``"host"``, or ``"managed"``.""" - @property def peer_access(self) -> tuple[int, ...]: """Device IDs with read-write access to this allocation.""" @@ -125,10 +107,7 @@ class FreeNode(GraphNode): dptr : int The device pointer being freed. """ - - def __repr__(self) -> str: - ... - + def __repr__(self) -> str: ... @property def dptr(self) -> int: """The device pointer being freed.""" @@ -151,10 +130,7 @@ class MemsetNode(GraphNode): pitch : int Pitch in bytes (unused if height is 1). """ - - def __repr__(self) -> str: - ... - + def __repr__(self) -> str: ... def update(self, *, dst: Buffer | int | None=None, value=None, width: int | None=None, height: int | None=None, pitch: int | None=None, dst_owner=None) -> None: """Replace selected memset parameters. @@ -172,27 +148,21 @@ class MemsetNode(GraphNode): that retains it cannot be broken by Python's cyclic garbage collector. Use a weak reference to break such cycles. """ - @property def dptr(self) -> int: """The destination device pointer.""" - @property def value(self) -> int: """The fill value.""" - @property def element_size(self) -> int: """Element size in bytes (1, 2, or 4).""" - @property def width(self) -> int: """Width of the row in elements.""" - @property def height(self) -> int: """Number of rows.""" - @property def pitch(self) -> int: """Pitch in bytes (unused if height is 1).""" @@ -209,10 +179,7 @@ class MemcpyNode(GraphNode): size : int The number of bytes copied. """ - - def __repr__(self) -> str: - ... - + def __repr__(self) -> str: ... def update(self, *, dst: Buffer | int | None=None, src: Buffer | int | None=None, size: int | None=None, dst_owner=None, src_owner=None) -> None: """Replace selected memcpy parameters. @@ -232,15 +199,12 @@ class MemcpyNode(GraphNode): that retains it cannot be broken by Python's cyclic garbage collector. Use a weak reference to break such cycles. """ - @property def dst(self) -> int: """The destination pointer.""" - @property def src(self) -> int: """The source pointer.""" - @property def size(self) -> int: """The number of bytes copied.""" @@ -253,16 +217,12 @@ class ChildGraphNode(GraphNode): child_graph : GraphDefinition The embedded graph definition (non-owning wrapper). """ - - def __repr__(self) -> str: - ... - + def __repr__(self) -> str: ... def update(self, child: GraphDefinition) -> None: """Replace the embedded graph with a clone of ``child``. ``child`` must belong to an independent graph hierarchy. """ - @property def child_graph(self) -> GraphDefinition: """The embedded graph definition (non-owning wrapper).""" @@ -275,13 +235,9 @@ class EventRecordNode(GraphNode): event : Event The event being recorded. """ - - def __repr__(self) -> str: - ... - + def __repr__(self) -> str: ... def update(self, event: Event) -> None: """Replace the event recorded by this node.""" - @property def event(self) -> Event: """The event being recorded.""" @@ -294,13 +250,9 @@ class EventWaitNode(GraphNode): event : Event The event being waited on. """ - - def __repr__(self) -> str: - ... - + def __repr__(self) -> str: ... def update(self, event: Event) -> None: """Replace the event waited on by this node.""" - @property def event(self) -> Event: """The event being waited on.""" @@ -313,10 +265,7 @@ class HostCallbackNode(GraphNode): callback : callable or None The Python callable (None for ctypes function pointer callbacks). """ - - def __repr__(self) -> str: - ... - + def __repr__(self) -> str: ... def update(self, fn, *, user_data=None) -> None: """Replace the callback and user-data binding for this node. @@ -335,7 +284,6 @@ class HostCallbackNode(GraphNode): retains it cannot be broken by Python's cyclic garbage collector. Use a weak reference to break such cycles. """ - @property def callback(self): """The Python callable, or None for ctypes function pointer callbacks.""" @@ -358,14 +306,10 @@ class ConditionalNode(GraphNode): branches : tuple of GraphDefinition The body graphs for each branch (empty pre-13.2). """ - - def __repr__(self) -> str: - ... - + def __repr__(self) -> str: ... @property def condition(self) -> GraphCondition | None: """The condition variable controlling execution.""" - @property def cond_type(self) -> GraphConditionalType | None: """The conditional type: GraphConditionalType.IF, .WHILE, or .SWITCH @@ -373,7 +317,6 @@ class ConditionalNode(GraphNode): Returns None when reconstructed from the driver pre-CUDA 13.2, as the conditional type cannot be determined. """ - @property def branches(self) -> tuple[GraphDefinition, ...]: """The body graphs for each branch as a tuple of GraphDefinition. @@ -384,43 +327,31 @@ class ConditionalNode(GraphNode): class IfNode(ConditionalNode): """An if-conditional node.""" - - def __repr__(self) -> str: - ... - + def __repr__(self) -> str: ... @property def then(self) -> GraphDefinition: """The 'then' branch graph.""" class IfElseNode(ConditionalNode): """An if-else conditional node.""" - - def __repr__(self) -> str: - ... - + def __repr__(self) -> str: ... @property def then(self) -> GraphDefinition: """The ``then`` branch graph (executed when condition is non-zero).""" - @property def else_(self) -> GraphDefinition: """The ``else`` branch graph (executed when condition is zero).""" class WhileNode(ConditionalNode): """A while-loop conditional node.""" - - def __repr__(self) -> str: - ... - + def __repr__(self) -> str: ... @property def body(self) -> GraphDefinition: """The loop body graph.""" class SwitchNode(ConditionalNode): """A switch conditional node.""" - - def __repr__(self) -> str: - ... + def __repr__(self) -> str: ... class ExecutableGraphNode: """A lightweight view pairing an executable graph with a source node. @@ -429,16 +360,11 @@ class ExecutableGraphNode: node identifies a node in the executable graph when an operation is performed. """ - - def __init__(self): - ... - - def __repr__(self) -> str: - ... + def __init__(self): ... + def __repr__(self) -> str: ... class ExecutableKernelNode(ExecutableGraphNode): """An executable kernel-node view.""" - def update(self, *, config: LaunchConfig, kernel: Kernel, args) -> None: """Replace all kernel launch parameters for future launches. @@ -446,70 +372,55 @@ class ExecutableKernelNode(ExecutableGraphNode): for a no-argument kernel. Clustered and cooperative launch configurations are not supported. """ - @property def is_enabled(self) -> bool: """Whether this node is enabled in the executable graph.""" - def enable(self) -> None: """Enable this node in the executable graph.""" - def disable(self) -> None: """Disable this node in the executable graph.""" class ExecutableMemsetNode(ExecutableGraphNode): """An executable memset-node view.""" - def update(self, *, dst: Buffer | int, value, width: int, height: int=1, pitch: int=0) -> None: """Replace all memset parameters for future launches.""" - @property def is_enabled(self) -> bool: """Whether this node is enabled in the executable graph.""" - def enable(self) -> None: """Enable this node in the executable graph.""" - def disable(self) -> None: """Disable this node in the executable graph.""" class ExecutableMemcpyNode(ExecutableGraphNode): """An executable memcpy-node view.""" - def update(self, *, dst: Buffer | int, src: Buffer | int, size: int) -> None: """Replace all one-dimensional memcpy parameters for future launches.""" - @property def is_enabled(self) -> bool: """Whether this node is enabled in the executable graph.""" - def enable(self) -> None: """Enable this node in the executable graph.""" - def disable(self) -> None: """Disable this node in the executable graph.""" class ExecutableChildGraphNode(ExecutableGraphNode): """An executable child-graph-node view.""" - def update(self, child: GraphDefinition) -> None: """Replace the embedded graph parameters for future launches.""" class ExecutableEventRecordNode(ExecutableGraphNode): """An executable event-record-node view.""" - def update(self, event: Event) -> None: """Replace the event recorded by future launches.""" class ExecutableEventWaitNode(ExecutableGraphNode): """An executable event-wait-node view.""" - def update(self, event: Event) -> None: """Replace the event waited on by future launches.""" class ExecutableHostCallbackNode(ExecutableGraphNode): """An executable host-callback-node view.""" - def update(self, fn, *, user_data=None) -> None: """Replace the callback and user-data binding for future launches. @@ -522,4 +433,3 @@ class ExecutableHostCallbackNode(ExecutableGraphNode): Callbacks must not call CUDA API functions. Doing so may deadlock or corrupt driver state. """ -__all__ = ['AllocNode', 'ChildGraphNode', 'ConditionalNode', 'EmptyNode', 'EventRecordNode', 'EventWaitNode', 'ExecutableChildGraphNode', 'ExecutableEventRecordNode', 'ExecutableEventWaitNode', 'ExecutableGraphNode', 'ExecutableHostCallbackNode', 'ExecutableKernelNode', 'ExecutableMemcpyNode', 'ExecutableMemsetNode', 'FreeNode', 'HostCallbackNode', 'IfElseNode', 'IfNode', 'KernelNode', 'MemcpyNode', 'MemsetNode', 'SwitchNode', 'WhileNode'] \ No newline at end of file diff --git a/cuda_core/cuda/core/system/_device.pyi b/cuda_core/cuda/core/system/_device.pyi index c758576f0ac..b2faecc5bb1 100644 --- a/cuda_core/cuda/core/system/_device.pyi +++ b/cuda_core/cuda/core/system/_device.pyi @@ -1,8 +1,6 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/system/_device.pyx +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/system/_device.pyx -from __future__ import annotations - -from typing import Iterable +from typing import Iterable, TypedDict import cuda.core from cuda.bindings import nvml @@ -15,27 +13,57 @@ from cuda.core.system.typing import (AddressingMode, AffinityScope, ClockId, TemperatureThresholds, ThermalController, ThermalTarget) +_CLOCK_ID_MAPPING = {ClockId.CURRENT: nvml.ClockId.CURRENT, ClockId.CUSTOMER_BOOST_MAX: nvml.ClockId.CUSTOMER_BOOST_MAX} +_CLOCKS_EVENT_REASONS_MAPPING = {nvml.ClocksEventReasons.EVENT_REASON_NONE: ClocksEventReasons.NONE, nvml.ClocksEventReasons.EVENT_REASON_GPU_IDLE: ClocksEventReasons.GPU_IDLE, nvml.ClocksEventReasons.EVENT_REASON_APPLICATIONS_CLOCKS_SETTING: ClocksEventReasons.APPLICATIONS_CLOCKS_SETTING, nvml.ClocksEventReasons.EVENT_REASON_SW_POWER_CAP: ClocksEventReasons.SW_POWER_CAP, nvml.ClocksEventReasons.THROTTLE_REASON_HW_SLOWDOWN: ClocksEventReasons.HW_SLOWDOWN, nvml.ClocksEventReasons.EVENT_REASON_SYNC_BOOST: ClocksEventReasons.SYNC_BOOST, nvml.ClocksEventReasons.EVENT_REASON_SW_THERMAL_SLOWDOWN: ClocksEventReasons.SW_THERMAL_SLOWDOWN, nvml.ClocksEventReasons.THROTTLE_REASON_HW_THERMAL_SLOWDOWN: ClocksEventReasons.HW_THERMAL_SLOWDOWN, nvml.ClocksEventReasons.THROTTLE_REASON_HW_POWER_BRAKE_SLOWDOWN: ClocksEventReasons.HW_POWER_BRAKE_SLOWDOWN, nvml.ClocksEventReasons.EVENT_REASON_DISPLAY_CLOCK_SETTING: ClocksEventReasons.DISPLAY_CLOCK_SETTING} +_CLOCK_TYPE_MAPPING = {ClockType.GRAPHICS: nvml.ClockType.CLOCK_GRAPHICS, ClockType.SM: nvml.ClockType.CLOCK_SM, ClockType.MEMORY: nvml.ClockType.CLOCK_MEM, ClockType.VIDEO: nvml.ClockType.CLOCK_VIDEO} +_COOLER_CONTROL_MAPPING = {nvml.CoolerControl.THERMAL_COOLER_SIGNAL_TOGGLE: CoolerControl.TOGGLE, nvml.CoolerControl.THERMAL_COOLER_SIGNAL_VARIABLE: CoolerControl.VARIABLE} +_COOLER_TARGET_MAPPING = {nvml.CoolerTarget.THERMAL_NONE: CoolerTarget.NONE, nvml.CoolerTarget.THERMAL_GPU: CoolerTarget.GPU, nvml.CoolerTarget.THERMAL_MEMORY: CoolerTarget.MEMORY, nvml.CoolerTarget.THERMAL_POWER_SUPPLY: CoolerTarget.POWER_SUPPLY} +_EVENT_TYPE_MAPPING = {nvml.EventType.NONE: EventType.NONE, nvml.EventType.SINGLE_BIT_ECC_ERROR: EventType.SINGLE_BIT_ECC_ERROR, nvml.EventType.DOUBLE_BIT_ECC_ERROR: EventType.DOUBLE_BIT_ECC_ERROR, nvml.EventType.PSTATE: EventType.PSTATE, nvml.EventType.XID_CRITICAL_ERROR: EventType.XID_CRITICAL_ERROR, nvml.EventType.CLOCK: EventType.CLOCK, nvml.EventType.POWER_SOURCE_CHANGE: EventType.POWER_SOURCE_CHANGE, nvml.EventType.MIG_CONFIG_CHANGE: EventType.MIG_CONFIG_CHANGE, nvml.EventType.SINGLE_BIT_ECC_ERROR_STORM: EventType.SINGLE_BIT_ECC_ERROR_STORM, nvml.EventType.DRAM_RETIREMENT_EVENT: EventType.DRAM_RETIREMENT_EVENT, nvml.EventType.DRAM_RETIREMENT_FAILURE: EventType.DRAM_RETIREMENT_FAILURE, nvml.EventType.NON_FATAL_POISON_ERROR: EventType.NON_FATAL_POISON_ERROR, nvml.EventType.FATAL_POISON_ERROR: EventType.FATAL_POISON_ERROR, nvml.EventType.GPU_UNAVAILABLE_ERROR: EventType.GPU_UNAVAILABLE_ERROR, nvml.EventType.GPU_RECOVERY_ACTION: EventType.GPU_RECOVERY_ACTION} +_EVENT_TYPE_INV_MAPPING = ... +_FAN_CONTROL_POLICY_MAPPING = {nvml.FanControlPolicy.TEMPERATURE_CONTINUOUS_SW: FanControlPolicy.TEMPERATURE_CONTROLLED, nvml.FanControlPolicy.MANUAL: FanControlPolicy.MANUAL} +_INFOROM_OBJECT_MAPPING = {InforomObject.OEM: nvml.InforomObject.INFOROM_OEM, InforomObject.ECC: nvml.InforomObject.INFOROM_ECC, InforomObject.POWER: nvml.InforomObject.INFOROM_POWER, InforomObject.DEN: nvml.InforomObject.INFOROM_DEN} +_NVLINK_VERSION_MAPPING = {nvml.NvlinkVersion.VERSION_1_0: (1, 0), nvml.NvlinkVersion.VERSION_2_0: (2, 0), nvml.NvlinkVersion.VERSION_2_2: (2, 2), nvml.NvlinkVersion.VERSION_3_0: (3, 0), nvml.NvlinkVersion.VERSION_3_1: (3, 1), nvml.NvlinkVersion.VERSION_4_0: (4, 0), nvml.NvlinkVersion.VERSION_5_0: (5, 0)} +_TEMPERATURE_THRESHOLD_MAPPING = {TemperatureThresholds.SHUTDOWN: nvml.TemperatureThresholds.TEMPERATURE_THRESHOLD_SHUTDOWN, TemperatureThresholds.SLOWDOWN: nvml.TemperatureThresholds.TEMPERATURE_THRESHOLD_SLOWDOWN, TemperatureThresholds.MEM_MAX: nvml.TemperatureThresholds.TEMPERATURE_THRESHOLD_MEM_MAX, TemperatureThresholds.GPU_MAX: nvml.TemperatureThresholds.TEMPERATURE_THRESHOLD_GPU_MAX, TemperatureThresholds.ACOUSTIC_MIN: nvml.TemperatureThresholds.TEMPERATURE_THRESHOLD_ACOUSTIC_MIN, TemperatureThresholds.ACOUSTIC_CURR: nvml.TemperatureThresholds.TEMPERATURE_THRESHOLD_ACOUSTIC_CURR, TemperatureThresholds.ACOUSTIC_MAX: nvml.TemperatureThresholds.TEMPERATURE_THRESHOLD_ACOUSTIC_MAX, TemperatureThresholds.GPS_CURR: nvml.TemperatureThresholds.TEMPERATURE_THRESHOLD_GPS_CURR} +_THERMAL_CONTROLLER_MAPPING = {nvml.ThermalController.GPU_INTERNAL: ThermalController.GPU_INTERNAL, nvml.ThermalController.ADM1032: ThermalController.ADM1032, nvml.ThermalController.ADT7461: ThermalController.ADT7461, nvml.ThermalController.MAX6649: ThermalController.MAX6649, nvml.ThermalController.MAX1617: ThermalController.MAX1617, nvml.ThermalController.LM99: ThermalController.LM99, nvml.ThermalController.LM89: ThermalController.LM89, nvml.ThermalController.LM64: ThermalController.LM64, nvml.ThermalController.G781: ThermalController.G781, nvml.ThermalController.ADT7473: ThermalController.ADT7473, nvml.ThermalController.SBMAX6649: ThermalController.SBMAX6649, nvml.ThermalController.VBIOSEVT: ThermalController.VBIOSEVT, nvml.ThermalController.OS: ThermalController.OS, nvml.ThermalController.NVSYSCON_CANOAS: ThermalController.NVSYSCON_CANOAS, nvml.ThermalController.NVSYSCON_E551: ThermalController.NVSYSCON_E551, nvml.ThermalController.MAX6649R: ThermalController.MAX6649R, nvml.ThermalController.ADT7473S: ThermalController.ADT7473S, nvml.ThermalController.UNKNOWN: ThermalController.UNKNOWN} +_THERMAL_TARGET_MAPPING = {nvml.ThermalTarget.NONE: ThermalTarget.NONE, nvml.ThermalTarget.GPU: ThermalTarget.GPU, nvml.ThermalTarget.MEMORY: ThermalTarget.MEMORY, nvml.ThermalTarget.POWER_SUPPLY: ThermalTarget.POWER_SUPPLY, nvml.ThermalTarget.BOARD: ThermalTarget.BOARD, nvml.ThermalTarget.VCD_BOARD: ThermalTarget.VCD_BOARD, nvml.ThermalTarget.VCD_INLET: ThermalTarget.VCD_INLET, nvml.ThermalTarget.VCD_OUTLET: ThermalTarget.VCD_OUTLET, nvml.ThermalTarget.ALL: ThermalTarget.ALL} +_THERMAL_TARGET_INV_MAPPING = ... +_ADDRESSING_MODE_MAPPING = {nvml.DeviceAddressingModeType.DEVICE_ADDRESSING_MODE_HMM: AddressingMode.HMM, nvml.DeviceAddressingModeType.DEVICE_ADDRESSING_MODE_ATS: AddressingMode.ATS} +_AFFINITY_SCOPE_MAPPING = {AffinityScope.NODE: nvml.AffinityScope.NODE, AffinityScope.SOCKET: nvml.AffinityScope.SOCKET} +_BRAND_TYPE_MAPPING = {nvml.BrandType.BRAND_UNKNOWN: 'Unknown', nvml.BrandType.BRAND_QUADRO: 'Quadro', nvml.BrandType.BRAND_TESLA: 'Tesla', nvml.BrandType.BRAND_NVS: 'NVS', nvml.BrandType.BRAND_GRID: 'GRID', nvml.BrandType.BRAND_GEFORCE: 'GeForce', nvml.BrandType.BRAND_TITAN: 'Titan', nvml.BrandType.BRAND_NVIDIA_VAPPS: 'NVIDIA vApps', nvml.BrandType.BRAND_NVIDIA_VPC: 'NVIDIA VPC', nvml.BrandType.BRAND_NVIDIA_VCS: 'NVIDIA VCS', nvml.BrandType.BRAND_NVIDIA_VWS: 'NVIDIA VWS', nvml.BrandType.BRAND_NVIDIA_CLOUD_GAMING: 'NVIDIA Cloud Gaming', nvml.BrandType.BRAND_NVIDIA_VGAMING: 'NVIDIA vGaming', nvml.BrandType.BRAND_QUADRO_RTX: 'Quadro RTX', nvml.BrandType.BRAND_NVIDIA_RTX: 'NVIDIA RTX', nvml.BrandType.BRAND_NVIDIA: 'NVIDIA', nvml.BrandType.BRAND_GEFORCE_RTX: 'GeForce RTX', nvml.BrandType.BRAND_TITAN_RTX: 'Titan RTX'} +_GPU_P2P_CAPS_INDEX_MAPPING = {GpuP2PCapsIndex.READ: nvml.GpuP2PCapsIndex.P2P_CAPS_INDEX_READ, GpuP2PCapsIndex.WRITE: nvml.GpuP2PCapsIndex.P2P_CAPS_INDEX_WRITE, GpuP2PCapsIndex.NVLINK: nvml.GpuP2PCapsIndex.P2P_CAPS_INDEX_NVLINK, GpuP2PCapsIndex.ATOMICS: nvml.GpuP2PCapsIndex.P2P_CAPS_INDEX_ATOMICS, GpuP2PCapsIndex.PCI: nvml.GpuP2PCapsIndex.P2P_CAPS_INDEX_PCI, GpuP2PCapsIndex.PROP: nvml.GpuP2PCapsIndex.P2P_CAPS_INDEX_PROP, GpuP2PCapsIndex.UNKNOWN: nvml.GpuP2PCapsIndex.P2P_CAPS_INDEX_UNKNOWN} +_GPU_P2P_STATUS_MAPPING = {nvml.GpuP2PStatus.P2P_STATUS_OK: GpuP2PStatus.OK, nvml.GpuP2PStatus.P2P_STATUS_CHIPSET_NOT_SUPPORTED: GpuP2PStatus.CHIPSET_NOT_SUPPORTED, nvml.GpuP2PStatus.P2P_STATUS_GPU_NOT_SUPPORTED: GpuP2PStatus.GPU_NOT_SUPPORTED, nvml.GpuP2PStatus.P2P_STATUS_IOH_TOPOLOGY_NOT_SUPPORTED: GpuP2PStatus.IOH_TOPOLOGY_NOT_SUPPORTED, nvml.GpuP2PStatus.P2P_STATUS_DISABLED_BY_REGKEY: GpuP2PStatus.DISABLED_BY_REGKEY, nvml.GpuP2PStatus.P2P_STATUS_NOT_SUPPORTED: GpuP2PStatus.NOT_SUPPORTED, nvml.GpuP2PStatus.P2P_STATUS_UNKNOWN: GpuP2PStatus.UNKNOWN} +_GPU_TOPOLOGY_LEVEL_MAPPING = {GpuTopologyLevel.INTERNAL: nvml.GpuTopologyLevel.TOPOLOGY_INTERNAL, GpuTopologyLevel.SINGLE: nvml.GpuTopologyLevel.TOPOLOGY_SINGLE, GpuTopologyLevel.MULTIPLE: nvml.GpuTopologyLevel.TOPOLOGY_MULTIPLE, GpuTopologyLevel.HOSTBRIDGE: nvml.GpuTopologyLevel.TOPOLOGY_HOSTBRIDGE, GpuTopologyLevel.NODE: nvml.GpuTopologyLevel.TOPOLOGY_NODE, GpuTopologyLevel.SYSTEM: nvml.GpuTopologyLevel.TOPOLOGY_SYSTEM} +_GPU_TOPOLOGY_LEVEL_INV_MAPPING = ... +__all__ = ['Device', 'get_p2p_status', 'get_topology_common_ancestor', 'NvlinkInfo'] + +class _GpuDynamicPstatesUtilization(TypedDict): + bIsPresent: int + percentage: int + incThreshold: int + decThreshold: int + +class _ThermalSensor(TypedDict): + controller: int + defaultMinTemp: int + defaultMaxTemp: int + currentTemp: int + target: int class ClockOffsets: """ Contains clock offset information. """ - - def __init__(self, clock_offset: nvml.ClockOffset): - ... - + def __init__(self, clock_offset: nvml.ClockOffset): ... @property def clock_offset_mhz(self) -> int: """ The current clock offset in MHz. """ - @property def max_offset_mhz(self) -> int: """ The maximum clock offset in MHz. """ - @property def min_offset_mhz(self) -> int: """ @@ -46,11 +74,8 @@ class ClockInfo: """ Accesses various clock information about a device. """ - - def __init__(self, handle: int, clock_type: ClockType | str): - ... - - def get_current_mhz(self, clock_id: ClockId | str=...) -> int: + def __init__(self, handle: int, clock_type: ClockType | str): ... + def get_current_mhz(self, clock_id: ClockId | str=ClockId.CURRENT) -> int: """ Get the current clock speed of a specific clock domain, in MHz. @@ -66,7 +91,6 @@ class ClockInfo: int The clock speed in MHz. """ - def get_max_mhz(self) -> int: """ Get the maximum clock speed of a specific clock domain, in MHz. @@ -81,7 +105,6 @@ class ClockInfo: int The maximum clock speed in MHz. """ - def get_max_customer_boost_mhz(self) -> int: """ Get the maximum customer boost clock speed of a specific clock, in MHz. @@ -93,7 +116,6 @@ class ClockInfo: int The maximum customer boost clock speed in MHz. """ - def get_min_max_clock_of_pstate_mhz(self, pstate: int) -> tuple[int, int]: """ Get the minimum and maximum clock speeds for this clock domain @@ -111,7 +133,6 @@ class ClockInfo: tuple[int, int] A tuple containing the minimum and maximum clock speeds in MHz. """ - def get_offsets(self, pstate: int) -> ClockOffsets: """ Retrieve min, max and current clock offset of some clock domain for a given Pstate. @@ -132,10 +153,7 @@ class ClockInfo: """ class CoolerInfo: - - def __init__(self, cooler_info: nvml.CoolerInfo): - ... - + def __init__(self, cooler_info: nvml.CoolerInfo): ... @property def signal_type(self) -> CoolerControl | None: """ @@ -143,7 +161,6 @@ class CoolerInfo: The possible types are variable and toggle. """ - @property def target(self) -> list[CoolerTarget]: """ @@ -157,58 +174,47 @@ class DeviceAttributes: """ Various device attributes. """ - - def __init__(self, attributes: nvml.DeviceAttributes): - ... - + def __init__(self, attributes: nvml.DeviceAttributes): ... @property def multiprocessor_count(self) -> int: """ The streaming multiprocessor count """ - @property def shared_copy_engine_count(self) -> int: """ The shared copy engine count """ - @property def shared_decoder_count(self) -> int: """ The shared decoder engine count """ - @property def shared_encoder_count(self) -> int: """ The shared encoder engine count """ - @property def shared_jpeg_count(self) -> int: """ The shared JPEG engine count """ - @property def shared_ofa_count(self) -> int: """ The shared optical flow accelerator (OFA) engine count """ - @property def gpu_instance_slice_count(self) -> int: """ The GPU instance slice count """ - @property def compute_instance_slice_count(self) -> int: """ The compute instance slice count """ - @property def memory_size_mb(self) -> int: """ @@ -219,22 +225,17 @@ class EventData: """ Data about a single event. """ - - def __init__(self, event_data: nvml.EventData): - ... - + def __init__(self, event_data: nvml.EventData): ... @property def device(self) -> Device: """ The device on which the event occurred. """ - @property def event_type(self) -> EventType: """ The type of event that was triggered. """ - @property def event_data(self) -> int: """ @@ -243,7 +244,6 @@ class EventData: Raises :class:`ValueError` for other event types. """ - @property def gpu_instance_id(self) -> int: """ @@ -253,7 +253,6 @@ class EventData: Raises :class:`ValueError` for other event types. """ - @property def compute_instance_id(self) -> int: """ @@ -268,13 +267,8 @@ class DeviceEvents: """ Represents a set of events that can be waited on for a specific device. """ - - def __init__(self, device_handle: int, events: EventType | str | list[EventType | str]): - ... - - def __dealloc__(self) -> None: - ... - + def __init__(self, device_handle: int, events: EventType | str | list[EventType | str]): ... + def __dealloc__(self) -> None: ... def wait(self, timeout_ms: int=0) -> EventData: """ Wait for events in the event set. @@ -322,10 +316,7 @@ class FanInfo: """ Manages information related to a specific fan on a specific device. """ - - def __init__(self, handle: int, fan: int): - ... - + def __init__(self, handle: int, fan: int): ... @property def speed(self) -> int: """ @@ -340,11 +331,8 @@ class FanInfo: The fan speed is expressed as a percentage of the product's maximum noise tolerance fan speed. This value may exceed 100% in certain cases. """ - @speed.setter - def speed(self, speed: int) -> None: - ... - + def speed(self, speed: int) -> None: ... @property def speed_rpm(self) -> int: """ @@ -359,7 +347,6 @@ class FanInfo: physically blocked and unable to spin, the output will not match the actual fan speed. """ - @property def target_speed(self) -> int: """ @@ -375,7 +362,6 @@ class FanInfo: The fan speed is expressed as a percentage of the product's maximum noise tolerance fan speed. This value may exceed 100% in certain cases. """ - @property def min_max_speed(self) -> tuple[int, int]: """ @@ -388,7 +374,6 @@ class FanInfo: tuple[int, int] A tuple of (min_speed, max_speed) """ - @property def control_policy(self) -> FanControlPolicy: """ @@ -398,7 +383,6 @@ class FanInfo: For all CUDA-capable discrete products with fans. """ - def set_default_speed(self) -> None: """ Set the speed of the fan control policy to default. @@ -412,29 +396,23 @@ class FieldValue: Use :meth:`Device.get_field_values` to get multiple field values at once. """ - - def __init__(self, field_value: nvml.FieldValue): - ... - + def __init__(self, field_value: nvml.FieldValue): ... @property def field_id(self) -> FieldId: """ The field ID. """ - @property def scope_id(self) -> int: """ The scope ID. """ - @property def timestamp(self) -> int: """ The CPU timestamp (in microseconds since 1970) at which the value was sampled. """ - @property def latency_usec(self) -> int: """ @@ -442,7 +420,6 @@ class FieldValue: be averaged across several fields that are serviced by the same driver call. """ - @property def value(self) -> int | float: """ @@ -458,16 +435,9 @@ class FieldValues: """ Container of multiple field values. """ - - def __init__(self, field_values: nvml.FieldValue): - ... - - def __getitem__(self, idx: int) -> FieldValue: - ... - - def __len__(self) -> int: - ... - + def __init__(self, field_values: nvml.FieldValue): ... + def __getitem__(self, idx: int) -> FieldValue: ... + def __len__(self) -> int: ... def validate(self) -> None: """ Validate that there are no issues in any of the contained field values. @@ -479,7 +449,6 @@ class FieldValues: :class:`cuda.core.system.NvmlError` If any of the contained field values has an associated exception. """ - def get_all_values(self) -> list[int | float]: """ Get all field values as a list. @@ -499,10 +468,7 @@ class FieldValues: """ class InforomInfo: - - def __init__(self, device: Device): - ... - + def __init__(self, device: Device): ... def get_version(self, inforom: InforomObject | str) -> str: """ Retrieves the InfoROM version for a given InfoROM object. @@ -522,7 +488,6 @@ class InforomInfo: str The InfoROM version. """ - @property def image_version(self) -> str: """ @@ -539,7 +504,6 @@ class InforomInfo: str The InfoROM image version. """ - @property def configuration_checksum(self) -> int: """ @@ -557,7 +521,6 @@ class InforomInfo: int The InfoROM checksum. """ - def validate(self) -> None: """ Reads the InfoROM from the flash and verifies the checksums. @@ -569,7 +532,6 @@ class InforomInfo: :class:`cuda.core.system.CorruptedInforomError` If the device's InfoROM is corrupted. """ - @property def bbx_flush_time(self) -> tuple[int, int]: """ @@ -584,7 +546,6 @@ class InforomInfo: - timestamp: The start timestamp of the last BBX flush - duration_us: The duration (in μs) of the last BBX flush """ - @property def board_part_number(self) -> str: """ @@ -595,28 +556,22 @@ class MemoryInfo: """ Memory allocation information for a device. """ - - def __init__(self, memory_info: nvml.Memory_v2): - ... - + def __init__(self, memory_info: nvml.Memory_v2): ... @property def free(self) -> int: """ Unallocated device memory (in bytes) """ - @property def total(self) -> int: """ Total physical device memory (in bytes) """ - @property def used(self) -> int: """ Allocated device memory (in bytes) """ - @property def reserved(self) -> int: """ @@ -627,22 +582,17 @@ class BAR1MemoryInfo(MemoryInfo): """ BAR1 Memory allocation information for a device. """ - - def __init__(self, memory_info: nvml.BAR1Memory): - ... - + def __init__(self, memory_info: nvml.BAR1Memory): ... @property def free(self) -> int: """ Unallocated BAR1 memory (in bytes) """ - @property def total(self) -> int: """ Total BAR1 memory (in bytes) """ - @property def used(self) -> int: """ @@ -650,10 +600,7 @@ class BAR1MemoryInfo(MemoryInfo): """ class MigInfo: - - def __init__(self, device: Device): - ... - + def __init__(self, device: Device): ... @property def is_mig_device(self) -> bool: """ @@ -666,7 +613,6 @@ class MigInfo: For Ampere™ or newer fully supported devices. """ - @property def mode(self) -> bool: """ @@ -682,7 +628,6 @@ class MigInfo: bool `True` if current MIG mode is enabled. """ - @mode.setter def mode(self, mode: bool) -> None: """ @@ -698,7 +643,6 @@ class MigInfo: mode: bool `True` to enable MIG mode, `False` to disable MIG mode. """ - @property def pending_mode(self) -> bool: """ @@ -716,7 +660,6 @@ class MigInfo: bool `True` if pending MIG mode is enabled. """ - @property def device_count(self) -> int: """ @@ -731,7 +674,6 @@ class MigInfo: int The number of MIG devices (compute instances) on this GPU. """ - @property def parent(self) -> Device: """ @@ -744,7 +686,6 @@ class MigInfo: Device The parent GPU device for this MIG device. """ - def get_device_by_index(self, index: int) -> Device: """ Get MIG device for the given index under its parent device. @@ -768,7 +709,6 @@ class MigInfo: Device The MIG device corresponding to the given index. """ - def get_all_devices(self) -> Iterable[Device]: """ Get all MIG devices under its parent device. @@ -788,7 +728,6 @@ class MigInfo: """ class _NvlinkInfoMeta(type): - @property def max_links(cls): """ @@ -807,10 +746,7 @@ class _NvlinkInfo: """ Nvlink information for a device. """ - - def __init__(self, device: Device, link: int): - ... - + def __init__(self, device: Device, link: int): ... @property def version(self) -> tuple[int, int]: """ @@ -823,7 +759,6 @@ class _NvlinkInfo: tuple[int, int] The Nvlink version as a tuple of (major, minor). """ - @property def state(self) -> bool: """ @@ -839,71 +774,58 @@ class _NvlinkInfo: `True` if the Nvlink is active. """ -class NvlinkInfo(_NvlinkInfo, metaclass=_NvlinkInfoMeta): - ... +class NvlinkInfo(_NvlinkInfo, metaclass=_NvlinkInfoMeta): ... class PciInfo: """ PCI information about a GPU device. """ - - def __init__(self, pci_info_ext: nvml.PciInfoExt_v1, handle: int): - ... - + def __init__(self, pci_info_ext: nvml.PciInfoExt_v1, handle: int): ... @property def bus(self) -> int: """ The bus on which the device resides, 0 to 255 """ - @property def bus_id(self) -> str: """ The tuple domain:bus:device.function PCI identifier string """ - @property def device(self) -> int: """ The device's id on the bus, 0 to 31 """ - @property def domain(self) -> int: """ The PCI domain on which the device's bus resides, 0 to 0xffffffff """ - @property def vendor_id(self) -> int: """ The PCI vendor id of the device """ - @property def device_id(self) -> int: """ The PCI device id of the device """ - @property def subsystem_id(self) -> int: """ The subsystem device ID """ - @property def base_class(self) -> int: """ The 8-bit PCI base class code """ - @property def sub_class(self) -> int: """ The 8-bit PCI sub class code """ - @property def link_generation(self) -> int: """ @@ -915,7 +837,6 @@ class PciInfo: PCIe bus, the max link generation this function will report is generation 1. """ - @property def max_link_generation(self) -> int: """ @@ -923,7 +844,6 @@ class PciInfo: For Fermi™ or newer fully supported devices. """ - @property def max_link_width(self) -> int: """ @@ -935,7 +855,6 @@ class PciInfo: PCIe system bus this function will report a max link width of 8. """ - @property def current_link_generation(self) -> int: """ @@ -943,7 +862,6 @@ class PciInfo: For Fermi™ or newer fully supported devices. """ - @property def current_link_width(self) -> int: """ @@ -951,7 +869,6 @@ class PciInfo: For Fermi™ or newer fully supported devices. """ - @property def rx_throughput(self) -> int: """ @@ -965,7 +882,6 @@ class PciInfo: This method is not supported in virtual machines running virtual GPU (vGPU). """ - @property def tx_throughput(self) -> int: """ @@ -979,7 +895,6 @@ class PciInfo: This method is not supported in virtual machines running virtual GPU (vGPU). """ - @property def replay_counter(self) -> int: """ @@ -989,28 +904,22 @@ class PciInfo: """ class GpuDynamicPstatesUtilization: - - def __init__(self, ptr: int, owner: object): - ... - + def __init__(self, ptr: int, owner: object): ... @property def is_present(self) -> bool: """ Set if the utilization domain is present on this GPU. """ - @property def percentage(self) -> int: """ Percentage of time where the domain is considered busy in the last 1-second interval. """ - @property def inc_threshold(self) -> int: """ Utilization threshold that can trigger a perf-increasing P-State change when crossed. """ - @property def dec_threshold(self) -> int: """ @@ -1021,36 +930,25 @@ class GpuDynamicPstatesInfo: """ Handles performance monitor samples from the device. """ - - def __init__(self, gpu_dynamic_pstates_info: nvml.GpuDynamicPstatesInfo): - ... - - def __len__(self) -> int: - ... - - def __getitem__(self, idx: int) -> GpuDynamicPstatesUtilization: - ... + def __init__(self, gpu_dynamic_pstates_info: nvml.GpuDynamicPstatesInfo): ... + def __len__(self) -> int: ... + def __getitem__(self, idx: int) -> GpuDynamicPstatesUtilization: ... class ProcessInfo: """ Information about running compute processes on the GPU. """ - - def __init__(self, device: Device, process_info: nvml.ProcessInfo): - ... - + def __init__(self, device: Device, process_info: nvml.ProcessInfo): ... @property def pid(self) -> int: """ The PID of the process. """ - @property def used_gpu_memory(self) -> int: """ The amount of GPU memory (in bytes) used by the process. """ - @property def gpu_instance_id(self) -> int: """ @@ -1058,7 +956,6 @@ class ProcessInfo: Only valid for processes running on MIG devices. """ - @property def compute_instance_id(self) -> int: """ @@ -1071,16 +968,12 @@ class RepairStatus: """ Repair status for TPC/Channel repair. """ - - def __init__(self, handle: int): - ... - + def __init__(self, handle: int): ... @property def channel_repair_pending(self) -> bool: """ `True` if a channel repair is pending. """ - @property def tpc_repair_pending(self) -> bool: """ @@ -1088,46 +981,25 @@ class RepairStatus: """ class ThermalSensor: - - def __init__(self, ptr: int, owner: object): - ... - + def __init__(self, ptr: int, owner: object): ... @property - def controller(self) -> ThermalController: - ... - + def controller(self) -> ThermalController: ... @property - def default_min_temp(self) -> int: - ... - + def default_min_temp(self) -> int: ... @property - def default_max_temp(self) -> int: - ... - + def default_max_temp(self) -> int: ... @property - def current_temp(self) -> int: - ... - + def current_temp(self) -> int: ... @property - def target(self) -> ThermalTarget: - ... + def target(self) -> ThermalTarget: ... class ThermalSettings: - - def __init__(self, thermal_settings: nvml.ThermalSettings): - ... - - def __len__(self) -> int: - ... - - def __getitem__(self, idx: int) -> nvml.ThermalSensor: - ... + def __init__(self, thermal_settings: nvml.ThermalSettings): ... + def __len__(self) -> int: ... + def __getitem__(self, idx: int) -> nvml.ThermalSensor: ... class Temperature: - - def __init__(self, handle: int): - ... - + def __init__(self, handle: int): ... def get_sensor(self) -> int: """ Get the temperature reading from a specific sensor on the device, in @@ -1140,7 +1012,6 @@ class Temperature: int The temperature in degrees Celsius. """ - def get_threshold(self, threshold_type: TemperatureThresholds | str) -> int: """ Retrieves the temperature threshold for this GPU with the specified @@ -1162,13 +1033,11 @@ class Temperature: use :meth:`get_field_values` with ``NVML_FI_DEV_TEMPERATURE_*`` fields to retrieve temperature thresholds on these architectures. """ - @property def margin(self) -> int: """ The thermal margin temperature (distance to nearest slowdown threshold) for the device. """ - def get_thermal_settings(self, sensor_index: ThermalTarget | str) -> ThermalSettings: """ Used to execute a list of thermal system instructions. @@ -1190,16 +1059,12 @@ class Utilization: For devices with compute capability 2.0 or higher. """ - - def __init__(self, utilization: nvml.Utilization): - ... - + def __init__(self, utilization: nvml.Utilization): ... @property def gpu(self) -> int: """ Percent of time over the past sample period during which one or more kernels was executing on the GPU. """ - @property def memory(self) -> int: """ @@ -1240,9 +1105,7 @@ class Device: """ _handle: int - def __init__(self, *, index: int | None=None, uuid: bytes | str | None=None, pci_bus_id: bytes | str | None=None) -> None: - ... - + def __init__(self, *, index: int | None=None, uuid: bytes | str | None=None, pci_bus_id: bytes | str | None=None) -> None: ... @property def index(self) -> int: """ @@ -1260,7 +1123,6 @@ class Device: Note: The NVML index may not correlate with other APIs, such as the CUDA device index. """ - @property def uuid(self) -> str: """ @@ -1272,7 +1134,6 @@ class Device: prefix. If you need a `uuid` without that prefix (for example, to interact with CUDA), use the `uuid_without_prefix` property. """ - @property def uuid_without_prefix(self) -> str: """ @@ -1284,13 +1145,11 @@ class Device: prefix. This property returns it without the prefix, to match the UUIDs used in CUDA. If you need the prefix, use the `uuid` property. """ - @property def pci_bus_id(self) -> str: """ Retrieves the PCI bus ID of this device. """ - @property def numa_node_id(self) -> int: """ @@ -1298,7 +1157,6 @@ class Device: This only applies to platforms where the GPUs are NUMA nodes. """ - @property def arch(self) -> DeviceArch: """ @@ -1308,13 +1166,11 @@ class Device: "VOLTA"``, and RTX A6000 will report ``DeviceArchitecture.name == "AMPERE"``. """ - @property def name(self) -> str: """ Name of the device, e.g.: `"Tesla V100-SXM2-32GB"` """ - @property def brand(self) -> str: """ @@ -1322,7 +1178,6 @@ class Device: Returns "Unknown" if the brand is unknown. """ - @property def serial(self) -> str: """ @@ -1331,7 +1186,6 @@ class Device: For all products with an InfoROM. """ - @property def module_id(self) -> int: """ @@ -1341,7 +1195,6 @@ class Device: on a given baseboard. For non-baseboard products, this ID would always be 0. """ - @property def minor_number(self) -> int: """ @@ -1352,13 +1205,11 @@ class Device: The minor number is used by the Linux device driver to identify the device node in ``/dev/nvidiaX``. """ - @property def is_c2c_enabled(self) -> bool: """ Whether the C2C (Chip-to-Chip) mode is enabled for this device. """ - @property def is_persistence_mode_enabled(self) -> bool: """ @@ -1366,11 +1217,8 @@ class Device: For Linux only. """ - @is_persistence_mode_enabled.setter - def is_persistence_mode_enabled(self, enabled: bool) -> None: - ... - + def is_persistence_mode_enabled(self, enabled: bool) -> None: ... @property def cuda_compute_capability(self) -> tuple[int, int]: """ @@ -1378,8 +1226,7 @@ class Device: Returns a tuple `(major, minor)`. """ - - def to_cuda_device(self) -> 'cuda.core.Device': + def to_cuda_device(self) -> cuda.core.Device: """ Get the corresponding :class:`cuda.core.Device` (which is used for CUDA access) for this :class:`cuda.core.system.Device` (which is used for @@ -1401,7 +1248,6 @@ class Device: available CUDA device, since it can not be used directly, even though it can be enumerated from NVML. """ - @classmethod def get_device_count(cls) -> int: """ @@ -1412,7 +1258,6 @@ class Device: int The number of available devices. """ - @classmethod def get_all_devices(cls) -> Iterable[Device]: """ @@ -1423,13 +1268,11 @@ class Device: Iterator over :obj:`~Device` An iterator over available devices. """ - @property def addressing_mode(self) -> AddressingMode | None: """ Get the :obj:`~AddressingMode` of the device. """ - @property def mig(self) -> MigInfo: """ @@ -1437,7 +1280,6 @@ class Device: For Ampere™ or newer fully supported devices. """ - @classmethod def get_all_devices_with_cpu_affinity(cls, cpu_index: int) -> Iterable[Device]: """ @@ -1455,8 +1297,7 @@ class Device: Iterator of :obj:`~Device` An iterator over available devices. """ - - def get_memory_affinity(self, scope: AffinityScope | str=...) -> list[int]: + def get_memory_affinity(self, scope: AffinityScope | str=AffinityScope.NODE) -> list[int]: """ Retrieves a list of indices of NUMA nodes or CPU sockets with the ideal memory affinity for the device. @@ -1481,8 +1322,7 @@ class Device: A list of indices of NUMA nodes or CPU sockets with the ideal memory affinity for the device. """ - - def get_cpu_affinity(self, scope: AffinityScope | str=...) -> list[int]: + def get_cpu_affinity(self, scope: AffinityScope | str=AffinityScope.NODE) -> list[int]: """ Retrieves a list of indices of NUMA nodes or CPU sockets with the ideal CPU affinity for the device. @@ -1507,7 +1347,6 @@ class Device: A list of indices of NUMA nodes or CPU sockets with the ideal memory affinity for the device. """ - def set_cpu_affinity(self) -> None: """ Sets the ideal affinity for the calling thread and device. @@ -1516,7 +1355,6 @@ class Device: Supported on Linux only. """ - def clear_cpu_affinity(self) -> None: """ Clear all affinity bindings for the calling thread. @@ -1525,12 +1363,10 @@ class Device: Supported on Linux only. """ - def get_clock(self, clock_type: ClockType | str) -> ClockInfo: """ :obj:`~_device.ClockInfo` object to get information about and manage a specific clock on a device. """ - @property def is_auto_boosted_clocks_enabled(self) -> tuple[bool, bool]: """ @@ -1554,7 +1390,6 @@ class Device: The default Auto Boosted clocks behavior """ - @property def current_clock_event_reasons(self) -> list[ClocksEventReasons]: """ @@ -1562,7 +1397,6 @@ class Device: For all fully supported products. """ - @property def supported_clock_event_reasons(self) -> list[ClocksEventReasons]: """ @@ -1573,13 +1407,11 @@ class Device: This method is not supported in virtual machines running virtual GPU (vGPU). """ - @property def cooler(self) -> CoolerInfo: """ :obj:`~_device.CoolerInfo` object with cooler information for the device. """ - @property def attributes(self) -> DeviceAttributes: """ @@ -1588,7 +1420,6 @@ class Device: For Ampere™ or newer fully supported devices. Only available on Linux systems. """ - @property def is_display_connected(self) -> bool: """ @@ -1597,7 +1428,6 @@ class Device: Indicates whether a physical display (e.g. monitor) is currently connected to any of the device's connectors. """ - @property def is_display_active(self) -> bool: """ @@ -1609,7 +1439,6 @@ class Device: Display can be active even when no monitor is physically attached. """ - def register_events(self, events: EventType | str | list[EventType | str]) -> DeviceEvents: """ Starts recording events on this device. @@ -1650,7 +1479,6 @@ class Device: :class:`cuda.core.system.NotSupportedError` None of the requested event types are registered. """ - def get_supported_event_types(self) -> list[EventType]: """ Get the list of event types supported by this device. @@ -1663,18 +1491,15 @@ class Device: list[EventType] The list of supported event types. """ - def get_fan(self, fan: int=0) -> FanInfo: """ :obj:`~_device.FanInfo` object to get information and manage a specific fan on a device. """ - @property def num_fans(self) -> int: """ The number of fans on the device. """ - def get_field_values(self, field_ids: list[int | tuple[int, int]]) -> FieldValues: """ Get multiple field values from the device. @@ -1699,7 +1524,6 @@ class Device: :obj:`~_device.FieldValues` Container of field values corresponding to the requested field IDs. """ - def clear_field_values(self, field_ids: list[int | tuple[int, int]]) -> None: """ Clear multiple field values from the device. @@ -1712,7 +1536,6 @@ class Device: Each item may be either a single value from the :class:`FieldId` enum, or a pair of (:class:`FieldId`, scope ID). """ - @property def inforom(self) -> InforomInfo: """ @@ -1720,7 +1543,6 @@ class Device: For all products with an InfoROM. """ - @property def bar1_memory_info(self) -> BAR1MemoryInfo: """ @@ -1730,13 +1552,11 @@ class Device: accessed by the CPU or by 3rd party devices (peer-to-peer on the PCIE bus). """ - @property def memory_info(self) -> MemoryInfo: """ :obj:`~_device.MemoryInfo` object with memory information. """ - def get_nvlink(self, link: int) -> NvlinkInfo: """ Get :obj:`~NvlinkInfo` about this device. @@ -1746,7 +1566,6 @@ class Device: .. version-changed:: 1.1.0 Any link number not supported by this specific device will raise a `ValueError`. """ - def get_nvlink_count(self) -> int: """ Get the number of NVLink links on this device. @@ -1755,7 +1574,6 @@ class Device: .. version-added:: 1.1.0 """ - def get_nvlinks(self) -> Iterable[NvlinkInfo]: """ Get :obj:`~NvlinkInfo` about all NVLink links on this device. @@ -1764,7 +1582,6 @@ class Device: .. version-added:: 1.1.0 """ - @property def pci_info(self) -> PciInfo: """ @@ -1773,7 +1590,6 @@ class Device: Non-physical devices, such as MIG devices, may not have PCI attributes. In that case, this property will raise a `RuntimeError`. """ - @property def performance_state(self) -> int | None: """ @@ -1788,13 +1604,11 @@ class Device: where 0 is maximum performance and higher numbers are lower performance. Returns `None` if the performance state is unknown. """ - @property def dynamic_pstates_info(self) -> GpuDynamicPstatesInfo: """ :obj:`~_device.GpuDynamicPstatesInfo` object with performance monitor samples from the associated subdevice. """ - @property def supported_pstates(self) -> list[int]: """ @@ -1810,7 +1624,6 @@ class Device: between 0 and 15, where 0 is maximum performance and higher numbers are lower performance. """ - @property def compute_running_processes(self) -> list[ProcessInfo]: """ @@ -1832,7 +1645,6 @@ class Device: Querying per-instance information using MIG device handles is not supported if the device is in vGPU Host virtualization mode. """ - @property def repair_status(self) -> RepairStatus: """ @@ -1840,13 +1652,11 @@ class Device: For Ampere™ or newer fully supported devices. """ - @property def temperature(self) -> Temperature: """ :obj:`~_device.Temperature` object with temperature information for the device. """ - def get_topology_nearest_gpus(self, level: GpuTopologyLevel | str) -> Iterable[Device]: """ Retrieve the GPUs that are nearest to this device at a specific interconnectivity level. @@ -1863,7 +1673,6 @@ class Device: Iterable of :class:`Device` The nearest devices at the given topology level. """ - @property def utilization(self) -> Utilization: """ @@ -1884,35 +1693,11 @@ class Device: Utilization An object containing the current utilization rates for the device. """ -_CLOCK_ID_MAPPING = {ClockId.CURRENT: nvml.ClockId.CURRENT, ClockId.CUSTOMER_BOOST_MAX: nvml.ClockId.CUSTOMER_BOOST_MAX} -_CLOCKS_EVENT_REASONS_MAPPING = {nvml.ClocksEventReasons.EVENT_REASON_NONE: ClocksEventReasons.NONE, nvml.ClocksEventReasons.EVENT_REASON_GPU_IDLE: ClocksEventReasons.GPU_IDLE, nvml.ClocksEventReasons.EVENT_REASON_APPLICATIONS_CLOCKS_SETTING: ClocksEventReasons.APPLICATIONS_CLOCKS_SETTING, nvml.ClocksEventReasons.EVENT_REASON_SW_POWER_CAP: ClocksEventReasons.SW_POWER_CAP, nvml.ClocksEventReasons.THROTTLE_REASON_HW_SLOWDOWN: ClocksEventReasons.HW_SLOWDOWN, nvml.ClocksEventReasons.EVENT_REASON_SYNC_BOOST: ClocksEventReasons.SYNC_BOOST, nvml.ClocksEventReasons.EVENT_REASON_SW_THERMAL_SLOWDOWN: ClocksEventReasons.SW_THERMAL_SLOWDOWN, nvml.ClocksEventReasons.THROTTLE_REASON_HW_THERMAL_SLOWDOWN: ClocksEventReasons.HW_THERMAL_SLOWDOWN, nvml.ClocksEventReasons.THROTTLE_REASON_HW_POWER_BRAKE_SLOWDOWN: ClocksEventReasons.HW_POWER_BRAKE_SLOWDOWN, nvml.ClocksEventReasons.EVENT_REASON_DISPLAY_CLOCK_SETTING: ClocksEventReasons.DISPLAY_CLOCK_SETTING} -_CLOCK_TYPE_MAPPING = {ClockType.GRAPHICS: nvml.ClockType.CLOCK_GRAPHICS, ClockType.SM: nvml.ClockType.CLOCK_SM, ClockType.MEMORY: nvml.ClockType.CLOCK_MEM, ClockType.VIDEO: nvml.ClockType.CLOCK_VIDEO} -_COOLER_CONTROL_MAPPING = {nvml.CoolerControl.THERMAL_COOLER_SIGNAL_TOGGLE: CoolerControl.TOGGLE, nvml.CoolerControl.THERMAL_COOLER_SIGNAL_VARIABLE: CoolerControl.VARIABLE} -_COOLER_TARGET_MAPPING = {nvml.CoolerTarget.THERMAL_NONE: CoolerTarget.NONE, nvml.CoolerTarget.THERMAL_GPU: CoolerTarget.GPU, nvml.CoolerTarget.THERMAL_MEMORY: CoolerTarget.MEMORY, nvml.CoolerTarget.THERMAL_POWER_SUPPLY: CoolerTarget.POWER_SUPPLY} -_EVENT_TYPE_MAPPING = {nvml.EventType.NONE: EventType.NONE, nvml.EventType.SINGLE_BIT_ECC_ERROR: EventType.SINGLE_BIT_ECC_ERROR, nvml.EventType.DOUBLE_BIT_ECC_ERROR: EventType.DOUBLE_BIT_ECC_ERROR, nvml.EventType.PSTATE: EventType.PSTATE, nvml.EventType.XID_CRITICAL_ERROR: EventType.XID_CRITICAL_ERROR, nvml.EventType.CLOCK: EventType.CLOCK, nvml.EventType.POWER_SOURCE_CHANGE: EventType.POWER_SOURCE_CHANGE, nvml.EventType.MIG_CONFIG_CHANGE: EventType.MIG_CONFIG_CHANGE, nvml.EventType.SINGLE_BIT_ECC_ERROR_STORM: EventType.SINGLE_BIT_ECC_ERROR_STORM, nvml.EventType.DRAM_RETIREMENT_EVENT: EventType.DRAM_RETIREMENT_EVENT, nvml.EventType.DRAM_RETIREMENT_FAILURE: EventType.DRAM_RETIREMENT_FAILURE, nvml.EventType.NON_FATAL_POISON_ERROR: EventType.NON_FATAL_POISON_ERROR, nvml.EventType.FATAL_POISON_ERROR: EventType.FATAL_POISON_ERROR, nvml.EventType.GPU_UNAVAILABLE_ERROR: EventType.GPU_UNAVAILABLE_ERROR, nvml.EventType.GPU_RECOVERY_ACTION: EventType.GPU_RECOVERY_ACTION} -_EVENT_TYPE_INV_MAPPING = {v: k for k, v in _EVENT_TYPE_MAPPING.items()} -_FAN_CONTROL_POLICY_MAPPING = {nvml.FanControlPolicy.TEMPERATURE_CONTINUOUS_SW: FanControlPolicy.TEMPERATURE_CONTROLLED, nvml.FanControlPolicy.MANUAL: FanControlPolicy.MANUAL} -_INFOROM_OBJECT_MAPPING = {InforomObject.OEM: nvml.InforomObject.INFOROM_OEM, InforomObject.ECC: nvml.InforomObject.INFOROM_ECC, InforomObject.POWER: nvml.InforomObject.INFOROM_POWER, InforomObject.DEN: nvml.InforomObject.INFOROM_DEN} -_NVLINK_VERSION_MAPPING = {nvml.NvlinkVersion.VERSION_1_0: (1, 0), nvml.NvlinkVersion.VERSION_2_0: (2, 0), nvml.NvlinkVersion.VERSION_2_2: (2, 2), nvml.NvlinkVersion.VERSION_3_0: (3, 0), nvml.NvlinkVersion.VERSION_3_1: (3, 1), nvml.NvlinkVersion.VERSION_4_0: (4, 0), nvml.NvlinkVersion.VERSION_5_0: (5, 0)} -_NVLINK_VERSION_6_0 = getattr(nvml.NvlinkVersion, 'VERSION_6_0', None) -_TEMPERATURE_THRESHOLD_MAPPING = {TemperatureThresholds.SHUTDOWN: nvml.TemperatureThresholds.TEMPERATURE_THRESHOLD_SHUTDOWN, TemperatureThresholds.SLOWDOWN: nvml.TemperatureThresholds.TEMPERATURE_THRESHOLD_SLOWDOWN, TemperatureThresholds.MEM_MAX: nvml.TemperatureThresholds.TEMPERATURE_THRESHOLD_MEM_MAX, TemperatureThresholds.GPU_MAX: nvml.TemperatureThresholds.TEMPERATURE_THRESHOLD_GPU_MAX, TemperatureThresholds.ACOUSTIC_MIN: nvml.TemperatureThresholds.TEMPERATURE_THRESHOLD_ACOUSTIC_MIN, TemperatureThresholds.ACOUSTIC_CURR: nvml.TemperatureThresholds.TEMPERATURE_THRESHOLD_ACOUSTIC_CURR, TemperatureThresholds.ACOUSTIC_MAX: nvml.TemperatureThresholds.TEMPERATURE_THRESHOLD_ACOUSTIC_MAX, TemperatureThresholds.GPS_CURR: nvml.TemperatureThresholds.TEMPERATURE_THRESHOLD_GPS_CURR} -_THERMAL_CONTROLLER_MAPPING = {nvml.ThermalController.GPU_INTERNAL: ThermalController.GPU_INTERNAL, nvml.ThermalController.ADM1032: ThermalController.ADM1032, nvml.ThermalController.ADT7461: ThermalController.ADT7461, nvml.ThermalController.MAX6649: ThermalController.MAX6649, nvml.ThermalController.MAX1617: ThermalController.MAX1617, nvml.ThermalController.LM99: ThermalController.LM99, nvml.ThermalController.LM89: ThermalController.LM89, nvml.ThermalController.LM64: ThermalController.LM64, nvml.ThermalController.G781: ThermalController.G781, nvml.ThermalController.ADT7473: ThermalController.ADT7473, nvml.ThermalController.SBMAX6649: ThermalController.SBMAX6649, nvml.ThermalController.VBIOSEVT: ThermalController.VBIOSEVT, nvml.ThermalController.OS: ThermalController.OS, nvml.ThermalController.NVSYSCON_CANOAS: ThermalController.NVSYSCON_CANOAS, nvml.ThermalController.NVSYSCON_E551: ThermalController.NVSYSCON_E551, nvml.ThermalController.MAX6649R: ThermalController.MAX6649R, nvml.ThermalController.ADT7473S: ThermalController.ADT7473S, nvml.ThermalController.UNKNOWN: ThermalController.UNKNOWN} -_THERMAL_TARGET_MAPPING = {nvml.ThermalTarget.NONE: ThermalTarget.NONE, nvml.ThermalTarget.GPU: ThermalTarget.GPU, nvml.ThermalTarget.MEMORY: ThermalTarget.MEMORY, nvml.ThermalTarget.POWER_SUPPLY: ThermalTarget.POWER_SUPPLY, nvml.ThermalTarget.BOARD: ThermalTarget.BOARD, nvml.ThermalTarget.VCD_BOARD: ThermalTarget.VCD_BOARD, nvml.ThermalTarget.VCD_INLET: ThermalTarget.VCD_INLET, nvml.ThermalTarget.VCD_OUTLET: ThermalTarget.VCD_OUTLET, nvml.ThermalTarget.ALL: ThermalTarget.ALL} -_THERMAL_TARGET_INV_MAPPING = {v: k for k, v in _THERMAL_TARGET_MAPPING.items()} -_ADDRESSING_MODE_MAPPING = {nvml.DeviceAddressingModeType.DEVICE_ADDRESSING_MODE_HMM: AddressingMode.HMM, nvml.DeviceAddressingModeType.DEVICE_ADDRESSING_MODE_ATS: AddressingMode.ATS} -_AFFINITY_SCOPE_MAPPING = {AffinityScope.NODE: nvml.AffinityScope.NODE, AffinityScope.SOCKET: nvml.AffinityScope.SOCKET} -_BRAND_TYPE_MAPPING = {nvml.BrandType.BRAND_UNKNOWN: 'Unknown', nvml.BrandType.BRAND_QUADRO: 'Quadro', nvml.BrandType.BRAND_TESLA: 'Tesla', nvml.BrandType.BRAND_NVS: 'NVS', nvml.BrandType.BRAND_GRID: 'GRID', nvml.BrandType.BRAND_GEFORCE: 'GeForce', nvml.BrandType.BRAND_TITAN: 'Titan', nvml.BrandType.BRAND_NVIDIA_VAPPS: 'NVIDIA vApps', nvml.BrandType.BRAND_NVIDIA_VPC: 'NVIDIA VPC', nvml.BrandType.BRAND_NVIDIA_VCS: 'NVIDIA VCS', nvml.BrandType.BRAND_NVIDIA_VWS: 'NVIDIA VWS', nvml.BrandType.BRAND_NVIDIA_CLOUD_GAMING: 'NVIDIA Cloud Gaming', nvml.BrandType.BRAND_NVIDIA_VGAMING: 'NVIDIA vGaming', nvml.BrandType.BRAND_QUADRO_RTX: 'Quadro RTX', nvml.BrandType.BRAND_NVIDIA_RTX: 'NVIDIA RTX', nvml.BrandType.BRAND_NVIDIA: 'NVIDIA', nvml.BrandType.BRAND_GEFORCE_RTX: 'GeForce RTX', nvml.BrandType.BRAND_TITAN_RTX: 'Titan RTX'} -_GPU_P2P_CAPS_INDEX_MAPPING = {GpuP2PCapsIndex.READ: nvml.GpuP2PCapsIndex.P2P_CAPS_INDEX_READ, GpuP2PCapsIndex.WRITE: nvml.GpuP2PCapsIndex.P2P_CAPS_INDEX_WRITE, GpuP2PCapsIndex.NVLINK: nvml.GpuP2PCapsIndex.P2P_CAPS_INDEX_NVLINK, GpuP2PCapsIndex.ATOMICS: nvml.GpuP2PCapsIndex.P2P_CAPS_INDEX_ATOMICS, GpuP2PCapsIndex.PCI: nvml.GpuP2PCapsIndex.P2P_CAPS_INDEX_PCI, GpuP2PCapsIndex.PROP: nvml.GpuP2PCapsIndex.P2P_CAPS_INDEX_PROP, GpuP2PCapsIndex.UNKNOWN: nvml.GpuP2PCapsIndex.P2P_CAPS_INDEX_UNKNOWN} -_GPU_P2P_STATUS_MAPPING = {nvml.GpuP2PStatus.P2P_STATUS_OK: GpuP2PStatus.OK, nvml.GpuP2PStatus.P2P_STATUS_CHIPSET_NOT_SUPPORTED: GpuP2PStatus.CHIPSET_NOT_SUPPORTED, nvml.GpuP2PStatus.P2P_STATUS_GPU_NOT_SUPPORTED: GpuP2PStatus.GPU_NOT_SUPPORTED, nvml.GpuP2PStatus.P2P_STATUS_IOH_TOPOLOGY_NOT_SUPPORTED: GpuP2PStatus.IOH_TOPOLOGY_NOT_SUPPORTED, nvml.GpuP2PStatus.P2P_STATUS_DISABLED_BY_REGKEY: GpuP2PStatus.DISABLED_BY_REGKEY, nvml.GpuP2PStatus.P2P_STATUS_NOT_SUPPORTED: GpuP2PStatus.NOT_SUPPORTED, nvml.GpuP2PStatus.P2P_STATUS_UNKNOWN: GpuP2PStatus.UNKNOWN} -_GPU_TOPOLOGY_LEVEL_MAPPING = {GpuTopologyLevel.INTERNAL: nvml.GpuTopologyLevel.TOPOLOGY_INTERNAL, GpuTopologyLevel.SINGLE: nvml.GpuTopologyLevel.TOPOLOGY_SINGLE, GpuTopologyLevel.MULTIPLE: nvml.GpuTopologyLevel.TOPOLOGY_MULTIPLE, GpuTopologyLevel.HOSTBRIDGE: nvml.GpuTopologyLevel.TOPOLOGY_HOSTBRIDGE, GpuTopologyLevel.NODE: nvml.GpuTopologyLevel.TOPOLOGY_NODE, GpuTopologyLevel.SYSTEM: nvml.GpuTopologyLevel.TOPOLOGY_SYSTEM} -_GPU_TOPOLOGY_LEVEL_INV_MAPPING = {v: k for k, v in _GPU_TOPOLOGY_LEVEL_MAPPING.items()} -__all__ = ['Device', 'get_p2p_status', 'get_topology_common_ancestor', 'NvlinkInfo'] def _unpack_bitmask(arr: object) -> list[int]: """ Unpack a list of integers containing bitmasks. """ - def get_topology_common_ancestor(device1: Device, device2: Device) -> GpuTopologyLevel: """ Retrieve the common ancestor for two devices. @@ -1931,7 +1716,6 @@ def get_topology_common_ancestor(device1: Device, device2: Device) -> GpuTopolog :class:`GpuTopologyLevel` The common ancestor level of the two devices. """ - def get_p2p_status(device1: Device, device2: Device, index: GpuP2PCapsIndex | str) -> GpuP2PStatus: """ Retrieve the P2P status between two devices. @@ -1949,4 +1733,4 @@ def get_p2p_status(device1: Device, device2: Device, index: GpuP2PCapsIndex | st ------- :class:`GpuP2PStatus` The P2P status between the two devices. - """ \ No newline at end of file + """ diff --git a/cuda_core/cuda/core/system/_nvml_context.pyi b/cuda_core/cuda/core/system/_nvml_context.pyi index e52a803b346..d61f31ddf40 100644 --- a/cuda_core/cuda/core/system/_nvml_context.pyi +++ b/cuda_core/cuda/core/system/_nvml_context.pyi @@ -1,17 +1,14 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/system/_nvml_context.pyx +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/system/_nvml_context.pyx -from __future__ import annotations +from typing import TypeAlias -import threading - -_NVMLState = int -_lock = threading.Lock() +_NVMLState: TypeAlias = int +def _get_nvml_state() -> _NVMLState: ... def _initialize() -> None: """ Initializes NVIDIA Management Library (NVML), ensuring it only happens once per process. """ - def validate() -> None: """ Validate NVML state. @@ -28,6 +25,3 @@ def validate() -> None: nvml.GpuNotFoundError If no GPUs are available. """ - -def _get_nvml_state() -> _NVMLState: - ... \ No newline at end of file diff --git a/cuda_core/cuda/core/system/_system.pyi b/cuda_core/cuda/core/system/_system.pyi index f25ce35be7f..0584101fa96 100644 --- a/cuda_core/cuda/core/system/_system.pyi +++ b/cuda_core/cuda/core/system/_system.pyi @@ -1,6 +1,4 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/system/_system.pyx - -from __future__ import annotations +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/system/_system.pyx CUDA_BINDINGS_NVML_IS_COMPATIBLE: bool __all__ = ['get_driver_branch', 'get_kernel_mode_driver_version', 'get_user_mode_driver_version', 'get_nvml_version', 'get_num_devices', 'get_process_name', 'CUDA_BINDINGS_NVML_IS_COMPATIBLE'] @@ -17,7 +15,6 @@ def get_user_mode_driver_version() -> tuple[int, ...]: version : tuple[int, ...] A 2-tuple ``(MAJOR, MINOR)``, e.g. ``(13, 0)`` for CUDA 13.0. """ - def get_kernel_mode_driver_version() -> tuple[int, ...]: """ Get the kernel-mode (KMD / GPU) driver version, e.g. 580.65.06. @@ -33,7 +30,6 @@ def get_kernel_mode_driver_version() -> tuple[int, ...]: RuntimeError If the NVML library is not available. """ - def get_nvml_version() -> tuple[int, ...]: """ The version of the NVML library. @@ -43,7 +39,6 @@ def get_nvml_version() -> tuple[int, ...]: version: tuple[int, ...] Tuple of integers representing the NVML version components. """ - def get_driver_branch() -> str: """ Retrieves the driver branch of the NVIDIA driver installed on the system. @@ -53,12 +48,10 @@ def get_driver_branch() -> str: branch: str The driver branch string (e.g., ``"560"``, ``"open"``, etc.). """ - def get_num_devices() -> int: """ Return the number of devices in the system. """ - def get_process_name(pid: int) -> str: """ The name of process with given PID. @@ -72,4 +65,4 @@ def get_process_name(pid: int) -> str: ------- name: str The process name. - """ \ No newline at end of file + """ diff --git a/cuda_core/cuda/core/system/_system_events.pyi b/cuda_core/cuda/core/system/_system_events.pyi index 5ae5b86bc57..ef367602975 100644 --- a/cuda_core/cuda/core/system/_system_events.pyi +++ b/cuda_core/cuda/core/system/_system_events.pyi @@ -1,33 +1,29 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/system/_system_events.pyx - -from __future__ import annotations +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/system/_system_events.pyx from cuda.bindings import nvml from cuda.core.system.typing import SystemEventType from . import _device +_SYSTEM_EVENT_TYPE_MAPPING = {nvml.SystemEventType.GPU_DRIVER_UNBIND: SystemEventType.UNBIND, nvml.SystemEventType.GPU_DRIVER_BIND: SystemEventType.BIND} +_SYSTEM_EVENT_TYPE_INV_MAPPING = ... +__all__ = ['register_events'] class SystemEvent: """ Data about a collection of system events. """ - - def __init__(self, event_data: nvml.SystemEventData_v1): - ... - + def __init__(self, event_data: nvml.SystemEventData_v1): ... @property def event_type(self) -> SystemEventType: """ The :obj:`~SystemEventType` that was triggered. """ - @property def gpu_id(self) -> int: """ The GPU ID in PCI ID format. """ - @property def device(self) -> _device.Device: """ @@ -38,13 +34,8 @@ class SystemEvents: """ Data about a collection of system events. """ - - def __init__(self, event_data: nvml.SystemEventData_v1): - ... - - def __len__(self) -> int: - ... - + def __init__(self, event_data: nvml.SystemEventData_v1): ... + def __len__(self) -> int: ... def __getitem__(self, idx: int) -> SystemEvent: """ Get the :obj:`~_system_events.SystemEvent` at the specified index. @@ -54,13 +45,8 @@ class RegisteredSystemEvents: """ Represents a set of events that can be waited on for a specific device. """ - - def __init__(self, events: SystemEventType | str | list[SystemEventType | str]): - ... - - def __dealloc__(self) -> None: - ... - + def __init__(self, events: SystemEventType | str | list[SystemEventType | str]): ... + def __dealloc__(self) -> None: ... def wait(self, timeout_ms: int=0, buffer_size: int=1) -> SystemEvents: """ Wait for events in the system event set. @@ -95,9 +81,6 @@ class RegisteredSystemEvents: :class:`cuda.core.system.GpuIsLostError` If the GPU has fallen off the bus or is otherwise inaccessible. """ -_SYSTEM_EVENT_TYPE_MAPPING = {nvml.SystemEventType.GPU_DRIVER_UNBIND: SystemEventType.UNBIND, nvml.SystemEventType.GPU_DRIVER_BIND: SystemEventType.BIND} -_SYSTEM_EVENT_TYPE_INV_MAPPING = {v: k for k, v in _SYSTEM_EVENT_TYPE_MAPPING.items()} -__all__ = ['register_events'] def register_events(events: SystemEventType | str | list[SystemEventType | str]) -> RegisteredSystemEvents: """ @@ -130,4 +113,4 @@ def register_events(events: SystemEventType | str | list[SystemEventType | str]) ------ :class:`cuda.core.system.NotSupportedError` None of the requested event types are registered. - """ \ No newline at end of file + """ diff --git a/cuda_core/cuda/core/texture/_array.pyi b/cuda_core/cuda/core/texture/_array.pyi index 380c2fe1c10..87b3530c63a 100644 --- a/cuda_core/cuda/core/texture/_array.pyi +++ b/cuda_core/cuda/core/texture/_array.pyi @@ -1,13 +1,14 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/texture/_array.pyx - -from __future__ import annotations +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/texture/_array.pyx from dataclasses import dataclass -import numpy from cuda.bindings import cydriver from cuda.core.typing import ArrayFormatType +_ARRAYFORMAT_TO_CU = {ArrayFormatType.UINT8: int(cydriver.CU_AD_FORMAT_UNSIGNED_INT8), ArrayFormatType.UINT16: int(cydriver.CU_AD_FORMAT_UNSIGNED_INT16), ArrayFormatType.UINT32: int(cydriver.CU_AD_FORMAT_UNSIGNED_INT32), ArrayFormatType.INT8: int(cydriver.CU_AD_FORMAT_SIGNED_INT8), ArrayFormatType.INT16: int(cydriver.CU_AD_FORMAT_SIGNED_INT16), ArrayFormatType.INT32: int(cydriver.CU_AD_FORMAT_SIGNED_INT32), ArrayFormatType.FLOAT16: int(cydriver.CU_AD_FORMAT_HALF), ArrayFormatType.FLOAT32: int(cydriver.CU_AD_FORMAT_FLOAT)} +_CU_TO_ARRAYFORMAT = ... +_NUMPY_DTYPE_TO_ARRAYFORMAT = ... +_FORMAT_ELEM_SIZE = {_ARRAYFORMAT_TO_CU[ArrayFormatType.UINT8]: 1, _ARRAYFORMAT_TO_CU[ArrayFormatType.INT8]: 1, _ARRAYFORMAT_TO_CU[ArrayFormatType.UINT16]: 2, _ARRAYFORMAT_TO_CU[ArrayFormatType.INT16]: 2, _ARRAYFORMAT_TO_CU[ArrayFormatType.FLOAT16]: 2, _ARRAYFORMAT_TO_CU[ArrayFormatType.UINT32]: 4, _ARRAYFORMAT_TO_CU[ArrayFormatType.INT32]: 4, _ARRAYFORMAT_TO_CU[ArrayFormatType.FLOAT32]: 4} @dataclass class OpaqueArrayOptions: @@ -35,8 +36,7 @@ class OpaqueArrayOptions: num_channels: int is_surface_load_store: bool = False - def __post_init__(self): - ... + def __post_init__(self): ... class OpaqueArray: """An opaque, hardware-laid-out GPU allocation for texture/surface access. @@ -61,19 +61,7 @@ class OpaqueArray: .. versionadded:: 1.1.0 """ - - def close(self): - """Release this object's reference to the underlying ``CUarray``. - - Destruction (``cuArrayDestroy``) happens via the handle's deleter when - the last reference is dropped; for a non-owning handle (graphics interop - or a mipmap-level view) nothing is destroyed. Idempotent: a second call - (or destruction after ``close()``) is a no-op. - """ - - def __init__(self, *args, **kwargs): - ... - + def __init__(self, *args, **kwargs): ... @classmethod def _from_handle(cls, handle: int, owning: bool, *, device_id=None): """Wrap an externally-allocated ``CUarray``. @@ -83,40 +71,31 @@ class OpaqueArray: underlying ``CUarray`` is never destroyed by this object. Shape, format, and channel count are queried from the driver. """ - @property def handle(self): """The underlying ``CUarray`` as an integer.""" - @property def shape(self): """Allocation shape, in elements.""" - @property def format(self): """The element :class:`~cuda.core.typing.ArrayFormatType`.""" - @property def num_channels(self): """Channels per element (1, 2, or 4).""" - @property def element_bytes(self): """Bytes per element (format size * channels).""" - @property def device(self): """The :class:`Device` this array was allocated on.""" - @property def is_surface_load_store(self): """True if this array was created with ``CUDA_ARRAY3D_SURFACE_LDST`` and can be bound as a :class:`SurfaceObject`.""" - def _extent_bytes(self): """Return (width_bytes, height, depth) for cuMemcpy3D, with height/depth normalized to >=1 for lower-rank arrays.""" - def copy_from(self, src, *, stream) -> None: """Copy a full-array's worth of data into this array. @@ -129,7 +108,6 @@ class OpaqueArray: Stream to issue the copy on. A :class:`~cuda.core.graph.GraphBuilder` is accepted so the copy can be captured into a graph. """ - def copy_to(self, dst, *, stream): """Copy a full-array's worth of data out of this array. @@ -146,23 +124,20 @@ class OpaqueArray: ------- The ``dst`` object, for parity with :meth:`Buffer.copy_to`. """ - @property def size_bytes(self): """Total bytes of array storage (``prod(shape) * element_bytes``).""" + def close(self): + """Release this object's reference to the underlying ``CUarray``. - def __enter__(self): - ... - - def __exit__(self, exc_type, exc, tb): - ... - - def __repr__(self): - ... -_ARRAYFORMAT_TO_CU = {ArrayFormatType.UINT8: int(cydriver.CU_AD_FORMAT_UNSIGNED_INT8), ArrayFormatType.UINT16: int(cydriver.CU_AD_FORMAT_UNSIGNED_INT16), ArrayFormatType.UINT32: int(cydriver.CU_AD_FORMAT_UNSIGNED_INT32), ArrayFormatType.INT8: int(cydriver.CU_AD_FORMAT_SIGNED_INT8), ArrayFormatType.INT16: int(cydriver.CU_AD_FORMAT_SIGNED_INT16), ArrayFormatType.INT32: int(cydriver.CU_AD_FORMAT_SIGNED_INT32), ArrayFormatType.FLOAT16: int(cydriver.CU_AD_FORMAT_HALF), ArrayFormatType.FLOAT32: int(cydriver.CU_AD_FORMAT_FLOAT)} -_CU_TO_ARRAYFORMAT = {cu: fmt for fmt, cu in _ARRAYFORMAT_TO_CU.items()} -_NUMPY_DTYPE_TO_ARRAYFORMAT = {numpy.dtype(fmt.value): fmt for fmt in ArrayFormatType} -_FORMAT_ELEM_SIZE = {_ARRAYFORMAT_TO_CU[ArrayFormatType.UINT8]: 1, _ARRAYFORMAT_TO_CU[ArrayFormatType.INT8]: 1, _ARRAYFORMAT_TO_CU[ArrayFormatType.UINT16]: 2, _ARRAYFORMAT_TO_CU[ArrayFormatType.INT16]: 2, _ARRAYFORMAT_TO_CU[ArrayFormatType.FLOAT16]: 2, _ARRAYFORMAT_TO_CU[ArrayFormatType.UINT32]: 4, _ARRAYFORMAT_TO_CU[ArrayFormatType.INT32]: 4, _ARRAYFORMAT_TO_CU[ArrayFormatType.FLOAT32]: 4} + Destruction (``cuArrayDestroy``) happens via the handle's deleter when + the last reference is dropped; for a non-owning handle (graphics interop + or a mipmap-level view) nothing is destroyed. Idempotent: a second call + (or destruction after ``close()``) is a no-op. + """ + def __enter__(self): ... + def __exit__(self, exc_type, exc, tb): ... + def __repr__(self): ... def _normalize_array_format(format): """Coerce ``format`` to an :class:`ArrayFormatType`. @@ -176,16 +151,13 @@ def _normalize_array_format(format): supported formats. Raises :class:`ValueError` on anything else.""" - def _validate_format_channels(format, num_channels): """Validate the ``(format, num_channels)`` pair shared by the array, mipmap, and texture factories. Returns the normalized :class:`ArrayFormatType`. Raises on an invalid combination.""" - def _validate_array_shape(shape): """Coerce ``shape`` to a tuple of ints and validate rank (1-3) and that every extent is >= 1. Returns the normalized tuple.""" - def _create_opaque_array(options): """Allocate a new :class:`OpaqueArray` on the current device. @@ -193,4 +165,4 @@ def _create_opaque_array(options): :class:`OpaqueArrayOptions` (or a mapping accepted by it); it is validated at construction, so ``shape`` is already a normalized tuple and ``format`` an :class:`~cuda.core.typing.ArrayFormatType`. - """ \ No newline at end of file + """ diff --git a/cuda_core/cuda/core/texture/_mipmapped_array.pyi b/cuda_core/cuda/core/texture/_mipmapped_array.pyi index db4413dbaf4..51835f8b36e 100644 --- a/cuda_core/cuda/core/texture/_mipmapped_array.pyi +++ b/cuda_core/cuda/core/texture/_mipmapped_array.pyi @@ -1,6 +1,4 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/texture/_mipmapped_array.pyx - -from __future__ import annotations +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/texture/_mipmapped_array.pyx from dataclasses import dataclass @@ -37,8 +35,7 @@ class MipmappedArrayOptions: num_levels: int is_surface_load_store: bool = False - def __post_init__(self): - ... + def __post_init__(self): ... class MipmappedArray: """A mipmapped CUDA array for texture/surface access across levels. @@ -54,19 +51,7 @@ class MipmappedArray: .. versionadded:: 1.1.0 """ - - def close(self): - """Release this object's reference to the underlying ``CUmipmappedArray``. - - Destruction (``cuMipmappedArrayDestroy``) happens via the handle's - deleter when the last reference is dropped. A level :class:`OpaqueArray` - from :meth:`get_level` holds its own reference to this mipmap's storage, - so it stays valid until both it and this object are released. Idempotent. - """ - - def __init__(self, *args, **kwargs): - ... - + def __init__(self, *args, **kwargs): ... def get_level(self, level): """Return a non-owning :class:`OpaqueArray` view of the given mip level. @@ -83,44 +68,39 @@ class MipmappedArray: returned :class:`OpaqueArray`; the underlying storage is released only when this :class:`MipmappedArray` is destroyed. """ - @property def handle(self): """The underlying ``CUmipmappedArray`` as an integer.""" - @property def shape(self): """Base-level (level 0) allocation shape, in elements.""" - @property def format(self): """The element :class:`~cuda.core.typing.ArrayFormatType`.""" - @property def num_channels(self): """Channels per element (1, 2, or 4).""" - @property def num_levels(self): """Number of mip levels.""" - @property def is_surface_load_store(self): """True if this mipmap (and each of its levels) was created with ``CUDA_ARRAY3D_SURFACE_LDST`` and can back a :class:`SurfaceObject`.""" - @property def device(self): """The :class:`Device` this mipmap was allocated on.""" + def close(self): + """Release this object's reference to the underlying ``CUmipmappedArray``. - def __enter__(self): - ... - - def __exit__(self, exc_type, exc, tb): - ... - - def __repr__(self): - ... + Destruction (``cuMipmappedArrayDestroy``) happens via the handle's + deleter when the last reference is dropped. A level :class:`OpaqueArray` + from :meth:`get_level` holds its own reference to this mipmap's storage, + so it stays valid until both it and this object are released. Idempotent. + """ + def __enter__(self): ... + def __exit__(self, exc_type, exc, tb): ... + def __repr__(self): ... def _create_mipmapped_array(options): """Allocate a new :class:`MipmappedArray` on the current device. @@ -128,4 +108,4 @@ def _create_mipmapped_array(options): Backs :meth:`cuda.core.Device.create_mipmapped_array`. ``options`` is a :class:`MipmappedArrayOptions` (or a mapping accepted by it); its fields are validated at construction. - """ \ No newline at end of file + """ diff --git a/cuda_core/cuda/core/texture/_surface.pyi b/cuda_core/cuda/core/texture/_surface.pyi index 977268abd5f..67eae47c9bb 100644 --- a/cuda_core/cuda/core/texture/_surface.pyi +++ b/cuda_core/cuda/core/texture/_surface.pyi @@ -1,7 +1,4 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/texture/_surface.pyx - -from __future__ import annotations - +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/texture/_surface.pyx class SurfaceObject: """A bindless surface handle for kernel-side typed load/store. @@ -19,38 +16,25 @@ class SurfaceObject: .. versionadded:: 1.1.0 """ - - def close(self): - """Release this object's reference to the underlying ``CUsurfObject``. - - Destruction (``cuSurfObjectDestroy``) and release of the backing array - happen via the handle's deleter when the last reference is dropped. - Idempotent. - """ - - def __init__(self, *args, **kwargs): - ... - + def __init__(self, *args, **kwargs): ... @property def handle(self): """The underlying ``CUsurfObject`` as an integer (64-bit kernel arg).""" - @property def resource(self): """The :class:`ResourceDescriptor` this surface was built from.""" - @property - def device(self): - ... - - def __enter__(self): - ... - - def __exit__(self, exc_type, exc, tb): - ... + def device(self): ... + def close(self): + """Release this object's reference to the underlying ``CUsurfObject``. - def __repr__(self): - ... + Destruction (``cuSurfObjectDestroy``) and release of the backing array + happen via the handle's deleter when the last reference is dropped. + Idempotent. + """ + def __enter__(self): ... + def __exit__(self, exc_type, exc, tb): ... + def __repr__(self): ... def _create_surface_object(resource): """Create a :class:`SurfaceObject` on the current device. @@ -59,4 +43,4 @@ def _create_surface_object(resource): :class:`ResourceDescriptor` wrapping an :class:`OpaqueArray` allocated with ``is_surface_load_store=True``; linear/pitch2d resources are not valid surface backings. - """ \ No newline at end of file + """ diff --git a/cuda_core/cuda/core/texture/_texture.pyi b/cuda_core/cuda/core/texture/_texture.pyi index 7840585bb4d..f475d8cb239 100644 --- a/cuda_core/cuda/core/texture/_texture.pyi +++ b/cuda_core/cuda/core/texture/_texture.pyi @@ -1,12 +1,17 @@ -# This file was generated by stubgen-pyx v0.2.6 from cuda_core/cuda/core/texture/_texture.pyx - -from __future__ import annotations +# This file was generated by stubgen-pyx v0.2.19 from cuda_core/cuda/core/texture/_texture.pyx from dataclasses import dataclass from cuda.bindings import cydriver from cuda.core.typing import AddressModeType, FilterModeType, ReadModeType +_TRSF_READ_AS_INTEGER = 1 +_TRSF_NORMALIZED_COORDINATES = 2 +_TRSF_SRGB = 16 +_TRSF_DISABLE_TRILINEAR_OPTIMIZATION = 32 +_TRSF_SEAMLESS_CUBEMAP = 64 +_ADDRESSMODE_TO_CU = {AddressModeType.WRAP: int(cydriver.CU_TR_ADDRESS_MODE_WRAP), AddressModeType.CLAMP: int(cydriver.CU_TR_ADDRESS_MODE_CLAMP), AddressModeType.MIRROR: int(cydriver.CU_TR_ADDRESS_MODE_MIRROR), AddressModeType.BORDER: int(cydriver.CU_TR_ADDRESS_MODE_BORDER)} +_FILTERMODE_TO_CU = {FilterModeType.POINT: int(cydriver.CU_TR_FILTER_MODE_POINT), FilterModeType.LINEAR: int(cydriver.CU_TR_FILTER_MODE_LINEAR)} class ResourceDescriptor: """Describes the memory backing a :class:`TextureObject`. @@ -30,13 +35,10 @@ class ResourceDescriptor: """ __slots__ = ('_kind', '_source', '_format', '_num_channels', '_size_bytes', '_width', '_height', '_pitch_bytes') - def __init__(self): - ... - + def __init__(self): ... @classmethod def from_opaque_array(cls, array): """Build a resource descriptor backed by a :class:`OpaqueArray`.""" - @classmethod def from_mipmapped_array(cls, mipmapped_array): """Build a resource descriptor backed by a :class:`MipmappedArray`. @@ -46,7 +48,6 @@ class ResourceDescriptor: require a single :class:`OpaqueArray` level (obtain via :meth:`MipmappedArray.get_level`). """ - @classmethod def from_linear(cls, buffer, *, format, num_channels, size_bytes=None): """Build a resource descriptor for a linear (typed 1D) texture fetch. @@ -71,7 +72,6 @@ class ResourceDescriptor: :class:`TextureObjectOptions` addressing/filtering fields — kernels read through a typed 1D fetch with bounds checking only. """ - @classmethod def from_pitch2d(cls, buffer, *, format, num_channels, width, height, pitch_bytes): """Build a resource descriptor for a row-pitched 2D image. @@ -95,41 +95,29 @@ class ResourceDescriptor: ``width * format_size * num_channels`` and meet the driver's ``CU_DEVICE_ATTRIBUTE_TEXTURE_PITCH_ALIGNMENT``. """ - @property - def kind(self): - ... - + def kind(self): ... @property - def source(self): - ... - + def source(self): ... @property def format(self): """The element :class:`~cuda.core.typing.ArrayFormatType` (``None`` for array-backed).""" - @property def num_channels(self): """Channels per element (``None`` for array-backed).""" - @property def size_bytes(self): """Bytes bound for a linear resource (``None`` for other kinds).""" - @property def width(self): """Pitch2D image width, in elements (``None`` for other kinds).""" - @property def height(self): """Pitch2D image height, in rows (``None`` for other kinds).""" - @property def pitch_bytes(self): """Pitch2D row pitch, in bytes (``None`` for other kinds).""" - - def __repr__(self): - ... + def __repr__(self): ... @dataclass class TextureObjectOptions: @@ -182,8 +170,7 @@ class TextureObjectOptions: max_mipmap_level_clamp: float = 0.0 border_color: tuple[float, ...] | None = None - def __post_init__(self): - ... + def __post_init__(self): ... class TextureObject: """A bindless texture handle for kernel-side sampled reads. @@ -197,61 +184,38 @@ class TextureObject: .. versionadded:: 1.1.0 """ - - def close(self): - """Release this object's reference to the underlying ``CUtexObject``. - - Destruction (``cuTexObjectDestroy``) and release of the backing resource - happen via the handle's deleter when the last reference is dropped. - Idempotent. - """ - - def __init__(self, *args, **kwargs): - ... - + def __init__(self, *args, **kwargs): ... @property def handle(self): """The underlying ``CUtexObject`` as an integer (64-bit kernel arg).""" - @property def resource(self): """The :class:`ResourceDescriptor` this texture was built from.""" - @property def options(self): """The :class:`TextureObjectOptions` this texture was built from.""" - @property - def device(self): - ... - - def __enter__(self): - ... - - def __exit__(self, exc_type, exc, tb): - ... + def device(self): ... + def close(self): + """Release this object's reference to the underlying ``CUtexObject``. - def __repr__(self): - ... -_TRSF_READ_AS_INTEGER = 1 -_TRSF_NORMALIZED_COORDINATES = 2 -_TRSF_SRGB = 16 -_TRSF_DISABLE_TRILINEAR_OPTIMIZATION = 32 -_TRSF_SEAMLESS_CUBEMAP = 64 -_ADDRESSMODE_TO_CU = {AddressModeType.WRAP: int(cydriver.CU_TR_ADDRESS_MODE_WRAP), AddressModeType.CLAMP: int(cydriver.CU_TR_ADDRESS_MODE_CLAMP), AddressModeType.MIRROR: int(cydriver.CU_TR_ADDRESS_MODE_MIRROR), AddressModeType.BORDER: int(cydriver.CU_TR_ADDRESS_MODE_BORDER)} -_FILTERMODE_TO_CU = {FilterModeType.POINT: int(cydriver.CU_TR_FILTER_MODE_POINT), FilterModeType.LINEAR: int(cydriver.CU_TR_FILTER_MODE_LINEAR)} + Destruction (``cuTexObjectDestroy``) and release of the backing resource + happen via the handle's deleter when the last reference is dropped. + Idempotent. + """ + def __enter__(self): ... + def __exit__(self, exc_type, exc, tb): ... + def __repr__(self): ... def _normalize_enum(name, value, enum_type): """Coerce ``value`` to ``enum_type`` (a StrEnum), accepting a plain str.""" - def _normalize_address_modes(address_mode): """Return a 3-tuple of :class:`AddressModeType` values from a scalar or 1-3 tuple. Individual entries may be plain strings.""" - def _create_texture_object(resource, options): """Create a :class:`TextureObject` on the current device. Backs :meth:`cuda.core.Device.create_texture_object`. ``resource`` is a :class:`ResourceDescriptor`; ``options`` is a :class:`TextureObjectOptions` (or a mapping accepted by it). - """ \ No newline at end of file + """ diff --git a/cuda_core/pyproject.toml b/cuda_core/pyproject.toml index f3afa29241d..4c2c65e9b3f 100644 --- a/cuda_core/pyproject.toml +++ b/cuda_core/pyproject.toml @@ -155,6 +155,14 @@ ignore_missing_imports = true module = "cuda.core._utils.cuda_utils" disable_error_code = ["type-arg"] +[[tool.mypy.overrides]] +# stubgen-pyx can't resolve DLPackExchangeAPI's C function-pointer typedef +# fields and emits bare "..." as their annotation, which is invalid outside +# a Callable[...] context. Suppress until upstream is fixed: +# https://github.com/jon-edward/stubgen-pyx/issues (report pending) +module = "cuda.core._dlpack" +disable_error_code = ["misc"] + [tool.cibuildwheel] skip = "*-musllinux_*" build-verbosity = 1 diff --git a/toolshed/run_stubgen_pyx.py b/toolshed/run_stubgen_pyx.py deleted file mode 100644 index 1a163ff0778..00000000000 --- a/toolshed/run_stubgen_pyx.py +++ /dev/null @@ -1,54 +0,0 @@ -# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -"""Run stubgen-pyx for cuda_core and normalize the generated stub headers. - -stubgen-pyx emits a path using the OS path separator in the first-line comment -(e.g. "# This file was generated by stubgen-pyx from cuda_core\\cuda\\..."). -This wrapper rewrites that separator to "/" so committed stubs are identical -across platforms. Line-ending normalization is handled by .gitattributes. - -This also forces stubgen-pyx to write files with UTF-8 encoding, which is not -the default on Windows. - -This wrapper can be removed once these stubgen-pyx issues are resolved: - https://github.com/jon-edward/stubgen-pyx/issues/41 - https://github.com/jon-edward/stubgen-pyx/issues/42 -""" - -from __future__ import annotations - -import os -import pathlib -import subprocess -import sys - -_HEADER_PREFIX = b"# This file was generated by stubgen-pyx" - - -def _normalize_stub_headers(root: pathlib.Path) -> None: - for stub in root.rglob("*.pyi"): - data = stub.read_bytes() - newline = data.find(b"\n") - first_line = data[:newline] if newline != -1 else data - if not first_line.startswith(_HEADER_PREFIX) or b"\\" not in first_line: - continue - stub.write_bytes(first_line.replace(b"\\", b"/") + data[newline:]) - - -def main() -> int: - env = os.environ.copy() - env.setdefault("PYTHONUTF8", "1") - env.setdefault("PYTHONIOENCODING", "utf-8") - result = subprocess.run( - ["stubgen-pyx", "cuda_core/cuda", "--continue-on-error", "--include-private"], # noqa: S607 - env=env, - ) - if result.returncode != 0: - return result.returncode - _normalize_stub_headers(pathlib.Path("cuda_core/cuda")) - return 0 - - -if __name__ == "__main__": - sys.exit(main())