-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
260 additions
and
0 deletions.
There are no files selected for viewing
107 changes: 107 additions & 0 deletions
107
.github/workflows/setup_macos_env_linux_arm64/action.yml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
name: Setup PATH for Self-Hosted MacOS Runner | ||
description: | | ||
This workflow sets up the workflow environment for the Self-Hosted MacOS runner. | ||
It should be called right after actions/checkout. | ||
inputs: | ||
python_version: | ||
description: Version of Python being used by the Job | ||
required: true | ||
|
||
outputs: | ||
python_version: | ||
description: 'The version of Python that was setup' | ||
value: ${{ steps.python_venv.outputs.python_version }} | ||
python_path: | ||
description: 'Full absolute path to the python binary' | ||
value: ${{ steps.python_venv.outputs.python_path }} | ||
venv_location: | ||
description: 'The path to the virtualenv created for python' | ||
value: ${{ steps.python_venv.outputs.venv_location }} | ||
venv_site_packages: | ||
description: 'The path to the site-packages folder for the python venv created' | ||
value: ${{ steps.site_packages.outputs.site_packages_dir }} | ||
|
||
|
||
runs: | ||
using: composite | ||
steps: | ||
|
||
# These environment variables ensure multi-threading workloads (ex: pytest-xdist) | ||
# work without any issues. Without them, the tests take hours to complete. | ||
- name: Setup MacOS Env Vars | ||
shell: bash | ||
run: | | ||
# The following two environment variables are set to ensure no threading related commands are blocked/slowed | ||
# by the OS. They may or may not be needed but added to ensure there are no slowdowns. | ||
echo 'no_proxy=*' >> $GITHUB_ENV | ||
echo 'OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES' >> $GITHUB_ENV | ||
# The following two flags are exported to ensure the correct homebrew installed libomp libraries are used | ||
# during build time. | ||
echo "LDFLAGS=-L/opt/homebrew/opt/libomp/lib $LDFLAGS" >> $GITHUB_ENV | ||
echo "CPPFLAGS=-I/opt/homebrew/opt/libomp/include $CPPFLAGS" >> $GITHUB_ENV | ||
# These binaries are added to PATH as there were issues adding them by default on job start | ||
- name: Add additional binaries to PATH | ||
shell: bash | ||
run: | | ||
additional_paths=("/opt/homebrew/bin" "$HOME/.pyenv/shims" "$HOME/.cargo/bin") | ||
for _path in ${additional_paths[@]}; | ||
do | ||
[[ ":$PATH:" != *":$_path:"* ]] && echo "$_path" >> $GITHUB_PATH | ||
done | ||
echo "PYENV_ROOT=$HOME/.pyenv" >> $GITHUB_ENV | ||
- name: Setup Python ${{ inputs.python_version }} | ||
id: python_setup | ||
shell: bash | ||
env: | ||
input_python_version: ${{ inputs.python_version }} | ||
run: | | ||
# Check if the requested Python version exists on the runner | ||
pyenv versions | grep "$input_python_version" | ||
if [ $? -ne 0 ]; then | ||
echo "Installing Python $input_python_version" | ||
pyenv install "$input_python_version" | ||
fi | ||
- name: Setup Python venv | ||
id: python_venv | ||
shell: bash | ||
env: | ||
input_python_version: ${{ inputs.python_version }} | ||
venv_name: py_venv_${{ inputs.python_version }}_${{ github.sha }} | ||
run: | | ||
rm -rf "$venv_name" | ||
echo "$input_python_version" > "$GITHUB_WORKSPACE/.python-version" | ||
python -m venv "$venv_name" | ||
echo "$GITHUB_WORKSPACE/$venv_name/bin" >> $GITHUB_PATH | ||
echo "venv_location=$GITHUB_WORKSPACE/$venv_name" >> $GITHUB_OUTPUT | ||
PY_PATH="$GITHUB_WORKSPACE/$venv_name/bin/python" | ||
PY_VERSION=$(python --version) | ||
echo "python_path=$PY_PATH" >> $GITHUB_OUTPUT | ||
echo "python_version=$PY_VERSION" >> $GITHUB_OUTPUT | ||
- name: Get site-packages path | ||
id: site_packages | ||
shell: bash | ||
run: | | ||
echo "site_packages_dir=$(python -c 'import sysconfig; print(sysconfig.get_path("platlib"))')" >> $GITHUB_OUTPUT | ||
- name: Display Python Setup | ||
shell: bash | ||
run: | | ||
set -x | ||
which python | ||
which pip | ||
python --version | ||
pip --version | ||
set +x |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
name: Wheel::Linux::ARM::CUDA | ||
|
||
# **What it does**: Builds lightning.gpu and lightning.tensor python wheels for | ||
# architecture ARM 64 and store it as artifacts. | ||
# Python versions: 3.9, 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: | ||
push: | ||
branches: | ||
- master | ||
release: | ||
types: [published] | ||
workflow_dispatch: | ||
|
||
env: | ||
MACOSX_DEPLOYMENT_TARGET: 14.0 | ||
ARCHS: 'arm64' | ||
PYTHON3_MIN_VERSION: "9" | ||
PYTHON3_MAX_VERSION: "12" | ||
|
||
concurrency: | ||
group: wheel_macos_arm64-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
mac-set-matrix-arm: | ||
if: | | ||
github.event_name != 'pull_request' || | ||
contains(github.event.pull_request.labels.*.name, 'ci:build_wheels') || | ||
github.event_name == 'workflow_dispatch' | ||
timeout-minutes: 60 | ||
name: Set builder matrix | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout PennyLane-Lightning | ||
uses: actions/checkout@v4 | ||
|
||
- name: Python version | ||
id: pyver | ||
run: | | ||
if [[ ${{ github.event_name }} == 'pull_request' ]]; then | ||
echo "python_version=$(python3 scripts/gen_pyver_matrix.py \ | ||
--min-version=3.${{ env.PYTHON3_MIN_VERSION }} \ | ||
--max-version=3.${{ env.PYTHON3_MAX_VERSION }})" >> $GITHUB_OUTPUT | ||
else | ||
echo "python_version=$(python3 scripts/gen_pyver_matrix.py \ | ||
--min-version=3.${{ env.PYTHON3_MIN_VERSION }} \ | ||
--max-version=3.${{ env.PYTHON3_MAX_VERSION }} --range)" >> $GITHUB_OUTPUT | ||
fi | ||
outputs: | ||
python_version: ${{ steps.pyver.outputs.python_version }} | ||
|
||
linux-wheels-arm64: | ||
needs: [mac-set-matrix-arm] | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [manylinux] | ||
arch: [arm64] | ||
cuda_version: ["12"] | ||
pl_backend: ["lightning_gpu"] | ||
cibw_build: ${{fromJson(needs.mac-set-matrix-arm.outputs.python_version)}} | ||
container_img: ["quay.io/pypa/manylinux_2_28_aarch64"] | ||
container_name: ["manylinux_2_28_aarch64"] | ||
timeout-minutes: 30 | ||
name: Linux::${{ matrix.arch }} - ${{ matrix.pl_backend }} CUDA ${{ matrix.cuda_version }} (Python ${{ fromJson('{ "cp39-*":"3.9","cp310-*":"3.10","cp311-*":"3.11","cp312-*":"3.12" }')[matrix.cibw_build] }}) | ||
runs-on: | ||
group: 'Office 24th floor M2 Mac' | ||
container: | ||
image: ${{ matrix.container_img }} | ||
options: --privileged | ||
|
||
steps: | ||
- name: Checkout PennyLane-Lightning | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Runner Environment | ||
id: setup_env | ||
uses: ./.github/workflows/setup_macos_env_linux_arm64 | ||
with: | ||
python_version: ${{ matrix.python_version }} | ||
|
||
- 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 cibuildwheel | ||
run: python -m pip install cibuildwheel~=2.16.0 | ||
|
||
- name: Configure pyproject.toml file | ||
run: PL_BACKEND="${{ matrix.pl_backend }}" python 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*" | ||
|
||
CIBW_CONFIG_SETTINGS: --global-option=build_ext --global-option=--define="LIGHTNING_RELEASE_TAG=master" | ||
|
||
# Python build settings | ||
CIBW_BEFORE_BUILD: | | ||
python -m pip install ninja cmake~=3.24.3 auditwheel~=5.0 custatevec-cu${{ matrix.cuda_version }} scipy | ||
dnf clean all -y | ||
dnf install gcc-toolset-12 dnf-utils -y | ||
source /opt/rh/gcc-toolset-12/enable -y | ||
yum-config-manager --add-repo http://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo -y | ||
dnf -y install cuda-toolkit-${{ matrix.cuda_version }}-0 git openssh wget | ||
# ensure nvcc is available | ||
CIBW_ENVIRONMENT: | | ||
PATH=/opt/rh/gcc-toolset-12/root/usr/bin:$PATH:/usr/local/cuda-${{ matrix.cuda_version }}/bin \ | ||
LD_LIBRARY_PATH=/opt/rh/gcc-toolset-12/root/usr/lib64:/opt/rh/gcc-toolset-12/root/usr/lib:/opt/rh/gcc-toolset-12/root/usr/lib64/dyninst:/opt/rh/gcc-toolset-12/root/usr/lib/dyninst:$LD_LIBRARY_PATH:/usr/local/cuda-${{ matrix.cuda_version }}/lib64 \ | ||
PKG_CONFIG_PATH=/opt/rh/gcc-toolset-12/root/usr/lib64/pkgconfig:$PKG_CONFIG_PATH | ||
CIBW_REPAIR_WHEEL_COMMAND_LINUX: "./bin/auditwheel repair -w {dest_dir} {wheel}" | ||
|
||
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 | ||
|
||
CIBW_BUILD_VERBOSITY: 3 | ||
|
||
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@v3 | ||
if: | | ||
github.event_name == 'release' || | ||
github.event_name == 'workflow_dispatch' || | ||
github.ref == 'refs/heads/master' || | ||
steps.rc_build.outputs.match != '' | ||
with: | ||
name: ${{ matrix.os }}-wheels-${{ matrix.pl_backend }}-${{ matrix.arch }}-cu${{ matrix.cuda_version }} | ||
path: ./wheelhouse/*.whl |