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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions ci/tools/run-tests
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0

Expand All @@ -20,6 +20,14 @@ fi

test_module=${1}

FREE_THREADING=""
PYTEST_PARALLEL_ARGS=()
if python -c 'import sys; assert not sys._is_gil_enabled()' 2> /dev/null; then
FREE_THREADING="-ft"
PYTEST_PARALLEL_ARGS=(--parallel-threads=4)
pip install pytest-run-parallel
fi

# For standard modes, install pathfinder up front (it is a direct dependency
# of bindings, and a transitive dependency of core). Nightly modes install
# all wheels together in a single pip call further below.
Expand All @@ -36,7 +44,7 @@ if [[ "${test_module}" == "pathfinder" ]]; then
"LD:${CUDA_PATHFINDER_TEST_LOAD_NVIDIA_DYNAMIC_LIB_STRICTNESS} " \
"FH:${CUDA_PATHFINDER_TEST_FIND_NVIDIA_HEADERS_STRICTNESS} " \
"BC:${CUDA_PATHFINDER_TEST_FIND_NVIDIA_BITCODE_LIB_STRICTNESS}"
pytest -ra -s -v --durations=0 tests/ |& tee /tmp/pathfinder_test_log.txt
pytest -ra -s -v --durations=0 "${PYTEST_PARALLEL_ARGS[@]}" tests/ |& tee /tmp/pathfinder_test_log.txt
# Report the number of "INFO test_" lines (including zero)
# to support quick validations based on GHA log archives.
line_count=$(awk '/^INFO test_/ {count++} END {print count+0}' /tmp/pathfinder_test_log.txt)
Expand All @@ -51,21 +59,16 @@ elif [[ "${test_module}" == "bindings" ]]; then
pip install $(ls "${CUDA_BINDINGS_ARTIFACTS_DIR}"/*.whl)[all] --group test
fi
echo "Running bindings tests"
${SANITIZER_CMD} pytest -rxXs -v --durations=0 --randomly-dont-reorganize tests/
${SANITIZER_CMD} pytest -rxXs -v --durations=0 --randomly-dont-reorganize "${PYTEST_PARALLEL_ARGS[@]}" tests/
if [[ "${SKIP_CYTHON_TEST}" == 0 ]]; then
${SANITIZER_CMD} pytest -rxXs -v --durations=0 --randomly-dont-reorganize tests/cython
${SANITIZER_CMD} pytest -rxXs -v --durations=0 --randomly-dont-reorganize "${PYTEST_PARALLEL_ARGS[@]}" tests/cython
fi
popd
elif [[ "${test_module}" == "core" || "${test_module}" == nightly-* ]]; then
# Shared setup for core and nightly modes.
TEST_CUDA_MAJOR="$(cut -d '.' -f 1 <<< ${CUDA_VER})"
CUDA_VER_MINOR="$(cut -d '.' -f 1-2 <<< "${CUDA_VER}")"

FREE_THREADING=""
if python -c 'import sys; assert not sys._is_gil_enabled()' 2> /dev/null; then
FREE_THREADING+="-ft"
fi

# Resolve bindings based on BINDINGS_SOURCE (set by env-vars):
# main/backport → local wheel from artifacts dir
# published → install from PyPI by version
Expand Down Expand Up @@ -105,11 +108,11 @@ elif [[ "${test_module}" == "core" || "${test_module}" == nightly-* ]]; then
echo "Installed packages before core tests:"
pip list
echo "Running core tests"
${SANITIZER_CMD} pytest -rxXs -v --durations=0 --randomly-dont-reorganize tests/
${SANITIZER_CMD} pytest -rxXs -v --durations=0 --randomly-dont-reorganize "${PYTEST_PARALLEL_ARGS[@]}" tests/
# Currently our CI always installs the latest bindings (from either major version).
# This is not compatible with the test requirements.
if [[ "${SKIP_CYTHON_TEST}" == 0 ]]; then
${SANITIZER_CMD} pytest -rxXs -v --durations=0 --randomly-dont-reorganize tests/cython
${SANITIZER_CMD} pytest -rxXs -v --durations=0 --randomly-dont-reorganize "${PYTEST_PARALLEL_ARGS[@]}" tests/cython
fi
popd
elif [[ "${test_module}" == "nightly-cuda-core" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion cuda_bindings/tests/test_cufile.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def ctx():
(err,) = cuda.cuCtxSetCurrent(ctx)
assert err == cuda.CUresult.CUDA_SUCCESS

yield
yield ctx

cuda.cuDevicePrimaryCtxRelease(device)

Expand Down
1 change: 1 addition & 0 deletions cuda_bindings/tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def test_example(example):

env = os.environ.copy()
env["CUDA_BINDINGS_SKIP_EXAMPLE"] = "100"
env["MPLBACKEND"] = "Agg" # avoid plt.show() from blocking

process = subprocess.run([sys.executable, example], capture_output=True, env=env) # noqa: S603
# returncode is a special value used in the examples to indicate that system requirements are not met.
Expand Down
3 changes: 0 additions & 3 deletions cuda_core/cuda/core/_device_resources.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#
# SPDX-License-Identifier: Apache-2.0

cimport cython

from cuda.bindings cimport cydriver
from cuda.core._resource_handles cimport ContextHandle, GreenCtxHandle

Expand All @@ -17,7 +15,6 @@ cdef class SMResource:
unsigned int _flags
bint _is_usable
object __weakref__
cython.pymutex _split_mutex

@staticmethod
cdef SMResource _from_dev_resource(cydriver.CUdevResource res, int device_id)
Expand Down
9 changes: 4 additions & 5 deletions cuda_core/cuda/core/_device_resources.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -498,11 +498,10 @@ cdef class SMResource:
)
_resolve_group_count(opts)
_check_green_ctx_support()
with self._split_mutex:
if _can_use_structured_sm_split():
return _split_with_general_api(self, opts, dry_run)
# SplitByCount requires the same 12.4+ as green ctx support (already checked above)
return _split_with_count_api(self, opts, dry_run)
if _can_use_structured_sm_split():
return _split_with_general_api(self, opts, dry_run)
# SplitByCount requires the same 12.4+ as green ctx support (already checked above)
return _split_with_count_api(self, opts, dry_run)


cdef class WorkqueueResource:
Expand Down
12 changes: 12 additions & 0 deletions cuda_core/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,18 @@ def wrapper(*args, **kwargs):
kwargs["mempool_device_x2"] = _mempool_device_impl(2)
if "mempool_device_x3" in kwargs:
kwargs["mempool_device_x3"] = _mempool_device_impl(3)

# These are used by test_green_context.py. The original fixtures include
# pytest.skip() but that should have correctly fired by this time.
if "sm_resource" in kwargs:
kwargs["sm_resource"] = device.resources.sm
if "wq_resource" in kwargs:
kwargs["wq_resource"] = device.resources.workqueue
if "green_ctx" in kwargs:
from cuda.core import ContextOptions, SMResourceOptions

groups, _ = device.resources.sm.split(SMResourceOptions(count=None))
kwargs["green_ctx"] = device.create_context(ContextOptions(resources=[groups[0]]))
return func(*args, **kwargs)

wrapper._cuda_core_worker_cuda_wrapped = True
Expand Down
Loading
Loading