diff --git a/.github/BACKPORT_BRANCH b/.github/BACKPORT_BRANCH new file mode 100644 index 00000000..9266e678 --- /dev/null +++ b/.github/BACKPORT_BRANCH @@ -0,0 +1 @@ +11.8.x diff --git a/.github/ISSUE_TEMPLATE/release_checklist.yml b/.github/ISSUE_TEMPLATE/release_checklist.yml index 34b7bcee..ce168c58 100644 --- a/.github/ISSUE_TEMPLATE/release_checklist.yml +++ b/.github/ISSUE_TEMPLATE/release_checklist.yml @@ -12,6 +12,7 @@ body: label: Tasks for cuda-bindings / cuda-python release options: - label: "Push any internal updates for accommodating a new CTK release to the public (**IMPORTANT**: Need to wait for CTK posting!)" + - label: "If it is a major release, create a new branch to backport to and update the branch name [here](../BACKPORT_BRANCH)" - label: Follow the check list for `cuda-core` below for the remaining steps - type: checkboxes diff --git a/.github/actions/fetch_ctk/action.yml b/.github/actions/fetch_ctk/action.yml index 7b8674ab..5850b4c7 100644 --- a/.github/actions/fetch_ctk/action.yml +++ b/.github/actions/fetch_ctk/action.yml @@ -20,35 +20,11 @@ runs: echo "CTK_CACHE_FILENAME=mini-ctk-${{ inputs.cuda-version }}-${{ inputs.host-platform }}.tar.gz" >> $GITHUB_ENV - name: Install dependencies - shell: bash --noprofile --norc -xeuo pipefail {0} - run: | - dependencies=(zstd curl xz-utils) - dependent_exes=(zstd curl xz) - - not_found=0 - for dep in ${dependent_exes[@]}; do - if ! (command -v curl 2>&1 >/dev/null); then - not_found=1 - break - fi - done - if [[ $not_found == 0 ]]; then - echo "All dependencies are found. Do nothing." - exit 0 - fi - if ! (command -v sudo 2>&1 >/dev/null); then - if [[ $EUID == 0 ]]; then - alias SUDO="" - else - echo "The following oprations require root access." - exit 1 - fi - else - alias SUDO="sudo" - fi - shopt -s expand_aliases - SUDO apt update - SUDO apt install -y ${dependencies[@]} + uses: ./.github/actions/install_unix_deps + continue-on-error: false + with: + dependencies: "zstd curl xz-utils" + dependent_exes: "zstd curl xz" - name: Download CTK cache id: ctk-get-cache diff --git a/.github/actions/install_unix_deps/action.yml b/.github/actions/install_unix_deps/action.yml new file mode 100644 index 00000000..f1ee73ab --- /dev/null +++ b/.github/actions/install_unix_deps/action.yml @@ -0,0 +1,45 @@ +name: Install dependencies on Ubuntu + +description: Install needed dependencies, regardless if using GitHub- or self- hosted runners, container, sudo or not. + +inputs: + dependencies: + required: true + type: string + dependent_exes: + required: true + type: string + +runs: + using: composite + steps: + - name: Install dependencies + shell: bash --noprofile --norc -xeuo pipefail {0} + run: | + dependencies=(${{ inputs.dependencies }}) + dependent_exes=(${{ inputs.dependent_exes }}) + + not_found=0 + for dep in ${dependent_exes[@]}; do + if ! (command -v $dep 2>&1 >/dev/null); then + not_found=1 + break + fi + done + if [[ $not_found == 0 ]]; then + echo "All dependencies are found. Do nothing." + exit 0 + fi + if ! (command -v sudo 2>&1 >/dev/null); then + if [[ $EUID == 0 ]]; then + alias SUDO="" + else + echo "The following oprations require root access." + exit 1 + fi + else + alias SUDO="sudo" + fi + shopt -s expand_aliases + SUDO apt update + SUDO apt install -y ${dependencies[@]} diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index 28bb2b41..47e2c531 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -19,6 +19,13 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + + - name: Load branch name + id: get-branch + run: | + OLD_BRANCH=$(cat .github/BACKPORT_BRANCH) + echo "OLD_BRANCH=${OLD_BRANCH}" >> $GITHUB_ENV + - name: Create backport pull requests uses: korthout/backport-action@v3 with: @@ -26,4 +33,5 @@ jobs: copy_labels_pattern: true copy_requested_reviewers: true label_pattern: to-be-backported - target_branches: 11.8.x + target_branches: ${{ fromJSON(env.OLD_BRANCH) }} + conflict_resolution: draft_commit_conflicts diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index bd7363c8..98e4827c 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -1,3 +1,4 @@ +# Note: This name is referred to in the test job, so make sure any changes are sync'd up! name: "CI: Build and test" concurrency: @@ -42,6 +43,9 @@ jobs: # (matrix.host-platform == 'win-64' && 'windows-amd64-cpu8') }} outputs: BUILD_CTK_VER: ${{ steps.pass_env.outputs.CUDA_VERSION }} + defaults: + run: + shell: bash --noprofile --norc -xeuo pipefail {0} steps: - name: Checkout ${{ github.event.repository.name }} uses: actions/checkout@v4 @@ -62,7 +66,6 @@ jobs: uses: ilammy/msvc-dev-cmd@v1 - name: Set environment variables - shell: bash --noprofile --norc -xeuo pipefail {0} run: | PYTHON_VERSION_FORMATTED=$(echo '${{ matrix.python-version }}' | tr -d '.') if [[ "${{ matrix.host-platform }}" == linux* ]]; then @@ -75,14 +78,17 @@ jobs: fi echo "PARALLEL_LEVEL=$(nproc)" >> $GITHUB_ENV - echo "CUDA_CORE_ARTIFACT_NAME=cuda-core-python${PYTHON_VERSION_FORMATTED}-${{ matrix.host-platform }}-${{ github.sha }}" >> $GITHUB_ENV + CUDA_CORE_ARTIFACT_BASENAME="cuda-core-python${PYTHON_VERSION_FORMATTED}-${{ matrix.host-platform }}" + echo "CUDA_CORE_ARTIFACT_BASENAME=${CUDA_CORE_ARTIFACT_BASENAME}" >> $GITHUB_ENV + echo "CUDA_CORE_ARTIFACT_NAME=${CUDA_CORE_ARTIFACT_BASENAME}-${{ github.sha }}" >> $GITHUB_ENV echo "CUDA_CORE_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_core/dist")" >> $GITHUB_ENV - echo "CUDA_BINDINGS_ARTIFACT_NAME=cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda${{ matrix.cuda-version }}-${{ matrix.host-platform }}-${{ github.sha }}" >> $GITHUB_ENV + CUDA_BINDINGS_ARTIFACT_BASENAME="cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda${{ matrix.cuda-version }}-${{ matrix.host-platform }}" + echo "CUDA_BINDINGS_ARTIFACT_BASENAME=${CUDA_BINDINGS_ARTIFACT_BASENAME}" >> $GITHUB_ENV + echo "CUDA_BINDINGS_ARTIFACT_NAME=${CUDA_BINDINGS_ARTIFACT_BASENAME}-${{ github.sha }}" >> $GITHUB_ENV echo "CUDA_BINDINGS_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_bindings/dist")" >> $GITHUB_ENV echo "CIBW_BUILD=${CIBW_BUILD}" >> $GITHUB_ENV - + - name: Dump environment - shell: bash --noprofile --norc -xeuo pipefail {0} run: | env @@ -97,7 +103,6 @@ jobs: output-dir: ${{ env.CUDA_CORE_ARTIFACTS_DIR }} - name: List the cuda.core artifacts directory - shell: bash --noprofile --norc -xeuo pipefail {0} run: | if [[ "${{ matrix.host-platform }}" == win* ]]; then export CHOWN=chown @@ -108,7 +113,6 @@ jobs: ls -lahR ${{ env.CUDA_CORE_ARTIFACTS_DIR }} - name: Check cuda.core wheel - shell: bash --noprofile --norc -xeuo pipefail {0} run: | pip install twine twine check ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl @@ -146,7 +150,6 @@ jobs: output-dir: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }} - name: List the cuda.bindings artifacts directory - shell: bash --noprofile --norc -xeuo pipefail {0} run: | if [[ "${{ matrix.host-platform }}" == win* ]]; then export CHOWN=chown @@ -158,7 +161,6 @@ jobs: # TODO: enable this after NVIDIA/cuda-python#297 is resolved # - name: Check cuda.bindings wheel - # shell: bash --noprofile --norc -xeuo pipefail {0} # run: | # twine check ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}/*.whl @@ -205,7 +207,7 @@ jobs: runner: H100 name: Test (${{ matrix.host-platform }}, Python ${{ matrix.python-version }}, CUDA ${{ matrix.cuda-version }}, Runner ${{ matrix.runner }}) # The build stage could fail but we want the CI to keep moving. - if: ${{ github.repository_owner == 'nvidia' && always() }} + if: ${{ github.repository_owner == 'nvidia' && !cancelled() }} permissions: id-token: write # This is required for configure-aws-credentials contents: read # This is required for actions/checkout @@ -221,9 +223,11 @@ jobs: NVIDIA_VISIBLE_DEVICES: ${{ env.NVIDIA_VISIBLE_DEVICES }} needs: - build + defaults: + run: + shell: bash --noprofile --norc -xeuo pipefail {0} steps: - name: Ensure GPU is working - shell: bash --noprofile --norc -xeuo pipefail {0} run: nvidia-smi - name: Checkout ${{ github.event.repository.name }} @@ -232,7 +236,6 @@ jobs: fetch-depth: 0 - name: Set environment variables - shell: bash --noprofile --norc -xeuo pipefail {0} run: | PYTHON_VERSION_FORMATTED=$(echo '${{ matrix.python-version }}' | tr -d '.') if [[ "${{ matrix.host-platform }}" == linux* ]]; then @@ -251,20 +254,56 @@ jobs: fi # make outputs from the previous job as env vars - echo "CUDA_CORE_ARTIFACT_NAME=cuda-core-python${PYTHON_VERSION_FORMATTED}-${{ matrix.host-platform }}-${{ github.sha }}" >> $GITHUB_ENV + CUDA_CORE_ARTIFACT_BASENAME="cuda-core-python${PYTHON_VERSION_FORMATTED}-${{ matrix.host-platform }}" + echo "PYTHON_VERSION_FORMATTED=${PYTHON_VERSION_FORMATTED}" >> $GITHUB_ENV + echo "CUDA_CORE_ARTIFACT_BASENAME=${CUDA_CORE_ARTIFACT_BASENAME}" >> $GITHUB_ENV + echo "CUDA_CORE_ARTIFACT_NAME=${CUDA_CORE_ARTIFACT_BASENAME}-${{ github.sha }}" >> $GITHUB_ENV echo "CUDA_CORE_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_core/dist")" >> $GITHUB_ENV - echo "CUDA_BINDINGS_ARTIFACT_NAME=cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda${{ needs.build.outputs.BUILD_CTK_VER }}-${{ matrix.host-platform }}-${{ github.sha }}" >> $GITHUB_ENV + CUDA_BINDINGS_ARTIFACT_BASENAME="cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda${{ needs.build.outputs.BUILD_CTK_VER }}-${{ matrix.host-platform }}" + echo "CUDA_BINDINGS_ARTIFACT_BASENAME=${CUDA_BINDINGS_ARTIFACT_BASENAME}" >> $GITHUB_ENV + echo "CUDA_BINDINGS_ARTIFACT_NAME=${CUDA_BINDINGS_ARTIFACT_BASENAME}-${{ github.sha }}" >> $GITHUB_ENV echo "CUDA_BINDINGS_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_bindings/dist")" >> $GITHUB_ENV echo "SKIP_CUDA_BINDINGS_TEST=${SKIP_CUDA_BINDINGS_TEST}" >> $GITHUB_ENV + - name: Install dependencies + uses: ./.github/actions/install_unix_deps + continue-on-error: false + with: + # gcc for Cython tests, jq/wget for artifact fetching + dependencies: "build-essential jq wget" + dependent_exes: "gcc jq wget" + - name: Download cuda.bindings build artifacts + if: ${{ env.SKIP_CUDA_BINDINGS_TEST == '0'}} uses: actions/download-artifact@v4 with: name: ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }} path: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }} + - name: Download cuda.bindings build artifacts from the prior branch + if: ${{ env.SKIP_CUDA_BINDINGS_TEST == '1'}} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # 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 + + OLD_BRANCH=$(cat .github/BACKPORT_BRANCH) + OLD_BASENAME="cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda*-${{ matrix.host-platform }}*" + LATEST_PRIOR_RUN_ID=$(gh run list -b ${OLD_BRANCH} -L 1 -w "CI: Build and test" -s completed -R NVIDIA/cuda-python --json databaseId | jq '.[]| .databaseId') + gh run download $LATEST_PRIOR_RUN_ID -p ${OLD_BASENAME} -R NVIDIA/cuda-python + ls -al $OLD_BASENAME + mkdir -p "${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}" + mv $OLD_BASENAME/*.whl "${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}"/ + - name: Display structure of downloaded cuda.bindings artifacts - shell: bash --noprofile --norc -xeuo pipefail {0} run: | pwd ls -lahR $CUDA_BINDINGS_ARTIFACTS_DIR @@ -276,7 +315,6 @@ jobs: path: ${{ env.CUDA_CORE_ARTIFACTS_DIR }} - name: Display structure of downloaded cuda.core build artifacts - shell: bash --noprofile --norc -xeuo pipefail {0} run: | pwd ls -lahR $CUDA_CORE_ARTIFACTS_DIR @@ -298,7 +336,6 @@ jobs: - name: Run cuda.bindings tests if: ${{ env.SKIP_CUDA_BINDINGS_TEST == '0' }} - shell: bash --noprofile --norc -xeuo pipefail {0} run: | ls $CUDA_PATH @@ -310,8 +347,6 @@ jobs: pip install -r requirements.txt pytest -rxXs tests/ if [[ "${{ matrix.host-platform }}" == linux* ]]; then - # cython tests require gcc - apt install -y build-essential bash tests/cython/build_tests.sh elif [[ "${{ matrix.host-platform }}" == win* ]]; then # TODO: enable this once win-64 runners are up @@ -321,18 +356,14 @@ jobs: popd - name: Run cuda.core tests - shell: bash --noprofile --norc -xeuo pipefail {0} run: | - if [[ ${{ matrix.python-version }} == "3.13" ]]; then - # TODO: remove this hack once cuda-python has a cp313 build - if [[ $SKIP_CUDA_BINDINGS_TEST == 1 ]]; then - echo "Python 3.13 + cuda-python ${{ matrix.cuda-version }} is not supported, skipping the test..." - exit 0 - fi - fi - # If build/test majors match: cuda.bindings is installed in the previous step. - # If mismatch: cuda.bindings is installed from PyPI. + # If mismatch: cuda.bindings is installed from the backport branch. + if [[ "${SKIP_CUDA_BINDINGS_TEST}" == 1 ]]; then + pushd "${CUDA_BINDINGS_ARTIFACTS_DIR}" + pip install *.whl + popd + fi TEST_CUDA_MAJOR="$(cut -d '.' -f 1 <<< ${{ matrix.cuda-version }})" pushd "${CUDA_CORE_ARTIFACTS_DIR}" pip install $(ls *.whl)["cu${TEST_CUDA_MAJOR}"] @@ -346,7 +377,7 @@ jobs: doc: name: Docs # The build stage could fail but we want the CI to keep moving. - if: ${{ github.repository_owner == 'nvidia' && always() }} + if: ${{ github.repository_owner == 'nvidia' && !cancelled() }} # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: id-token: write diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 0f6ad311..cafb1fc9 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -11,7 +11,7 @@ jobs: build: name: Build docs # The build stage could fail but we want the CI to keep moving. - if: ${{ github.repository_owner == 'nvidia' && always() }} + if: ${{ github.repository_owner == 'nvidia' && !cancelled() }} # WAR: Building the doc currently requires a GPU (NVIDIA/cuda-python#326,327) runs-on: linux-amd64-gpu-t4-latest-1-testing #runs-on: ubuntu-latest @@ -61,9 +61,13 @@ jobs: REPO_DIR=$(pwd) # make outputs from the previous job as env vars - echo "CUDA_CORE_ARTIFACT_NAME=cuda-core-python${PYTHON_VERSION_FORMATTED}-linux-64-${{ github.sha }}" >> $GITHUB_ENV + CUDA_CORE_ARTIFACT_BASENAME="cuda-core-python${PYTHON_VERSION_FORMATTED}-linux-64" + echo "CUDA_CORE_ARTIFACT_BASENAME=${CUDA_CORE_ARTIFACT_BASENAME}" >> $GITHUB_ENV + echo "CUDA_CORE_ARTIFACT_NAME=${CUDA_CORE_ARTIFACT_BASENAME}-${{ github.sha }}" >> $GITHUB_ENV echo "CUDA_CORE_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_core/dist")" >> $GITHUB_ENV - echo "CUDA_BINDINGS_ARTIFACT_NAME=cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda${{ inputs.build_ctk_ver }}-linux-64-${{ github.sha }}" >> $GITHUB_ENV + CUDA_BINDINGS_ARTIFACT_BASENAME="cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda${{ inputs.build_ctk_ver }}-linux-64" + echo "CUDA_BINDINGS_ARTIFACT_BASENAME=${CUDA_BINDINGS_ARTIFACT_BASENAME}" >> $GITHUB_ENV + echo "CUDA_BINDINGS_ARTIFACT_NAME=${CUDA_BINDINGS_ARTIFACT_BASENAME}-${{ github.sha }}" >> $GITHUB_ENV echo "CUDA_BINDINGS_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_bindings/dist")" >> $GITHUB_ENV - name: Download cuda.bindings build artifacts