Skip to content

On-Board Lightning Linux workflows (that are run on PRs) to large runners based on label #1547

On-Board Lightning Linux workflows (that are run on PRs) to large runners based on label

On-Board Lightning Linux workflows (that are run on PRs) to large runners based on label #1547

name: Wheel::Linux::x86_64::CUDA
# **What it does**: Builds python wheels for Linux (ubuntu-latest) architecture x86_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-gpu installation.
# **Who does it impact**: Wheels to be uploaded to PyPI.
env:
GCC_VERSION: "11"
on:
pull_request:
push:
branches:
- master
release:
types: [published]
workflow_dispatch:
concurrency:
group: wheel_linux_x86_64_cu12-${{ github.ref }}
cancel-in-progress: true
jobs:
set_wheel_build_matrix:
if: |
github.event_name != 'pull_request' ||
contains(github.event.pull_request.labels.*.name, 'ci:build_wheels') ||
github.event_name == 'workflow_dispatch'
name: "Set wheel build matrix"
uses: ./.github/workflows/set_wheel_build_matrix.yml
with:
event_name: ${{ github.event_name }}
determine_runner:
name: Determine runner type to use
uses: ./.github/workflows/determine-workflow-runner.yml
with:
default_runner: ubuntu-latest
linux-wheels-x86-64:
needs: [set_wheel_build_matrix, determine_runner]
strategy:
fail-fast: false
matrix:
arch: [x86_64]
pl_backend: ["lightning_gpu"]
cuda_version: ["12"]
cibw_build: ${{ fromJson(needs.set_wheel_build_matrix.outputs.python_version) }}
container_img: ["quay.io/pypa/manylinux2014_x86_64"]
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: ${{ needs.determine_runner.outputs.runner_group }}
container: ${{ matrix.container_img }}
steps:
- name: Checkout PennyLane-Lightning
uses: actions/checkout@v3
- name: Install dependencies (CentOS)
if: ${{ (matrix.container_img == 'quay.io/pypa/manylinux2014_x86_64') }}
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 docker
- name: Install cibuildwheel
run: python3.9 -m pip install cibuildwheel~=2.16.0
- name: Build wheels
env:
CIBW_ARCHS_LINUX: ${{ matrix.arch }}
CIBW_BUILD: ${{ matrix.cibw_build }}
CIBW_SKIP: "*-musllinux*"
CIBW_CONFIG_SETTINGS: --global-option=build_ext --global-option=--define="CMAKE_CXX_COMPILER=$(which g++);CMAKE_C_COMPILER=$(which gcc);LIGHTNING_RELEASE_TAG=master"
# Python build settings
CIBW_BEFORE_BUILD: |
cat /etc/yum.conf | sed "s/\[main\]/\[main\]\ntimeout=5/g" > /etc/yum.conf
python -m pip install ninja cmake~=3.24.3 auditwheel~=5.0 custatevec-cu${{ matrix.cuda_version }} scipy
yum clean all -y
yum install centos-release-scl-rh -y
yum install devtoolset-11-gcc-c++ -y
source /opt/rh/devtoolset-11/enable -y
yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-rhel7.repo -y
yum -y install cuda-${{ matrix.cuda_version }}-0 git openssh wget
# ensure nvcc is available
CIBW_ENVIRONMENT: |
PATH=/opt/rh/devtoolset-11/root/usr/bin:$PATH:/usr/local/cuda-${{ matrix.cuda_version }}/bin \
LD_LIBRARY_PATH=/opt/rh/devtoolset-11/root/usr/lib64:/opt/rh/devtoolset-11/root/usr/lib:/opt/rh/devtoolset-11/root/usr/lib64/dyninst:/opt/rh/devtoolset-11/root/usr/lib/dyninst:$LD_LIBRARY_PATH:/usr/local/cuda-${{ matrix.cuda_version }}/lib64 \
PL_BACKEND="${{ matrix.pl_backend }}" \
PKG_CONFIG_PATH=/opt/rh/devtoolset-11/root/usr/lib64/pkgconfig:$PKG_CONFIG_PATH
CIBW_REPAIR_WHEEL_COMMAND_LINUX: "./bin/auditwheel repair -w {dest_dir} {wheel}"
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_BUILD_VERBOSITY: 3
run: python3.9 -m cibuildwheel --output-dir wheelhouse
- name: Validate wheels
run: |
python3.9 -m pip install twine
python3.9 -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: ${{ runner.os }}-wheels-${{ matrix.pl_backend }}-${{ matrix.arch }}-cu${{ matrix.cuda_version }}
path: ./wheelhouse/*.whl
upload-pypi:
needs: linux-wheels-x86-64
strategy:
matrix:
arch: [x86_64]
pl_backend: ["lightning_gpu"]
cuda_version: ["12"]
runs-on: ubuntu-latest
if: |
github.event_name == 'release' ||
github.ref == 'refs/heads/master'
steps:
- uses: actions/download-artifact@v3
with:
name: ${{ runner.os }}-wheels-${{ matrix.pl_backend }}-${{ matrix.arch }}-cu${{ matrix.cuda_version }}
path: dist
- name: Upload wheels to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_LGPU_TOKEN }}
repository_url: https://test.pypi.org/legacy/