Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
7557967
set up build system for targeting different cuda-bindings major verions
leofang Sep 27, 2025
1976597
defer cythonization until cuda-bindings is installed
leofang Sep 27, 2025
67db25e
cythonize stream module
leofang Sep 28, 2025
07df441
nit: move dlpack.h to the include dir
leofang Sep 28, 2025
6be8e7d
purge cu11
leofang Sep 28, 2025
021e0f3
check in a working merger script
leofang Sep 28, 2025
19020b2
support loading from the versioned module if any exists
leofang Sep 28, 2025
e51f910
fix linter errors
leofang Sep 28, 2025
61617cf
set up double-build CI workflow
leofang Sep 28, 2025
9e799e4
ensure CUDA_PATH is honored by the build backend
leofang Sep 28, 2025
d5001d4
try to reuse cuda-bindings wheels for 3.13t/3.14/3.14t
leofang Sep 29, 2025
1180ab6
disable building/testing 313t/314/314t for now
leofang Sep 29, 2025
8cbf40c
deprecate PY39 as per #846
leofang Sep 29, 2025
9519904
also turn on parallel cythonization
leofang Sep 29, 2025
96ce480
cythonize event
leofang Sep 29, 2025
e702b5e
fix error handling
leofang Sep 29, 2025
1f5159e
Revert "disable building/testing 313t/314/314t for now"
leofang Sep 29, 2025
566f966
Merge branch 'main' into merge_wheel
leofang Sep 29, 2025
dc8d076
fix artifact location
leofang Sep 29, 2025
a501cc7
cythonize device
leofang Sep 30, 2025
13bd07b
Merge branch 'main' into merge_wheel
leofang Sep 30, 2025
04d3f5d
making the linter happy, again
leofang Sep 30, 2025
a5d6826
fix uuid handling
leofang Sep 30, 2025
578984d
update release notes to note about compatibility requirement
leofang Sep 30, 2025
0e6f927
fix env vars being passed twice
leofang Sep 30, 2025
0e28aa1
fix uuid handling, again
leofang Sep 30, 2025
b5cc2ff
Merge branch 'main' into merge_wheel
leofang Sep 30, 2025
4ba0090
Apply suggestions from code review
leofang Sep 30, 2025
0471e44
Merge branch 'main' into merge_wheel
leofang Oct 1, 2025
20c5a99
address review comments
leofang Oct 1, 2025
473f8f2
Merge branch 'merge_wheel' of https://github.com/leofang/cuda-python …
leofang Oct 1, 2025
d79e317
switch to use FutureWarning
leofang Oct 2, 2025
4a37f97
Merge branch 'main' into merge_wheel
leofang Oct 3, 2025
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
17 changes: 14 additions & 3 deletions .github/actions/fetch_ctk/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ inputs:
required: false
type: string
default: "cuda_nvcc,cuda_cudart,cuda_crt,libnvvm,cuda_nvrtc,cuda_profiler_api,cuda_cccl,libnvjitlink,libcufile"
cuda-path:
description: "where the CTK components will be installed to, relative to $PWD"
required: false
type: string
default: "./cuda_toolkit"

runs:
using: composite
Expand Down Expand Up @@ -159,18 +164,24 @@ runs:
exit 1
fi

- name: Move CTK to the specified location
if: ${{ inputs.cuda-path != './cuda_toolkit' }}
shell: bash --noprofile --norc -xeuo pipefail {0}
run: |
mv ./cuda_toolkit ${{ inputs.cuda-path }}

- name: Set output environment variables
shell: bash --noprofile --norc -xeuo pipefail {0}
run: |
# mimics actual CTK installation
if [[ "${{ inputs.host-platform }}" == linux* ]]; then
CUDA_PATH=$(realpath "./cuda_toolkit")
echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH:-}:${CUDA_PATH}/lib" >> $GITHUB_ENV
CUDA_PATH=$(realpath "${{ inputs.cuda-path }}")
echo "LD_LIBRARY_PATH=${CUDA_PATH}/lib:${LD_LIBRARY_PATH:-}" >> $GITHUB_ENV
elif [[ "${{ inputs.host-platform }}" == win* ]]; then
function normpath() {
echo "$(echo $(cygpath -w $1) | sed 's/\\/\\\\/g')"
}
CUDA_PATH=$(normpath $(realpath "./cuda_toolkit"))
CUDA_PATH=$(normpath $(realpath "${{ inputs.cuda-path }}"))
echo "$(normpath ${CUDA_PATH}/bin)" >> $GITHUB_PATH
fi
echo "CUDA_PATH=${CUDA_PATH}" >> $GITHUB_ENV
Expand Down
186 changes: 158 additions & 28 deletions .github/workflows/build-wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ on:
cuda-version:
required: true
type: string
prev-cuda-version:
required: true
type: string

defaults:
run:
Expand Down Expand Up @@ -109,33 +112,6 @@ jobs:
path: cuda_pathfinder/*.whl
if-no-files-found: error

- name: Build cuda.core wheel
uses: pypa/cibuildwheel@7c619efba910c04005a835b110b057fc28fd6e93 # v3.2.0
with:
package-dir: ./cuda_core/
output-dir: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}

- name: List the cuda.core artifacts directory
run: |
if [[ "${{ inputs.host-platform }}" == win* ]]; then
export CHOWN=chown
else
export CHOWN="sudo chown"
fi
$CHOWN -R $(whoami) ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
ls -lahR ${{ env.CUDA_CORE_ARTIFACTS_DIR }}

- name: Check cuda.core wheel
run: |
twine check --strict ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl

- name: Upload cuda.core build artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: ${{ env.CUDA_CORE_ARTIFACT_NAME }}
path: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl
if-no-files-found: error

- name: Set up mini CTK
uses: ./.github/actions/fetch_ctk
continue-on-error: false
Expand All @@ -148,6 +124,15 @@ jobs:
with:
package-dir: ./cuda_bindings/
output-dir: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
env:
CIBW_BUILD: ${{ env.CIBW_BUILD }}
# CIBW mounts the host filesystem under /host
CIBW_ENVIRONMENT_LINUX: >
CUDA_PATH=/host/${{ env.CUDA_PATH }}
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
CIBW_ENVIRONMENT_WINDOWS: >
CUDA_PATH="$(cygpath -w ${{ env.CUDA_PATH }})"
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}

- name: List the cuda.bindings artifacts directory
run: |
Expand All @@ -170,6 +155,47 @@ jobs:
path: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}/*.whl
if-no-files-found: error

- name: Build cuda.core wheel
uses: pypa/cibuildwheel@c923d83ad9c1bc00211c5041d0c3f73294ff88f6 # v3.1.4
with:
package-dir: ./cuda_core/
output-dir: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
env:
CIBW_BUILD: ${{ env.CIBW_BUILD }}
# CIBW mounts the host filesystem under /host
CIBW_ENVIRONMENT_LINUX: >
CUDA_PATH=/host/${{ env.CUDA_PATH }}
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
CUDA_CORE_BUILD_MAJOR=${{ env.BUILD_CUDA_MAJOR }}
PIP_FIND_LINKS=/host/${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
CIBW_ENVIRONMENT_WINDOWS: >
CUDA_PATH="$(cygpath -w ${{ env.CUDA_PATH }})"
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
CUDA_CORE_BUILD_MAJOR=${{ env.BUILD_CUDA_MAJOR }}
PIP_FIND_LINKS="$(cygpath -w ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }})"

- name: List the cuda.core artifacts directory and rename
run: |
if [[ "${{ inputs.host-platform }}" == win* ]]; then
export CHOWN=chown
else
export CHOWN="sudo chown"
fi
$CHOWN -R $(whoami) ${{ env.CUDA_CORE_ARTIFACTS_DIR }}

# Rename wheel to include CUDA version suffix
mkdir -p "${{ env.CUDA_CORE_ARTIFACTS_DIR }}/cu${BUILD_CUDA_MAJOR}"
for wheel in ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl; do
if [[ -f "${wheel}" ]]; then
base_name=$(basename "${wheel}" .whl)
new_name="${base_name}.cu${BUILD_CUDA_MAJOR}.whl"
mv "${wheel}" "${{ env.CUDA_CORE_ARTIFACTS_DIR }}/cu${BUILD_CUDA_MAJOR}/${new_name}"
echo "Renamed wheel to: ${new_name}"
fi
done

ls -lahR ${{ env.CUDA_CORE_ARTIFACTS_DIR }}

# We only need/want a single pure python wheel, pick linux-64 index 0.
- name: Build and check cuda-python wheel
if: ${{ strategy.job-index == 0 && inputs.host-platform == 'linux-64' }}
Expand Down Expand Up @@ -241,7 +267,7 @@ jobs:

- name: Build cuda.core Cython tests
run: |
pip install ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl --group ./cuda_core/pyproject.toml:test
pip install ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/"cu${BUILD_CUDA_MAJOR}"/*.whl --group ./cuda_core/pyproject.toml:test
pushd ${{ env.CUDA_CORE_CYTHON_TESTS_DIR }}
bash build_tests.sh
popd
Expand All @@ -252,3 +278,107 @@ jobs:
name: ${{ env.CUDA_CORE_ARTIFACT_NAME }}-tests
path: ${{ env.CUDA_CORE_CYTHON_TESTS_DIR }}/test_*${{ env.PY_EXT_SUFFIX }}
if-no-files-found: error

# Note: This overwrites CUDA_PATH etc
- name: Set up mini CTK
uses: ./.github/actions/fetch_ctk
continue-on-error: false
with:
host-platform: ${{ inputs.host-platform }}
cuda-version: ${{ inputs.prev-cuda-version }}
cuda-path: "./cuda_toolkit_prev"

- name: Download cuda.bindings build artifacts from the prior branch
if: ${{ matrix.python-version == '3.13t'
|| matrix.python-version == '3.14'
|| matrix.python-version == '3.14t' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if ! (command -v gh 2>&1 >/dev/null); then
# See https://github.com/cli/cli/blob/trunk/docs/install_linux.md#debian-ubuntu-linux-raspberry-pi-os-apt.
# gh is needed for artifact fetching.
mkdir -p -m 755 /etc/apt/keyrings \
&& out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
&& cat $out | tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
&& chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
&& 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 \
&& apt update \
&& apt install gh -y
fi

OLD_BRANCH=$(cat .github/BACKPORT_BRANCH)
OLD_BASENAME="cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda*-${{ inputs.host-platform }}*"
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')
if [[ "$LATEST_PRIOR_RUN_ID" == "" ]]; then
echo "LATEST_PRIOR_RUN_ID not found!"
exit 1
fi

gh run download $LATEST_PRIOR_RUN_ID -p ${OLD_BASENAME} -R NVIDIA/cuda-python
rm -rf ${OLD_BASENAME}-tests # exclude cython test artifacts
ls -al $OLD_BASENAME
mkdir -p "${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}"
mv $OLD_BASENAME/*.whl "${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}"
rmdir $OLD_BASENAME

- name: Build cuda.core wheel
uses: pypa/cibuildwheel@c923d83ad9c1bc00211c5041d0c3f73294ff88f6 # v3.1.4
with:
package-dir: ./cuda_core/
output-dir: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
env:
CIBW_BUILD: ${{ env.CIBW_BUILD }}
# CIBW mounts the host filesystem under /host
CIBW_ENVIRONMENT_LINUX: >
CUDA_PATH=/host/${{ env.CUDA_PATH }}
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
CUDA_CORE_BUILD_MAJOR=${{ env.BUILD_PREV_CUDA_MAJOR }}
PIP_FIND_LINKS=/host/${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
CIBW_ENVIRONMENT_WINDOWS: >
CUDA_PATH="$(cygpath -w ${{ env.CUDA_PATH }})"
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
CUDA_CORE_BUILD_MAJOR=${{ env.BUILD_PREV_CUDA_MAJOR }}
PIP_FIND_LINKS="$(cygpath -w ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }})"

- name: List the cuda.core artifacts directory and rename
run: |
if [[ "${{ inputs.host-platform }}" == win* ]]; then
export CHOWN=chown
else
export CHOWN="sudo chown"
fi
$CHOWN -R $(whoami) ${{ env.CUDA_CORE_ARTIFACTS_DIR }}
ls -lahR ${{ env.CUDA_CORE_ARTIFACTS_DIR }}

# Rename wheel to include CUDA version suffix
mkdir -p "${{ env.CUDA_CORE_ARTIFACTS_DIR }}/cu${BUILD_PREV_CUDA_MAJOR}"
for wheel in ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl; do
if [[ -f "${wheel}" ]]; then
base_name=$(basename "${wheel}" .whl)
new_name="${base_name}.cu${BUILD_PREV_CUDA_MAJOR}.whl"
mv "${wheel}" "${{ env.CUDA_CORE_ARTIFACTS_DIR }}/cu${BUILD_PREV_CUDA_MAJOR}/${new_name}"
echo "Renamed wheel to: ${new_name}"
fi
done

ls -lahR ${{ env.CUDA_CORE_ARTIFACTS_DIR }}

- name: Merge cuda.core wheels
run: |
pip install wheel
python ci/tools/merge_cuda_core_wheels.py \
"${{ env.CUDA_CORE_ARTIFACTS_DIR }}"/cu"${BUILD_CUDA_MAJOR}"/cuda_core*.whl \
"${{ env.CUDA_CORE_ARTIFACTS_DIR }}"/cu"${BUILD_PREV_CUDA_MAJOR}"/cuda_core*.whl \
--output-dir "${{ env.CUDA_CORE_ARTIFACTS_DIR }}"

- name: Check cuda.core wheel
run: |
twine check --strict ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl

- name: Upload cuda.core build artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: ${{ env.CUDA_CORE_ARTIFACT_NAME }}
path: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl
if-no-files-found: error
9 changes: 8 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,21 @@ jobs:
runs-on: ubuntu-latest
outputs:
CUDA_BUILD_VER: ${{ steps.get-vars.outputs.cuda_build_ver }}
CUDA_PREV_BUILD_VER: ${{ steps.get-vars.outputs.cuda_prev_build_ver }}
steps:
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0
- name: Get CUDA build version
- name: Get CUDA build versions
id: get-vars
run: |
cuda_build_ver=$(jq -r .cuda.build.version ci/versions.json)
echo "cuda_build_ver=$cuda_build_ver" >> $GITHUB_OUTPUT

cuda_prev_build_ver=$(jq -r .cuda.prev_build.version ci/versions.json)
echo "cuda_prev_build_ver=$cuda_prev_build_ver" >> $GITHUB_OUTPUT

should-skip:
runs-on: ubuntu-latest
outputs:
Expand Down Expand Up @@ -69,6 +73,7 @@ jobs:
with:
host-platform: ${{ matrix.host-platform }}
cuda-version: ${{ needs.ci-vars.outputs.CUDA_BUILD_VER }}
prev-cuda-version: ${{ needs.ci-vars.outputs.CUDA_PREV_BUILD_VER }}

# WARNING: make sure all of the build jobs are in sync
build-linux-aarch64:
Expand All @@ -87,6 +92,7 @@ jobs:
with:
host-platform: ${{ matrix.host-platform }}
cuda-version: ${{ needs.ci-vars.outputs.CUDA_BUILD_VER }}
prev-cuda-version: ${{ needs.ci-vars.outputs.CUDA_PREV_BUILD_VER }}

# WARNING: make sure all of the build jobs are in sync
build-windows:
Expand All @@ -105,6 +111,7 @@ jobs:
with:
host-platform: ${{ matrix.host-platform }}
cuda-version: ${{ needs.ci-vars.outputs.CUDA_BUILD_VER }}
prev-cuda-version: ${{ needs.ci-vars.outputs.CUDA_PREV_BUILD_VER }}

# WARNING: make sure both Linux test jobs are in sync
test-linux-64:
Expand Down
2 changes: 1 addition & 1 deletion .spdx-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ requirements*.txt
cuda_bindings/examples/*

# Vendored
cuda_core/cuda/core/experimental/dlpack.h
cuda_core/cuda/core/experimental/include/dlpack.h
3 changes: 3 additions & 0 deletions ci/tools/env-vars
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ if [[ "${1}" == "build" ]]; then
# platform is handled by the default value of platform (`auto`) in cibuildwheel
# here we only need to specify the python version we want
echo "CIBW_BUILD=cp${PYTHON_VERSION_FORMATTED}-*" >> $GITHUB_ENV
BUILD_CUDA_MAJOR="$(cut -d '.' -f 1 <<< ${CUDA_VER})"
echo "BUILD_CUDA_MAJOR=${BUILD_CUDA_MAJOR}" >> $GITHUB_ENV
echo "BUILD_PREV_CUDA_MAJOR=$((${BUILD_CUDA_MAJOR} - 1))" >> $GITHUB_ENV
CUDA_BINDINGS_ARTIFACT_BASENAME="cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda${CUDA_VER}-${HOST_PLATFORM}"
elif [[ "${1}" == "test" ]]; then
BUILD_CUDA_MAJOR="$(cut -d '.' -f 1 <<< ${BUILD_CUDA_VER})"
Expand Down
Loading
Loading