-
Notifications
You must be signed in to change notification settings - Fork 40
230 lines (197 loc) · 7.82 KB
/
wheel_win_x86_64.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
name: Wheel::Windows::x86_64
# **What it does**: Builds python wheels for Windows (windows-latest) 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:
DISTUTILS_USE_SDK: 1
MSSdk: 1
concurrency:
group: wheel_win_x86_64-${{ 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 }}
build_dependencies:
needs: [set_wheel_build_matrix]
strategy:
fail-fast: false
matrix:
os: [windows-2022]
exec_model: ["SERIAL"]
kokkos_version: ${{ fromJson(needs.set_wheel_build_matrix.outputs.kokkos_version) }}
timeout-minutes: 30
name: Kokkos core (${{ matrix.exec_model }})
runs-on: ${{ matrix.os }}
steps:
- name: Cache installation directories
id: kokkos-cache
uses: actions/cache@v4
with:
path: D:\a\install_dir\${{ matrix.exec_model }}
key: ${{ matrix.os }}-kokkos${{ matrix.kokkos_version }}-${{ matrix.exec_model }}-RelWithDebInfo
- name: Clone Kokkos libs
if: steps.kokkos-cache.outputs.cache-hit != 'true'
run: |
cd D:\a
git clone --branch ${{ matrix.kokkos_version }} https://github.com/kokkos/kokkos.git
- name: Install dependencies
if: steps.kokkos-cache.outputs.cache-hit != 'true'
run: |
python -m pip install cmake build
- name: Build Kokkos core library
if: steps.kokkos-cache.outputs.cache-hit != 'true'
run: |
mkdir -p D:\a\install_dir\${{ matrix.exec_model }}
cd D:\a\kokkos
cmake -BBuild . -DCMAKE_INSTALL_PREFIX=D:\a\install_dir\${{ 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_BUILD_TYPE=RelWithDebInfo `
-T clangcl
cmake --build ./Build --config RelWithDebInfo --verbose
cmake --install ./Build --config RelWithDebInfo --verbose
win-wheels:
needs: [set_wheel_build_matrix, build_dependencies]
strategy:
fail-fast: false
matrix:
os: [windows-2022]
arch: [AMD64]
pl_backend: ["lightning_qubit"]
cibw_build: ${{ fromJson(needs.set_wheel_build_matrix.outputs.python_version) }}
exec_model: ["SERIAL"]
kokkos_version: ${{ fromJson(needs.set_wheel_build_matrix.outputs.kokkos_version) }}
timeout-minutes: 30
name: ${{ matrix.os }} - ${{ matrix.pl_backend }} (Python ${{ fromJson('{ "cp39-*":"3.9","cp310-*":"3.10","cp311-*":"3.11","cp312-*":"3.12" }')[matrix.cibw_build] }})
runs-on: ${{ matrix.os }}
steps:
- name: Restoring cached dependencies
id: kokkos-cache
uses: actions/cache@v4
with:
path: D:\a\install_dir\${{ matrix.exec_model }}
key: ${{ matrix.os }}-kokkos${{ matrix.kokkos_version }}-${{ matrix.exec_model }}-RelWithDebInfo
- name: Checkout PennyLane-Lightning
uses: actions/checkout@v4
- name: Copy cached libraries
if: steps.kokkos-cache.outputs.cache-hit == 'true'
run: |
Copy-Item -Path "D:\a\install_dir\${{ matrix.exec_model }}\" `
-Destination "D:\a\pennylane-lightning\pennylane-lightning\Kokkos" -Recurse -Force
- name: Install cibuildwheel
run: python -m pip install cibuildwheel~=2.16.0 wheel
- name: Build wheels
env:
CIBW_ARCHS_WINDOWS: ${{matrix.arch}}
CIBW_BUILD: ${{ matrix.cibw_build }}
# Python build settings
CIBW_BEFORE_BUILD: |
python -m pip install pybind11 cmake~=3.24.0 build
CIBW_ENVIRONMENT: |
CMAKE_ARGS="-DENABLE_LAPACK=OFF"
PL_BACKEND="${{ matrix.pl_backend }}"
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_BUILD_VERBOSITY: 3
CIBW_BUILD_FRONTEND: build
run: python -m cibuildwheel --output-dir wheelhouse
- name: Patch wheels
run: |
cd wheelhouse
$wheels = Get-ChildItem "./" -Filter *.whl
foreach ($i in $wheels){
python -m wheel unpack $i.Name
$name = $i.Name
$dirName = python -c "s = '$name'; print('-'.join(s.split('-')[0:2]))"
if (Test-Path -Path $dirName\pennylane_lightning\RelWithDebInfo) {
Move-Item -Path $dirName\pennylane_lightning\RelWithDebInfo\* -Destination $dirName\pennylane_lightning
Remove-Item $dirName\pennylane_lightning\RelWithDebInfo -Recurse
python -m wheel pack $dirName
echo "Patched $name"
}
Remove-Item $dirName -Recurse
}
cd ..
- name: Determine Python version
id: pyvs
shell: bash
run: |
echo "version=$(echo ${{ matrix.cibw_build }} | tr -cd '[:digit:].' | sed 's/./&./1')" >> $GITHUB_OUTPUT
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: ${{ steps.pyvs.outputs.version }}
- name: Test wheels
run: |
python -m ensurepip --upgrade
python -m pip install setuptools
python -m pip install -r requirements-tests.txt
if (${{ matrix.pl_backend == 'lightning_kokkos'}}) {
SKIP_COMPILATION=True PL_BACKEND="lightning_qubit" python -m pip install . -vv
}
pushd wheelhouse
$wheels = Get-ChildItem "./" -Filter *.whl
foreach ($i in $wheels){
python -m pip install $i.Name
}
popd
$DEVICENAME=(echo ${{ matrix.pl_backend }} | %{$_ -replace "_","."})
pl-device-test --device=$DEVICENAME --skip-ops -x --tb=short --no-flaky-report
- 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: ${{ runner.os }}-wheels-${{ matrix.pl_backend }}-${{ matrix.arch }}.zip
path: ./wheelhouse/*.whl
upload-pypi:
needs: win-wheels
strategy:
matrix:
arch: [AMD64]
pl_backend: ["lightning_qubit"]
runs-on: ubuntu-latest
if: |
github.event_name == 'release' ||
github.ref == 'refs/heads/master'
steps:
- uses: actions/download-artifact@v3
with:
name: Windows-wheels-${{ matrix.pl_backend }}-${{ matrix.arch }}.zip
path: dist
- name: Upload wheels to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/