-
Notifications
You must be signed in to change notification settings - Fork 152
406 lines (323 loc) · 13.3 KB
/
concrete_python_release.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
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
name: Concrete Python Release
on:
workflow_dispatch:
inputs:
instance_id:
description: 'Instance ID'
type: string
instance_image_id:
description: 'Instance AMI ID'
type: string
instance_type:
description: 'Instance product type'
type: string
runner_name:
description: 'Action runner name'
type: string
request_id:
description: 'Slab request ID'
type: string
user_inputs:
description: 'either "nightly" or "public" to specify the release type'
required: true
default: 'nightly'
type: string
env:
DOCKER_IMAGE_TEST: ghcr.io/zama-ai/concrete-compiler
GLIB_VER: 2_28
RELEASE_TYPE: ${{ inputs.user_inputs }}
jobs:
linux-x86:
continue-on-error: true
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
runs-on: ${{ github.event.inputs.runner_name }}
steps:
- name: Log instance configuration
run: |
echo "IDs: ${{ inputs.instance_id }}"
echo "AMI: ${{ inputs.instance_image_id }}"
echo "Type: ${{ inputs.instance_type }}"
echo "Request ID: ${{ inputs.request_id }}"
echo "User Inputs: ${{ inputs.user_inputs }}"
- name: Set up SSH agent
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.CONCRETE_CI_SSH_PRIVATE }}
- name: Set up GitHub environment
run: |
echo "HOME=/home/ubuntu" >> "${GITHUB_ENV}"
#echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK)" >> "${GITHUB_ENV}"
echo "SSH_AUTH_SOCK_DIR=$(dirname $SSH_AUTH_SOCK)" >> "${GITHUB_ENV}"
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
token: ${{ secrets.CONCRETE_ACTIONS_TOKEN }}
- name: Set release version (nightly)
if: ${{ env.RELEASE_TYPE == 'nightly' }}
run: |
VERSION=$(date +"%Y.%m.%d")
echo "__version__ = \"$VERSION\"" >| frontends/concrete-python/version.txt
git tag nightly-$VERSION || true
git push origin nightly-$VERSION || true
- name: Set release version (public)
if: ${{ env.RELEASE_TYPE == 'public' }}
run: echo "__version__ = \"`git describe --tags --abbrev=0 | grep -e '[0-9].*' -o`\"" >| frontends/concrete-python/version.txt
- name: Expose release version from Python
run: cp frontends/concrete-python/version.txt frontends/concrete-python/concrete/fhe/version.py
- name: Create build directory
run: mkdir build
- name: Build wheel
uses: addnab/docker-run-action@v3
id: build-compiler-bindings
with:
registry: ghcr.io
image: ${{ env.DOCKER_IMAGE_TEST }}
username: ${{ secrets.GHCR_LOGIN }}
password: ${{ secrets.GHCR_PASSWORD }}
options: >-
-v ${{ github.workspace }}:/concrete
-v ${{ github.workspace }}/build:/build
-v ${{ env.SSH_AUTH_SOCK }}:/ssh.socket
-e SSH_AUTH_SOCK=/ssh.socket
${{ env.DOCKER_GPU_OPTION }}
shell: bash
run: |
set -e
rm -rf /build/*
export PYTHON=${{ format('python{0}', matrix.python-version) }}
echo "Using $PYTHON"
cd /concrete/frontends/concrete-python
make PYTHON=$PYTHON venv
source .venv/bin/activate
cd /concrete/compilers/concrete-compiler/compiler
make BUILD_DIR=/build CCACHE=ON DATAFLOW_EXECUTION_ENABLED=ON Python3_EXECUTABLE=$(which python) python-bindings
echo "Debug: ccache statistics (after the build):"
ccache -s
cd /concrete/frontends/concrete-python
export COMPILER_BUILD_DIRECTORY="/build"
make whl
deactivate
- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: ${{ format('wheel-{0}-linux-x86', matrix.python-version) }}
path: frontends/concrete-python/dist/*manylinux*.whl
retention-days: 3
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Test wheel
run: |
set -e
export CONCRETE_PYTHON=$(pwd)/frontends/concrete-python
cd $(mktemp -d)
python -m venv .testenv
source .testenv/bin/activate
pip install $CONCRETE_PYTHON/dist/*manylinux*.whl
pip install -r $CONCRETE_PYTHON/requirements.dev.txt
expected_version=$(cat "$CONCRETE_PYTHON/version.txt")
actual_version=$(python -c "from concrete import fhe; print(f'__version__ = \"{fhe.__version__}\"')")
if [ "$actual_version" != "$expected_version" ]; then
echo "Release version is not properly set"
exit 1
fi
cp -R $CONCRETE_PYTHON/tests .
cp -R $CONCRETE_PYTHON/pytest.ini .
pytest -svv -n auto tests --key-cache /tmp/KeySetCache
rm -rf /tmp/KeySetCache
deactivate
macos:
continue-on-error: true
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
runs-on: ["aws-mac1-metal", "aws-mac2-metal"]
runs-on: ${{ matrix.runs-on }}
steps:
- name: Set up SSH agent
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.CONCRETE_CI_SSH_PRIVATE }}
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
token: ${{ secrets.CONCRETE_ACTIONS_TOKEN }}
- name: Install OS Dependencies
run: |
brew install ninja ccache
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- name: Set release version (nightly)
if: ${{ env.RELEASE_TYPE == 'nightly' }}
run: echo "__version__ = \"$(date +"%Y.%m.%d")\"" >| frontends/concrete-python/version.txt
- name: Set release version (public)
if: ${{ env.RELEASE_TYPE == 'public' }}
run: echo "__version__ = \"`git describe --tags --abbrev=0 | grep -e '[0-9].*' -o`\"" >| frontends/concrete-python/version.txt
- name: Expose release version from Python
run: cp frontends/concrete-python/version.txt frontends/concrete-python/concrete/fhe/version.py
- name: Create build directory
run: mkdir build
- name: Build wheel
run: |
set -e
cd frontends/concrete-python
# Setup pkg-config to find OpenBLAS (scipy need it)
export PKG_CONFIG_PATH="/opt/homebrew/opt/openblas/lib/pkgconfig"
rm -rf .venv
${{ format('python{0}', matrix.python-version) }} -m venv .venv
. .venv/bin/activate
pip install -r requirements.dev.txt
pip install -r requirements.txt
cd $GITHUB_WORKSPACE/compilers/concrete-compiler/compiler
echo "Debug: ccache statistics (prior to the build):"
ccache -s
make Python3_EXECUTABLE=$(which python) python-bindings
echo "Debug: ccache statistics (after the build):"
ccache -s
export COMPILER_BUILD_DIRECTORY=$(pwd)/build
cd $GITHUB_WORKSPACE/frontends/concrete-python
rm -rf dist
mkdir -p dist
pip wheel -v --no-deps -w dist .
delocate-wheel -v dist/*macos*.whl
deactivate
- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: ${{ format('wheel-{0}-{1}', matrix.python-version, matrix.runs-on) }}
path: frontends/concrete-python/dist/*macos*.whl
retention-days: 3
- name: Test wheel
run: |
set -e
export CONCRETE_PYTHON=$(pwd)/frontends/concrete-python
export TEST_TMP_DIR=$(mktemp -d)
cd $TEST_TMP_DIR
export PYTHON_VERSION=${{ format('python{0}', matrix.python-version) }}
$PYTHON_VERSION -m venv .testenv
source .testenv/bin/activate
pip install $CONCRETE_PYTHON/dist/*macos*.whl
pip install -r $CONCRETE_PYTHON/requirements.dev.txt
expected_version=$(cat "$CONCRETE_PYTHON/version.txt")
actual_version=$(python -c "from concrete import fhe; print(f'__version__ = \"{fhe.__version__}\"')")
if [ "$actual_version" != "$expected_version" ]; then
echo "Release version is not properly set"
exit 1
fi
# MacOS x86 have conflict between our OpenMP library, and one from torch
# we fix it by using a single one (from torch)
# see discussion: https://discuss.python.org/t/conflicting-binary-extensions-in-different-packages/25332/8
export SITE_PACKAGES=$(pwd)/.testenv/lib/$PYTHON_VERSION/site-packages/
export CONCRETE_LIB_OMP=$SITE_PACKAGES/concrete/.dylibs/libomp.dylib
# Where is libiomp? Possibilities ordered in increasing priorities
export TORCH_LIB_IOMP="this shouldn't exist"
ls $SITE_PACKAGES/torch/lib/libiomp5.dylib && export TORCH_LIB_IOMP=$SITE_PACKAGES/torch/lib/libiomp5.dylib
ls $SITE_PACKAGES/torch/.dylibs/libiomp5.dylib && export TORCH_LIB_IOMP=$SITE_PACKAGES/torch/.dylibs/libiomp5.dylib
ls $SITE_PACKAGES/functorch/.dylibs/libiomp5.dylib && export TORCH_LIB_IOMP=$SITE_PACKAGES/functorch/.dylibs/libiomp5.dylib
ls $TORCH_LIB_IOMP \
&& rm $CONCRETE_LIB_OMP \
&& ln -s $TORCH_LIB_IOMP $CONCRETE_LIB_OMP
cp -R $CONCRETE_PYTHON/tests .
cp -R $CONCRETE_PYTHON/pytest.ini .
pytest tests -svv -n auto -m "not dataflow" --key-cache /tmp/KeySetCache
rm -rf /tmp/KeySetCache
rm -rf $TEST_TMP_DIR
push:
needs: [linux-x86, macos]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
continue-on-error: ${{ env.RELEASE_TYPE == 'nightly' }}
with:
name: wheel-3.8-linux-x86
path: wheels
- uses: actions/download-artifact@v4
continue-on-error: ${{ env.RELEASE_TYPE == 'nightly' }}
with:
name: wheel-3.9-linux-x86
path: wheels
- uses: actions/download-artifact@v4
continue-on-error: ${{ env.RELEASE_TYPE == 'nightly' }}
with:
name: wheel-3.10-linux-x86
path: wheels
- uses: actions/download-artifact@v4
continue-on-error: ${{ env.RELEASE_TYPE == 'nightly' }}
with:
name: wheel-3.11-linux-x86
path: wheels
- uses: actions/download-artifact@v4
continue-on-error: ${{ env.RELEASE_TYPE == 'nightly' }}
with:
name: wheel-3.8-aws-mac1-metal
path: wheels
- uses: actions/download-artifact@v4
continue-on-error: ${{ env.RELEASE_TYPE == 'nightly' }}
with:
name: wheel-3.9-aws-mac1-metal
path: wheels
- uses: actions/download-artifact@v4
continue-on-error: ${{ env.RELEASE_TYPE == 'nightly' }}
with:
name: wheel-3.10-aws-mac1-metal
path: wheels
- uses: actions/download-artifact@v4
continue-on-error: ${{ env.RELEASE_TYPE == 'nightly' }}
with:
name: wheel-3.11-aws-mac1-metal
path: wheels
- uses: actions/download-artifact@v4
continue-on-error: ${{ env.RELEASE_TYPE == 'nightly' }}
with:
name: wheel-3.8-aws-mac2-metal
path: wheels
- uses: actions/download-artifact@v4
continue-on-error: ${{ env.RELEASE_TYPE == 'nightly' }}
with:
name: wheel-3.9-aws-mac2-metal
path: wheels
- uses: actions/download-artifact@v4
continue-on-error: ${{ env.RELEASE_TYPE == 'nightly' }}
with:
name: wheel-3.10-aws-mac2-metal
path: wheels
- uses: actions/download-artifact@v4
continue-on-error: ${{ env.RELEASE_TYPE == 'nightly' }}
with:
name: wheel-3.11-aws-mac2-metal
path: wheels
- name: Push wheels to internal PyPI (nightly)
if: ${{ env.RELEASE_TYPE == 'nightly' }}
run: |
pip install twine==4.0.2
twine upload wheels/*.whl \
-u "${{ secrets.INTERNAL_PYPI_USER }}" \
-p "${{ secrets.INTERNAL_PYPI_PASSWORD }}" \
--repository-url "${{ secrets.INTERNAL_PYPI_URL }}"
- name: Push wheels to public PyPI (public)
if: ${{ env.RELEASE_TYPE == 'public' }}
run: |
pip install twine==4.0.2
twine upload wheels/*.whl \
-u "${{ secrets.PUBLIC_PYPI_USER }}" \
-p "${{ secrets.PUBLIC_PYPI_PASSWORD }}" \
-r pypi
- name: Start pushing Docker images
if: ${{ env.RELEASE_TYPE == 'public' }}
run: |
export TAG=$(git describe --tags --abbrev=0)
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.CONCRETE_ACTIONS_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/zama-ai/concrete/actions/workflows/concrete_python_push_docker_image.yml/dispatches \
-d '{"ref":"$TAG","inputs":{"tag":"$TAG"}}'