Skip to content

Commit 1d2ac75

Browse files
authored
Merge branch 'main' into main
2 parents dad236b + 0a6372c commit 1d2ac75

File tree

191 files changed

+4818
-1950
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

191 files changed

+4818
-1950
lines changed

.bandit

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/actions/doc_preview/action.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

5-
name: Preview or clean up docs built from PRs
5+
name: Docs in PRs
6+
description: Preview or clean up docs built from PRs
67

78
# A re-implementation based on the logic of https://github.com/rossjrw/pr-preview-action/blob/41a957c44a456a34718e9bcf825363194db5e6d5/README.md, due to limitations illustrated in NVIDIA/cuda-python#380.
89

910
inputs:
1011
source-folder:
1112
required: true
1213
type: string
14+
description: "Source code directory"
1315
pr-number:
1416
required: true
1517
type: string
18+
description: "Pull request number"
1619

1720
runs:
1821
using: composite

.github/actions/fetch_ctk/action.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ inputs:
1818
required: false
1919
type: string
2020
default: "cuda_nvcc,cuda_cudart,cuda_crt,libnvvm,cuda_nvrtc,cuda_profiler_api,cuda_cccl,libnvjitlink,libcufile"
21+
cuda-path:
22+
description: "where the CTK components will be installed to, relative to $PWD"
23+
required: false
24+
type: string
25+
default: "./cuda_toolkit"
2126

2227
runs:
2328
using: composite
@@ -135,7 +140,7 @@ runs:
135140
ls -l $CUDA_PATH
136141
137142
- name: Upload CTK cache
138-
if: ${{ always() &&
143+
if: ${{ !cancelled() &&
139144
steps.ctk-get-cache.outputs.cache-hit != 'true' }}
140145
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
141146
with:
@@ -159,18 +164,24 @@ runs:
159164
exit 1
160165
fi
161166
167+
- name: Move CTK to the specified location
168+
if: ${{ inputs.cuda-path != './cuda_toolkit' }}
169+
shell: bash --noprofile --norc -xeuo pipefail {0}
170+
run: |
171+
mv ./cuda_toolkit ${{ inputs.cuda-path }}
172+
162173
- name: Set output environment variables
163174
shell: bash --noprofile --norc -xeuo pipefail {0}
164175
run: |
165176
# mimics actual CTK installation
166177
if [[ "${{ inputs.host-platform }}" == linux* ]]; then
167-
CUDA_PATH=$(realpath "./cuda_toolkit")
168-
echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH:-}:${CUDA_PATH}/lib" >> $GITHUB_ENV
178+
CUDA_PATH=$(realpath "${{ inputs.cuda-path }}")
179+
echo "LD_LIBRARY_PATH=${CUDA_PATH}/lib:${LD_LIBRARY_PATH:-}" >> $GITHUB_ENV
169180
elif [[ "${{ inputs.host-platform }}" == win* ]]; then
170181
function normpath() {
171182
echo "$(echo $(cygpath -w $1) | sed 's/\\/\\\\/g')"
172183
}
173-
CUDA_PATH=$(normpath $(realpath "./cuda_toolkit"))
184+
CUDA_PATH=$(normpath $(realpath "${{ inputs.cuda-path }}"))
174185
echo "$(normpath ${CUDA_PATH}/bin)" >> $GITHUB_PATH
175186
fi
176187
echo "CUDA_PATH=${CUDA_PATH}" >> $GITHUB_ENV

.github/workflows/backport.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
echo "OLD_BRANCH=${OLD_BRANCH}" >> $GITHUB_ENV
3333
3434
- name: Create backport pull requests
35-
uses: korthout/backport-action@ca4972adce8039ff995e618f5fc02d1b7961f27a # v3.3.0
35+
uses: korthout/backport-action@d07416681cab29bf2661702f925f020aaa962997 # v3.4.1
3636
with:
3737
copy_assignees: true
3838
copy_labels_pattern: true

.github/workflows/bandit.yml

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,27 @@ jobs:
1919
permissions:
2020
security-events: write
2121
steps:
22-
- name: Perform Bandit Analysis
23-
# KEEP IN SYNC WITH bandit rev in .pre-commit-config.yaml
24-
# Current runner uses Python 3.8, so the action installs bandit==1.7.10
25-
# via `pip install bandit[sarif]`. If runner Python moves to >=3.9,
26-
# the action will resolve to 1.8.x and you'll need to bump pre-commit.
27-
# (Bandit >=1.8.0 dropped Python 3.8 via Requires-Python metadata.)
28-
uses: PyCQA/bandit-action@8a1b30610f61f3f792fe7556e888c9d7dffa52de # v1.0.0
22+
- name: Checkout
23+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
24+
25+
- name: Install uv
26+
uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6.8.0
27+
28+
- name: Get ignore codes
29+
id: ignore-codes
30+
# This are computed so that we can run only the `S` (bandit)
31+
# checks. Passing --select to ruff overrides any config files
32+
# (ruff.toml, pyproject.toml, etc), so to avoid having keep everything
33+
# in sync we grab them from the TOML programmatically
34+
run: |
35+
set -euxo pipefail
36+
37+
echo "codes=$(uvx toml2json ./ruff.toml | jq -r '.lint.ignore | map(select(test("^S\\d+"))) | join(",")')" >> "$GITHUB_OUTPUT"
38+
- name: Perform Bandit Analysis using Ruff
39+
uses: astral-sh/ruff-action@57714a7c8a2e59f32539362ba31877a1957dded1 # v3.5.1
40+
with:
41+
args: "check --select S --ignore ${{ steps.ignore-codes.outputs.codes }} --output-format sarif --output-file results.sarif"
42+
- name: Upload SARIF file
43+
uses: github/codeql-action/upload-sarif@v3
44+
with:
45+
sarif_file: results.sarif

.github/workflows/build-wheel.yml

Lines changed: 158 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
cuda-version:
1212
required: true
1313
type: string
14+
prev-cuda-version:
15+
required: true
16+
type: string
1417

1518
defaults:
1619
run:
@@ -31,6 +34,8 @@ jobs:
3134
- "3.12"
3235
- "3.13"
3336
- "3.13t"
37+
- "3.14"
38+
- "3.14t"
3439
name: py${{ matrix.python-version }}
3540
runs-on: ${{ (inputs.host-platform == 'linux-64' && 'linux-amd64-cpu8') ||
3641
(inputs.host-platform == 'linux-aarch64' && 'linux-arm64-cpu8') ||
@@ -107,42 +112,6 @@ jobs:
107112
path: cuda_pathfinder/*.whl
108113
if-no-files-found: error
109114

110-
- name: Build cuda.core wheel
111-
uses: pypa/cibuildwheel@c923d83ad9c1bc00211c5041d0c3f73294ff88f6 # v3.1.4
112-
env:
113-
CIBW_BUILD: ${{ env.CIBW_BUILD }}
114-
CIBW_ARCHS_LINUX: "native"
115-
CIBW_BUILD_VERBOSITY: 1
116-
CIBW_BEFORE_BUILD_WINDOWS: "pip install delvewheel"
117-
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair --namespace-pkg cuda -w {dest_dir} {wheel}"
118-
CIBW_ENVIRONMENT: >
119-
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
120-
CIBW_ENABLE: "cpython-freethreading"
121-
with:
122-
package-dir: ./cuda_core/
123-
output-dir: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
124-
125-
- name: List the cuda.core artifacts directory
126-
run: |
127-
if [[ "${{ inputs.host-platform }}" == win* ]]; then
128-
export CHOWN=chown
129-
else
130-
export CHOWN="sudo chown"
131-
fi
132-
$CHOWN -R $(whoami) ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
133-
ls -lahR ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
134-
135-
- name: Check cuda.core wheel
136-
run: |
137-
twine check --strict ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl
138-
139-
- name: Upload cuda.core build artifacts
140-
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
141-
with:
142-
name: ${{ env.CUDA_CORE_ARTIFACT_NAME }}
143-
path: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl
144-
if-no-files-found: error
145-
146115
- name: Set up mini CTK
147116
uses: ./.github/actions/fetch_ctk
148117
continue-on-error: false
@@ -151,24 +120,19 @@ jobs:
151120
cuda-version: ${{ inputs.cuda-version }}
152121

153122
- name: Build cuda.bindings wheel
154-
uses: pypa/cibuildwheel@c923d83ad9c1bc00211c5041d0c3f73294ff88f6 # v3.1.4
123+
uses: pypa/cibuildwheel@7c619efba910c04005a835b110b057fc28fd6e93 # v3.2.0
124+
with:
125+
package-dir: ./cuda_bindings/
126+
output-dir: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
155127
env:
156128
CIBW_BUILD: ${{ env.CIBW_BUILD }}
157-
CIBW_ARCHS_LINUX: "native"
158-
CIBW_BUILD_VERBOSITY: 1
159129
# CIBW mounts the host filesystem under /host
160130
CIBW_ENVIRONMENT_LINUX: >
161131
CUDA_PATH=/host/${{ env.CUDA_PATH }}
162132
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
163133
CIBW_ENVIRONMENT_WINDOWS: >
164-
CUDA_HOME="$(cygpath -w ${{ env.CUDA_PATH }})"
134+
CUDA_PATH="$(cygpath -w ${{ env.CUDA_PATH }})"
165135
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
166-
CIBW_BEFORE_BUILD_WINDOWS: "pip install delvewheel"
167-
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair --namespace-pkg cuda -w {dest_dir} {wheel}"
168-
CIBW_ENABLE: "cpython-freethreading"
169-
with:
170-
package-dir: ./cuda_bindings/
171-
output-dir: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
172136
173137
- name: List the cuda.bindings artifacts directory
174138
run: |
@@ -191,6 +155,47 @@ jobs:
191155
path: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}/*.whl
192156
if-no-files-found: error
193157

158+
- name: Build cuda.core wheel
159+
uses: pypa/cibuildwheel@c923d83ad9c1bc00211c5041d0c3f73294ff88f6 # v3.1.4
160+
with:
161+
package-dir: ./cuda_core/
162+
output-dir: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
163+
env:
164+
CIBW_BUILD: ${{ env.CIBW_BUILD }}
165+
# CIBW mounts the host filesystem under /host
166+
CIBW_ENVIRONMENT_LINUX: >
167+
CUDA_PATH=/host/${{ env.CUDA_PATH }}
168+
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
169+
CUDA_CORE_BUILD_MAJOR=${{ env.BUILD_CUDA_MAJOR }}
170+
PIP_FIND_LINKS=/host/${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
171+
CIBW_ENVIRONMENT_WINDOWS: >
172+
CUDA_PATH="$(cygpath -w ${{ env.CUDA_PATH }})"
173+
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
174+
CUDA_CORE_BUILD_MAJOR=${{ env.BUILD_CUDA_MAJOR }}
175+
PIP_FIND_LINKS="$(cygpath -w ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }})"
176+
177+
- name: List the cuda.core artifacts directory and rename
178+
run: |
179+
if [[ "${{ inputs.host-platform }}" == win* ]]; then
180+
export CHOWN=chown
181+
else
182+
export CHOWN="sudo chown"
183+
fi
184+
$CHOWN -R $(whoami) ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
185+
186+
# Rename wheel to include CUDA version suffix
187+
mkdir -p "${{ env.CUDA_CORE_ARTIFACTS_DIR }}/cu${BUILD_CUDA_MAJOR}"
188+
for wheel in ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl; do
189+
if [[ -f "${wheel}" ]]; then
190+
base_name=$(basename "${wheel}" .whl)
191+
new_name="${base_name}.cu${BUILD_CUDA_MAJOR}.whl"
192+
mv "${wheel}" "${{ env.CUDA_CORE_ARTIFACTS_DIR }}/cu${BUILD_CUDA_MAJOR}/${new_name}"
193+
echo "Renamed wheel to: ${new_name}"
194+
fi
195+
done
196+
197+
ls -lahR ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
198+
194199
# We only need/want a single pure python wheel, pick linux-64 index 0.
195200
- name: Build and check cuda-python wheel
196201
if: ${{ strategy.job-index == 0 && inputs.host-platform == 'linux-64' }}
@@ -227,7 +232,7 @@ jobs:
227232
python-version: ${{ matrix.python-version == '3.13' && '3.13.5' || matrix.python-version }}
228233

229234
- name: verify free-threaded build
230-
if: endsWith(matrix.python-verison, 't')
235+
if: endsWith(matrix.python-version, 't')
231236
run: python -c 'import sys; assert not sys._is_gil_enabled()'
232237

233238
- name: Set up Python include paths
@@ -246,7 +251,7 @@ jobs:
246251
247252
- name: Build cuda.bindings Cython tests
248253
run: |
249-
pip install $(ls ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}/*.whl)[test]
254+
pip install ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}/*.whl --group ./cuda_bindings/pyproject.toml:test
250255
pushd ${{ env.CUDA_BINDINGS_CYTHON_TESTS_DIR }}
251256
bash build_tests.sh
252257
popd
@@ -260,7 +265,7 @@ jobs:
260265

261266
- name: Build cuda.core Cython tests
262267
run: |
263-
pip install $(ls ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl)[test]
268+
pip install ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/"cu${BUILD_CUDA_MAJOR}"/*.whl --group ./cuda_core/pyproject.toml:test
264269
pushd ${{ env.CUDA_CORE_CYTHON_TESTS_DIR }}
265270
bash build_tests.sh
266271
popd
@@ -271,3 +276,107 @@ jobs:
271276
name: ${{ env.CUDA_CORE_ARTIFACT_NAME }}-tests
272277
path: ${{ env.CUDA_CORE_CYTHON_TESTS_DIR }}/test_*${{ env.PY_EXT_SUFFIX }}
273278
if-no-files-found: error
279+
280+
# Note: This overwrites CUDA_PATH etc
281+
- name: Set up mini CTK
282+
uses: ./.github/actions/fetch_ctk
283+
continue-on-error: false
284+
with:
285+
host-platform: ${{ inputs.host-platform }}
286+
cuda-version: ${{ inputs.prev-cuda-version }}
287+
cuda-path: "./cuda_toolkit_prev"
288+
289+
- name: Download cuda.bindings build artifacts from the prior branch
290+
if: ${{ matrix.python-version == '3.13t'
291+
|| matrix.python-version == '3.14'
292+
|| matrix.python-version == '3.14t' }}
293+
env:
294+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
295+
run: |
296+
if ! (command -v gh 2>&1 >/dev/null); then
297+
# See https://github.com/cli/cli/blob/trunk/docs/install_linux.md#debian-ubuntu-linux-raspberry-pi-os-apt.
298+
# gh is needed for artifact fetching.
299+
mkdir -p -m 755 /etc/apt/keyrings \
300+
&& out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
301+
&& cat $out | tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
302+
&& chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
303+
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
304+
&& apt update \
305+
&& apt install gh -y
306+
fi
307+
308+
OLD_BRANCH=$(cat .github/BACKPORT_BRANCH)
309+
OLD_BASENAME="cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda*-${{ inputs.host-platform }}*"
310+
LATEST_PRIOR_RUN_ID=$(gh run list -b ${OLD_BRANCH} -L 1 -w "ci.yml" -s completed -R NVIDIA/cuda-python --json databaseId | jq '.[]| .databaseId')
311+
if [[ "$LATEST_PRIOR_RUN_ID" == "" ]]; then
312+
echo "LATEST_PRIOR_RUN_ID not found!"
313+
exit 1
314+
fi
315+
316+
gh run download $LATEST_PRIOR_RUN_ID -p ${OLD_BASENAME} -R NVIDIA/cuda-python
317+
rm -rf ${OLD_BASENAME}-tests # exclude cython test artifacts
318+
ls -al $OLD_BASENAME
319+
mkdir -p "${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}"
320+
mv $OLD_BASENAME/*.whl "${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}"
321+
rmdir $OLD_BASENAME
322+
323+
- name: Build cuda.core wheel
324+
uses: pypa/cibuildwheel@c923d83ad9c1bc00211c5041d0c3f73294ff88f6 # v3.1.4
325+
with:
326+
package-dir: ./cuda_core/
327+
output-dir: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
328+
env:
329+
CIBW_BUILD: ${{ env.CIBW_BUILD }}
330+
# CIBW mounts the host filesystem under /host
331+
CIBW_ENVIRONMENT_LINUX: >
332+
CUDA_PATH=/host/${{ env.CUDA_PATH }}
333+
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
334+
CUDA_CORE_BUILD_MAJOR=${{ env.BUILD_PREV_CUDA_MAJOR }}
335+
PIP_FIND_LINKS=/host/${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
336+
CIBW_ENVIRONMENT_WINDOWS: >
337+
CUDA_PATH="$(cygpath -w ${{ env.CUDA_PATH }})"
338+
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
339+
CUDA_CORE_BUILD_MAJOR=${{ env.BUILD_PREV_CUDA_MAJOR }}
340+
PIP_FIND_LINKS="$(cygpath -w ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }})"
341+
342+
- name: List the cuda.core artifacts directory and rename
343+
run: |
344+
if [[ "${{ inputs.host-platform }}" == win* ]]; then
345+
export CHOWN=chown
346+
else
347+
export CHOWN="sudo chown"
348+
fi
349+
$CHOWN -R $(whoami) ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
350+
ls -lahR ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
351+
352+
# Rename wheel to include CUDA version suffix
353+
mkdir -p "${{ env.CUDA_CORE_ARTIFACTS_DIR }}/cu${BUILD_PREV_CUDA_MAJOR}"
354+
for wheel in ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl; do
355+
if [[ -f "${wheel}" ]]; then
356+
base_name=$(basename "${wheel}" .whl)
357+
new_name="${base_name}.cu${BUILD_PREV_CUDA_MAJOR}.whl"
358+
mv "${wheel}" "${{ env.CUDA_CORE_ARTIFACTS_DIR }}/cu${BUILD_PREV_CUDA_MAJOR}/${new_name}"
359+
echo "Renamed wheel to: ${new_name}"
360+
fi
361+
done
362+
363+
ls -lahR ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
364+
365+
- name: Merge cuda.core wheels
366+
run: |
367+
pip install wheel
368+
python ci/tools/merge_cuda_core_wheels.py \
369+
"${{ env.CUDA_CORE_ARTIFACTS_DIR }}"/cu"${BUILD_CUDA_MAJOR}"/cuda_core*.whl \
370+
"${{ env.CUDA_CORE_ARTIFACTS_DIR }}"/cu"${BUILD_PREV_CUDA_MAJOR}"/cuda_core*.whl \
371+
--output-dir "${{ env.CUDA_CORE_ARTIFACTS_DIR }}"
372+
373+
- name: Check cuda.core wheel
374+
run: |
375+
twine check --strict ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl
376+
377+
- name: Upload cuda.core build artifacts
378+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
379+
with:
380+
name: ${{ env.CUDA_CORE_ARTIFACT_NAME }}
381+
path: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl
382+
if-no-files-found: error

0 commit comments

Comments
 (0)