Skip to content

Commit 8e85fce

Browse files
AmintorDuskoringo-but-quantumvincentmrmaliasadi
authored
Fix/lightning tests (#850)
Fixing Lightning tests in the Plugin-Test-Matrix **Context:** Tests were falling. After changes, they are passing: [stable/stable](https://github.com/PennyLaneAI/pennylane-lightning/actions/runs/10389962394) [stable/latest](https://github.com/PennyLaneAI/pennylane-lightning/actions/runs/10389965473) **Description of the Change:** **Benefits:** **Possible Drawbacks:** **Related GitHub Issues:** [sc-71386] --------- Co-authored-by: ringo-but-quantum <[email protected]> Co-authored-by: Vincent Michaud-Rioux <[email protected]> Co-authored-by: Ali Asadi <[email protected]>
1 parent c6b86a5 commit 8e85fce

8 files changed

+64
-65
lines changed

.github/CHANGELOG.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
### Breaking changes
1212

13-
* Add `getData()` in `lightning.tensor` C++ backend. Users should be responsible for ensuring sufficient host memory is allocated for the full state vector.
13+
* Add `getData()` in `lightning.tensor` C++ backend. Users should be responsible for ensuring sufficient host memory is allocated for the full state vector.
1414
[(#827)](https://github.com/PennyLaneAI/pennylane-lightning/pull/827)
1515

1616
* Remove `NDpermuter.hpp` which is no longer required.
@@ -92,6 +92,9 @@
9292

9393
### Bug fixes
9494

95+
* Fix plugin-test-matrix CI/CD workflows.
96+
[(#850)](https://github.com/PennyLaneAI/pennylane-lightning/pull/850)
97+
9598
* Set the `immutable` parameter value as `false` for the `cutensornetStateApplyTensorOperator` to allow the following `cutensornetStateUpdateTensorOperator` call.
9699
[(#845)](https://github.com/PennyLaneAI/pennylane-lightning/pull/845)
97100

.github/workflows/tests_lgpu_python.yml

+8-9
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,12 @@ jobs:
177177
run: |
178178
cd main
179179
rm -rf build
180-
PL_BACKEND=lightning_qubit python scripts/configure_pyproject_toml.py
181-
CMAKE_ARGS="-DENABLE_PYTHON=ON -DCMAKE_CXX_COMPILER=$(which g++-$GCC_VERSION)" \
182-
python -m pip install . -vv
180+
PL_BACKEND=lightning_qubit python scripts/configure_pyproject_toml.py || true
181+
PL_BACKEND=lightning_qubit SKIP_COMPILATION=True python -m pip install . -vv
183182
184183
rm -rf build
185-
PL_BACKEND=${{ matrix.pl_backend }} python scripts/configure_pyproject_toml.py
186-
CMAKE_ARGS="-DENABLE_PYTHON=ON -DCMAKE_CXX_COMPILER=$(which g++-$GCC_VERSION) -DPython_EXECUTABLE=${{ steps.python_path.outputs.python }}" \
184+
PL_BACKEND=${{ matrix.pl_backend }} python scripts/configure_pyproject_toml.py || true
185+
PL_BACKEND=${{ matrix.pl_backend }} CMAKE_ARGS="-DPython_EXECUTABLE=${{ steps.python_path.outputs.python }}" \
187186
python -m pip install . -vv
188187
189188
- name: Run PennyLane-Lightning-GPU unit tests
@@ -206,12 +205,12 @@ jobs:
206205
run: |
207206
cd main
208207
rm -rf build
209-
CMAKE_ARGS="-DPL_BACKEND=${{matrix.default_backend}} -DENABLE_PYTHON=ON -DCMAKE_CXX_COMPILER=$(which g++-$GCC_VERSION)" \
210-
python -m pip install . -vv
208+
PL_BACKEND=lightning_qubit python scripts/configure_pyproject_toml.py || true
209+
PL_BACKEND=lightning_qubit python -m pip install . -vv
211210
rm -rf build
212211
213-
CMAKE_ARGS="-DPL_BACKEND=${{ matrix.pl_backend }} -DENABLE_PYTHON=ON -DCMAKE_CXX_COMPILER=$(which g++-$GCC_VERSION)" \
214-
python -m pip install . -vv
212+
PL_BACKEND=${{ matrix.pl_backend }} python scripts/configure_pyproject_toml.py || true
213+
PL_BACKEND=${{ matrix.pl_backend }} python -m pip install . -vv
215214
216215
- name: Run PennyLane-Lightning unit tests for lightning.qubit with all devices installed
217216
if: ${{ matrix.pl_backend == 'all' }}

.github/workflows/tests_lgpumpi_python.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,14 @@ jobs:
105105
echo "pip=$pip_path" >> $GITHUB_OUTPUT
106106
107107
- name: Install required packages
108+
env:
109+
PL_BACKEND: lightning_qubit
108110
run: |
109111
source /etc/profile.d/modules.sh && module use /opt/modules/ && module load ${{ matrix.mpilib }}/cuda-${{ matrix.cuda_version_maj }}.${{ matrix.cuda_version_min }}
110112
python -m pip install -r requirements-dev.txt
111113
112114
python -m pip install custatevec-cu${{ matrix.cuda_version_maj }} mpi4py openfermionpyscf
113-
PL_BACKEND=lightning_qubit python scripts/configure_pyproject_toml.py
115+
python scripts/configure_pyproject_toml.py || true
114116
python -m pip install . -vv
115117
116118
- name: Checkout PennyLane for release build
@@ -131,9 +133,10 @@ jobs:
131133
- name: Build and install package
132134
env:
133135
CUQUANTUM_SDK: $(python -c "import site; print( f'{site.getsitepackages()[0]}/cuquantum')")
136+
PL_BACKEND: lightning_gpu
134137
run: |
135138
source /etc/profile.d/modules.sh && module use /opt/modules/ && module load ${{ matrix.mpilib }}/cuda-${{ matrix.cuda_version_maj }}.${{ matrix.cuda_version_min }}
136-
PL_BACKEND=lightning_gpu python scripts/configure_pyproject_toml.py
139+
python scripts/configure_pyproject_toml.py || true
137140
CMAKE_ARGS="-DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpicxx -DENABLE_MPI=ON -DCMAKE_CUDA_COMPILER=$(which nvcc) -DCMAKE_CUDA_ARCHITECTURES=${{ env.CI_CUDA_ARCH }} -DPython_EXECUTABLE=${{ steps.python_path.outputs.python }}" \
138141
python -m pip install . -vv
139142

.github/workflows/tests_lkcpu_python.yml

+17-19
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,16 @@ jobs:
6969
uses: actions/checkout@v4
7070
with:
7171
fetch-tags: true
72-
path: main
7372

7473
- name: Switch to release build of Lightning
7574
if: inputs.lightning-version == 'release'
7675
run: |
77-
cd main
7876
git fetch --all
7977
git checkout $(git branch -a --list "origin/v0.*rc*" | sort | tail -1)
8078
8179
- name: Switch to stable build of Lightning
8280
if: inputs.lightning-version == 'stable'
8381
run: |
84-
cd main
8582
git fetch --tags --force
8683
git checkout latest_release
8784
git log -1 --format='%H'
@@ -114,17 +111,25 @@ jobs:
114111
115112
- name: Get required Python packages
116113
run: |
117-
cd main
118114
python -m pip install -r requirements-dev.txt
119115
120-
- name: Configure and build device wheel
121-
env:
122-
PL_BACKEND: ${{ matrix.pl_backend }}
116+
# TODO: Update after Release 0.37
117+
- name: Create device wheel ${{ inputs.lightning-version }}
118+
if: inputs.lightning-version == 'stable'
119+
run: |
120+
PL_BACKEND=${{ matrix.pl_backend }} CMAKE_ARGS="-DCMAKE_PREFIX_PATH=${{ github.workspace }}/Kokkos" \
121+
python setup.py bdist_wheel
122+
cd dist
123+
WHEEL_NAME=$(ls *.whl)
124+
cp $WHEEL_NAME ${{ github.workspace }}/wheel_${{ matrix.pl_backend }}-${{ matrix.exec_model }}.whl
125+
echo $WHEEL_NAME > ${{ github.workspace }}/${{ matrix.pl_backend }}-${{ matrix.exec_model }}_name.txt
126+
127+
# TODO: Remove after Release 0.37
128+
- name: Create device wheel ${{ inputs.lightning-version }}
129+
if: inputs.lightning-version != 'stable'
123130
run: |
124-
cd main
125-
python scripts/configure_pyproject_toml.py
126-
CMAKE_ARGS="-DCMAKE_PREFIX_PATH=${{ github.workspace }}/Kokkos -DENABLE_PYTHON=ON -DCMAKE_CXX_COMPILER=$(which g++-$GCC_VERSION)" \
127-
python -m build
131+
PL_BACKEND=${{ matrix.pl_backend }} python scripts/configure_pyproject_toml.py
132+
CMAKE_ARGS="-DCMAKE_PREFIX_PATH=${{ github.workspace }}/Kokkos" python -m build
128133
cd dist
129134
WHEEL_NAME=$(ls *.whl)
130135
cp $WHEEL_NAME ${{ github.workspace }}/wheel_${{ matrix.pl_backend }}-${{ matrix.exec_model }}.whl
@@ -170,12 +175,10 @@ jobs:
170175
uses: actions/checkout@v4
171176
with:
172177
fetch-tags: true
173-
path: main
174178

175179
- name: Switch to release tag of Lightning
176180
if: inputs.lightning-version == 'release'
177181
run: |
178-
cd main
179182
git fetch --all
180183
git checkout $(git branch -a --list "origin/v0.*rc*" | sort | tail -1)
181184
@@ -187,7 +190,6 @@ jobs:
187190
- name: Switch to stable tag of Lightning
188191
if: inputs.lightning-version == 'stable'
189192
run: |
190-
cd main
191193
git fetch --tags --force
192194
git checkout latest_release
193195
git log -1 --format='%H'
@@ -208,7 +210,6 @@ jobs:
208210
run: |
209211
WHEEL_NAME=$(cat ${{ github.workspace }}/${{ matrix.pl_backend }}-${{ matrix.exec_model }}_name.txt)
210212
mv ${{ github.workspace }}/wheel_${{ matrix.pl_backend }}-${{ matrix.exec_model }}.whl ${{ github.workspace }}/$WHEEL_NAME
211-
cd main
212213
python -m pip install -r requirements-dev.txt
213214
python -m pip install openfermionpyscf
214215
if [ '${{ inputs.lightning-version }}' != 'stable' ]; then
@@ -235,7 +236,6 @@ jobs:
235236
- name: Install Stable PennyLane
236237
if: inputs.pennylane-version == 'stable'
237238
run: |
238-
cd main
239239
python -m pip uninstall -y pennylane && python -m pip install -U pennylane
240240
241241
- name: Install ML libraries for interfaces
@@ -246,7 +246,6 @@ jobs:
246246
247247
- name: Run PennyLane-Lightning unit tests
248248
run: |
249-
cd main/
250249
DEVICENAME=`echo ${{ matrix.pl_backend }} | sed "s/_/./g"`
251250
# Remove `python -m` to avoid running tests with relative modules
252251
PL_DEVICE=${DEVICENAME} pytest tests/ $COVERAGE_FLAGS --splits 7 --group ${{ matrix.group }} \
@@ -268,7 +267,7 @@ jobs:
268267
uses: actions/upload-artifact@v3
269268
with:
270269
name: ubuntu-codecov-results-python
271-
path: ./main/.coverage-${{ github.job }}-${{ matrix.pl_backend }}-${{ matrix.group }}
270+
path: ./.coverage-${{ github.job }}-${{ matrix.pl_backend }}-${{ matrix.group }}
272271
if-no-files-found: error
273272

274273
upload-to-codecov-linux-python:
@@ -280,7 +279,6 @@ jobs:
280279
uses: actions/checkout@v4
281280
with:
282281
fetch-tags: true
283-
path: main
284282

285283
- name: Download coverage reports
286284
uses: actions/download-artifact@v3

.github/workflows/tests_lkcuda_python.yml

+8-10
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,11 @@ jobs:
242242
ls -l ${{ github.workspace }}/Kokkos
243243
cd main
244244
245-
PL_BACKEND=lightning_qubit python scripts/configure_pyproject_toml.py
246-
SKIP_COMPILATION=True python -m pip install . -vv
245+
PL_BACKEND=lightning_qubit python scripts/configure_pyproject_toml.py || true
246+
PL_BACKEND=lightning_qubit SKIP_COMPILATION=True python -m pip install . -vv
247247
248-
PL_BACKEND=${{ matrix.pl_backend }} python scripts/configure_pyproject_toml.py
249-
CMAKE_ARGS="-DCMAKE_PREFIX_PATH=${{ github.workspace }}/Kokkos -DENABLE_PYTHON=ON -DCMAKE_CXX_COMPILER=$(which g++-$GCC_VERSION)" \
248+
PL_BACKEND=${{ matrix.pl_backend }} python scripts/configure_pyproject_toml.py || true
249+
PL_BACKEND=${{ matrix.pl_backend }} CMAKE_ARGS="-DCMAKE_PREFIX_PATH=${{ github.workspace }}/Kokkos" \
250250
python -m pip install . -vv
251251
252252
- name: Run PennyLane-Lightning unit tests
@@ -267,13 +267,11 @@ jobs:
267267
run: |
268268
cd main
269269
270-
PL_BACKEND=lightning_qubit python scripts/configure_pyproject_toml.py
271-
CMAKE_ARGS="-DENABLE_PYTHON=ON -DCMAKE_CXX_COMPILER=$(which g++-$GCC_VERSION)" \
272-
python -m pip install . -vv
270+
PL_BACKEND=lightning_qubit python scripts/configure_pyproject_toml.py || true
271+
PL_BACKEND=lightning_qubit python -m pip install . -vv
273272
274-
PL_BACKEND="lightning_kokkos" python scripts/configure_pyproject_toml.py
275-
CMAKE_ARGS="-DCMAKE_PREFIX_PATH=${{ github.workspace }}/Kokkos -DENABLE_PYTHON=ON -DCMAKE_CXX_COMPILER=$(which g++-$GCC_VERSION)" \
276-
python -m pip install . -vv
273+
PL_BACKEND="lightning_kokkos" python scripts/configure_pyproject_toml.py || true
274+
PL_BACKEND="lightning_kokkos" CMAKE_ARGS="-DCMAKE_PREFIX_PATH=${{ github.workspace }}/Kokkos" python -m pip install . -vv
277275
278276
- name: Run PennyLane-Lightning unit tests for lightning.qubit with all devices installed
279277
if: ${{ matrix.pl_backend == 'all' }}

.github/workflows/tests_lqcpu_python.yml

+16-16
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,16 @@ jobs:
5454
uses: actions/checkout@v4
5555
with:
5656
fetch-tags: true
57-
path: main
5857

5958
- name: Switch to release build of Lightning
6059
if: inputs.lightning-version == 'release'
6160
run: |
62-
cd main
6361
git fetch --all
6462
git checkout $(git branch -a --list "origin/v0.*rc*" | sort | tail -1)
6563
6664
- name: Switch to stable build of Lightning
6765
if: inputs.lightning-version == 'stable'
6866
run: |
69-
cd main
7067
git fetch --tags --force
7168
git checkout latest_release
7269
git log -1 --format='%H'
@@ -79,16 +76,25 @@ jobs:
7976
8077
- name: Get required Python packages
8178
run: |
82-
cd main
8379
python -m pip install -r requirements-dev.txt
8480
85-
- name: Create device wheel
86-
id: create_lq_wheel
81+
# TODO: Update after Release 0.37
82+
- name: Create device wheel ${{ inputs.lightning-version }}
83+
if: inputs.lightning-version != 'stable'
8784
run: |
88-
cd main
8985
PL_BACKEND=${{ matrix.pl_backend }} python scripts/configure_pyproject_toml.py
90-
CMAKE_ARGS="-DENABLE_BLAS=${{ matrix.blas }} -DLQ_ENABLE_KERNEL_OMP=ON -DENABLE_PYTHON=ON -DCMAKE_CXX_COMPILER=$(which g++-$GCC_VERSION)" \
91-
python -m build
86+
CMAKE_ARGS="-DENABLE_BLAS=${{ matrix.blas }} -DLQ_ENABLE_KERNEL_OMP=ON -DENABLE_PYTHON=ON" python -m build
87+
cd dist
88+
WHEEL_NAME=$(ls *.whl)
89+
cp $WHEEL_NAME ${{ github.workspace }}/wheel_${{ matrix.pl_backend }}-${{ matrix.blas }}.whl
90+
echo $WHEEL_NAME > ${{ github.workspace }}/${{ matrix.pl_backend }}-${{ matrix.blas }}_name.txt
91+
92+
# TODO: Remove after Release 0.37
93+
- name: Create device wheel (stable)
94+
if: inputs.lightning-version == 'stable'
95+
run: |
96+
PL_BACKEND=${{ matrix.pl_backend }} CMAKE_ARGS="-DENABLE_BLAS=${{ matrix.blas }} -DLQ_ENABLE_KERNEL_OMP=ON -DENABLE_PYTHON=ON" \
97+
python -m setup.py bdist_wheel
9298
cd dist
9399
WHEEL_NAME=$(ls *.whl)
94100
cp $WHEEL_NAME ${{ github.workspace }}/wheel_${{ matrix.pl_backend }}-${{ matrix.blas }}.whl
@@ -132,7 +138,6 @@ jobs:
132138
uses: actions/checkout@v4
133139
with:
134140
fetch-tags: true
135-
path: main
136141

137142
- uses: actions/download-artifact@v4
138143
with:
@@ -147,7 +152,6 @@ jobs:
147152
- name: Get required Python packages
148153
run: |
149154
WHEEL_NAME=$(cat ${{ github.workspace }}/${{ matrix.pl_backend }}-${{ matrix.blas }}_name.txt)
150-
cd main
151155
mv ${{ github.workspace }}/wheel_${{ matrix.pl_backend }}-${{ matrix.blas }}.whl ${{ github.workspace }}/$WHEEL_NAME
152156
python -m pip install -r requirements-dev.txt
153157
python -m pip install openfermionpyscf
@@ -172,7 +176,6 @@ jobs:
172176
- name: Install Stable PennyLane
173177
if: inputs.pennylane-version == 'stable'
174178
run: |
175-
cd main
176179
python -m pip uninstall -y pennylane && python -m pip install -U pennylane --no-deps
177180
178181
- name: Install ML libraries for interfaces
@@ -184,15 +187,13 @@ jobs:
184187
- name: Switch to stable tag of Lightning
185188
if: inputs.lightning-version == 'stable'
186189
run: |
187-
cd main
188190
git fetch --tags --force
189191
git checkout latest_release
190192
git log -1 --format='%H'
191193
git status
192194
193195
- name: Run PennyLane-Lightning unit tests
194196
run: |
195-
cd main/
196197
DEVICENAME=`echo ${{ matrix.pl_backend }} | sed "s/_/./g"`
197198
OMP_NUM_THREADS=1 PL_DEVICE=${DEVICENAME} python -m pytest -n auto tests/ -k "not unitary_correct" \
198199
$COVERAGE_FLAGS --splits 4 --group ${{ matrix.group }} \
@@ -207,7 +208,7 @@ jobs:
207208
with:
208209
name: ubuntu-codecov-results-python
209210
path: |
210-
./main/.coverage-${{ github.job }}-${{ matrix.pl_backend }}-${{ matrix.group }}
211+
./.coverage-${{ github.job }}-${{ matrix.pl_backend }}-${{ matrix.group }}
211212
if-no-files-found: error
212213

213214
upload-to-codecov-linux-python:
@@ -219,7 +220,6 @@ jobs:
219220
uses: actions/checkout@v4
220221
with:
221222
fetch-tags: true
222-
path: main
223223

224224
- name: Download coverage reports
225225
uses: actions/download-artifact@v3

.github/workflows/tests_without_binary.yml

+5-7
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
- name: Make disk space
4646
run: |
4747
for DIR in /usr/share/dotnet /usr/local/share/powershell /usr/share/swift; do
48-
sudo du -sh $DIR || echo $DIR not found
48+
sudo du -sh $DIR || echo $DIR not found
4949
sudo rm -rf $DIR
5050
done
5151
@@ -101,19 +101,17 @@ jobs:
101101
- name: Install the pennylane_lightning core package (lightning_qubit)
102102
env:
103103
SKIP_COMPILATION: True
104-
PL_BACKEND: "lightning_qubit"
105104
run: |
106-
python scripts/configure_pyproject_toml.py
107-
python -m pip install . -vv
105+
PL_BACKEND="lightning_qubit" python scripts/configure_pyproject_toml.py || true
106+
PL_BACKEND="lightning_qubit" python -m pip install . -vv
108107
109108
- name: Install extra backend device
110109
if: matrix.pl_backend != 'lightning_qubit'
111110
env:
112111
SKIP_COMPILATION: True
113-
PL_BACKEND: ${{ matrix.pl_backend }}
114112
run: |
115-
python scripts/configure_pyproject_toml.py
116-
python -m pip install . -vv
113+
PL_BACKEND=${{ matrix.pl_backend }} python scripts/configure_pyproject_toml.py || true
114+
PL_BACKEND=${{ matrix.pl_backend }} python -m pip install . -vv
117115
118116
- name: Run PennyLane-Lightning unit tests for all backends
119117
run: |

pennylane_lightning/core/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
Version number (major.minor.patch[-label])
1717
"""
1818

19-
__version__ = "0.38.0-dev32"
19+
__version__ = "0.38.0-dev33"

0 commit comments

Comments
 (0)