Add measurement processes to capabilities #2189
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Catalyst Wheel on Linux (x86_64) | |
on: | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
- labeled | |
push: | |
branches: [ main ] | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
determine_runner: | |
name: Determine runner type to use | |
uses: ./.github/workflows/determine-workflow-runner.yml | |
with: | |
default_runner: ubuntu-latest | |
check_if_wheel_build_required: | |
uses: ./.github/workflows/check-for-wheel-build.yml | |
constants: | |
needs: [check_if_wheel_build_required, determine_runner] | |
if: needs.check_if_wheel_build_required.outputs.build-wheels == 'true' | |
name: "Set build matrix" | |
uses: ./.github/workflows/constants.yaml | |
with: | |
runs_on: ${{ needs.determine_runner.outputs.runner_group }} | |
build-dependencies: | |
needs: [constants, check_if_wheel_build_required, determine_runner] | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest] | |
arch: [x86_64] | |
python_version: [3.9] | |
container_img: ["quay.io/pypa/manylinux2014_x86_64"] | |
name: Build Dependencies (Python ${{ matrix.python_version }}) | |
runs-on: ${{ needs.determine_runner.outputs.runner_group }} | |
container: ${{ matrix.container_img }} | |
if: needs.check_if_wheel_build_required.outputs.build-wheels == 'true' | |
steps: | |
# TODO: Cannot use actions/checkout@v4 as node20 is not supported in manylinux2014 container | |
- name: Checkout Catalyst repo | |
uses: actions/checkout@v3 | |
- name: Set Ownership in Container | |
run: | | |
# To fix the git issue with the owner of the checkout dir | |
chown -R $(id -u):$(id -g) $PWD | |
# Cache external project sources | |
# Note that these caches will not be the same as for our main check-catalyst action, since | |
# GH doesn't support using caches across un-/containerized actions (those with `container_img`). | |
- name: Cache LLVM Source | |
id: cache-llvm-source | |
uses: actions/cache@v3 | |
with: | |
path: mlir/llvm-project | |
key: ${{ runner.os }}-llvm-${{ needs.constants.outputs.llvm_version }}-generic-source | |
enableCrossOsArchive: True | |
- name: Cache MHLO Source | |
id: cache-mhlo-source | |
uses: actions/cache@v3 | |
with: | |
path: mlir/mlir-hlo | |
key: ${{ runner.os }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-generic-source | |
enableCrossOsArchive: True | |
- name: Cache Enzyme Source | |
id: cache-enzyme-source | |
uses: actions/cache@v3 | |
with: | |
path: mlir/Enzyme | |
key: ${{ runner.os }}-enzyme-${{ needs.constants.outputs.enzyme_version }}-generic-source | |
enableCrossOsArchive: True | |
# TODO: Cannot use actions/checkout@v4 as node20 is not supported in manylinux2014 container | |
- name: Clone LLVM Submodule | |
if: steps.cache-llvm-source.outputs.cache-hit != 'true' | |
uses: actions/checkout@v3 | |
with: | |
repository: llvm/llvm-project | |
ref: ${{ needs.constants.outputs.llvm_version }} | |
path: mlir/llvm-project | |
# TODO: Cannot use actions/checkout@v4 as node20 is not supported in manylinux2014 container | |
- name: Clone MHLO Submodule | |
if: steps.cache-mhlo-source.outputs.cache-hit != 'true' | |
uses: actions/checkout@v3 | |
with: | |
repository: tensorflow/mlir-hlo | |
ref: ${{ needs.constants.outputs.mhlo_version }} | |
path: mlir/mlir-hlo | |
# TODO: Cannot use actions/checkout@v4 as node20 is not supported in manylinux2014 container | |
- name: Clone Enzyme Submodule | |
if: steps.cache-enzyme-source.outputs.cache-hit != 'true' | |
uses: actions/checkout@v3 | |
with: | |
repository: EnzymeAD/Enzyme | |
ref: ${{ needs.constants.outputs.enzyme_version }} | |
path: mlir/Enzyme | |
# Cache external project builds | |
- name: Cache LLVM Build | |
id: cache-llvm-build | |
uses: actions/cache@v3 | |
with: | |
path: llvm-build | |
key: ${{ runner.os }}-llvm-${{ needs.constants.outputs.llvm_version }}-${{matrix.python_version}}-generic-build | |
- name: Cache MHLO Build | |
id: cache-mhlo-build | |
uses: actions/cache@v3 | |
with: | |
path: mhlo-build | |
key: ${{ runner.os }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-generic-build | |
- name: Cache Enzyme Build | |
id: cache-enzyme-build | |
uses: actions/cache@v3 | |
with: | |
path: enzyme-build | |
key: ${{ runner.os }}-enzyme-${{ needs.constants.outputs.llvm_version }}-${{ needs.constants.outputs.enzyme_version }}-generic-build | |
- name: Install dependencies (CentOS) | |
if: | | |
steps.cache-llvm-build.outputs.cache-hit != 'true' || | |
steps.cache-mhlo-build.outputs.cache-hit != 'true' || | |
steps.cache-enzyme-build.outputs.cache-hit != 'true' | |
run: | | |
# Reduce wait time for repos not responding | |
cat /etc/yum.conf | sed "s/\[main\]/\[main\]\ntimeout=5/g" > /etc/yum.conf | |
yum update -y && yum install -y libzstd-devel | |
- name: Install Dependencies (Python) | |
run: | | |
python${{ matrix.python_version }} -m pip install numpy pybind11 PyYAML cmake ninja | |
PYTHON_BINS=$(find /opt/_internal/cpython-${{ matrix.python_version }}.*/bin -maxdepth 1 -type d | tr '\n' ':' | sed 's/:$//') | |
echo $PYTHON_BINS >> $GITHUB_PATH | |
# Required for MHLO and building MLIR with protected symbols. | |
# (Don't forget to add the build directory to PATH in subsequent steps, so | |
# other tools can find it, in particular collect2 invoked by gcc.) | |
- name: Build LLD | |
if: steps.cache-llvm-build.outputs.cache-hit != 'true' | |
run: | | |
cmake -S mlir/llvm-project/llvm -B llvm-build -G Ninja \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DLLVM_TARGETS_TO_BUILD="host" \ | |
-DLLVM_ENABLE_PROJECTS="lld" | |
cmake --build llvm-build --target lld | |
- name: Build LLVM / MLIR | |
if: steps.cache-llvm-build.outputs.cache-hit != 'true' | |
run: | | |
export PATH=$GITHUB_WORKSPACE/llvm-build/bin:$PATH | |
cmake -S mlir/llvm-project/llvm -B llvm-build -G Ninja \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DLLVM_BUILD_EXAMPLES=OFF \ | |
-DLLVM_TARGETS_TO_BUILD="host" \ | |
-DLLVM_ENABLE_PROJECTS="mlir" \ | |
-DLLVM_ENABLE_ASSERTIONS=ON \ | |
-DLLVM_INSTALL_UTILS=ON \ | |
-DLLVM_ENABLE_ZLIB=OFF \ | |
-DLLVM_ENABLE_ZSTD=FORCE_ON \ | |
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \ | |
-DPython3_EXECUTABLE=$(which python${{ matrix.python_version }}) \ | |
-DPython3_NumPy_INCLUDE_DIRS=$(python${{ matrix.python_version }} -c "import numpy as np; print(np.get_include())") \ | |
-DCMAKE_CXX_VISIBILITY_PRESET=protected \ | |
-DLLVM_ENABLE_LLD=ON | |
# TODO: when updating LLVM, test to see if mlir/unittests/Bytecode/BytecodeTest.cpp:55 is passing | |
# and remove filter | |
# This tests fails on CI/CD not locally. | |
LIT_FILTER_OUT="Bytecode" cmake --build llvm-build --target check-mlir | |
- name: Build MHLO Dialect | |
if: steps.cache-mhlo-build.outputs.cache-hit != 'true' | |
# building with LLD is a strong requirement for mhlo | |
run: | | |
export PATH=$GITHUB_WORKSPACE/llvm-build/bin:$PATH | |
cmake -S mlir/mlir-hlo -B mhlo-build -G Ninja \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DLLVM_ENABLE_ASSERTIONS=ON \ | |
-DMLIR_DIR=$GITHUB_WORKSPACE/llvm-build/lib/cmake/mlir \ | |
-DPython3_EXECUTABLE=$(which python${{ matrix.python_version }}) \ | |
-DLLVM_ENABLE_ZLIB=OFF \ | |
-DLLVM_ENABLE_ZSTD=FORCE_ON \ | |
-DCMAKE_CXX_VISIBILITY_PRESET=protected \ | |
-DLLVM_ENABLE_LLD=ON | |
cmake --build mhlo-build --target check-mlir-hlo | |
- name: Build Enzyme | |
if: steps.cache-enzyme-build.outputs.cache-hit != 'true' | |
run: | | |
export PATH=$GITHUB_WORKSPACE/llvm-build/bin:$PATH | |
cmake -S mlir/Enzyme/enzyme -B enzyme-build -G Ninja \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DLLVM_DIR=$GITHUB_WORKSPACE/llvm-build/lib/cmake/llvm \ | |
-DENZYME_STATIC_LIB=ON \ | |
-DCMAKE_CXX_VISIBILITY_PRESET=protected \ | |
-DLLVM_ENABLE_LLD=ON | |
cmake --build enzyme-build --target EnzymeStatic-18 | |
catalyst-linux-wheels-x86-64: | |
needs: [constants, build-dependencies, determine_runner] | |
strategy: | |
fail-fast: false | |
matrix: | |
os: ${{ fromJSON(format('["{0}"]', needs.determine_runner.outputs.runner_group)) }} | |
arch: [x86_64] | |
python_version: ${{ fromJSON(needs.constants.outputs.python_versions) }} | |
container_img: ["quay.io/pypa/manylinux2014_x86_64"] | |
name: Build Wheels (Python ${{ matrix.python_version }}) | |
runs-on: ${{ matrix.os }} | |
container: ${{ matrix.container_img }} | |
steps: | |
# TODO: Cannot use actions/checkout@v4 as node20 is not supported in manylinux2014 container | |
- name: Checkout Catalyst repo | |
uses: actions/checkout@v3 | |
- name: Install dependencies (CentOS) | |
run: | | |
# Reduce wait time for repos not responding | |
cat /etc/yum.conf | sed "s/\[main\]/\[main\]\ntimeout=5/g" > /etc/yum.conf | |
yum update -y && yum install -y openmpi-devel libzstd-devel | |
- name: Install Dependencies (Python) | |
run: | | |
python${{ matrix.python_version }} -m pip install numpy pybind11 PyYAML cmake ninja | |
PYTHON_BINS=$(find /opt/_internal/cpython-${{ matrix.python_version }}.*/bin -maxdepth 1 -type d | tr '\n' ':' | sed 's/:$//') | |
echo $PYTHON_BINS >> $GITHUB_PATH | |
- name: Get Cached LLVM Source | |
id: cache-llvm-source | |
uses: actions/cache@v3 | |
with: | |
path: mlir/llvm-project | |
key: ${{ runner.os }}-llvm-${{ needs.constants.outputs.llvm_version }}-generic-source | |
enableCrossOsArchive: True | |
fail-on-cache-miss: True | |
- name: Get Cached LLVM Build | |
id: cache-llvm-build | |
uses: actions/cache@v3 | |
with: | |
path: llvm-build | |
key: ${{ runner.os }}-llvm-${{ needs.constants.outputs.llvm_version }}-3.9-generic-build | |
fail-on-cache-miss: True | |
- name: Get Cached MHLO Source | |
id: cache-mhlo-source | |
uses: actions/cache@v3 | |
with: | |
path: mlir/mlir-hlo | |
key: ${{ runner.os }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-generic-source | |
enableCrossOsArchive: True | |
fail-on-cache-miss: True | |
- name: Get Cached MHLO Build | |
id: cache-mhlo-build | |
uses: actions/cache@v3 | |
with: | |
path: mhlo-build | |
key: ${{ runner.os }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-generic-build | |
fail-on-cache-miss: True | |
- name: Get Cached Enzyme Source | |
id: cache-enzyme-source | |
uses: actions/cache@v3 | |
with: | |
path: mlir/Enzyme | |
key: ${{ runner.os }}-enzyme-${{ needs.constants.outputs.enzyme_version }}-generic-source | |
fail-on-cache-miss: True | |
- name: Get Cached Enzyme Build | |
id: cache-enzyme-build | |
uses: actions/cache@v3 | |
with: | |
path: enzyme-build | |
key: ${{ runner.os }}-enzyme-${{ needs.constants.outputs.llvm_version }}-${{ needs.constants.outputs.enzyme_version }}-generic-build | |
fail-on-cache-miss: True | |
# Build Catalyst-Runtime | |
- name: Build Catalyst-Runtime | |
run: | | |
cmake -S runtime -B runtime-build -G Ninja \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=$GITHUB_WORKSPACE/runtime-build/lib \ | |
-DPYTHON_EXECUTABLE=$(which python${{ matrix.python_version }}) \ | |
-Dpybind11_DIR=$(python${{ matrix.python_version }} -c "import pybind11; print(pybind11.get_cmake_dir())") \ | |
-DENABLE_LIGHTNING_KOKKOS=ON \ | |
-DENABLE_LAPACK=OFF \ | |
-DLIGHTNING_GIT_TAG=5feb4a10c9cd15fa590c513fc7c6a10a0b334269 \ | |
-DKokkos_ENABLE_SERIAL=ON \ | |
-DKokkos_ENABLE_OPENMP=ON \ | |
-DENABLE_WARNINGS=OFF \ | |
-DENABLE_OPENQASM=ON \ | |
-DENABLE_OPENMP=OFF \ | |
-DLQ_ENABLE_KERNEL_OMP=OFF | |
cmake --build runtime-build --target rt_capi rtd_lightning rtd_openqasm | |
# Build OQC-Runtime | |
- name: Build OQC-Runtime | |
run: | | |
C_COMPILER=$(which gcc) \ | |
CXX_COMPILER=$(which g++) \ | |
OQC_BUILD_DIR="$(pwd)/oqc-build" \ | |
RT_BUILD_DIR="$(pwd)/runtime-build" \ | |
make oqc | |
# Build Quantum and Gradient Dialects | |
- name: Build MLIR Dialects | |
run: | | |
export PATH=$GITHUB_WORKSPACE/llvm-build/bin:$PATH | |
cmake -S mlir -B quantum-build -G Ninja \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DLLVM_ENABLE_ASSERTIONS=ON \ | |
-DQUANTUM_ENABLE_BINDINGS_PYTHON=ON \ | |
-DPython3_EXECUTABLE=$(which python${{ matrix.python_version }}) \ | |
-DPython3_NumPy_INCLUDE_DIRS=$(python${{ matrix.python_version }} -c "import numpy as np; print(np.get_include())") \ | |
-DMLIR_DIR=$GITHUB_WORKSPACE/llvm-build/lib/cmake/mlir \ | |
-DMHLO_DIR=$GITHUB_WORKSPACE/mhlo-build/lib/cmake/mlir-hlo \ | |
-DMHLO_BINARY_DIR=$GITHUB_WORKSPACE/mhlo-build/bin \ | |
-DEnzyme_DIR=$GITHUB_WORKSPACE/enzyme-build \ | |
-DENZYME_SRC_DIR=$GITHUB_WORKSPACE/mlir/Enzyme \ | |
-DLLVM_ENABLE_ZLIB=OFF \ | |
-DLLVM_ENABLE_ZSTD=FORCE_ON \ | |
-DLLVM_ENABLE_LLD=ON | |
cmake --build quantum-build --target check-dialects compiler_driver | |
- name: Build wheel | |
run: | | |
PYTHON=python${{ matrix.python_version }} \ | |
LLVM_BUILD_DIR=$GITHUB_WORKSPACE/llvm-build \ | |
MHLO_BUILD_DIR=$GITHUB_WORKSPACE/mhlo-build \ | |
DIALECTS_BUILD_DIR=$GITHUB_WORKSPACE/quantum-build \ | |
RT_BUILD_DIR=$GITHUB_WORKSPACE/runtime-build \ | |
OQC_BUILD_DIR=$GITHUB_WORKSPACE/oqc-build \ | |
ENZYME_BUILD_DIR=$GITHUB_WORKSPACE/enzyme-build \ | |
make wheel | |
- name: Repair wheel using auditwheel | |
run: | | |
# exclude libopenblas as we rely on the openblas/lapack library shipped by scipy | |
auditwheel repair dist/*.whl -w ./wheel --no-update-tags --exclude libopenblasp-r0-23e5df77.3.21.dev.so | |
- name: Upload Wheel Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: catalyst-manylinux2014_x86_64-wheel-py-${{ matrix.python_version }}.zip | |
path: wheel/ | |
retention-days: 14 | |
test-wheels: | |
needs: [constants, catalyst-linux-wheels-x86-64, determine_runner] | |
strategy: | |
fail-fast: false | |
matrix: | |
os: ${{ fromJSON(format('["{0}"]', needs.determine_runner.outputs.runner_group)) }} | |
python_version: ${{ fromJSON(needs.constants.outputs.python_versions) }} | |
# To check all wheels for supported python3 versions | |
name: Test Wheels (Python ${{ matrix.python_version }}) on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout Catalyst repo | |
uses: actions/checkout@v4 | |
- name: Download Wheel Artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: catalyst-manylinux2014_x86_64-wheel-py-${{ matrix.python_version }}.zip | |
path: dist | |
- name: Set up Python ${{ matrix.python_version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python_version }} | |
- name: Install Python dependencies | |
run: | | |
python${{ matrix.python_version }} -m pip install pytest pytest-xdist | |
- name: Install PennyLane Plugins | |
run: | | |
python${{ matrix.python_version }} -m pip install PennyLane-Lightning-Kokkos | |
python${{ matrix.python_version }} -m pip install amazon-braket-pennylane-plugin "boto3==1.26" | |
- name: Install OQC client | |
if: ${{ matrix.python_version == '3.9' || matrix.python_version == '3.10'}} | |
run: | | |
python${{ matrix.python_version }} -m pip install oqc-qcaas-client | |
- name: Install Catalyst | |
run: | | |
python${{ matrix.python_version }} -m pip install $GITHUB_WORKSPACE/dist/*.whl --extra-index-url https://test.pypi.org/simple | |
- name: Run Python Pytest Tests | |
run: | | |
python${{ matrix.python_version }} -m pytest $GITHUB_WORKSPACE/frontend/test/pytest -n auto | |
python${{ matrix.python_version }} -m pytest $GITHUB_WORKSPACE/frontend/test/pytest --backend="lightning.kokkos" -n auto | |
python${{ matrix.python_version }} -m pytest $GITHUB_WORKSPACE/frontend/test/async_tests | |
python${{ matrix.python_version }} -m pytest $GITHUB_WORKSPACE/frontend/test/pytest --runbraket=LOCAL -n auto | |
python${{ matrix.python_version }} -m pytest $GITHUB_WORKSPACE/frontend/test/test_oqc/oqc -n auto |