Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for CI testing #124

Merged
merged 58 commits into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
c626b95
Adding support for CI testing.
sandeepd-nv Sep 23, 2024
5467b52
Supply python-version.
sandeepd-nv Nov 26, 2024
c78ebfd
Update test driver to test bindings and core separately.
sandeepd-nv Nov 26, 2024
e5bf104
Adding support for CI testing.
sandeepd-nv Sep 23, 2024
360e1b2
Adding support for CI testing. Attempt 2.
sandeepd-nv Sep 23, 2024
67b7aed
Adding support for CI testing. Attempt 3.
sandeepd-nv Sep 23, 2024
6fab977
Use container for tests on the GPU runner.
sandeepd-nv Sep 23, 2024
f2a0939
Use container for tests on the GPU runner. Attempt 2.
sandeepd-nv Sep 23, 2024
508a83c
Remove build caching.
sandeepd-nv Nov 15, 2024
72062aa
Hard select Build (without container).
sandeepd-nv Nov 15, 2024
32ca908
Use container with preinstalled conda for build.
sandeepd-nv Nov 15, 2024
970a8e5
Use container with preinstalled conda for build. Attempt 2.
sandeepd-nv Nov 15, 2024
be969e5
Use container with preinstalled conda for build. Attempt 3.
sandeepd-nv Nov 15, 2024
3382d68
Updated paths.
sandeepd-nv Nov 29, 2024
a9ed0c6
Removed duplicate tests section.
sandeepd-nv Nov 29, 2024
84124b5
Run cuda_core tests before cuda_binding.
sandeepd-nv Dec 4, 2024
47a7235
Merge branch 'main' into add_ci_test
leofang Dec 7, 2024
aeebaf7
skip testing on win; remove mac
leofang Dec 7, 2024
76a8822
fix typo
leofang Dec 7, 2024
c23467f
skip setup if build stage was called
leofang Dec 7, 2024
3d892ad
set build output
leofang Dec 7, 2024
ae0a994
pass output from build to test
leofang Dec 7, 2024
c3fe6a1
wrong place
leofang Dec 7, 2024
0bbc706
it's the build workflow, not action, that should have outputs
leofang Dec 7, 2024
ba0bbde
fix indentation
leofang Dec 7, 2024
aed5bb6
try to take output as a string
leofang Dec 7, 2024
330251d
fix logic
leofang Dec 7, 2024
076104b
multiple fixes
leofang Dec 7, 2024
7c6fba0
merge build & test workflows to allow passing env vars; further simpl…
leofang Dec 8, 2024
ca7b437
no need to pass secrets as we don't have reusable workflows anymore
leofang Dec 8, 2024
5d0b014
pass job outputs explicitly...
leofang Dec 8, 2024
7350965
try changing the order
leofang Dec 8, 2024
eedffd9
fix syntax
leofang Dec 8, 2024
c7d3e03
fix workflow merge error
leofang Dec 8, 2024
35c244f
allow mini-ctk to be cached & reused in tests
leofang Dec 8, 2024
5615d54
fix typo
leofang Dec 8, 2024
bb5fed3
try to escape | and > ...
leofang Dec 8, 2024
9d6e69b
switch to gz for simplicity
leofang Dec 8, 2024
8ec6090
fix artifact parallel upload & lack of cache key
leofang Dec 8, 2024
9456177
fix download path
leofang Dec 8, 2024
2f2046d
fix extract
leofang Dec 8, 2024
c361ad8
propagate cuda-version
leofang Dec 8, 2024
37a3bb1
install binding test deps
leofang Dec 8, 2024
54707dc
fix paths
leofang Dec 8, 2024
3faf8a3
include nvjitlink to mini CTK for testing
leofang Dec 8, 2024
e35706a
ensure cupy is an optional test dependency
leofang Dec 8, 2024
e0c610e
per arch ctk
leofang Dec 8, 2024
fb487d0
fix arg passing
leofang Dec 8, 2024
c01e015
fix invalid context during test teardown
leofang Dec 8, 2024
f1d0e40
WAR: mark PTX test xfail due to CI condition
leofang Dec 8, 2024
a08fbc9
debug
leofang Dec 8, 2024
f36393e
also detect if CUDA is ever initialized
leofang Dec 8, 2024
7f623a0
Merge branch 'add_ci_test' of https://github.com/sandeepd-nv/cuda-pyt…
leofang Dec 8, 2024
f3cc6bd
ensure CUDA is init'd at test start time
leofang Dec 8, 2024
b1f07a3
enforce the right CC is passed to NVRTC
leofang Dec 8, 2024
8a6738b
fix xfail mark
leofang Dec 8, 2024
ed0386a
switch to use github cache to improve reuse
leofang Dec 8, 2024
7b074f0
clean up legacy CI scripts
leofang Dec 8, 2024
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
43 changes: 43 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,22 @@ runs:
run: |
env

- name: Set up CTK cache variable
shell: bash --noprofile --norc -xeuo pipefail {0}
run: |
echo "CTK_CACHE_KEY=mini-ctk-${{ inputs.cuda-version }}-${{ inputs.host-platform }}" >> $GITHUB_ENV
echo "CTK_CACHE_FILENAME=mini-ctk-${{ inputs.cuda-version }}-${{ inputs.host-platform }}.tar.gz" >> $GITHUB_ENV

- name: Download CTK cache
id: ctk-get-cache
uses: actions/cache/restore@v4
continue-on-error: true
with:
key: ${{ env.CTK_CACHE_KEY }}
path: ./${{ env.CTK_CACHE_FILENAME }}

- name: Get CUDA components
if: ${{ steps.ctk-get-cache.outputs.cache-hit != 'true' }}
shell: bash --noprofile --norc -xeuo pipefail {0}
run: |
CUDA_PATH="./cuda_toolkit"
Expand Down Expand Up @@ -90,15 +105,43 @@ runs:
}

# Get headers and shared libraries in place
# Note: the existing artifact would need to be manually deleted (ex: through web UI)
# if this list is changed, as the artifact actions do not offer any option for us to
# invalidate the artifact.
populate_cuda_path cuda_nvcc
populate_cuda_path cuda_cudart
populate_cuda_path cuda_nvrtc
populate_cuda_path cuda_profiler_api
populate_cuda_path libnvjitlink
ls -l $CUDA_PATH

# Prepare the cache
# Note: try to escape | and > ...
tar -czvf ${CTK_CACHE_FILENAME} ${CUDA_PATH}

# Note: the headers will be copied into the cibuildwheel manylinux container,
# so setting the CUDA_PATH env var here is meaningless.

- name: Upload CTK cache
if: ${{ always() &&
steps.ctk-get-cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v4
with:
key: ${{ env.CTK_CACHE_KEY }}
path: ./${{ env.CTK_CACHE_FILENAME }}

- name: Restore CTK cache
if: ${{ steps.ctk-get-cache.outputs.cache-hit == 'true' }}
shell: bash --noprofile --norc -xeuo pipefail {0}
run: |
ls -l
CUDA_PATH="./cuda_toolkit"
tar -xzvf $CTK_CACHE_FILENAME
ls -l $CUDA_PATH
if [ ! -d "$CUDA_PATH/include" ]; then
exit 1
fi

- name: Set environment variables
shell: bash --noprofile --norc -xeuo pipefail {0}
run: |
Expand Down
93 changes: 93 additions & 0 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: test

description: Run tests in specified project

inputs:
test-options:
required: true
type: string

runs:
using: composite
steps:
- name: Run nvidia-smi to make sure GPU is working
shell: bash --noprofile --norc -xeuo pipefail {0}
run: nvidia-smi

- name: Download bindings build artifacts
uses: actions/download-artifact@v4
with:
name: ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }}
path: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}

- name: Display structure of downloaded bindings artifacts
shell: bash --noprofile --norc -xeuo pipefail {0}
run: |
pwd
ls -lahR $CUDA_BINDINGS_ARTIFACTS_DIR

- name: Download core build artifacts
uses: actions/download-artifact@v4
with:
name: ${{ env.CUDA_CORE_ARTIFACT_NAME }}
path: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}

- name: Display structure of downloaded core build artifacts
shell: bash --noprofile --norc -xeuo pipefail {0}
run: |
pwd
ls -lahR $CUDA_CORE_ARTIFACTS_DIR

- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Set up CTK cache variable
shell: bash --noprofile --norc -xeuo pipefail {0}
run: |
echo "CTK_CACHE_KEY=mini-ctk-${CTK_BUILD_VER}-${HOST_PLATFORM}" >> $GITHUB_ENV
echo "CTK_CACHE_FILENAME=mini-ctk-${CTK_BUILD_VER}-${HOST_PLATFORM}.tar.gz" >> $GITHUB_ENV

- name: Download CTK cache
id: ctk-get-cache
uses: actions/cache/restore@v4
continue-on-error: true
with:
key: ${{ env.CTK_CACHE_KEY }}
path: ./${{ env.CTK_CACHE_FILENAME }}
fail-on-cache-miss: true

- name: Restore CTK cache
shell: bash --noprofile --norc -xeuo pipefail {0}
run: |
ls -l
CUDA_PATH="$(pwd)/cuda_toolkit"
tar -xzvf $CTK_CACHE_FILENAME
ls -l $CUDA_PATH
if [ ! -d "$CUDA_PATH/include" ]; then
exit 1
fi

echo "CUDA_PATH=$CUDA_PATH" >> $GITHUB_ENV
echo "PATH=$PATH:$CUDA_PATH/bin" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CUDA_PATH/lib" >> $GITHUB_ENV

- name: Run test / analysis
shell: bash --noprofile --norc -xeuo pipefail {0}
run: |
REPO_DIR=$(pwd)

cd "${CUDA_BINDINGS_ARTIFACTS_DIR}"
pip install *.whl

cd "${CUDA_CORE_ARTIFACTS_DIR}"
pip install *.whl

cd "${REPO_DIR}/cuda_bindings"
pip install -r requirements.txt
pytest tests/
#pytest tests/cython

cd "${REPO_DIR}/cuda_core"
pytest -rxXs tests/
6 changes: 3 additions & 3 deletions .github/workflows/ci-gh.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and test
name: "CI"

concurrency:
group: ${{ startsWith(github.ref_name, 'main') && format('unique-{0}', github.run_id) || format('ci-build-and-test-on-{0}-from-{1}', github.event_name, github.ref_name) }}
Expand All @@ -11,8 +11,7 @@ on:
- "main"

jobs:
build-and-test:
name: Build and test (${{ matrix.host-platform }}, ${{ matrix.target-device }}, ${{ matrix.build-mode }})
ci:
strategy:
fail-fast: false
matrix:
Expand All @@ -35,6 +34,7 @@ jobs:
# Note: this is for build-time only; the test-time matrix needs to be
# defined separately.
- "12.6.2"
name: "CI"
uses:
./.github/workflows/gh-build-and-test.yml
with:
Expand Down
113 changes: 96 additions & 17 deletions .github/workflows/gh-build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,100 @@ on:

jobs:
build:
name: Build (${{ inputs.host-platform }}, Python "${{ inputs.python-version }}")
if: ${{ github.repository_owner == 'nvidia' }}
uses:
./.github/workflows/gh-build.yml
with:
client-repo: ${{ github.event.repository.name }}
target-device: ${{ inputs.target-device }}
runs-on: ${{ (inputs.host-platform == 'linux-x64' && 'linux-amd64-cpu8') ||
(inputs.host-platform == 'linux-aarch64' && 'linux-arm64-cpu8') ||
(inputs.host-platform == 'win-x64' && 'windows-2019') }}
# (inputs.host-platform == 'win-x64' && 'windows-amd64-cpu8') }}
build-type: ${{ inputs.build-type }}
host-platform: ${{ inputs.host-platform }}
build-mode: ${{ inputs.build-mode }}
upload-enabled: ${{ inputs.upload-enabled }}
python-version: ${{ inputs.python-version }}
cuda-version: ${{ inputs.cuda-version }}
dependencies-file: ""
secrets: inherit
permissions:
id-token: write # This is required for configure-aws-credentials
contents: read # This is required for actions/checkout
runs-on: ${{ (inputs.host-platform == 'linux-x64' && 'linux-amd64-cpu8') ||
(inputs.host-platform == 'linux-aarch64' && 'linux-arm64-cpu8') ||
(inputs.host-platform == 'win-x64' && 'windows-2019') }}
# (inputs.host-platform == 'win-x64' && 'windows-amd64-cpu8') }}
outputs:
CUDA_CORE_ARTIFACT_NAME: ${{ steps.pass_env.outputs.CUDA_CORE_ARTIFACT_NAME }}
CUDA_CORE_ARTIFACTS_DIR: ${{ steps.pass_env.outputs.CUDA_CORE_ARTIFACTS_DIR }}
CUDA_BINDINGS_ARTIFACT_NAME: ${{ steps.pass_env.outputs.CUDA_BINDINGS_ARTIFACT_NAME }}
CUDA_BINDINGS_ARTIFACTS_DIR: ${{ steps.pass_env.outputs.CUDA_BINDINGS_ARTIFACTS_DIR }}
steps:
- name: Checkout ${{ github.event.repository.name }}
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up build environment
uses: ./.github/actions/setup
with:
client-repo: ${{ github.event.repository.name }}
build-type: ${{ inputs.build-type }}
target-device: "${{ inputs.target-device }}"
host-platform: ${{ inputs.host-platform }}
build-mode: ${{ inputs.build-mode }}
upload-enabled: ${{ inputs.upload-enabled }}
python-version: ${{ inputs.python-version }}
cuda-version: ${{ inputs.cuda-version }}

- name: Call build action
uses: ./.github/actions/build
with:
build-type: ${{ inputs.build-type }}
target-device: "${{ inputs.target-device }}"
host-platform: ${{ inputs.host-platform }}
upload-enabled: ${{ inputs.upload-enabled }}

- name: Pass environment variables
id: pass_env
run: |
echo "CUDA_CORE_ARTIFACT_NAME=${CUDA_CORE_ARTIFACT_NAME}" >> $GITHUB_OUTPUT
echo "CUDA_CORE_ARTIFACTS_DIR=${CUDA_CORE_ARTIFACTS_DIR}" >> $GITHUB_OUTPUT
echo "CUDA_BINDINGS_ARTIFACT_NAME=${CUDA_BINDINGS_ARTIFACT_NAME}" >> $GITHUB_OUTPUT
echo "CUDA_BINDINGS_ARTIFACTS_DIR=${CUDA_BINDINGS_ARTIFACTS_DIR}" >> $GITHUB_OUTPUT

test:
# TODO: improve the name once a separate test matrix is defined
name: Test (CUDA ${{ inputs.cuda-version }})
# TODO: enable testing once linux-aarch64 & win-64 GPU runners are up
if: ${{ (github.repository_owner == 'nvidia') &&
startsWith(inputs.host-platform, 'linux-x64') }}
permissions:
id-token: write # This is required for configure-aws-credentials
contents: read # This is required for actions/checkout
runs-on: ${{ (inputs.host-platform == 'linux-x64' && 'linux-amd64-gpu-v100-latest-1') }}
# TODO: use a different (nvidia?) container, or just run on bare image
container:
options: -u root --security-opt seccomp=unconfined --privileged --shm-size 16g
image: condaforge/miniforge3:latest
env:
NVIDIA_VISIBLE_DEVICES: ${{ env.NVIDIA_VISIBLE_DEVICES }}
needs:
- build
steps:
- name: Checkout ${{ github.event.repository.name }}
uses: actions/checkout@v4
with:
fetch-depth: 0

# TODO: we probably don't need this?
# - name: Setup
# if: ${{ inputs.has-built != 'true' }}
# uses: ./.github/actions/setup
# with:
# client-repo: ${{ github.event.repository.name }}
# build-type: ${{ inputs.build-type }}
# target-device: "${{ inputs.target-device }}"
# host-platform: ${{ inputs.host-platform }}
# build-mode: ${{ inputs.build-mode }}
# upload-enabled: ${{ inputs.upload-enabled }}
# python-version: ${{ inputs.python-version }}

- name: Call test action
uses: ./.github/actions/test
with:
test-options: ${{ inputs.build-type }}
env:
CUDA_CORE_ARTIFACT_NAME: ${{ needs.build.outputs.CUDA_CORE_ARTIFACT_NAME }}
CUDA_CORE_ARTIFACTS_DIR: ${{ needs.build.outputs.CUDA_CORE_ARTIFACTS_DIR }}
CUDA_BINDINGS_ARTIFACT_NAME: ${{ needs.build.outputs.CUDA_BINDINGS_ARTIFACT_NAME }}
CUDA_BINDINGS_ARTIFACTS_DIR: ${{ needs.build.outputs.CUDA_BINDINGS_ARTIFACTS_DIR }}
PYTHON_VERSION: ${{ inputs.python-version }}
CTK_BUILD_VER: ${{ inputs.cuda-version }}
HOST_PLATFORM: ${{ inputs.host-platform }}
73 changes: 0 additions & 73 deletions .github/workflows/gh-build.yml

This file was deleted.

Loading
Loading