Skip to content

Commit 38a8ea2

Browse files
committed
ci: test free-threading builds with multiple threads
1 parent 32b0f12 commit 38a8ea2

File tree

6 files changed

+25
-11
lines changed

6 files changed

+25
-11
lines changed

.github/workflows/test-wheel-linux.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ defaults:
2424
run:
2525
shell: bash --noprofile --norc -xeuo pipefail {0}
2626

27+
env:
28+
FREE_THREADING_TEST_ITERATIONS: 10
29+
FREE_THREADING_TEST_THREADS: 10
30+
2731
jobs:
2832
compute-matrix:
2933
runs-on: ubuntu-latest

.github/workflows/test-wheel-windows.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ on:
2020
type: string
2121
default: "."
2222

23+
env:
24+
FREE_THREADING_TEST_ITERATIONS: 10
25+
FREE_THREADING_TEST_THREADS: 10
26+
2327
jobs:
2428
compute-matrix:
2529
runs-on: ubuntu-latest

ci/tools/run-tests

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ fi
2020

2121
test_module=${1}
2222

23+
PYTEST_ARGS=()
24+
25+
FREE_THREADING=""
26+
if python -c 'import sys; assert not sys._is_gil_enabled()' 2> /dev/null; then
27+
FREE_THREADING+="-ft"
28+
PYTEST_ARGS+=("--require-gil-disabled" "--threads" "${FREE_THREADING_TEST_THREADS}" "--iterations" "${FREE_THREADING_TEST_ITERATIONS}")
29+
fi
30+
31+
2332
# Unconditionally install pathfinder wheel
2433
# (it is a direct dependency of bindings, and a transitive dependency of core)
2534
pushd ./cuda_pathfinder
@@ -35,7 +44,7 @@ if [[ "${test_module}" == "pathfinder" ]]; then
3544
"LD:${CUDA_PATHFINDER_TEST_LOAD_NVIDIA_DYNAMIC_LIB_STRICTNESS} " \
3645
"FH:${CUDA_PATHFINDER_TEST_FIND_NVIDIA_HEADERS_STRICTNESS}"
3746
pwd
38-
pytest -ra -s -v tests/ |& tee /tmp/pathfinder_test_log.txt
47+
pytest "${PYTEST_ARGS[@]}" -ra -s -v tests/ |& tee /tmp/pathfinder_test_log.txt
3948
# Fail if no "INFO test_" lines are found; capture line count otherwise
4049
line_count=$(grep '^INFO test_' /tmp/pathfinder_test_log.txt | wc -l)
4150
echo "Number of \"INFO test_\" lines: $line_count"
@@ -55,9 +64,9 @@ elif [[ "${test_module}" == "bindings" ]]; then
5564
pushd ./cuda_bindings
5665
echo "Running bindinds tests"
5766
pwd
58-
${SANITIZER_CMD} pytest -rxXs -v tests/
67+
${SANITIZER_CMD} pytest "${PYTEST_ARGS[@]}" -rxXs -v tests/
5968
if [[ "${SKIP_CYTHON_TEST}" == 0 ]]; then
60-
${SANITIZER_CMD} pytest -rxXs -v tests/cython
69+
${SANITIZER_CMD} pytest "${PYTEST_ARGS[@]}" -rxXs -v tests/cython
6170
fi
6271
popd
6372
elif [[ "${test_module}" == "core" ]]; then
@@ -81,11 +90,6 @@ elif [[ "${test_module}" == "core" ]]; then
8190
pwd
8291
ls
8392

84-
FREE_THREADING=""
85-
if python -c 'import sys; assert not sys._is_gil_enabled()' 2> /dev/null; then
86-
FREE_THREADING+="-ft"
87-
fi
88-
8993
if [[ "${LOCAL_CTK}" == 1 ]]; then
9094
# We already installed cuda-bindings, and all CTK components exist locally,
9195
# so just install the test dependencies.
@@ -97,11 +101,11 @@ elif [[ "${test_module}" == "core" ]]; then
97101
pushd ./cuda_core
98102
echo "Running core tests"
99103
pwd
100-
${SANITIZER_CMD} pytest -rxXs -v tests/
104+
${SANITIZER_CMD} pytest "${PYTEST_ARGS[@]}" -rxXs -v tests/
101105
# Currently our CI always installs the latest bindings (from either major version).
102106
# This is not compatible with the test requirements.
103107
if [[ "${SKIP_CYTHON_TEST}" == 0 ]]; then
104-
${SANITIZER_CMD} pytest -rxXs -v tests/cython
108+
${SANITIZER_CMD} pytest "${PYTEST_ARGS[@]}" -rxXs -v tests/cython
105109
fi
106110
popd
107111
fi

cuda_bindings/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ test = [
4242
"numpy>=1.21.1",
4343
"pytest>=6.2.4",
4444
"pytest-benchmark>=3.4.1",
45+
"pytest-freethreaded; python_version >= '3.13'"
4546
]
4647

4748
[project.urls]

cuda_core/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ cu13 = ["cuda-bindings[all]==13.*"]
5252
# TODO: these should all be in development dependencies; optional dependencies
5353
# are for features exposed to *users*, not a dumping ground for all tooling
5454
# needed to build and test the project
55-
test = ["cython>=3.1", "setuptools", "pytest>=6.2.4"]
55+
test = ["cython>=3.1", "setuptools", "pytest>=6.2.4", "pytest-freethreaded; python_version >= '3.13'"]
5656
test-cu11 = ["cuda-core[test]", "cupy-cuda11x; python_version < '3.14'", "cuda-toolkit[cudart]==11.*"] # runtime headers needed by CuPy
5757
test-cu12 = ["cuda-core[test]", "cupy-cuda12x; python_version < '3.14'", "cuda-toolkit[cudart]==12.*"] # runtime headers needed by CuPy
5858
test-cu13 = ["cuda-core[test]", "cupy-cuda13x; python_version < '3.14'", "cuda-toolkit[cudart]==13.*"] # runtime headers needed by CuPy

cuda_pathfinder/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ dependencies = []
1313
[project.optional-dependencies]
1414
test = [
1515
"pytest>=6.2.4",
16+
"pytest-freethreaded; python_version >= '3.13'"
1617
]
1718
test_nvidia_wheels_cu12 = [
1819
"cuda-toolkit[nvcc,cublas,nvrtc,cudart,cufft,curand,cusolver,cusparse,npp,nvfatbin,nvjitlink,nvjpeg,cccl]==12.*",

0 commit comments

Comments
 (0)