forked from NVIDIA/cuda-quantum
-
Notifications
You must be signed in to change notification settings - Fork 0
292 lines (259 loc) · 11.1 KB
/
test_in_devenv.yml
File metadata and controls
292 lines (259 loc) · 11.1 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
on:
workflow_call:
inputs:
platform:
type: string
required: false
default: linux/amd64
mpi:
type: string
required: false
default: openmpi
devdeps_image:
required: false
type: string
devdeps_cache:
required: true
type: string
devdeps_archive:
required: true
type: string
export_environment:
required: false
type: boolean
name: Run CI within the dev environment container
jobs:
build_and_test:
name: Dev environment (Debug)
runs-on: ${{ (contains(inputs.platform, 'arm') && 'linux-arm64-cpu8') || 'linux-amd64-cpu8' }}
permissions:
contents: read
packages: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Restore environment
id: restore_devdeps
if: inputs.devdeps_image == ''
uses: actions/cache/restore@v4
with:
path: ${{ inputs.devdeps_archive }}
key: ${{ inputs.devdeps_cache }}
fail-on-cache-miss: true
- name: Log in to GitHub CR
if: inputs.devdeps_image != ''
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Set up context for buildx
run: |
docker context create builder_context
- name: Set up buildx runner
uses: docker/setup-buildx-action@v3
with:
endpoint: builder_context
version: v0.19.0
buildkitd-config: /etc/buildkit/buildkitd.toml # hard-coded to run on our runners
driver-opts: |
image=moby/buildkit:v0.19.0
- name: Build CUDA Quantum
run: |
if ${{ steps.restore_devdeps.outcome != 'skipped' }}; then
load_output=`docker load --input "${{ inputs.devdeps_archive }}"`
base_image=`echo "$load_output" | grep -o 'Loaded image: \S*:\S*' | head -1 | cut -d ' ' -f 3`
elif ${{ inputs.devdeps_image != '' }}; then
base_image=${{ inputs.devdeps_image }}
else
echo "::error file=test_in_devenv.yml::Missing configuration for development dependencies. Either specify the image (i.e. provide devdeps_image) or cache (i.e. provide devdeps_cache and devdeps_archive) that should be used for the build."
exit 1
fi
DOCKER_BUILDKIT=1 docker build --platform ${{ inputs.platform }} \
-t cuda-quantum-dev:local -f docker/build/cudaq.dev.Dockerfile . \
--build-arg base_image=$base_image \
--build-arg install="CMAKE_BUILD_TYPE=Debug" \
--build-arg mpi="${{ inputs.mpi }}"
- name: Test CUDA Quantum
uses: ./.github/actions/run-in-docker
with:
image: cuda-quantum-dev:local
shell: bash
run: |
cd $CUDAQ_REPO_ROOT
python3 -m pip install iqm-client==28.0.0
python3 -m pytest -v --durations=0 build/python/tests/interop/
pytest_status=$?
if [ ! $pytest_status -eq 0 ]; then
echo "::error file=test_in_devenv.yml::Python interop tests failed with status $pytest_status."
exit 1
fi
ctest --output-on-failure --test-dir build -E "ctest-nvqpp|ctest-targettests"
ctest_status=$?
$LLVM_INSTALL_PREFIX/bin/llvm-lit -v --time-tests --param nvqpp_site_config=build/test/lit.site.cfg.py build/test
lit_status=$?
$LLVM_INSTALL_PREFIX/bin/llvm-lit -v --time-tests --param nvqpp_site_config=build/targettests/lit.site.cfg.py build/targettests
targ_status=$?
$LLVM_INSTALL_PREFIX/bin/llvm-lit -v --time-tests --param nvqpp_site_config=build/python/tests/mlir/lit.site.cfg.py build/python/tests/mlir
pymlir_status=$?
if [ ! $ctest_status -eq 0 ] || [ ! $lit_status -eq 0 ] || [ $targ_status -ne 0 ] || [ $pymlir_status -ne 0 ]; then
echo "::error file=test_in_devenv.yml::C++ tests failed (ctest status $ctest_status, llvm-lit status $lit_status, \
target tests status $targ_status, Python MLIR status $pymlir_status)."
exit 1
fi
- name: Test CUDA Quantum MPI Plugin Activation
uses: ./.github/actions/run-in-docker
with:
image: cuda-quantum-dev:local
shell: bash
run: |
# Set MPI_PATH depending on OMPI/MPICH
has_ompiinfo=$(which ompi_info || true)
if [[ ! -z $has_ompiinfo ]]; then
export MPI_PATH="/usr/lib/$(uname -m)-linux-gnu/openmpi/"
else
export MPI_PATH="/usr/lib/$(uname -m)-linux-gnu/mpich/"
fi
# Run the activation script
source $CUDAQ_INSTALL_PREFIX/distributed_interfaces/activate_custom_mpi.sh
external_plugin_build_status=$?
if [ ! $external_plugin_build_status -eq 0 ] ; then
echo "::error file=test_in_devenv.yml::Test CUDA Quantum MPI Plugin Activation failed to activate the plugin with status $external_plugin_build_status."
exit 1
fi
echo $CUDAQ_MPI_COMM_LIB
# Rerun the MPI plugin test
cd $CUDAQ_REPO_ROOT
ctest --test-dir build -R MPIApiTest -V
external_plugin_status=$?
if [ ! $external_plugin_status -eq 0 ] ; then
echo "::error file=test_in_devenv.yml::Test CUDA Quantum MPI Plugin Activation failed with status $external_plugin_status."
exit 1
fi
- name: Save environment
id: env_save
if: inputs.export_environment
run: |
output_directory=/tmp
platform_id=`echo ${{ inputs.platform }} | sed 's/linux\///g' | tr -d ' '`
filename=${platform_id}_debug_build
docker run --name cuda-quantum-dev cuda-quantum-dev:local
docker export cuda-quantum-dev > $output_directory/$filename.tar
docker rm -f cuda-quantum-dev
echo "filename=$filename" >> $GITHUB_OUTPUT
echo "output_directory=$output_directory" >> $GITHUB_OUTPUT
- name: Upload environment
uses: actions/upload-artifact@v4
if: inputs.export_environment
with:
name: ${{ steps.env_save.outputs.filename }}
path: ${{ steps.env_save.outputs.output_directory }}/${{ steps.env_save.outputs.filename }}.tar
retention-days: 1
build_and_test_python:
name: Dev environment (Python)
runs-on: ${{ (contains(inputs.platform, 'arm') && 'linux-arm64-cpu8') || 'linux-amd64-cpu8' }}
permissions:
contents: read
packages: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Restore environment
id: restore_devdeps
if: inputs.devdeps_image == ''
uses: actions/cache/restore@v4
with:
path: ${{ inputs.devdeps_archive }}
key: ${{ inputs.devdeps_cache }}
fail-on-cache-miss: true
- name: Log in to GitHub CR
if: inputs.devdeps_image != ''
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Set up context for buildx
run: |
docker context create builder_context
- name: Set up buildx runner
uses: docker/setup-buildx-action@v3
with:
endpoint: builder_context
version: v0.19.0
buildkitd-config: /etc/buildkit/buildkitd.toml # hard-coded to run on our runners
driver-opts: |
image=moby/buildkit:v0.19.0
- name: Set up dev environment
id: dev_env
run: |
if ${{ steps.restore_devdeps.outcome != 'skipped' }}; then
load_output=`docker load --input "${{ inputs.devdeps_archive }}"`
base_image=`echo "$load_output" | grep -o 'Loaded image: \S*:\S*' | head -1 | cut -d ' ' -f 3`
elif ${{ inputs.devdeps_image != '' }}; then
base_image=${{ inputs.devdeps_image }}
else
echo "::error file=test_in_devenv.yml::Missing configuration for development dependencies. Either specify the image (i.e. provide devdeps_image) or cache (i.e. provide devdeps_cache and devdeps_archive) that should be used for the build."
exit 1
fi
DOCKER_BUILDKIT=1 docker build --platform ${{ inputs.platform }} \
-t dev_env:local -f docker/build/cudaq.dev.Dockerfile . \
--build-arg base_image=$base_image
- name: Setup proxy cache
uses: nv-gha-runners/setup-proxy-cache@main
- name: Build and test CUDA Quantum (Python)
uses: ./.github/actions/run-in-docker
with:
image: dev_env:local
shell: bash
run: |
cd $CUDAQ_REPO_ROOT
export DEBIAN_FRONTEND=noninteractive
apt-get update -y && apt-get install -y python3-venv
VENV_DIR="$HOME/.venvs/cudaq"
python3 -m venv --system-site-packages "$VENV_DIR"
. "$VENV_DIR/bin/activate"
pip install iqm-client==28.0.0
pip install . -vvv
pyinstall_status=$?
if [ ! $pyinstall_status -eq 0 ]; then
echo "::error file=test_in_devenv.yml:: Pip install of CUDA Quantum failed with status $pyinstall_status."
exit 1
fi
python -m pip install pytest
python -m pytest -v --durations=0 python/tests/ \
--ignore python/tests/backends
pytest_status=$?
if [ ! $pytest_status -eq 0 ]; then
echo "::error file=test_in_devenv.yml::Python tests failed with status $pytest_status."
exit 1
fi
for backendTest in python/tests/backends/*.py; do
python -m pytest -v --durations=0 $backendTest
pytest_status=$?
# Exit code 5 indicates that no tests were collected,
# i.e. all tests in this file were skipped.
if [ ! $pytest_status -eq 0 ] && [ ! $pytest_status -eq 5 ]; then
echo "::error file=test_in_devenv.yml::Python $backendTest tests failed with status $pytest_status."
exit 1
fi
done
- name: Save environment
id: env_save
if: inputs.export_environment
run: |
output_directory=/tmp
platform_id=`echo ${{ inputs.platform }} | sed 's/linux\///g' | tr -d ' '`
filename=${platform_id}_python_build
docker run --name dev_env dev_env:local
docker export dev_env > $output_directory/$filename.tar
docker rm -f dev_env
echo "filename=$filename" >> $GITHUB_OUTPUT
echo "output_directory=$output_directory" >> $GITHUB_OUTPUT
- name: Upload environment
uses: actions/upload-artifact@v4
if: inputs.export_environment
with:
name: ${{ steps.env_save.outputs.filename }}
path: ${{ steps.env_save.outputs.output_directory }}/${{ steps.env_save.outputs.filename }}.tar
retention-days: 1