Lightning Kokkos arg test fix for MacOS #9887
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: Wheel::Linux::x86_64 | |
# **What it does**: Builds python wheels for Linux (ubuntu-latest) architecture x86_64 and store it as artifacts. | |
# Python versions: 3.10, 3.11, 3.12. | |
# **Why we have it**: To build wheels for pennylane-lightning installation. | |
# **Who does it impact**: Wheels to be uploaded to PyPI. | |
env: | |
GCC_VERSION: 13 | |
on: | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
- ready_for_review | |
push: | |
branches: | |
- master | |
release: | |
types: [published] | |
workflow_dispatch: | |
concurrency: | |
group: wheel_linux_x86_64-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
set_wheel_build_matrix: | |
if: | | |
github.event_name != 'pull_request' || | |
(github.event.pull_request.draft == false && contains(github.event.pull_request.labels.*.name, 'ci:build_wheels')) | |
name: "Set wheel build matrix" | |
uses: ./.github/workflows/set_wheel_build_matrix.yml | |
with: | |
event_name: ${{ github.event_name }} | |
determine_runner: | |
if: github.event.pull_request.draft == false | |
name: Determine runner type to use | |
uses: ./.github/workflows/determine-workflow-runner.yml | |
with: | |
default_runner: ubuntu-latest | |
build_dependencies: | |
needs: [set_wheel_build_matrix, determine_runner] | |
strategy: | |
matrix: | |
exec_model: ${{ fromJson(needs.set_wheel_build_matrix.outputs.exec_model) }} | |
kokkos_version: ${{ fromJson(needs.set_wheel_build_matrix.outputs.kokkos_version) }} | |
container_img: ["quay.io/pypa/manylinux_2_28_x86_64"] | |
timeout-minutes: 30 | |
name: Kokkos core (${{ matrix.exec_model }}) | |
runs-on: ${{ needs.determine_runner.outputs.runner_group }} | |
container: ${{ matrix.container_img }} | |
steps: | |
- name: Cache installation directories | |
id: kokkos-cache | |
uses: actions/cache@v4 | |
with: | |
path: /root/Kokkos_install/${{ matrix.exec_model }} | |
key: ${{ matrix.container_img }}-kokkos${{ matrix.kokkos_version }}-${{ matrix.exec_model }} | |
- name: Install dependencies (Ubuntu) | |
if: ${{ (matrix.container_img == 'ubuntu-latest') && (steps.kokkos-cache.outputs.cache-hit != 'true') }} | |
run: | | |
apt-get update && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y -q install cmake gcc-$GCC_VERSION g++-$GCC_VERSION ninja-build git | |
echo "COMPILER=g++-13" >> $GITHUB_ENV | |
- name: Install dependencies (AlmaLinux) | |
if: ${{ (matrix.container_img == 'quay.io/pypa/manylinux_2_28_x86_64') && (steps.kokkos-cache.outputs.cache-hit != 'true') }} | |
run: | | |
dnf update -y && dnf install -y cmake ninja-build | |
echo "COMPILER=g++" >> $GITHUB_ENV | |
- name: Clone Kokkos libs | |
if: steps.kokkos-cache.outputs.cache-hit != 'true' | |
run: | | |
git clone --branch ${{ matrix.kokkos_version }} https://github.com/kokkos/kokkos.git | |
pushd . &> /dev/null | |
- name: Build Kokkos core library | |
if: steps.kokkos-cache.outputs.cache-hit != 'true' | |
run: | | |
mkdir -p /root/Kokkos_install/${{ matrix.exec_model }} | |
cd kokkos | |
cmake -BBuild . -DCMAKE_INSTALL_PREFIX=/root/Kokkos_install/${{ matrix.exec_model }} \ | |
-DKokkos_ENABLE_COMPLEX_ALIGN=OFF \ | |
-DKokkos_ENABLE_SERIAL=ON \ | |
-DKokkos_ENABLE_${{ matrix.exec_model }}=ON \ | |
-DKokkos_ENABLE_DEPRECATION_WARNINGS=OFF \ | |
-DCMAKE_CXX_COMPILER=${{ env.COMPILER }} \ | |
-DCMAKE_CXX_STANDARD=20 \ | |
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \ | |
-G Ninja | |
cmake --build ./Build --verbose | |
cmake --install ./Build | |
cd - | |
linux-wheels-x86-64: | |
needs: [set_wheel_build_matrix, build_dependencies, determine_runner] | |
strategy: | |
fail-fast: false | |
matrix: | |
arch: [x86_64] | |
pl_backend: ["lightning_kokkos", "lightning_qubit"] | |
cibw_build: ${{ fromJson(needs.set_wheel_build_matrix.outputs.python_version) }} | |
exec_model: ${{ fromJson(needs.set_wheel_build_matrix.outputs.exec_model) }} | |
kokkos_version: ${{ fromJson(needs.set_wheel_build_matrix.outputs.kokkos_version) }} | |
container_img: ["quay.io/pypa/manylinux_2_28_x86_64"] | |
timeout-minutes: 30 | |
name: Linux::${{ matrix.arch }} - ${{ matrix.pl_backend }} (Python ${{ fromJson('{ "cp310-*":"3.10","cp311-*":"3.11","cp312-*":"3.12" }')[matrix.cibw_build] }}) | |
runs-on: ${{ needs.determine_runner.outputs.runner_group }} | |
container: | |
image: ${{ matrix.container_img }} | |
options: --privileged | |
steps: | |
- name: Restoring cached dependencies | |
id: kokkos-cache | |
uses: actions/cache@v4 | |
with: | |
path: /root/Kokkos_install/${{ matrix.exec_model }} | |
key: ${{ matrix.container_img }}-kokkos${{ matrix.kokkos_version }}-${{ matrix.exec_model }} | |
- name: Checkout PennyLane-Lightning | |
uses: actions/checkout@v4 | |
- name: Copy cached libraries | |
if: steps.kokkos-cache.outputs.cache-hit == 'true' | |
run: | | |
mkdir Kokkos | |
cp -rf /root/Kokkos_install/${{ matrix.exec_model }}/* Kokkos/ | |
- name: Install dependencies (AlmaLinux) | |
if: ${{ (matrix.container_img == 'quay.io/pypa/manylinux_2_28_x86_64') }} | |
run: | | |
dnf update -y && dnf install -y podman | |
- name: Install dependencies | |
run: python3.10 -m pip install cibuildwheel~=2.20.0 tomlkit | |
- name: Configure pyproject.toml file | |
run: PL_BACKEND="${{ matrix.pl_backend }}" python3.10 scripts/configure_pyproject_toml.py | |
- name: Build wheels | |
env: | |
CIBW_CONTAINER_ENGINE: "podman" | |
CIBW_ARCHS_LINUX: ${{matrix.arch}} | |
CIBW_BUILD: ${{ matrix.cibw_build }} | |
CIBW_SKIP: "*-musllinux*" | |
# Python build settings | |
CIBW_BEFORE_BUILD: | | |
cat /etc/dnf.conf | sed "s/\[main\]/\[main\]\ntimeout=5/g" > /etc/dnf.conf | |
python -m pip install ninja cmake~=3.27.0 scipy | |
dnf clean all -y | |
dnf install gcc-toolset-13 -y | |
source /opt/rh/gcc-toolset-13/enable -y | |
PATH="/opt/rh/gcc-toolset-13/root/usr/bin:$PATH" | |
CIBW_ENVIRONMENT: | | |
PATH="/opt/rh/gcc-toolset-13/root/usr/bin:$PATH" CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release" | |
CIBW_BEFORE_TEST: | | |
python -m pip install -r requirements-tests.txt | |
if ${{ matrix.pl_backend == 'lightning_kokkos'}} | |
then | |
PL_BACKEND="lightning_qubit" python scripts/configure_pyproject_toml.py | |
SKIP_COMPILATION=True python -m pip install . -vv | |
fi | |
CIBW_TEST_COMMAND: | | |
DEVICENAME=`echo ${{ matrix.pl_backend }} | sed "s/_/./g"` | |
pl-device-test --device=${DEVICENAME} --skip-ops -x --tb=short --no-flaky-report | |
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 | |
CIBW_BUILD_VERBOSITY: 3 | |
run: python3.10 -m cibuildwheel --output-dir wheelhouse | |
- name: Validate wheels | |
run: | | |
python3.10 -m pip install twine | |
python3.10 -m twine check ./wheelhouse/*.whl | |
- uses: actions-ecosystem/action-regex-match@main | |
id: rc_build | |
with: | |
text: ${{ github.event.pull_request.head.ref }} | |
regex: '.*[0-9]+.[0-9]+.[0-9]+[-_]?rc[0-9]+' | |
- uses: actions/upload-artifact@v4 | |
if: | | |
github.event_name == 'pull_request' || | |
github.event_name == 'workflow_dispatch' || | |
github.ref == 'refs/heads/master' || | |
steps.rc_build.outputs.match != '' | |
with: | |
name: ${{ runner.os }}-wheels-${{ matrix.pl_backend }}-${{ fromJson('{ "cp310-*":"py310","cp311-*":"py311","cp312-*":"py312" }')[matrix.cibw_build] }}-${{ matrix.arch }}.zip | |
path: ./wheelhouse/*.whl | |
retention-days: 1 | |
include-hidden-files: true | |
upload-pypi: | |
needs: [set_wheel_build_matrix, linux-wheels-x86-64] | |
strategy: | |
matrix: | |
arch: [x86_64] | |
pl_backend: ["lightning_qubit", "lightning_kokkos"] | |
cibw_build: ${{ fromJson(needs.set_wheel_build_matrix.outputs.python_version) }} | |
runs-on: ubuntu-latest | |
if: | | |
github.event_name == 'pull_request' || | |
github.ref == 'refs/heads/master' | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: ${{ runner.os }}-wheels-${{ matrix.pl_backend }}-${{ fromJson('{ "cp310-*":"py310","cp311-*":"py311","cp312-*":"py312" }')[matrix.cibw_build] }}-${{ matrix.arch }}.zip | |
path: dist | |
- name: Upload wheels to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ ( matrix.pl_backend == 'lightning_qubit' ) && secrets.TEST_PYPI_API_TOKEN || secrets.TEST_PYPI_LKOKKOS_TOKEN }} | |
repository-url: https://test.pypi.org/legacy/ |