Skip to content

Commit f401388

Browse files
rwgkcursoragent
andauthored
[no-ci] toolshed: modernize conda_create_for_pathfinder_testing scripts (#2013)
* toolshed: modernize conda_create_for_pathfinder_testing scripts Bring the bash and PowerShell helpers used to spin up CUDA-pathfinder test environments into line with how cuda_pathfinder/pyproject.toml is now organized, and harden them so common shell mistakes surface immediately. Highlights: - Add ``set -euo pipefail`` (bash) and ``Set-StrictMode -Version Latest`` (PowerShell) so unset variables and non-zero exit codes fail loudly. - Pick the Python version from the CUDA major: ``12.x`` -> 3.12, ``13.x`` -> 3.14. Reject other CUDA majors with a clear error instead of silently installing 3.13. - Bash: wrap ``conda activate`` and ``conda install`` in ``set +u`` / ``set -u`` because conda's shims dereference unset variables, which otherwise abort the script under ``set -u``. - Realign the conda package lists with the platform-scoped groups in ``cuda_pathfinder/pyproject.toml``: - Add ``cutlass`` (Linux + Windows) and ``libcusolvermp-dev`` (Linux). - Drop ``libnvpl-fft-dev`` from the unconditional Linux list and from Windows entirely. - On Linux, install ``libnvpl-fft-dev`` only on ``aarch64`` and add ``libcudla-dev`` for the ``cu13``/``aarch64`` combination. - Drop ``libcublasmp-dev``, ``libcufftmp-dev``, ``libnvshmem3``, and ``libnvshmem-dev`` from the Windows list to match what ``pyproject`` installs there. - Refresh SPDX copyright to ``2025-2026``. Co-authored-by: Cursor <cursoragent@cursor.com> * toolshed: batch the conda installs into a single solve Replace the per-package ``conda install`` loop in both the bash and PowerShell helpers with a single batched call that hands the full package list to one solver invocation. A single ``conda install -y -c conda-forge "${cpkgs[@]}"`` (bash) / ``conda install -y -c conda-forge @cpkgs`` (PowerShell) is both faster and more consistent than calling ``conda install`` N times: the loop form runs the solver once per package, and each independent solve can downgrade or upgrade shared dependencies that the prior step just installed. The ``set +u`` / ``set -u`` shim around the bash call is preserved because conda's shell wrapper still dereferences unset variables regardless of how many packages are passed. Not yet exercised against a real conda environment; the next end-to-end run will use this batched form. Addresses review feedback from @rparolin on PR #2013. * toolshed: take python_major_minor as an argument and align variable naming Make the Python version a required argument to both helpers instead of deriving it from the CUDA major. The previous case/switch over the CUDA major was a brittle source of truth: every time a new Python or CUDA line was supported, the helper would silently install the wrong Python until it was updated. Pushing the choice to the caller keeps the helpers focused on the conda environment they manage and lets the caller pick whatever Python they actually want to test against. New usage on both platforms is parallel: conda_create_for_pathfinder_testing.sh 3.12 12.9.2 conda_create_for_pathfinder_testing.ps1 3.12 12.9.2 Variable / parameter names now match the usage line and read identically across the two scripts: - bash: ``python_major_minor`` / ``cuda_major_minor_patch`` - PowerShell: ``$PythonMajorMinor`` / ``$CudaMajorMinorPatch`` The PowerShell ``param()`` block uses ``Mandatory + Position 0/1`` so the script accepts both positional invocation (matching the bash style above) and the named ``-PythonMajorMinor`` / ``-CudaMajorMinorPatch`` form. Switch the ``libcudla-dev`` gate from ``cuda_major == "13"`` to ``(( cuda_major >= 13 ))`` so future CUDA majors fall through to the correct branch automatically. ``(( ))`` is the idiomatic bash form for integer comparison; the script is already firmly bash-only (``#!/bin/bash``, ``set -euo pipefail``), so the syntax is in keeping with the rest of the file. --------- Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent ffac267 commit f401388

2 files changed

Lines changed: 56 additions & 34 deletions

File tree

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION
22
# SPDX-License-Identifier: Apache-2.0
33

44
param(
5-
[Parameter(Mandatory = $true)]
6-
[string]$CudaVersion
5+
[Parameter(Mandatory = $true, Position = 0)]
6+
[string]$PythonMajorMinor,
7+
[Parameter(Mandatory = $true, Position = 1)]
8+
[string]$CudaMajorMinorPatch
79
)
810

911
$ErrorActionPreference = "Stop"
12+
Set-StrictMode -Version Latest
1013

1114
& "$env:CONDA_EXE" "shell.powershell" "hook" | Out-String | Invoke-Expression
1215

13-
conda create --yes -n "pathfinder_testing_cu$CudaVersion" python=3.13 "cuda-toolkit=$CudaVersion"
14-
conda activate "pathfinder_testing_cu$CudaVersion"
16+
conda create --yes -n "pathfinder_testing_cu$CudaMajorMinorPatch" "python=$PythonMajorMinor" "cuda-toolkit=$CudaMajorMinorPatch"
17+
conda activate "pathfinder_testing_cu$CudaMajorMinorPatch"
1518

19+
# Keep this list aligned with the Windows-installable subset of
20+
# cuda_pathfinder/pyproject.toml.
1621
$cpkgs = @(
1722
"cusparselt-dev",
1823
"cutensor",
19-
"libcublasmp-dev",
24+
"cutlass",
2025
"libcudss-dev",
21-
"libcufftmp-dev",
22-
"libmathdx-dev",
23-
"libnvshmem3",
24-
"libnvshmem-dev",
25-
"libnvpl-fft-dev"
26+
"libmathdx-dev"
2627
)
2728

28-
foreach ($cpkg in $cpkgs) {
29-
Write-Host "CONDA INSTALL: $cpkg"
30-
conda install -y -c conda-forge $cpkg
31-
}
29+
Write-Host "CONDA INSTALL: $($cpkgs -join ' ')"
30+
conda install -y -c conda-forge @cpkgs
Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,51 @@
11
#!/bin/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
# SPDX-License-Identifier: Apache-2.0
55

6-
if [[ $# -ne 1 ]]; then
7-
echo "Usage: $(basename "$0") ctk-major-minor-patch" 1>&2
6+
set -euo pipefail
7+
8+
if [[ $# -ne 2 ]]; then
9+
echo "Usage: $(basename "$0") python_major_minor cuda_major_minor_patch" 1>&2
810
exit 1
911
fi
1012

13+
python_major_minor="$1"
14+
cuda_major_minor_patch="$2"
15+
cuda_major="${cuda_major_minor_patch%%.*}"
16+
uname_m="$(uname -m)"
17+
1118
eval "$(conda shell.bash hook)"
1219

13-
conda create --yes -n "pathfinder_testing_cu$1" python=3.13 cuda-toolkit="$1"
14-
conda activate "pathfinder_testing_cu$1"
15-
16-
for cpkg in \
17-
cusparselt-dev \
18-
cutensor \
19-
libcublasmp-dev \
20-
libcudss-dev \
21-
libcufftmp-dev \
22-
libmathdx-dev \
23-
libnvshmem3 \
24-
libnvshmem-dev \
25-
libnvpl-fft-dev; do
26-
echo "CONDA INSTALL: $cpkg"
27-
conda install -y -c conda-forge "$cpkg"
28-
done
20+
conda create --yes -n "pathfinder_testing_cu$cuda_major_minor_patch" "python=$python_major_minor" cuda-toolkit="$cuda_major_minor_patch"
21+
set +u
22+
conda activate "pathfinder_testing_cu$cuda_major_minor_patch"
23+
set -u
24+
25+
# Keep this list aligned with the Linux-installable subset of
26+
# cuda_pathfinder/pyproject.toml.
27+
cpkgs=(
28+
"cusparselt-dev"
29+
"cutensor"
30+
"cutlass"
31+
"libcublasmp-dev"
32+
"libcudss-dev"
33+
"libcufftmp-dev"
34+
"libcusolvermp-dev"
35+
"libmathdx-dev"
36+
"libnvshmem3"
37+
"libnvshmem-dev"
38+
)
39+
40+
# Keep the conda environment aligned with platform-scoped pyproject groups.
41+
if [[ "$uname_m" == "aarch64" ]]; then
42+
cpkgs+=("libnvpl-fft-dev")
43+
if (( cuda_major >= 13 )); then
44+
cpkgs+=("libcudla-dev")
45+
fi
46+
fi
47+
48+
echo "CONDA INSTALL: ${cpkgs[*]}"
49+
set +u
50+
conda install -y -c conda-forge "${cpkgs[@]}"
51+
set -u

0 commit comments

Comments
 (0)