Skip to content

Add exatn cpp binding #10514

Add exatn cpp binding

Add exatn cpp binding #10514

name: Wheel::MacOS::Intel
# **What it does**: Builds python wheels for MacOS (10.15) 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.
on:
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
push:
branches:
- master
release:
types: [published]
workflow_dispatch:
env:
MACOSX_DEPLOYMENT_TARGET: 13.0
concurrency:
group: wheel_macos_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 }}
build_dependencies:
needs: [set_wheel_build_matrix]
strategy:
matrix:
os: [macos-13]
arch: [x86_64]
exec_model: ${{ fromJson(needs.set_wheel_build_matrix.outputs.exec_model) }}
kokkos_version: ${{ fromJson(needs.set_wheel_build_matrix.outputs.kokkos_version) }}
timeout-minutes: 30
name: Kokkos (${{ matrix.exec_model }}::${{ matrix.arch }})
runs-on: ${{ matrix.os }}
steps:
- name: Cache installation directories
id: kokkos-cache
uses: actions/cache@v4
with:
path: ${{ github.workspace}}/Kokkos_install/${{ matrix.exec_model }}
key: ${{ matrix.os }}-kokkos${{ matrix.kokkos_version }}-${{ matrix.exec_model }}
- name: Install clang
run: |
brew install libomp
- 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
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.10'
- name: Build Kokkos core library
if: steps.kokkos-cache.outputs.cache-hit != 'true'
run: |
mkdir -p ${{ github.workspace}}/Kokkos_install/${{ matrix.exec_model }}
cd kokkos
python -m pip install cmake ninja
cmake -BBuild . -DCMAKE_INSTALL_PREFIX=${{ github.workspace}}/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_STANDARD=20 \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DCMAKE_CXX_COMPILER=g++ \
-DOpenMP_ROOT=$(brew --prefix libomp) \
-G Ninja
cmake --build ./Build --verbose
cmake --install ./Build
cd -
mac-wheels-x86:
needs: [set_wheel_build_matrix, build_dependencies]
strategy:
fail-fast: false
matrix:
os: [macos-13]
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) }}
timeout-minutes: 30
name: ${{ matrix.os }} - ${{ matrix.pl_backend }} (Python ${{ fromJson('{ "cp310-*":"3.10","cp311-*":"3.11","cp312-*":"3.12" }')[matrix.cibw_build] }})
runs-on: ${{ matrix.os }}
steps:
- name: Checkout PennyLane-Lightning
uses: actions/checkout@v4
- name: Restoring cached dependencies
id: kokkos-cache
uses: actions/cache@v4
with:
path: ${{ github.workspace}}/Kokkos_install/${{ matrix.exec_model }}
key: ${{ matrix.os }}-kokkos${{ matrix.kokkos_version }}-${{ matrix.exec_model }}
- name: Copy cached libraries
run: |
mkdir Kokkos
cp -rf ${{ github.workspace }}/Kokkos_install/${{ matrix.exec_model }}/* Kokkos/
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.10'
- name: Install dependencies
run: python -m pip install cibuildwheel~=2.20.0 tomlkit
- name: Configure pyproject.toml file
run: PL_BACKEND="${{ matrix.pl_backend }}" python scripts/configure_pyproject_toml.py
- name: Build wheels
env:
CIBW_BUILD: ${{ matrix.cibw_build }}
# MacOS specific build settings
CIBW_BEFORE_ALL_MACOS: |
brew uninstall --force oclint
brew install libomp
# Python build settings
CIBW_BEFORE_BUILD: |
python -m pip install pybind11 ninja cmake~=3.27.0 setuptools scipy
CIBW_ENVIRONMENT: |
CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release"
PL_BACKEND: ${{ matrix.pl_backend }}
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_BUILD_VERBOSITY: 1
CIBW_ARCHS_MACOS: ${{matrix.arch}}
run: |
python -m cibuildwheel --output-dir wheelhouse
- name: Validate wheels
run: |
python -m pip install twine
python -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 == 'release' ||
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, mac-wheels-x86]
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
permissions:
id-token: write
if: |
github.event_name == 'release' ||
github.ref == 'refs/heads/master'
steps:
- uses: actions/download-artifact@v4
with:
name: macOS-wheels-${{ matrix.pl_backend }}-${{ fromJson('{ "cp310-*":"py310","cp311-*":"py311","cp312-*":"py312" }')[matrix.cibw_build] }}-${{ matrix.arch }}.zip
path: dist
- name: Upload wheels to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
repository-url: https://test.pypi.org/legacy/