Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,6 @@ jobs:

- name: Install test dependencies and coverage tools
run: |
.venv/Scripts/pip install -v ./cuda_python_test_helpers
.venv/Scripts/pip install coverage pytest-cov Cython
.venv/Scripts/pip install --group ./cuda_pathfinder/pyproject.toml:test
.venv/Scripts/pip install --group ./cuda_bindings/pyproject.toml:test
Expand Down
6 changes: 0 additions & 6 deletions cuda_bindings/cuda/bindings/_test_helpers/__init__.py

This file was deleted.

70 changes: 0 additions & 70 deletions cuda_bindings/cuda/bindings/_test_helpers/arch_check.py

This file was deleted.

3 changes: 3 additions & 0 deletions cuda_bindings/pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ cuda-version = ["12.*", "13.3.*"]
[feature.test.dependencies]
cuda-bindings = { path = "." }
pytest = ">=6.2.4"

[feature.test.pypi-dependencies]
cuda-python-test-helpers = { path = "../cuda_python_test_helpers", editable = true }
pytest-benchmark = ">=3.4.1"
pytest-randomly = "*"
pytest-repeat = "*"
Expand Down
28 changes: 15 additions & 13 deletions cuda_bindings/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,32 @@
# SPDX-License-Identifier: Apache-2.0

import functools
import importlib
import inspect
import pathlib
import sys
from contextlib import contextmanager
from importlib.metadata import PackageNotFoundError, distribution

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"
# Keep in sync with cuda_core/tests/conftest.py.
try:
distribution("cuda-python-test-helpers")
except PackageNotFoundError as exc:
import cuda_python_test_helpers._pytest_plugin # noqa: F401
except ImportError as e:
# Don't call .resolve(): resolving symlinks can make parents[2] point
# somewhere other than the monorepo root if a sub-directory is symlinked.
_test_helpers_root = pathlib.Path(__file__).parents[2] / "cuda_python_test_helpers"
if not _test_helpers_root.is_dir():
raise RuntimeError(
f"cuda-python-test-helpers not installed; expected checkout path {_test_helpers_root}"
) from exc

test_helpers_root = str(_test_helpers_root)
if test_helpers_root not in sys.path:
sys.path.insert(0, test_helpers_root)
raise RuntimeError(f"cuda-python-test-helpers not installed and not found at {_test_helpers_root}") from e
for _k in list(sys.modules):
if _k == "cuda_python_test_helpers" or _k.startswith("cuda_python_test_helpers."):
del sys.modules[_k]
sys.path.insert(0, str(_test_helpers_root))
importlib.invalidate_caches()

pytest_plugins = ["cuda_python_test_helpers._pytest_plugin"]


def pytest_configure(config):
Expand Down
3 changes: 1 addition & 2 deletions cuda_bindings/tests/nvml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@


import pytest

from cuda.bindings._test_helpers.arch_check import hardware_supports_nvml
from cuda_python_test_helpers.arch_check import hardware_supports_nvml

if not hardware_supports_nvml():
pytest.skip("NVML not supported on this platform", allow_module_level=True)
2 changes: 1 addition & 1 deletion cuda_bindings/tests/nvml/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from collections import namedtuple

import pytest
from cuda_python_test_helpers.arch_check import unsupported_before # noqa: F401

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


class NVMLInitializer:
Expand Down
6 changes: 3 additions & 3 deletions cuda_bindings/tests/nvml/test_pynvml.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import pytest

from cuda.bindings import nvml
from cuda_python_test_helpers import IS_WINDOWS, IS_WSL

from . import util
from .conftest import unsupported_before

XFAIL_LEGACY_NVLINK_MSG = "Legacy NVLink test expected to fail."
Expand Down Expand Up @@ -64,7 +64,7 @@ def test_device_get_handle_by_pci_bus_id(ngpus, pci_info):


@pytest.mark.parametrize("scope", [nvml.AffinityScope.NODE, nvml.AffinityScope.SOCKET])
@pytest.mark.skipif(util.is_wsl() or util.is_windows(), reason="Not supported on WSL or Windows")
@pytest.mark.skipif(IS_WSL or IS_WINDOWS, reason="Not supported on WSL or Windows")
def test_device_get_memory_affinity(handles, scope):
size = 1024
for handle in handles:
Expand All @@ -75,7 +75,7 @@ def test_device_get_memory_affinity(handles, scope):


@pytest.mark.parametrize("scope", [nvml.AffinityScope.NODE, nvml.AffinityScope.SOCKET])
@pytest.mark.skipif(util.is_wsl() or util.is_windows(), reason="Not supported on WSL or Windows")
@pytest.mark.skipif(IS_WSL or IS_WINDOWS, reason="Not supported on WSL or Windows")
def test_device_get_cpu_affinity_within_scope(handles, scope):
size = 1024
for handle in handles:
Expand Down
21 changes: 0 additions & 21 deletions cuda_bindings/tests/nvml/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,8 @@
# SPDX-License-Identifier: Apache-2.0


import functools
import platform
from pathlib import Path

from cuda.bindings import nvml

current_os = platform.system()
if current_os == "VMkernel":
current_os = "Linux" # Treat VMkernel as Linux


def is_windows(os=current_os):
return os == "Windows"


def is_linux(os=current_os):
return os == "Linux"


@functools.cache
def is_wsl(os=current_os):
return os == "Linux" and "microsoft" in Path("/proc/version").read_text().lower()


def is_vgpu(device):
"""
Expand Down
2 changes: 1 addition & 1 deletion cuda_bindings/tests/test_cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

import numpy as np
import pytest
from cuda_python_test_helpers.mempool import xfail_if_mempool_oom

import cuda.bindings.driver as cuda
import cuda.bindings.runtime as cudart
from cuda.bindings import driver
from cuda.bindings._test_helpers.mempool import xfail_if_mempool_oom


def driverVersionLessThan(target):
Expand Down
2 changes: 1 addition & 1 deletion cuda_bindings/tests/test_cudart.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

import numpy as np
import pytest
from cuda_python_test_helpers.mempool import xfail_if_mempool_oom

import cuda.bindings.driver as cuda
import cuda.bindings.runtime as cudart
from cuda import pathfinder
from cuda.bindings import runtime
from cuda.bindings._test_helpers.mempool import xfail_if_mempool_oom


def isSuccess(err):
Expand Down
3 changes: 1 addition & 2 deletions cuda_bindings/tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
import sys

import pytest

from cuda.bindings._test_helpers.pep723 import has_package_requirements_or_skip
from cuda_python_test_helpers.pep723 import has_package_requirements_or_skip

examples_path = os.path.join(os.path.dirname(__file__), "..", "examples")
examples_files = glob.glob(os.path.join(examples_path, "**/*.py"), recursive=True)
Expand Down
2 changes: 1 addition & 1 deletion cuda_bindings/tests/test_interoperability.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

import numpy as np
import pytest
from cuda_python_test_helpers.mempool import xfail_if_mempool_oom

import cuda.bindings.driver as cuda
import cuda.bindings.runtime as cudart
from cuda.bindings._test_helpers.mempool import xfail_if_mempool_oom


def supportsMemoryPool():
Expand Down
3 changes: 3 additions & 0 deletions cuda_core/pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ cuda-version = ["12.*", "13.3.*"]
cuda-core = { path = "." }
ml_dtypes = "*"
pytest = "*"

[feature.test.pypi-dependencies]
cuda-python-test-helpers = { path = "../cuda_python_test_helpers", editable = true }
pytest-benchmark = "*"
pytest-randomly = "*"
pytest-repeat = "*"
Expand Down
Loading
Loading