Skip to content
Closed
14 changes: 7 additions & 7 deletions cuda_core/cuda/core/experimental/_linker.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import weakref
from contextlib import contextmanager
from dataclasses import dataclass
from typing import TYPE_CHECKING, List, Tuple, Union
from typing import TYPE_CHECKING, Union
from warnings import warn

if TYPE_CHECKING:
Expand Down Expand Up @@ -140,14 +140,14 @@ class LinkerOptions:
fma : bool, optional
Use fast multiply-add.
Default: True.
kernels_used : [Union[str, Tuple[str], List[str]]], optional
kernels_used : [Union[str, tuple[str], list[str]]], optional
Pass a kernel or sequence of kernels that are used; any not in the list can be removed.
variables_used : [Union[str, Tuple[str], List[str]]], optional
variables_used : [Union[str, tuple[str], list[str]]], optional
Pass a variable or sequence of variables that are used; any not in the list can be removed.
optimize_unused_variables : bool, optional
Assume that if a variable is not referenced in device code, it can be removed.
Default: False.
ptxas_options : [Union[str, Tuple[str], List[str]]], optional
ptxas_options : [Union[str, tuple[str], list[str]]], optional
Pass options to PTXAS.
split_compile : int, optional
Split compilation maximum thread count. Use 0 to use all available processors. Value of 1 disables split
Expand Down Expand Up @@ -177,10 +177,10 @@ class LinkerOptions:
prec_div: bool | None = None
prec_sqrt: bool | None = None
fma: bool | None = None
kernels_used: Union[str, Tuple[str], List[str]] | None = None
variables_used: Union[str, Tuple[str], List[str]] | None = None
kernels_used: Union[str, tuple[str], list[str]] | None = None
variables_used: Union[str, tuple[str], list[str]] | None = None
optimize_unused_variables: bool | None = None
ptxas_options: Union[str, Tuple[str], List[str]] | None = None
ptxas_options: Union[str, tuple[str], list[str]] | None = None
split_compile: int | None = None
split_compile_extended: int | None = None
no_cache: bool | None = None
Expand Down
10 changes: 5 additions & 5 deletions cuda_core/cuda/core/experimental/_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import abc
import weakref
from typing import Tuple, TypeVar, Union
from typing import TypeVar, Union

from cuda.core.experimental._dlpack import DLDeviceType, make_py_capsule
from cuda.core.experimental._stream import Stream, default_stream
Expand Down Expand Up @@ -169,8 +169,8 @@ def __dlpack__(
self,
*,
stream: int | None = None,
max_version: Tuple[int, int] | None = None,
dl_device: Tuple[int, int] | None = None,
max_version: tuple[int, int] | None = None,
dl_device: tuple[int, int] | None = None,
copy: bool | None = None,
) -> PyCapsule:
# Note: we ignore the stream argument entirely (as if it is -1).
Expand All @@ -183,12 +183,12 @@ def __dlpack__(
versioned = False
else:
if not isinstance(max_version, tuple) or len(max_version) != 2:
raise BufferError(f"Expected max_version Tuple[int, int], got {max_version}")
raise BufferError(f"Expected max_version tuple[int, int], got {max_version}")
versioned = max_version >= (1, 0)
capsule = make_py_capsule(self, versioned)
return capsule

def __dlpack_device__(self) -> Tuple[int, int]:
def __dlpack_device__(self) -> tuple[int, int]:
d_h = (bool(self.is_device_accessible), bool(self.is_host_accessible))
if d_h == (True, False):
return (DLDeviceType.kDLCUDA, self.device_id)
Expand Down
44 changes: 22 additions & 22 deletions cuda_core/cuda/core/experimental/_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import weakref
from dataclasses import dataclass
from typing import TYPE_CHECKING, List, Tuple, Union
from typing import TYPE_CHECKING, Union
from warnings import warn

if TYPE_CHECKING:
Expand All @@ -33,22 +33,22 @@ def _process_define_macro_inner(formatted_options, macro):
return True
if isinstance(macro, tuple):
if len(macro) != 2 or any(not isinstance(val, str) for val in macro):
raise RuntimeError(f"Expected define_macro Tuple[str, str], got {macro}")
raise RuntimeError(f"Expected define_macro tuple[str, str], got {macro}")
formatted_options.append(f"--define-macro={macro[0]}={macro[1]}")
return True
return False


def _process_define_macro(formatted_options, macro):
union_type = "Union[str, Tuple[str, str]]"
union_type = "Union[str, tuple[str, str]]"
if _process_define_macro_inner(formatted_options, macro):
return
if is_nested_sequence(macro):
for seq_macro in macro:
if not _process_define_macro_inner(formatted_options, seq_macro):
raise RuntimeError(f"Expected define_macro {union_type}, got {seq_macro}")
return
raise RuntimeError(f"Expected define_macro {union_type}, List[{union_type}], got {macro}")
raise RuntimeError(f"Expected define_macro {union_type}, list[{union_type}], got {macro}")


@dataclass
Expand Down Expand Up @@ -79,7 +79,7 @@ class ProgramOptions:
Enable device code optimization. When specified along with ‘-G’, enables limited debug information generation
for optimized device code.
Default: None
ptxas_options : Union[str, List[str]], optional
ptxas_options : Union[str, list[str]], optional
Specify one or more options directly to ptxas, the PTX optimizing assembler. Options should be strings.
For example ["-v", "-O2"].
Default: None
Expand Down Expand Up @@ -113,17 +113,17 @@ class ProgramOptions:
gen_opt_lto : bool, optional
Run the optimizer passes before generating the LTO IR.
Default: False
define_macro : Union[str, Tuple[str, str], List[Union[str, Tuple[str, str]]]], optional
define_macro : Union[str, tuple[str, str], list[Union[str, tuple[str, str]]]], optional
Predefine a macro. Can be either a string, in which case that macro will be set to 1, a 2 element tuple of
strings, in which case the first element is defined as the second, or a list of strings or tuples.
Default: None
undefine_macro : Union[str, List[str]], optional
undefine_macro : Union[str, list[str]], optional
Cancel any previous definition of a macro, or list of macros.
Default: None
include_path : Union[str, List[str]], optional
include_path : Union[str, list[str]], optional
Add the directory or directories to the list of directories to be searched for headers.
Default: None
pre_include : Union[str, List[str]], optional
pre_include : Union[str, list[str]], optional
Preinclude one or more headers during preprocessing. Can be either a string or a list of strings.
Default: None
no_source_include : bool, optional
Expand Down Expand Up @@ -156,13 +156,13 @@ class ProgramOptions:
no_display_error_number : bool, optional
Disable the display of a diagnostic number for warning messages.
Default: False
diag_error : Union[int, List[int]], optional
diag_error : Union[int, list[int]], optional
Emit error for a specified diagnostic message number or comma separated list of numbers.
Default: None
diag_suppress : Union[int, List[int]], optional
diag_suppress : Union[int, list[int]], optional
Suppress a specified diagnostic message number or comma separated list of numbers.
Default: None
diag_warn : Union[int, List[int]], optional
diag_warn : Union[int, list[int]], optional
Emit warning for a specified diagnostic message number or comma separated lis of numbers.
Default: None
brief_diagnostics : bool, optional
Expand All @@ -189,7 +189,7 @@ class ProgramOptions:
debug: bool | None = None
lineinfo: bool | None = None
device_code_optimize: bool | None = None
ptxas_options: Union[str, List[str], Tuple[str]] | None = None
ptxas_options: Union[str, list[str], tuple[str]] | None = None
max_register_count: int | None = None
ftz: bool | None = None
prec_sqrt: bool | None = None
Expand All @@ -200,11 +200,11 @@ class ProgramOptions:
link_time_optimization: bool | None = None
gen_opt_lto: bool | None = None
define_macro: (
Union[str, Tuple[str, str], List[Union[str, Tuple[str, str]]], Tuple[Union[str, Tuple[str, str]]]] | None
Union[str, tuple[str, str], list[Union[str, tuple[str, str]]], tuple[Union[str, tuple[str, str]]]] | None
) = None
undefine_macro: Union[str, List[str], Tuple[str]] | None = None
include_path: Union[str, List[str], Tuple[str]] | None = None
pre_include: Union[str, List[str], Tuple[str]] | None = None
undefine_macro: Union[str, list[str], tuple[str]] | None = None
include_path: Union[str, list[str], tuple[str]] | None = None
pre_include: Union[str, list[str], tuple[str]] | None = None
no_source_include: bool | None = None
std: str | None = None
builtin_move_forward: bool | None = None
Expand All @@ -215,9 +215,9 @@ class ProgramOptions:
device_int128: bool | None = None
optimization_info: str | None = None
no_display_error_number: bool | None = None
diag_error: Union[int, List[int], Tuple[int]] | None = None
diag_suppress: Union[int, List[int], Tuple[int]] | None = None
diag_warn: Union[int, List[int], Tuple[int]] | None = None
diag_error: Union[int, list[int], tuple[int]] | None = None
diag_suppress: Union[int, list[int], tuple[int]] | None = None
diag_warn: Union[int, list[int], tuple[int]] | None = None
brief_diagnostics: bool | None = None
time: str | None = None
split_compile: int | None = None
Expand Down Expand Up @@ -453,8 +453,8 @@ def compile(self, target_type, name_expressions=(), logs=None):
target_type : Any
String of the targeted compilation type.
Supported options are "ptx", "cubin" and "ltoir".
name_expressions : Union[List, Tuple], optional
List of explicit name expressions to become accessible.
name_expressions : Union[list, tuple], optional
list of explicit name expressions to become accessible.
(Default to no expressions)
logs : Any, optional
Object with a write method to receive the logs generated
Expand Down
4 changes: 1 addition & 3 deletions cuda_core/cuda/core/experimental/_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#
# SPDX-License-Identifier: Apache-2.0

from typing import Tuple

from cuda.core.experimental._device import Device
from cuda.core.experimental._utils.cuda_utils import driver, handle_return, runtime

Expand All @@ -26,7 +24,7 @@ def __init__(self):
self._initialized = True

@property
def driver_version(self) -> Tuple[int, int]:
def driver_version(self) -> tuple[int, int]:
"""
Query the CUDA driver version.

Expand Down
4 changes: 1 addition & 3 deletions cuda_core/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,9 @@ select = [
]

ignore = [
"UP006",
"UP007",
"UP007", # Use X | Y for union types (requires Python 3.10+, we support 3.9+)
"E741", # ambiguous variable name such as I
"B007", # rename unsued loop variable to _name
"UP035" # UP006, UP007, UP035 complain about deprecated Typing.<type> use, but disregard backward compatibility of python version
]

exclude = ["cuda/core/_version.py"]
Expand Down