1
+ name : Tests::Linux::x86_64::LGPU::MPI
2
+ on :
3
+ workflow_call :
4
+ inputs :
5
+ lightning-version :
6
+ type : string
7
+ required : true
8
+ description : The version of lightning to use. Valid values are either 'stable' (most recent git-tag) or 'latest' (most recent commit from master)
9
+ pennylane-version :
10
+ type : string
11
+ required : true
12
+ description : The version of PennyLane to use. Valid values are either 'stable' (most recent git-tag) or 'latest' (most recent commit from master)
13
+ release :
14
+ push :
15
+ branches :
16
+ - main
17
+ pull_request :
18
+
19
+ env :
20
+ COVERAGE_FLAGS : " --cov=pennylane_lightning --cov-report=term-missing --cov-report=xml:./coverage.xml --no-flaky-report -p no:warnings --tb=native"
21
+ GCC_VERSION : 11
22
+ OMP_NUM_THREADS : " 2"
23
+ CI_CUDA_ARCH : 86
24
+
25
+ concurrency :
26
+ group : gpu-test-mpi-${{ github.ref }}-${{ inputs.lightning-version }}-${{ inputs.pennylane-version }}
27
+ cancel-in-progress : true
28
+
29
+ jobs :
30
+ cpp_tests :
31
+ if : contains(github.event.pull_request.labels.*.name, 'ci:use-multi-gpu-runner') || (inputs.lightning-version != '' && inputs.pennylane-version != '')
32
+ runs-on :
33
+ - self-hosted
34
+ - linux
35
+ - x64
36
+ - ubuntu-22.04
37
+ - multi-gpu
38
+ strategy :
39
+ max-parallel : 1
40
+ matrix :
41
+ mpilib : ["mpich", "openmpi"]
42
+ timeout-minutes : 30
43
+
44
+ steps :
45
+ - name : Checkout
46
+ uses : actions/checkout@v3
47
+ with :
48
+ fetch-tags : true
49
+
50
+ - name : Switch to stable build of Lightning-GPU
51
+ if : inputs.lightning-version == 'stable'
52
+ run : |
53
+ git fetch tags --force
54
+ git checkout $(git tag | sort -V | tail -1)
55
+ - uses : actions/setup-python@v4
56
+ id : setup_python
57
+ name : Install Python
58
+ with :
59
+ python-version : ' 3.9'
60
+
61
+ # Since the self-hosted runner can be re-used. It is best to set up all package
62
+ # installations in a virtual environment that gets cleaned at the end of each workflow run
63
+ - name : Setup Python virtual environment
64
+ id : setup_venv
65
+ env :
66
+ VENV_NAME : ${{ github.workspace }}/venv_${{ steps.setup_python.outputs.python-version }}_${{ github.sha }}
67
+ run : |
68
+ # Clear any pre-existing venvs
69
+ rm -rf venv_*
70
+
71
+ # Create new venv for this workflow_run
72
+ python --version
73
+ python -m venv ${{ env.VENV_NAME }}
74
+
75
+ # Add the venv to PATH for subsequent steps
76
+ echo ${{ env.VENV_NAME }}/bin >> $GITHUB_PATH
77
+
78
+ # Adding venv name as an output for subsequent steps to reference if needed
79
+ echo "venv_name=${{ env.VENV_NAME }}" >> $GITHUB_OUTPUT
80
+
81
+ - name : Display Python-Path
82
+ id : python_path
83
+ run : |
84
+ py_path=$(which python)
85
+ echo "Python Interpreter Path => $py_path"
86
+ echo "python=$py_path" >> $GITHUB_OUTPUT
87
+
88
+ pip_path=$(which python)
89
+ echo "PIP Path => $pip_path"
90
+ echo "pip=$pip_path" >> $GITHUB_OUTPUT
91
+
92
+ - name : Install required packages
93
+ run : |
94
+ python -m pip install ninja cmake custatevec-cu11
95
+
96
+ - name : Validate GPU version and installed compiler
97
+ run : |
98
+ source /etc/profile.d/modules.sh && module use /opt/modules && module load cuda/11.8
99
+ which -a nvcc
100
+ nvcc --version
101
+ - name : Validate Multi-GPU packages
102
+ run : |
103
+ source /etc/profile.d/modules.sh && module use /opt/modules/ && module load ${{ matrix.mpilib }}
104
+ echo 'Checking for ${{ matrix.mpilib }}'
105
+ which -a mpirun
106
+ mpirun --version
107
+ which -a mpicxx
108
+ mpicxx --version
109
+ module unload ${{ matrix.mpilib }}
110
+ - name : Install Latest PennyLane
111
+ if : inputs.pennylane-version == 'latest'
112
+ run : python -m pip install git+https://github.com/PennyLaneAI/pennylane.git@master
113
+
114
+ - name : Build and run unit tests
115
+ run : |
116
+ source /etc/profile.d/modules.sh && module use /opt/modules/ && module load ${{ matrix.mpilib }}
117
+ export CUQUANTUM_SDK=$(python -c "import site; print( f'{site.getsitepackages()[0]}/cuquantum/lib')")
118
+ cmake . -BBuild \
119
+ -DPL_BACKEND=lightning_gpu \
120
+ -DENABLE_MPI=ON \
121
+ -DCMAKE_BUILD_TYPE=Debug \
122
+ -DENABLE_COVERAGE=ON \
123
+ -DBUILD_TESTS=ON \
124
+ -DCMAKE_CXX_COMPILER=mpicxx \
125
+ -DCMAKE_CUDA_COMPILER="/usr/local/cuda/bin/nvcc" \
126
+ -DCMAKE_CUDA_ARCHITECTURES="86" \
127
+ -DPython_EXECUTABLE:FILE="${{ steps.python_path.outputs.python }}" \
128
+ -G Ninja
129
+ cmake --build ./Build
130
+ cd ./Build
131
+ mkdir -p ./tests/results
132
+ for file in *runner ; do ./$file --order lex --reporter junit --out ./tests/results/report_$file.xml; done;
133
+ for file in *runner_mpi ; do /opt/mpi/${{ matrix.mpilib }}/bin/mpirun -np 2 ./$file --order lex --reporter junit --out ./tests/results/report_$file.xml; done;
134
+ lcov --directory . -b ../pennylane_lightning/src --capture --output-file coverage.info
135
+ lcov --remove coverage.info '/usr/*' --output-file coverage.info
136
+ mv coverage.info coverage-${{ github.job }}-lightning_gpu_${{ matrix.mpilib }}.info
137
+
138
+ - name : Upload test results
139
+ uses : actions/upload-artifact@v3
140
+ if : always()
141
+ with :
142
+ if-no-files-found : error
143
+ name : ubuntu-tests-reports
144
+ path : ./Build/tests/results/
145
+
146
+ - name : Upload code coverage results
147
+ uses : actions/upload-artifact@v3
148
+ with :
149
+ if-no-files-found : error
150
+ name : ubuntu-codecov-results-cpp
151
+ path : ./Build/coverage-${{ github.job }}-lightning_gpu_${{ matrix.mpilib }}.info
152
+
153
+ - name : Cleanup
154
+ if : always()
155
+ run : |
156
+ rm -rf ${{ steps.setup_venv.outputs.venv_name }}
157
+ rm -rf * .git .gitignore .github
158
+ pip cache purge
159
+
160
+ upload-to-codecov-linux-cpp :
161
+ needs : ["cpp_tests"]
162
+ name : Upload coverage data to codecov
163
+ runs-on : ubuntu-latest
164
+ steps :
165
+ - name : Checkout
166
+ uses : actions/checkout@v3
167
+
168
+ - name : Download coverage reports
169
+ uses : actions/download-artifact@v3
170
+ with :
171
+ name : ubuntu-codecov-results-cpp
172
+
173
+ - name : Upload to Codecov
174
+ uses : codecov/codecov-action@v3
175
+ with :
176
+ fail_ci_if_error : true
177
+ verbose : true
178
+ token : ${{ secrets.CODECOV_TOKEN }}
179
+
180
+ - name : Cleanup
181
+ if : always()
182
+ run : |
183
+ rm -rf ${{ steps.setup_venv.outputs.venv_name }}
184
+ rm -rf * .git .gitignore .github
185
+ pip cache purge
0 commit comments