Skip to content

All libs (Release)

All libs (Release) #34

name: All libs (Release)
on:
workflow_dispatch:
inputs:
release-number:
description: 'Release Number (e.g. 0.3.0)'
required: true
default: '0.0.0'
assets_repo:
type: string
description: Retrieve assets from a draft release from this repo (e.g. NVIDIA/cudaqx)
default: 'NVIDIA/cudaqx'
required: false
assets_tag:
type: string
description: Retrieve assets from a draft release with this tag (e.g. docker-files-123)
required: false
jobs:
pr-build:
name: Build and test
strategy:
fail-fast: false
matrix:
runner: [
{ arch: arm64, gpu: a100 },
{ arch: amd64, gpu: a100 },
]
cuda_version: ['12.6', '13.0']
runs-on: linux-${{ matrix.runner.arch }}-gpu-${{ matrix.runner.gpu }}-latest-1
container:
image: >-
${{
inputs.release-number == '0.0.0'
&& format('ghcr.io/nvidia/cudaqx-dev:{0}-{1}-cu{2}', 'latest', matrix.runner.arch, matrix.cuda_version)
|| format('ghcr.io/nvidia/cudaqx-dev:{0}-{1}', inputs.release-number, matrix.runner.arch)
}}
env:
NVIDIA_VISIBLE_DEVICES: ${{ env.NVIDIA_VISIBLE_DEVICES }}
permissions: write-all
steps:
- name: Install dependencies
run: |
apt update && apt install -y --no-install-recommends zip unzip patchelf git-lfs
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.release-number == '0.0.0' && 'main' || format('releases/v{0}', inputs.release-number) }}
set-safe-directory: true
lfs: true # download assets file(s) for TRT tests
- name: Set git safe directory
run: git config --global --add safe.directory $GITHUB_WORKSPACE
- name: Set release number
id: set-release-number
run: |
echo "CUDAQX_QEC_VERSION=${{ inputs.release-number }}" >> $GITHUB_ENV
echo "CUDAQX_SOLVERS_VERSION=${{ inputs.release-number }}" >> $GITHUB_ENV
# And output to the GitHub Actions summary.
echo "Setting CUDAQX_QEC_VERSION=${{ inputs.release-number }}" >> $GITHUB_STEP_SUMMARY
echo "Setting CUDAQX_SOLVERS_VERSION=${{ inputs.release-number }}" >> $GITHUB_STEP_SUMMARY
- name: Fetch assets and set QEC_EXTERNAL_DECODERS
env:
GH_TOKEN: ${{ github.token }}
id: fetch-assets
run: |
if [[ -n "${{ inputs.assets_repo }}" ]] && [[ -n "${{ inputs.assets_tag }}" ]]; then
bash .github/workflows/scripts/install_git_cli.sh
# Fetch the assets into this directory
gh release download -R ${{ inputs.assets_repo }} ${{ inputs.assets_tag }}
# Show what was downloaded
ls
# Show release info (and save to summary)
gh release view -R ${{ inputs.assets_repo }} ${{ inputs.assets_tag }} >> $GITHUB_STEP_SUMMARY
# Extract the decoder that needs to be embedded in the release
mkdir -p tmp
tar -C tmp -xzvf nv-qldpc-decoder-${{ matrix.runner.arch }}_ubuntu24.04_cuda${{ matrix.cuda_version }}_release.tar.gz
echo "QEC_EXTERNAL_DECODERS=$(pwd)/tmp/libcudaq-qec-nv-qldpc-decoder.so" >> $GITHUB_ENV
fi
shell: bash
- name: Configure
id: config
run: |
cuda_major=`echo ${{ matrix.cuda_version }} | cut -d . -f1`
echo "cuda_major=$cuda_major" >> $GITHUB_OUTPUT
# ========================================================================
# Build
# ========================================================================
- name: Build
id: build
uses: ./.github/actions/build-lib
with:
lib: "all"
cuda_version: ${{ matrix.cuda_version }}
platform: ${{ matrix.runner.arch }}
install-prefix: /usr/local/cudaq
- name: Save build artifacts
run: |
cmake --build ${{ steps.build.outputs.build-dir }} --target zip_installed_files --parallel
cd ${{ steps.build.outputs.build-dir }}
mv installed_files.zip installed_files-${{ matrix.runner.arch }}-cu${{ matrix.cuda_version }}.zip
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: installed_files-${{ matrix.runner.arch }}-cu${{ matrix.cuda_version }}
path: ${{ steps.build.outputs.build-dir }}/installed_files-${{ matrix.runner.arch }}-cu${{ matrix.cuda_version }}.zip
# ========================================================================
# Run tests
# ========================================================================
#
- name: Run tests
run: cmake --build ${{ steps.build.outputs.build-dir }} --target run_tests
# ========================================================================
# Run python tests
# ========================================================================
- name: Install python requirements
env:
LD_LIBRARY_PATH: ${{ env.MPI_PATH }}/lib:${{ env.LD_LIBRARY_PATH }}
shell: bash
run: |
# Install the correct torch first.
cuda_no_dot=$(echo ${{ steps.config.outputs.cuda_major }} | sed 's/\.//')
pip install torch==2.9.0 --index-url https://download.pytorch.org/whl/cu${cuda_no_dot}
pip install numpy pytest cupy-cuda${{ steps.config.outputs.cuda_major }}x cuquantum-cu${{ steps.config.outputs.cuda_major }} lightning ml_collections mpi4py transformers quimb opt_einsum nvidia-cublas cuquantum-python-cu${{ steps.config.outputs.cuda_major }}==25.09
# The following tests are needed for docs/sphinx/examples/qec/python/tensor_network_decoder.py.
if [ "$(uname -m)" == "x86_64" ]; then
# Stim is not currently available on manylinux ARM wheels, so only
# install for x86_64.
pip install stim beliefmatching
fi
- name: Run Python tests
env:
LD_LIBRARY_PATH: ${{ env.MPI_PATH }}/lib:${{ env.LD_LIBRARY_PATH }}
OMPI_MCA_pml: ob1
run: |
if [[ -n "${{ env.QEC_EXTERNAL_DECODERS }}" ]]; then
# Verify that external decoder is available if applicable
export PYTHONPATH="/usr/local/cudaq:$HOME/.cudaqx"
python3 -c "import cudaq_qec as qec; print(qec.__version__); d = qec.get_decoder('nv-qldpc-decoder', qec.get_code('steane').get_parity()); print(d.get_version())"
fi
cmake --build ${{ steps.build.outputs.build-dir }} --target run_python_tests
shell: bash
# ========================================================================
# Run example tests
# ========================================================================
- name: Run example tests
env:
LD_LIBRARY_PATH: ${{ env.MPI_PATH }}/lib:${{ env.LD_LIBRARY_PATH }}
OMPI_MCA_pml: ob1
run: |
ln -s /usr/local/cudaq /cudaq-install
bash scripts/ci/test_examples.sh all