-
Notifications
You must be signed in to change notification settings - Fork 71
508 lines (443 loc) · 19.7 KB
/
build-wheel-linux-arm64.yml
File metadata and controls
508 lines (443 loc) · 19.7 KB
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
name: Build Catalyst Wheel on Linux (arm64)
on:
pull_request:
types:
- opened
- reopened
- synchronize
- labeled
- ready_for_review
push:
branches: [ main ]
schedule:
# Thursdays we test the standalone plugin
- cron: '35 4 * * 4'
workflow_dispatch:
inputs:
build_standalone_plugin:
description: 'Build the standalone plugin wheel'
type: choice
options:
- 'true'
- 'false'
required: false
default: 'false'
workflow_call:
inputs:
build_standalone_plugin:
description: 'Build the standalone plugin wheel'
type: boolean
required: false
default: false
branch:
description: 'Branch to build from'
required: false
default: 'main'
type: string
concurrency:
group: Build Catalyst Wheel on Linux (arm64)-${{ github.ref }}
cancel-in-progress: true
env:
# If the `inputs.build_standalone_plugin` is set to a value (true/false), then that is used.
# If the input is empty (meaning this workflow was not triggered by a workflow_call/workflow_dispatch), then check if event_name is schedule.
# If event_name is NOT schedule, default to false
BUILD_STANDALONE_PLUGIN: ${{ format('{0}', inputs.build_standalone_plugin) || github.event_name == 'schedule' }}
jobs:
check_if_wheel_build_required:
if: github.event.pull_request.draft == false
uses: ./.github/workflows/check-for-wheel-build.yml
constants:
needs: [check_if_wheel_build_required]
if: needs.check_if_wheel_build_required.outputs.build-wheels == 'true'
name: "Set build matrix"
uses: ./.github/workflows/constants.yaml
build-dependencies:
needs: [constants, check_if_wheel_build_required]
strategy:
fail-fast: false
matrix:
python_version: ${{ fromJson(format('["{0}"]', needs.constants.outputs.primary_python_version)) }}
container_img: ["manylinux_2_28_aarch64"]
name: Build Dependencies (Python ${{ matrix.python_version }})
runs-on: ubuntu-24.04-arm
container: quay.io/pypa/${{ matrix.container_img }}
if: needs.check_if_wheel_build_required.outputs.build-wheels == 'true'
steps:
- name: Checkout Catalyst repo
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch || github.ref }}
- name: Cache LLVM Source
id: cache-llvm-source
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/mlir/llvm-project
key: llvm-${{ needs.constants.outputs.llvm_version }}-container-source
enableCrossOsArchive: True
- name: Cache Stablehlo Source
id: cache-stablehlo-source
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/mlir/stablehlo
key: stablehlo-${{ needs.constants.outputs.stablehlo_version }}-container-source
enableCrossOsArchive: True
- name: Cache Enzyme Source
id: cache-enzyme-source
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/mlir/Enzyme
key: enzyme-${{ needs.constants.outputs.enzyme_version }}-container-source
enableCrossOsArchive: True
- name: Clone LLVM Submodule
if: steps.cache-llvm-source.outputs.cache-hit != 'true'
uses: actions/checkout@v4
with:
repository: llvm/llvm-project
ref: ${{ needs.constants.outputs.llvm_version }}
path: ${{ github.workspace }}/mlir/llvm-project
- name: Patch LLVM Source
if: steps.cache-llvm-source.outputs.cache-hit != 'true'
run: |
cd $GITHUB_WORKSPACE/mlir/llvm-project
git apply $GITHUB_WORKSPACE/mlir/patches/llvm-bufferization-segfault.patch
- name: Clone Stablehlo Submodule
if: steps.cache-stablehlo-source.outputs.cache-hit != 'true'
uses: actions/checkout@v4
with:
repository: openxla/stablehlo
ref: ${{ needs.constants.outputs.stablehlo_version }}
path: ${{ github.workspace }}/mlir/stablehlo
- name: Clone Enzyme Submodule
if: steps.cache-enzyme-source.outputs.cache-hit != 'true'
uses: actions/checkout@v4
with:
repository: EnzymeAD/Enzyme
ref: ${{ needs.constants.outputs.enzyme_version }}
path: ${{ github.workspace }}/mlir/Enzyme
- name: Patch Enzyme Source
if: steps.cache-enzyme-source.outputs.cache-hit != 'true'
run: |
cd $GITHUB_WORKSPACE/mlir/Enzyme
git apply $GITHUB_WORKSPACE/mlir/patches/enzyme-nvvm-fabs-intrinsics.patch
# Cache external project builds
- name: Restore LLVM Build
id: cache-llvm-build
uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}/llvm-build
key: ${{ matrix.container_img }}-llvm-${{ needs.constants.outputs.llvm_version }}-${{ matrix.python_version }}-wheel-build
- name: Check Stablehlo Build Cache
id: cache-stablehlo-build
uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}/stablehlo-build
key: ${{ matrix.container_img }}-stablehlo-${{ needs.constants.outputs.stablehlo_version }}-wheel-build
lookup-only: True
- name: Check Enzyme Build Cache
id: cache-enzyme-build
uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}/enzyme-build
key: ${{ matrix.container_img }}-enzyme-${{ needs.constants.outputs.llvm_version }}-${{ needs.constants.outputs.enzyme_version }}-wheel-build
lookup-only: True
- name: Install dependencies
if: |
steps.cache-llvm-build.outputs.cache-hit != 'true' ||
steps.cache-stablehlo-build.outputs.cache-hit != 'true' ||
steps.cache-enzyme-build.outputs.cache-hit != 'true'
run: |
cat /etc/dnf.conf | sed "s/\[main\]/\[main\]\ntimeout=5/g" > /etc/dnf.conf
dnf update -y && dnf install -y libzstd-devel gcc-toolset-13
# Update env vars valid for all tasks of this job
echo '/opt/rh/gcc-toolset-13/root/usr/bin' >> $GITHUB_PATH
- name: Install Dependencies (Python)
run: |
python${{ matrix.python_version }} -m pip install numpy nanobind pybind11 PyYAML cmake ninja
# Add cmake and ninja to the PATH env var
PYTHON_BINS=$(find /opt/_internal/cpython-${{ matrix.python_version }}.*/bin -maxdepth 1 -type d | tr '\n' ':' | sed 's/:$//')
echo $PYTHON_BINS >> $GITHUB_PATH
- name: Build LLVM / MLIR
if: steps.cache-llvm-build.outputs.cache-hit != 'true'
run: |
export PATH=$GITHUB_WORKSPACE/llvm-build/bin:$PATH
PYTHON=$(which python${{ matrix.python_version }}) \
C_COMPILER=$(which gcc) \
CXX_COMPILER=$(which g++) \
LLVM_BUILD_DIR="$GITHUB_WORKSPACE/llvm-build" \
LLVM_PROJECTS="lld;mlir" \
LLVM_TARGETS="lld check-mlir" \
ENABLE_ZLIB=FORCE_ON \
ENABLE_LLD=OFF \
make llvm
- name: Save LLVM Build
id: save-llvm-build
if: steps.cache-llvm-build.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: ${{ github.workspace }}/llvm-build
key: ${{ matrix.container_img }}-llvm-${{ needs.constants.outputs.llvm_version }}-${{matrix.python_version}}-wheel-build
- name: Build Stablehlo Dialect
if: steps.cache-stablehlo-build.outputs.cache-hit != 'true'
run: |
C_COMPILER=$(which gcc) \
CXX_COMPILER=$(which g++) \
LLVM_BUILD_DIR="$(pwd)/llvm-build" \
STABLEHLO_BUILD_DIR="$GITHUB_WORKSPACE/stablehlo-build" \
COMPILER_LAUNCHER="" \
ENABLE_LLD=OFF \
make stablehlo
- name: Save Stablehlo Build
id: save-stablehlo-build
if: steps.cache-stablehlo-build.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: ${{ github.workspace }}/stablehlo-build
key: ${{ matrix.container_img }}-stablehlo-${{ needs.constants.outputs.stablehlo_version }}-wheel-build
- name: Build Enzyme
if: steps.cache-enzyme-build.outputs.cache-hit != 'true'
run: |
export PATH=$GITHUB_WORKSPACE/llvm-build/bin:$PATH
cmake -S mlir/Enzyme/enzyme -B $GITHUB_WORKSPACE/enzyme-build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_DIR="$GITHUB_WORKSPACE/llvm-build/lib/cmake/llvm" \
-DENZYME_STATIC_LIB=ON \
-DCMAKE_CXX_VISIBILITY_PRESET=default \
-DCMAKE_CXX_FLAGS="-fuse-ld=lld"
cmake --build $GITHUB_WORKSPACE/enzyme-build --target EnzymeStatic-22
- name: Save Enzyme Build
id: save-enzyme-build
if: steps.cache-enzyme-build.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: ${{ github.workspace }}/enzyme-build
key: ${{ matrix.container_img }}-enzyme-${{ needs.constants.outputs.llvm_version }}-${{ needs.constants.outputs.enzyme_version }}-wheel-build
catalyst-linux-wheels-arm64:
needs: [constants, build-dependencies]
strategy:
fail-fast: false
matrix:
python_version: ${{ fromJSON(needs.constants.outputs.python_versions) }}
container_img: ["manylinux_2_28_aarch64"]
name: Build Wheels (Python ${{ matrix.python_version }})
runs-on: ubuntu-24.04-arm
container: quay.io/pypa/${{ matrix.container_img }}
steps:
- name: Checkout Catalyst repo
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch || github.ref }}
- name: Install dependencies (AlmaLinux)
run: |
# Reduce wait time for repos not responding
cat /etc/dnf.conf | sed "s/\[main\]/\[main\]\ntimeout=5/g" > /etc/dnf.conf
dnf update -y && dnf install -y openmpi-devel libzstd-devel gcc-toolset-13
# Update env vars valid for all tasks of this job
echo '/opt/rh/gcc-toolset-13/root/usr/bin' >> $GITHUB_PATH
- name: Install Dependencies (Python)
run: |
python${{ matrix.python_version }} -m pip install numpy nanobind pybind11 PyYAML cmake ninja
# Add cmake and ninja to the PATH env var
PYTHON_BINS=$(find /opt/_internal/cpython-${{ matrix.python_version }}.*/bin -maxdepth 1 -type d | tr '\n' ':' | sed 's/:$//')
echo $PYTHON_BINS >> $GITHUB_PATH
- name: Get Cached LLVM Source
id: cache-llvm-source
uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}/mlir/llvm-project
key: llvm-${{ needs.constants.outputs.llvm_version }}-container-source
enableCrossOsArchive: True
fail-on-cache-miss: True
- name: Get Cached LLVM Build
id: cache-llvm-build
uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}/llvm-build
key: ${{ matrix.container_img }}-llvm-${{ needs.constants.outputs.llvm_version }}-3.11-wheel-build
fail-on-cache-miss: True
- name: Get Cached Stablehlo Source
id: cache-stablehlo-source
uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}/mlir/stablehlo
key: stablehlo-${{ needs.constants.outputs.stablehlo_version }}-container-source
enableCrossOsArchive: True
fail-on-cache-miss: True
- name: Get Cached Stablehlo Build
id: cache-stablehlo-build
uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}/stablehlo-build
key: ${{ matrix.container_img }}-stablehlo-${{ needs.constants.outputs.stablehlo_version }}-wheel-build
fail-on-cache-miss: True
- name: Get Cached Enzyme Source
id: cache-enzyme-source
uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}/mlir/Enzyme
key: enzyme-${{ needs.constants.outputs.enzyme_version }}-container-source
enableCrossOsArchive: True
fail-on-cache-miss: True
- name: Get Cached Enzyme Build
id: cache-enzyme-build
uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}/enzyme-build
key: ${{ matrix.container_img }}-enzyme-${{ needs.constants.outputs.llvm_version }}-${{ needs.constants.outputs.enzyme_version }}-wheel-build
fail-on-cache-miss: True
- name: Build Catalyst-Runtime
run: |
cmake -S runtime -B $GITHUB_WORKSPACE/runtime-build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY="$GITHUB_WORKSPACE/runtime-build/lib" \
-DPython_EXECUTABLE=$(which python${{ matrix.python_version }}) \
-DENABLE_OPENQASM=ON \
-DENABLE_OQD=OFF \
-DMLIR_INCLUDE_DIRS="$GITHUB_WORKSPACE/mlir/llvm-project/mlir/include"
cmake --build $GITHUB_WORKSPACE/runtime-build --target rt_capi rt_rsdecomp rtd_openqasm rtd_null_qubit
- name: Build OQC-Runtime
run: |
C_COMPILER=$(which gcc) \
CXX_COMPILER=$(which g++) \
OQC_BUILD_DIR="$GITHUB_WORKSPACE/oqc-build" \
RT_BUILD_DIR="$GITHUB_WORKSPACE/runtime-build" \
PYTHON=$(which python${{ matrix.python_version }}) \
make oqc
# Build Quantum and Gradient Dialects
- name: Build MLIR Dialects
run: |
export PATH=$GITHUB_WORKSPACE/llvm-build/bin:$PATH
cmake -S mlir -B $GITHUB_WORKSPACE/quantum-build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DQUANTUM_ENABLE_BINDINGS_PYTHON=ON \
-DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/catalyst/catalyst \
-DPython3_EXECUTABLE=$(which python${{ matrix.python_version }}) \
-DPython3_NumPy_INCLUDE_DIRS=$(python${{ matrix.python_version }} -c "import numpy as np; print(np.get_include())") \
-DMLIR_DIR="$GITHUB_WORKSPACE/llvm-build/lib/cmake/mlir" \
-DSTABLEHLO_DIR="$GITHUB_WORKSPACE/mlir/stablehlo" \
-DSTABLEHLO_BUILD_DIR="$GITHUB_WORKSPACE/stablehlo-build" \
-DEnzyme_DIR="$GITHUB_WORKSPACE/enzyme-build" \
-DENZYME_SRC_DIR="$GITHUB_WORKSPACE/mlir/Enzyme" \
-DLLVM_ENABLE_ZLIB=FORCE_ON \
-DLLVM_ENABLE_ZSTD=OFF \
-DLLVM_ENABLE_LLD=ON
cmake --build $GITHUB_WORKSPACE/quantum-build --target check-dialects catalyst-cli
- name: Build Plugin wheel
# Run only on Thursday at the given time
if: env.BUILD_STANDALONE_PLUGIN == 'true'
run: |
MLIR_DIR="$GITHUB_WORKSPACE/llvm-build/lib/cmake/mlir" \
LLVM_BUILD_DIR="$GITHUB_WORKSPACE/llvm-build" \
C_COMPILER=$(which gcc) \
CXX_COMPILER=$(which g++) \
make plugin-wheel
- name: Build wheel
run: |
PYTHON=python${{ matrix.python_version }} \
LLVM_BUILD_DIR="$GITHUB_WORKSPACE/llvm-build" \
STABLEHLO_BUILD_DIR="$GITHUB_WORKSPACE/stablehlo-build" \
DIALECTS_BUILD_DIR="$GITHUB_WORKSPACE/quantum-build" \
RT_BUILD_DIR="$GITHUB_WORKSPACE/runtime-build" \
OQC_BUILD_DIR="$GITHUB_WORKSPACE/oqc-build" \
ENZYME_BUILD_DIR="$GITHUB_WORKSPACE/enzyme-build" \
make wheel
- name: Repair wheel using auditwheel
run: |
# exclude libopenblas as we rely on the openblas/lapack library shipped by scipy
auditwheel repair dist/*.whl -w ./wheel --no-update-tags --exclude libopenblasp-r0-23e5df77.3.21.dev.so
- name: Upload Wheel Artifact
uses: actions/upload-artifact@v4
with:
name: catalyst-linux_arm_64-wheel-py-${{ matrix.python_version }}.zip
path: ${{ github.workspace }}/wheel/
retention-days: 14
- name: Upload Standalone Plugin Wheel Artifact
# Run only on Thursday at the given time
if: env.BUILD_STANDALONE_PLUGIN == 'true'
uses: actions/upload-artifact@v4
with:
name: standalone-plugin-linux_arm_64-wheel-py-${{ matrix.python_version }}.zip
path: ${{ github.workspace }}/standalone_plugin_wheel/dist
retention-days: 14
test-wheels:
needs: [constants, catalyst-linux-wheels-arm64]
strategy:
fail-fast: false
matrix:
python_version: ${{ fromJson(needs.constants.outputs.python_test_versions) }}
# To check all wheels for supported python3 versions
name: Test Wheels (Python ${{ matrix.python_version }}) on Linux Arm
runs-on: ubuntu-24.04-arm
steps:
- name: Checkout Catalyst repo
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch || github.ref }}
- name: Setup Python ${{ matrix.python_version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
# choose FORWARD_COMPAT_BASE_VERSION if python version > FORWARD_COMPAT_BASE_VERSION
- name: Determine which python build version to use
id: python_build_version
env:
FORWARD_COMPAT_BASE_VERSION: ${{ needs.constants.outputs.forward_compat_python_version }}
IS_VERSION_SUPPORTED: ${{ contains(fromJson(needs.constants.outputs.python_versions), matrix.python_version) }}
run: |
if [[ $IS_VERSION_SUPPORTED == "true" ]]; then
echo "python_build_version=${{ matrix.python_version }}" >> $GITHUB_OUTPUT
else
echo "python_build_version=$FORWARD_COMPAT_BASE_VERSION" >> $GITHUB_OUTPUT
fi
- name: Download Wheel Artifact
uses: actions/download-artifact@v4
with:
name: catalyst-linux_arm_64-wheel-py-${{ steps.python_build_version.outputs.python_build_version }}.zip
path: ${{ github.workspace }}/dist
- name: Download Standalone Plugin Wheel Artifact
# Run only on Thursday at the given time
if: env.BUILD_STANDALONE_PLUGIN == 'true'
uses: actions/download-artifact@v4
with:
name: standalone-plugin-linux_arm_64-wheel-py-${{ steps.python_build_version.outputs.python_build_version }}.zip
path: ${{ github.workspace }}/standalone_plugin_wheel/wheel
- name: Set up Python ${{ matrix.python_version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
- name: Install Python dependencies
run: |
python${{ matrix.python_version }} -m pip install pytest pytest-xdist pytest-mock
# Install graphviz for testing graph visualization
sudo apt-get install -y graphviz
python${{ matrix.python_version }} -m pip install graphviz pydot matplotlib
- name: Install PennyLane Plugins
run: |
python${{ matrix.python_version }} -m pip install PennyLane-Lightning-Kokkos
python${{ matrix.python_version }} -m pip install 'amazon-braket-pennylane-plugin>=1.31.0'
- name: Install OQC client
run: |
python_minor=$(echo "${{ matrix.python_version }}" | cut -d. -f2)
if [ "$python_minor" -lt 13 ]; then
python${{ matrix.python_version }} -m pip install oqc-qcaas-client
fi
- name: Install Catalyst
run: |
python${{ matrix.python_version }} -m pip install dist/*.whl --extra-index-url https://test.pypi.org/simple
- name: Install Standalone Plugin
# Run only on Thursday at the given time
if: env.BUILD_STANDALONE_PLUGIN == 'true'
run: |
python${{ matrix.python_version }} -m pip install standalone_plugin_wheel/wheel/*.whl --no-deps
- name: Run Python Pytest Tests
run: |
python${{ matrix.python_version }} -m pytest frontend/test/pytest -n auto
python${{ matrix.python_version }} -m pytest frontend/test/pytest --backend="lightning.kokkos" -n auto -m "not xdsl"
python${{ matrix.python_version }} -m pytest frontend/test/async_tests
python${{ matrix.python_version }} -m pytest frontend/test/pytest --runbraket=LOCAL -n auto -m "not xdsl" || true
python${{ matrix.python_version }} -m pytest frontend/test/test_oqc/oqc -n auto
- name: Run Standalone Plugin Tests
# Run only on Thursday at the given time
if: env.BUILD_STANDALONE_PLUGIN == 'true'
run: |
python${{ matrix.python_version }} -m pytest standalone_plugin_wheel/standalone_plugin/test -n auto