-
Notifications
You must be signed in to change notification settings - Fork 184
255 lines (244 loc) · 11.2 KB
/
integration_tests.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
name: Nightly integration tests
# Run on request and every day at 3 AM UTC
on:
workflow_dispatch:
inputs:
target:
description: 'Target (choose nightly to run like nightly tests)'
required: true
default: 'nightly'
type: choice
options:
- nightly
- ionq
- iqm
- oqc
- quantinuum
single_test_name:
type: string
required: false
description: 'Single test (e.g., targettests/quantinuum/load_value.cpp). Runs default tests if left blank'
target_machine:
type: string
required: false
description: 'Target machine (e.g., H1-1E).'
schedule:
- cron: 0 3 * * *
jobs:
integration_test:
name: Integration test
runs-on: ubuntu-latest
environment: backend-validation
container:
image: nvcr.io/nvidia/nightly/cuda-quantum:latest
options: --user root
steps:
- name: Get commit SHA
id: commit-sha
run: |
echo "sha=$(cat $CUDA_QUANTUM_PATH/assets/build_info | grep -o 'source-sha: \S*' | cut -d ' ' -f 2)" >> $GITHUB_OUTPUT
- name: Get code
uses: actions/checkout@v3
with:
ref: ${{ steps.commit-sha.outputs.sha }}
fetch-depth: 1
- name: Get tests
id: gettests
run: |
if [ -n "${{ inputs.single_test_name }}" ]; then
if [ -e ${{ inputs.single_test_name }} ]; then
echo "testlist=${{ inputs.single_test_name }}" >> $GITHUB_OUTPUT
else
# User's request test does not exit
echo "::error::File ${{ inputs.single_test_name}} not found"
exit 1
fi
else
filelist="targettests/*/*.cpp"
echo "testlist=$filelist" >> $GITHUB_OUTPUT
fi
- name: Setup quantinum account
if: github.event_name == 'schedule' || inputs.target == 'nightly' || inputs.target == 'quantinuum'
run: |
curl -X POST -H "Content Type: application/json" -d '{ "email":"${{ secrets.BACKEND_LOGIN_EMAIL }}","password":"${{ secrets.QUANTINUUM_PASSWORD }}" }' https://qapi.quantinuum.com/v1/login > credentials.json
id_token=`cat credentials.json | jq -r '."id-token"'`
refresh_token=`cat credentials.json | jq -r '."refresh-token"'`
echo "key: $id_token" > ~/.quantinuum_config
echo "refresh: $refresh_token" >> ~/.quantinuum_config
- name: QIR syntax check (Quantinuum)
if: github.event_name == 'schedule' || inputs.target == 'nightly'
run: |
echo "### QIR syntax check (Quantinuum)" >> $GITHUB_STEP_SUMMARY
export CUDAQ_LOG_LEVEL="info"
set +e # Allow script to keep going through errors
test_err_sum=0
for filename in ${{ steps.gettests.outputs.testlist }}; do
case $filename in
targettests/quantinuum/*)
[ -e "$filename" ] || echo "::error::Couldn't find files ($filename)"
nvq++ -v $filename -DSYNTAX_CHECK --target quantinuum --quantinuum-machine H1-1SC
test_status=$?
if [ $test_status -eq 0 ]; then
./a.out
test_status=$?
if [ $test_status -eq 0 ]; then
echo ":white_check_mark: Successfully ran test: $filename" >> $GITHUB_STEP_SUMMARY
else
echo ":x: Test failed (failed to execute): $filename" >> $GITHUB_STEP_SUMMARY
test_err_sum=$((test_err_sum+1))
fi
else
echo ":x: Test failed (failed to compile): $filename" >> $GITHUB_STEP_SUMMARY
test_err_sum=$((test_err_sum+1))
fi
;;
esac
done
set -e # Re-enable exit code error checking
if [ ! $test_err_sum -eq 0 ]; then
echo "::error::${test_err_sum} tests failed. See step summary for a list of failures"
exit 1
fi
shell: bash
- name: Submit to IonQ Simulator
if: (success() || failure()) && (inputs.target == 'ionq' || github.event_name == 'schedule' || inputs.target == 'nightly')
run: |
echo "### Submit to IonQ Simulator" >> $GITHUB_STEP_SUMMARY
export IONQ_API_KEY="${{ secrets.IONQ_API_KEY }}"
# TODO: remove this flag once https://github.com/NVIDIA/cuda-quantum/issues/512 is addressed.
export CUDAQ_LOG_LEVEL="info"
set +e # Allow script to keep going through errors
test_err_sum=0
for filename in ${{ steps.gettests.outputs.testlist }}; do
case $filename in
targettests/ionq/*)
[ -e "$filename" ] || echo "::error::Couldn't find files ($filename)"
nvq++ -v $filename --target ionq
test_status=$?
if [ $test_status -eq 0 ]; then
./a.out
test_status=$?
if [ $test_status -eq 0 ]; then
echo ":white_check_mark: Successfully ran test: $filename" >> $GITHUB_STEP_SUMMARY
else
echo ":x: Test failed (failed to execute): $filename" >> $GITHUB_STEP_SUMMARY
test_err_sum=$((test_err_sum+1))
fi
else
echo ":x: Test failed (failed to compile): $filename" >> $GITHUB_STEP_SUMMARY
test_err_sum=$((test_err_sum+1))
fi
;;
esac
done
set -e # Re-enable exit code error checking
if [ ! $test_err_sum -eq 0 ]; then
echo "::error::${test_err_sum} tests failed. See step summary for a list of failures"
exit 1
fi
shell: bash
- name: Submit to IQM Demo server
if: (success() || failure()) && (inputs.target == 'iqm' || github.event_name == 'schedule' || inputs.target == 'nightly')
run: |
# Must install iqm-cortex-cli to authenticate
pip install iqm-cortex-cli
echo "### Submit to IQM Demo server" >> $GITHUB_STEP_SUMMARY
# IQM demo server info is from: https://demo.qc.iqm.fi/cocos/info/
cortex init --config-file ${HOME}/.config/iqm-cortex-cli/config.json --tokens-file ${HOME}/.cache/iqm-cortex-cli/tokens.json --auth-server-url https://demo.qc.iqm.fi/auth --client-id iqm_client --realm cortex --username '${{ secrets.IQM_USER }}'
cortex auth login --username '${{ secrets.IQM_USER }}' --password '${{ secrets.IQM_PASSWORD }}'
echo ":white_check_mark: Successfully installed iqm-cortex-cli and logged in" >> $GITHUB_STEP_SUMMARY
# Use the demo machine, which is Adonis architecture
export IQM_SERVER_URL="https://demo.qc.iqm.fi/cocos"
export CUDAQ_LOG_LEVEL="info"
set +e # Allow script to keep going through errors
test_err_sum=0
for filename in ${{ steps.gettests.outputs.testlist }}; do
[ -e "$filename" ] || echo "::error::Couldn't find files ($filename)"
# Only the following tests are currently supported on IQM
case $filename in
targettests/iqm/*)
nvq++ -DSYNTAX_CHECK --target iqm --iqm-machine Adonis $filename
test_status=$?
if [ $test_status -eq 0 ]; then
./a.out
test_status=$?
if [ $test_status -eq 0 ]; then
echo ":white_check_mark: Successfully ran test: $filename" >> $GITHUB_STEP_SUMMARY
else
echo ":x: Test failed (failed to execute): $filename" >> $GITHUB_STEP_SUMMARY
test_err_sum=$((test_err_sum+1))
fi
else
echo ":x: Test failed (failed to compile): $filename" >> $GITHUB_STEP_SUMMARY
test_err_sum=$((test_err_sum+1))
fi
;;
esac
done
set -e # Re-enable exit code error checking
cortex auth logout -f
echo ":white_check_mark: Successfully logged out of IQM" >> $GITHUB_STEP_SUMMARY
if [ ! $test_err_sum -eq 0 ]; then
echo "::error::${test_err_sum} tests failed. See step summary for a list of failures"
exit 1
fi
shell: bash
- name: Submit to OQC Sandbox server
if: (success() || failure()) && (inputs.target == 'oqc' || github.event_name == 'schedule' || inputs.target == 'nightly')
run: |
echo "### Submit to OQC sandbox server" >> $GITHUB_STEP_SUMMARY
export CUDAQ_LOG_LEVEL="info"
export OQC_EMAIL="${{ secrets.BACKEND_LOGIN_EMAIL }}"
export OQC_PASSWORD="${{ secrets.OQC_PASSWORD }}"
set +e # Allow script to keep going through errors
test_err_sum=0
for filename in ${{ steps.gettests.outputs.testlist }}; do
[ -e "$filename" ] || echo "::error::Couldn't find files ($filename)"
# Only the following tests are currently supported on OQC
case $filename in
targettests/oqc/*)
nvq++ -DSYNTAX_CHECK --target oqc $filename
test_status=$?
if [ $test_status -eq 0 ]; then
./a.out
test_status=$?
if [ $test_status -eq 0 ]; then
echo ":white_check_mark: Successfully ran test: $filename" >> $GITHUB_STEP_SUMMARY
else
echo ":x: Test failed (failed to execute): $filename" >> $GITHUB_STEP_SUMMARY
test_err_sum=$((test_err_sum+1))
fi
else
echo ":x: Test failed (failed to compile): $filename" >> $GITHUB_STEP_SUMMARY
test_err_sum=$((test_err_sum+1))
fi
;;
esac
done
set -e # Re-enable exit code error checking
if [ ! $test_err_sum -eq 0 ]; then
echo "::error::${test_err_sum} tests failed. See step summary for a list of failures"
exit 1
fi
shell: bash
- name: Submit to ${{ inputs.target }}
# The full set of tests used by this step is currently only supported on
# Quantinuum. The other supported tests are tested by the step above.
# The main point of this special step is to run with a special
# target_machine. It also doesn't use -DSYNTAX_CHECK, so you probably
# don't want to run this on a simple Syntax Check machine.
if: inputs.target == 'quantinuum' && github.event_name == 'workflow_dispatch'
run: |
if ${{inputs.target == 'ionq'}}; then
export IONQ_API_KEY="${{ secrets.IONQ_API_KEY }}"
fi
for filename in ${{ steps.gettests.outputs.testlist }}; do
[ -e "$filename" ] || echo "::error::Couldn't find files ($filename)"
case $filename in
targettests/quantinuum/*)
nvq++ -v $filename --target ${{ inputs.target }} --${{ inputs.target }}-machine ${{ inputs.target_machine }}
CUDAQ_LOG_LEVEL=info ./a.out
;;
esac
done
shell: bash