Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
009c28d
Unify ruff config across sub-repos
cpcloud Feb 26, 2026
13d6ccb
Add ruff to pixi dependencies
cpcloud Feb 26, 2026
3ff3b9b
Update ruff config with review feedback
cpcloud Feb 27, 2026
4c472f3
fix(ruff/cuda_core): I001 sort imports
cpcloud Feb 27, 2026
deb8828
fix(ruff/cuda_core): RUF100 remove stale noqa comments
cpcloud Feb 27, 2026
c01fa30
fix(ruff/cuda_core): C4 simplify comprehensions
cpcloud Feb 27, 2026
28a5977
fix(ruff/cuda_core): PIE misc cleanup
cpcloud Feb 27, 2026
63702cf
fix(ruff/cuda_core): PT pytest-style fixes
cpcloud Feb 27, 2026
a730ec1
fix(ruff/cuda_core): RUF ruff-specific fixes
cpcloud Feb 27, 2026
48fabbd
fix(ruff/cuda_core): E pycodestyle fixes
cpcloud Feb 27, 2026
b675201
fix(ruff/cuda_core): N naming convention fixes
cpcloud Feb 27, 2026
b2c6578
fix(ruff/cuda_core): ARG unused argument suppression
cpcloud Feb 27, 2026
4b33abd
fix(ruff/cuda_core): F pyflakes fixes
cpcloud Feb 27, 2026
c94d839
fix(ruff/cuda_core): B bugbear fixes
cpcloud Feb 27, 2026
da79bdc
fix(ruff/cuda_core): S bandit security suppressions
cpcloud Feb 27, 2026
b61030f
fix(ruff/cuda_bindings): I001 sort imports
cpcloud Feb 27, 2026
c99baa3
fix(ruff/cuda_bindings): RUF100 remove stale noqa comments
cpcloud Feb 27, 2026
b3abd22
fix(ruff/cuda_bindings): C4 simplify comprehensions
cpcloud Feb 27, 2026
701c4ce
fix(ruff/cuda_bindings): PIE misc cleanup
cpcloud Feb 27, 2026
b38faf4
fix(ruff/cuda_bindings): PT pytest-style fixes
cpcloud Feb 27, 2026
67a1803
fix(ruff/cuda_bindings): F pyflakes fixes
cpcloud Feb 27, 2026
b527939
fix(ruff/cuda_bindings): S bandit security suppressions
cpcloud Feb 27, 2026
578d439
fix(ruff/cuda_pathfinder): RUF100 remove stale noqa comments
cpcloud Feb 27, 2026
cf8fe12
fix(ruff/cuda_pathfinder): SIM simplify code
cpcloud Feb 27, 2026
68cdef8
fix(ruff/cuda_pathfinder): S bandit security suppressions
cpcloud Feb 27, 2026
592f729
fix(ruff/cuda_python_test_helpers): I001 sort imports
cpcloud Feb 27, 2026
68c8ee8
fix(ruff/cuda_python_test_helpers): RUF100 remove stale noqa comments
cpcloud Feb 27, 2026
2e59977
fix(ruff/cuda_python_test_helpers): RUF ruff-specific fixes
cpcloud Feb 27, 2026
751d252
fix(ruff/toolshed): I001 sort imports
cpcloud Feb 27, 2026
5e86288
fix(ruff/toolshed): RUF100 remove stale noqa comments
cpcloud Feb 27, 2026
5f2cc88
fix(ruff/toolshed): DTZ datetime timezone fixes
cpcloud Feb 27, 2026
d39cab5
fix(ruff/toolshed): N naming convention fixes
cpcloud Feb 27, 2026
99e0a81
fix(ruff/toolshed): S bandit security suppressions
cpcloud Feb 27, 2026
4c97999
fix(ruff/ci): RUF100 remove stale noqa comments
cpcloud Feb 27, 2026
11e89ad
fix(ruff/ci): RUF ruff-specific fixes
cpcloud Feb 27, 2026
15f39a5
fix(ruff/ci): S bandit security suppressions
cpcloud Feb 27, 2026
8332d62
fix(ruff/root): ARG unused argument suppression
cpcloud Feb 27, 2026
f843dd4
fixup: correct S noqa placement for multiline calls
cpcloud Feb 27, 2026
e3a033f
fix(ruff): apply ruff formatting
cpcloud Feb 27, 2026
1e931db
fix(ruff): add RUF012 to test/benchmark per-file-ignores
cpcloud Feb 27, 2026
b303f85
fix(core): use CUmemAllocationType for VMM allocation enums
cpcloud Mar 2, 2026
9e39ad0
fix(tests): use pytest.param in test_utils
cpcloud Mar 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ci/tools/merge_cuda_core_wheels.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from typing import List


def run_command(cmd: List[str], cwd: Path = None, env: dict = os.environ) -> subprocess.CompletedProcess:
def run_command(cmd: List[str], cwd: Path | None = None, env: dict = os.environ) -> subprocess.CompletedProcess:
"""Run a command with error handling."""
print(f"Running: {' '.join(cmd)}")
if cwd:
Expand All @@ -47,7 +47,7 @@ def run_command(cmd: List[str], cwd: Path = None, env: dict = os.environ) -> sub
return result


def print_wheel_directory_structure(wheel_path: Path, filter_prefix: str = "cuda/core/", label: str = None):
def print_wheel_directory_structure(wheel_path: Path, filter_prefix: str = "cuda/core/", label: str | None = None):
"""Print the directory structure of a wheel file, similar to unzip -l output.

Args:
Expand Down
2 changes: 1 addition & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pytest


def pytest_collection_modifyitems(config, items):
def pytest_collection_modifyitems(config, items): # noqa: ARG001
cuda_home = os.environ.get("CUDA_HOME")
for item in items:
nodeid = item.nodeid.replace("\\", "/")
Expand Down
5 changes: 3 additions & 2 deletions cuda_bindings/benchmarks/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import numpy as np
import pytest

from cuda.bindings import driver as cuda
from cuda.bindings import nvrtc
from cuda.bindings import runtime as cudart
Expand All @@ -22,7 +23,7 @@ def ASSERT_DRV(err):
raise RuntimeError(f"Unknown error type: {err}")


@pytest.fixture(scope="function")
@pytest.fixture
def init_cuda():
# Initialize
(err,) = cuda.cuInit(0)
Expand All @@ -44,7 +45,7 @@ def init_cuda():
ASSERT_DRV(err)


@pytest.fixture(scope="function")
@pytest.fixture
def load_module():
module = None

Expand Down
2 changes: 1 addition & 1 deletion cuda_bindings/benchmarks/test_launch_latency.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import ctypes

import pytest
from cuda.bindings import driver as cuda
from kernels import kernel_string

from conftest import ASSERT_DRV
from cuda.bindings import driver as cuda


def launch(kernel, stream, args=(), arg_types=()):
Expand Down
2 changes: 1 addition & 1 deletion cuda_bindings/benchmarks/test_pointer_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import random

import pytest
from cuda.bindings import driver as cuda

from conftest import ASSERT_DRV
from cuda.bindings import driver as cuda

random.seed(0)

Expand Down
16 changes: 8 additions & 8 deletions cuda_bindings/build_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,20 +176,20 @@ def _parse_headers(header_dict, include_path_list, parser_caching):
CUDA_VERSION = parser.defs["macros"].get("CUDA_VERSION", "Unknown")
print(f"Found CUDA_VERSION: {CUDA_VERSION}", flush=True)

found_types += {key for key in parser.defs["types"]}
found_types += {key for key in parser.defs["structs"]}
found_types += {key for key in parser.defs["unions"]}
found_types += {key for key in parser.defs["enums"]}
found_functions += {key for key in parser.defs["functions"]}
found_values += {key for key in parser.defs["values"]}
found_types += set(parser.defs["types"])
found_types += set(parser.defs["structs"])
found_types += set(parser.defs["unions"])
found_types += set(parser.defs["enums"])
found_functions += set(parser.defs["functions"])
found_values += set(parser.defs["values"])

for key, value in parser.defs["structs"].items():
struct_list[key] = _Struct(key, value["members"])
for key, value in parser.defs["unions"].items():
struct_list[key] = _Struct(key, value["members"])

for key, value in struct_list.items():
if key.startswith("anon_union") or key.startswith("anon_struct"):
if key.startswith(("anon_union", "anon_struct")):
continue

found_struct += [key]
Expand Down Expand Up @@ -408,7 +408,7 @@ def _cleanup_dst_files():
)

# Cythonize
cython_directives = dict(language_level=3, embedsignature=True, binding=True, freethreading_compatible=True)
cython_directives = {"language_level": 3, "embedsignature": True, "binding": True, "freethreading_compatible": True}
if compile_for_coverage:
cython_directives["linetrace"] = True

Expand Down
1 change: 1 addition & 0 deletions cuda_bindings/cuda/bindings/_test_helpers/arch_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from functools import cache

import pytest

from cuda.bindings import nvml


Expand Down
5 changes: 3 additions & 2 deletions cuda_bindings/examples/0_Introduction/clock_nvrtc_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import numpy as np
from common import common
from common.helper_cuda import checkCudaErrors, findCudaDevice

from cuda.bindings import driver as cuda

clock_nvrtc = """\
Expand Down Expand Up @@ -67,7 +68,7 @@ def main():
timer = np.empty(NUM_BLOCKS * 2, dtype="int64")
hinput = np.empty(NUM_THREADS * 2, dtype="float32")

for i in range(0, NUM_THREADS * 2):
for i in range(NUM_THREADS * 2):
hinput[i] = i

devID = findCudaDevice()
Expand Down Expand Up @@ -105,7 +106,7 @@ def main():

avgElapsedClocks = 0.0

for i in range(0, NUM_BLOCKS):
for i in range(NUM_BLOCKS):
avgElapsedClocks += timer[i + NUM_BLOCKS] - timer[i]

avgElapsedClocks = avgElapsedClocks / NUM_BLOCKS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import numpy as np
from common import common
from common.helper_cuda import checkCudaErrors, findCudaDevice

from cuda.bindings import driver as cuda
from cuda.bindings import runtime as cudart

Expand Down
1 change: 1 addition & 0 deletions cuda_bindings/examples/0_Introduction/simpleP2P_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import numpy as np
from common import common
from common.helper_cuda import checkCudaErrors

from cuda.bindings import driver as cuda
from cuda.bindings import runtime as cudart

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from common import common
from common.helper_cuda import checkCudaErrors
from common.helper_string import checkCmdLineFlag, getCmdLineArgumentInt

from cuda.bindings import driver as cuda
from cuda.bindings import runtime as cudart

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import numpy as np
from common import common
from common.helper_cuda import checkCudaErrors, findCudaDevice

from cuda.bindings import driver as cuda
from cuda.bindings import runtime as cudart

Expand Down
1 change: 1 addition & 0 deletions cuda_bindings/examples/0_Introduction/vectorAddDrv_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import numpy as np
from common import common
from common.helper_cuda import checkCudaErrors, findCudaDeviceDRV

from cuda.bindings import driver as cuda

vectorAddDrv = """\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import numpy as np
from common import common
from common.helper_cuda import checkCudaErrors, findCudaDeviceDRV

from cuda.bindings import driver as cuda

vectorAddMMAP = """\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from common import common
from common.helper_cuda import checkCudaErrors, findCudaDevice
from common.helper_string import checkCmdLineFlag

from cuda.bindings import driver as cuda
from cuda.bindings import runtime as cudart

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from common import common
from common.helper_cuda import checkCudaErrors, findCudaDevice
from common.helper_string import checkCmdLineFlag, getCmdLineArgumentInt

from cuda.bindings import driver as cuda
from cuda.bindings import runtime as cudart

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import numpy as np
from common import common
from common.helper_cuda import checkCudaErrors, findCudaDevice

from cuda.bindings import driver as cuda
from cuda.bindings import runtime as cudart

Expand Down Expand Up @@ -116,7 +117,7 @@
def init_input(a, size):
ctypes.c_float.from_address(a)
a_list = ctypes.pointer(ctypes.c_float.from_address(a))
for i in range(0, size):
for i in range(size):
a_list[i] = rnd.random()


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import numpy as np
from common import common
from common.helper_cuda import checkCudaErrors, findCudaDevice

from cuda.bindings import driver as cuda
from cuda.bindings import runtime as cudart

Expand Down
1 change: 1 addition & 0 deletions cuda_bindings/examples/common/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import numpy as np
from common.helper_cuda import checkCudaErrors

from cuda import pathfinder
from cuda.bindings import driver as cuda
from cuda.bindings import nvrtc
Expand Down
1 change: 1 addition & 0 deletions cuda_bindings/examples/common/helper_cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE

from common.helper_string import checkCmdLineFlag, getCmdLineArgumentInt

from cuda.bindings import driver as cuda
from cuda.bindings import nvrtc
from cuda.bindings import runtime as cudart
Expand Down
1 change: 1 addition & 0 deletions cuda_bindings/examples/extra/isoFDModelling_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import numpy as np
from common import common
from common.helper_cuda import checkCudaErrors

from cuda.bindings import driver as cuda
from cuda.bindings import runtime as cudart

Expand Down
1 change: 1 addition & 0 deletions cuda_bindings/examples/extra/jit_program_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import ctypes

import numpy as np

from cuda.bindings import driver as cuda
from cuda.bindings import nvrtc

Expand Down
5 changes: 3 additions & 2 deletions cuda_bindings/examples/extra/numba_emm_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,16 @@

from ctypes import c_size_t

from cuda.bindings import driver as cuda
from cuda.bindings import driver as cuda_driver
from numba.cuda import (
GetIpcHandleMixin,
HostOnlyCUDAMemoryManager,
MemoryInfo,
MemoryPointer,
)

from cuda.bindings import driver as cuda
from cuda.bindings import driver as cuda_driver

# Python functions for allocation, deallocation, and memory info via the NVIDIA
# CUDA Python Driver API

Expand Down
3 changes: 2 additions & 1 deletion cuda_bindings/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
import sys
from importlib.metadata import PackageNotFoundError, distribution

import cuda.bindings.driver as cuda
import pytest

import cuda.bindings.driver as cuda

# Import shared test helpers for tests across subprojects.
# PLEASE KEEP IN SYNC with copies in other conftest.py in this repo.
_test_helpers_root = pathlib.Path(__file__).resolve().parents[2] / "cuda_python_test_helpers"
Expand Down
1 change: 1 addition & 0 deletions cuda_bindings/tests/nvml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


import pytest

from cuda.bindings._test_helpers.arch_check import hardware_supports_nvml

if not hardware_supports_nvml():
Expand Down
3 changes: 2 additions & 1 deletion cuda_bindings/tests/nvml/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from collections import namedtuple

import pytest

from cuda.bindings import nvml
from cuda.bindings._test_helpers.arch_check import unsupported_before # noqa: F401

Expand Down Expand Up @@ -74,7 +75,7 @@ def get_devices(device_info):
@pytest.fixture
def all_devices(device_info):
with NVMLInitializer():
yield sorted(list(set(get_devices(device_info))))
yield sorted(set(get_devices(device_info)))


@pytest.fixture
Expand Down
1 change: 1 addition & 0 deletions cuda_bindings/tests/nvml/test_compute_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import sys

import pytest

from cuda.bindings import nvml

from .conftest import unsupported_before
Expand Down
1 change: 1 addition & 0 deletions cuda_bindings/tests/nvml/test_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from functools import cache

import pytest

from cuda.bindings import nvml

from .conftest import unsupported_before
Expand Down
1 change: 1 addition & 0 deletions cuda_bindings/tests/nvml/test_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import numpy as np
import pytest

from cuda.bindings import nvml

from . import util
Expand Down
5 changes: 3 additions & 2 deletions cuda_bindings/tests/nvml/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import warnings

import pytest

from cuda.bindings import nvml


Expand All @@ -24,10 +25,10 @@ def test_devices_are_the_same_architecture(all_devices):
# they won't be tested properly. This tests for the (hopefully rare) case
# where a system has devices of different architectures and produces a warning.

all_arches = set(nvml.DeviceArch(nvml.device_get_architecture(device)) for device in all_devices)
all_arches = {nvml.DeviceArch(nvml.device_get_architecture(device)) for device in all_devices}

if len(all_arches) > 1:
warnings.warn( # noqa: B028
warnings.warn(
f"System has devices of multiple architectures ({', '.join(x.name for x in all_arches)}). "
f" Some tests may be skipped unexpectedly",
UserWarning,
Expand Down
1 change: 1 addition & 0 deletions cuda_bindings/tests/nvml/test_page_retirement.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE

import pytest

from cuda.bindings import nvml

from . import util
Expand Down
1 change: 1 addition & 0 deletions cuda_bindings/tests/nvml/test_pynvml.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import time

import pytest

from cuda.bindings import nvml

from . import util
Expand Down
1 change: 1 addition & 0 deletions cuda_bindings/tests/test_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import sys

import pytest

from cuda.bindings._internal import _fast_enum

# Test both with the FastEnum implementation and the stdlib enum.IntEnum (even
Expand Down
Loading
Loading