11#! /usr/bin/env bash
22
3- # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+ # SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
44#
55# SPDX-License-Identifier: Apache-2.0
66
2020
2121test_module=${1}
2222
23+ FREE_THREADING=" "
24+ PYTEST_PARALLEL_ARGS=()
25+ if python -c ' import sys; assert not sys._is_gil_enabled()' 2> /dev/null; then
26+ FREE_THREADING=" -ft"
27+ PYTEST_PARALLEL_ARGS=(--parallel-threads=4)
28+ pip install pytest-run-parallel
29+ fi
30+
2331# For standard modes, install pathfinder up front (it is a direct dependency
2432# of bindings, and a transitive dependency of core). Nightly modes install
2533# all wheels together in a single pip call further below.
@@ -36,7 +44,7 @@ if [[ "${test_module}" == "pathfinder" ]]; then
3644 " LD:${CUDA_PATHFINDER_TEST_LOAD_NVIDIA_DYNAMIC_LIB_STRICTNESS} " \
3745 " FH:${CUDA_PATHFINDER_TEST_FIND_NVIDIA_HEADERS_STRICTNESS} " \
3846 " BC:${CUDA_PATHFINDER_TEST_FIND_NVIDIA_BITCODE_LIB_STRICTNESS} "
39- pytest -ra -s -v --durations=0 tests/ | & tee /tmp/pathfinder_test_log.txt
47+ pytest -ra -s -v --durations=0 " ${PYTEST_PARALLEL_ARGS[@]} " tests/ | & tee /tmp/pathfinder_test_log.txt
4048 # Report the number of "INFO test_" lines (including zero)
4149 # to support quick validations based on GHA log archives.
4250 line_count=$( awk ' /^INFO test_/ {count++} END {print count+0}' /tmp/pathfinder_test_log.txt)
@@ -51,21 +59,16 @@ elif [[ "${test_module}" == "bindings" ]]; then
5159 pip install $( ls " ${CUDA_BINDINGS_ARTIFACTS_DIR} " /* .whl) [all] --group test
5260 fi
5361 echo " Running bindings tests"
54- ${SANITIZER_CMD} pytest -rxXs -v --durations=0 --randomly-dont-reorganize tests/
62+ ${SANITIZER_CMD} pytest -rxXs -v --durations=0 --randomly-dont-reorganize " ${PYTEST_PARALLEL_ARGS[@]} " tests/
5563 if [[ " ${SKIP_CYTHON_TEST} " == 0 ]]; then
56- ${SANITIZER_CMD} pytest -rxXs -v --durations=0 --randomly-dont-reorganize tests/cython
64+ ${SANITIZER_CMD} pytest -rxXs -v --durations=0 --randomly-dont-reorganize " ${PYTEST_PARALLEL_ARGS[@]} " tests/cython
5765 fi
5866 popd
5967elif [[ " ${test_module} " == " core" || " ${test_module} " == nightly-* ]]; then
6068 # Shared setup for core and nightly modes.
6169 TEST_CUDA_MAJOR=" $( cut -d ' .' -f 1 <<< ${CUDA_VER} ) "
6270 CUDA_VER_MINOR=" $( cut -d ' .' -f 1-2 <<< " ${CUDA_VER}" ) "
6371
64- FREE_THREADING=" "
65- if python -c ' import sys; assert not sys._is_gil_enabled()' 2> /dev/null; then
66- FREE_THREADING+=" -ft"
67- fi
68-
6972 # Resolve bindings based on BINDINGS_SOURCE (set by env-vars):
7073 # main/backport → local wheel from artifacts dir
7174 # published → install from PyPI by version
@@ -106,11 +109,11 @@ elif [[ "${test_module}" == "core" || "${test_module}" == nightly-* ]]; then
106109 echo " Installed packages before core tests:"
107110 pip list
108111 echo " Running core tests"
109- ${SANITIZER_CMD} pytest -rxXs -v --durations=0 --randomly-dont-reorganize tests/
112+ ${SANITIZER_CMD} pytest -rxXs -v --durations=0 --randomly-dont-reorganize " ${PYTEST_PARALLEL_ARGS[@]} " tests/
110113 # Currently our CI always installs the latest bindings (from either major version).
111114 # This is not compatible with the test requirements.
112115 if [[ " ${SKIP_CYTHON_TEST} " == 0 ]]; then
113- ${SANITIZER_CMD} pytest -rxXs -v --durations=0 --randomly-dont-reorganize tests/cython
116+ ${SANITIZER_CMD} pytest -rxXs -v --durations=0 --randomly-dont-reorganize " ${PYTEST_PARALLEL_ARGS[@]} " tests/cython
114117 fi
115118 else
116119 # Nightly optional-dependency testing.
0 commit comments