Skip to content

Commit

Permalink
Fix/lightning tests (#850)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
4 people authored Aug 14, 2024
1 parent c6b86a5 commit 8e85fce
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 65 deletions.
5 changes: 4 additions & 1 deletion .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

### Breaking changes

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

* Remove `NDpermuter.hpp` which is no longer required.
Expand Down Expand Up @@ -92,6 +92,9 @@

### Bug fixes

* Fix plugin-test-matrix CI/CD workflows.
[(#850)](https://github.com/PennyLaneAI/pennylane-lightning/pull/850)

* Set the `immutable` parameter value as `false` for the `cutensornetStateApplyTensorOperator` to allow the following `cutensornetStateUpdateTensorOperator` call.
[(#845)](https://github.com/PennyLaneAI/pennylane-lightning/pull/845)

Expand Down
17 changes: 8 additions & 9 deletions .github/workflows/tests_lgpu_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,12 @@ jobs:
run: |
cd main
rm -rf build
PL_BACKEND=lightning_qubit python scripts/configure_pyproject_toml.py
CMAKE_ARGS="-DENABLE_PYTHON=ON -DCMAKE_CXX_COMPILER=$(which g++-$GCC_VERSION)" \
python -m pip install . -vv
PL_BACKEND=lightning_qubit python scripts/configure_pyproject_toml.py || true
PL_BACKEND=lightning_qubit SKIP_COMPILATION=True python -m pip install . -vv
rm -rf build
PL_BACKEND=${{ matrix.pl_backend }} python scripts/configure_pyproject_toml.py
CMAKE_ARGS="-DENABLE_PYTHON=ON -DCMAKE_CXX_COMPILER=$(which g++-$GCC_VERSION) -DPython_EXECUTABLE=${{ steps.python_path.outputs.python }}" \
PL_BACKEND=${{ matrix.pl_backend }} python scripts/configure_pyproject_toml.py || true
PL_BACKEND=${{ matrix.pl_backend }} CMAKE_ARGS="-DPython_EXECUTABLE=${{ steps.python_path.outputs.python }}" \
python -m pip install . -vv
- name: Run PennyLane-Lightning-GPU unit tests
Expand All @@ -206,12 +205,12 @@ jobs:
run: |
cd main
rm -rf build
CMAKE_ARGS="-DPL_BACKEND=${{matrix.default_backend}} -DENABLE_PYTHON=ON -DCMAKE_CXX_COMPILER=$(which g++-$GCC_VERSION)" \
python -m pip install . -vv
PL_BACKEND=lightning_qubit python scripts/configure_pyproject_toml.py || true
PL_BACKEND=lightning_qubit python -m pip install . -vv
rm -rf build
CMAKE_ARGS="-DPL_BACKEND=${{ matrix.pl_backend }} -DENABLE_PYTHON=ON -DCMAKE_CXX_COMPILER=$(which g++-$GCC_VERSION)" \
python -m pip install . -vv
PL_BACKEND=${{ matrix.pl_backend }} python scripts/configure_pyproject_toml.py || true
PL_BACKEND=${{ matrix.pl_backend }} python -m pip install . -vv
- name: Run PennyLane-Lightning unit tests for lightning.qubit with all devices installed
if: ${{ matrix.pl_backend == 'all' }}
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/tests_lgpumpi_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,14 @@ jobs:
echo "pip=$pip_path" >> $GITHUB_OUTPUT
- name: Install required packages
env:
PL_BACKEND: lightning_qubit
run: |
source /etc/profile.d/modules.sh && module use /opt/modules/ && module load ${{ matrix.mpilib }}/cuda-${{ matrix.cuda_version_maj }}.${{ matrix.cuda_version_min }}
python -m pip install -r requirements-dev.txt
python -m pip install custatevec-cu${{ matrix.cuda_version_maj }} mpi4py openfermionpyscf
PL_BACKEND=lightning_qubit python scripts/configure_pyproject_toml.py
python scripts/configure_pyproject_toml.py || true
python -m pip install . -vv
- name: Checkout PennyLane for release build
Expand All @@ -131,9 +133,10 @@ jobs:
- name: Build and install package
env:
CUQUANTUM_SDK: $(python -c "import site; print( f'{site.getsitepackages()[0]}/cuquantum')")
PL_BACKEND: lightning_gpu
run: |
source /etc/profile.d/modules.sh && module use /opt/modules/ && module load ${{ matrix.mpilib }}/cuda-${{ matrix.cuda_version_maj }}.${{ matrix.cuda_version_min }}
PL_BACKEND=lightning_gpu python scripts/configure_pyproject_toml.py
python scripts/configure_pyproject_toml.py || true
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 }}" \
python -m pip install . -vv
Expand Down
36 changes: 17 additions & 19 deletions .github/workflows/tests_lkcpu_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,16 @@ jobs:
uses: actions/checkout@v4
with:
fetch-tags: true
path: main

- name: Switch to release build of Lightning
if: inputs.lightning-version == 'release'
run: |
cd main
git fetch --all
git checkout $(git branch -a --list "origin/v0.*rc*" | sort | tail -1)
- name: Switch to stable build of Lightning
if: inputs.lightning-version == 'stable'
run: |
cd main
git fetch --tags --force
git checkout latest_release
git log -1 --format='%H'
Expand Down Expand Up @@ -114,17 +111,25 @@ jobs:
- name: Get required Python packages
run: |
cd main
python -m pip install -r requirements-dev.txt
- name: Configure and build device wheel
env:
PL_BACKEND: ${{ matrix.pl_backend }}
# TODO: Update after Release 0.37
- name: Create device wheel ${{ inputs.lightning-version }}
if: inputs.lightning-version == 'stable'
run: |
PL_BACKEND=${{ matrix.pl_backend }} CMAKE_ARGS="-DCMAKE_PREFIX_PATH=${{ github.workspace }}/Kokkos" \
python setup.py bdist_wheel
cd dist
WHEEL_NAME=$(ls *.whl)
cp $WHEEL_NAME ${{ github.workspace }}/wheel_${{ matrix.pl_backend }}-${{ matrix.exec_model }}.whl
echo $WHEEL_NAME > ${{ github.workspace }}/${{ matrix.pl_backend }}-${{ matrix.exec_model }}_name.txt
# TODO: Remove after Release 0.37
- name: Create device wheel ${{ inputs.lightning-version }}
if: inputs.lightning-version != 'stable'
run: |
cd main
python scripts/configure_pyproject_toml.py
CMAKE_ARGS="-DCMAKE_PREFIX_PATH=${{ github.workspace }}/Kokkos -DENABLE_PYTHON=ON -DCMAKE_CXX_COMPILER=$(which g++-$GCC_VERSION)" \
python -m build
PL_BACKEND=${{ matrix.pl_backend }} python scripts/configure_pyproject_toml.py
CMAKE_ARGS="-DCMAKE_PREFIX_PATH=${{ github.workspace }}/Kokkos" python -m build
cd dist
WHEEL_NAME=$(ls *.whl)
cp $WHEEL_NAME ${{ github.workspace }}/wheel_${{ matrix.pl_backend }}-${{ matrix.exec_model }}.whl
Expand Down Expand Up @@ -170,12 +175,10 @@ jobs:
uses: actions/checkout@v4
with:
fetch-tags: true
path: main

- name: Switch to release tag of Lightning
if: inputs.lightning-version == 'release'
run: |
cd main
git fetch --all
git checkout $(git branch -a --list "origin/v0.*rc*" | sort | tail -1)
Expand All @@ -187,7 +190,6 @@ jobs:
- name: Switch to stable tag of Lightning
if: inputs.lightning-version == 'stable'
run: |
cd main
git fetch --tags --force
git checkout latest_release
git log -1 --format='%H'
Expand All @@ -208,7 +210,6 @@ jobs:
run: |
WHEEL_NAME=$(cat ${{ github.workspace }}/${{ matrix.pl_backend }}-${{ matrix.exec_model }}_name.txt)
mv ${{ github.workspace }}/wheel_${{ matrix.pl_backend }}-${{ matrix.exec_model }}.whl ${{ github.workspace }}/$WHEEL_NAME
cd main
python -m pip install -r requirements-dev.txt
python -m pip install openfermionpyscf
if [ '${{ inputs.lightning-version }}' != 'stable' ]; then
Expand All @@ -235,7 +236,6 @@ jobs:
- name: Install Stable PennyLane
if: inputs.pennylane-version == 'stable'
run: |
cd main
python -m pip uninstall -y pennylane && python -m pip install -U pennylane
- name: Install ML libraries for interfaces
Expand All @@ -246,7 +246,6 @@ jobs:
- name: Run PennyLane-Lightning unit tests
run: |
cd main/
DEVICENAME=`echo ${{ matrix.pl_backend }} | sed "s/_/./g"`
# Remove `python -m` to avoid running tests with relative modules
PL_DEVICE=${DEVICENAME} pytest tests/ $COVERAGE_FLAGS --splits 7 --group ${{ matrix.group }} \
Expand All @@ -268,7 +267,7 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: ubuntu-codecov-results-python
path: ./main/.coverage-${{ github.job }}-${{ matrix.pl_backend }}-${{ matrix.group }}
path: ./.coverage-${{ github.job }}-${{ matrix.pl_backend }}-${{ matrix.group }}
if-no-files-found: error

upload-to-codecov-linux-python:
Expand All @@ -280,7 +279,6 @@ jobs:
uses: actions/checkout@v4
with:
fetch-tags: true
path: main

- name: Download coverage reports
uses: actions/download-artifact@v3
Expand Down
18 changes: 8 additions & 10 deletions .github/workflows/tests_lkcuda_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,11 @@ jobs:
ls -l ${{ github.workspace }}/Kokkos
cd main
PL_BACKEND=lightning_qubit python scripts/configure_pyproject_toml.py
SKIP_COMPILATION=True python -m pip install . -vv
PL_BACKEND=lightning_qubit python scripts/configure_pyproject_toml.py || true
PL_BACKEND=lightning_qubit SKIP_COMPILATION=True python -m pip install . -vv
PL_BACKEND=${{ matrix.pl_backend }} python scripts/configure_pyproject_toml.py
CMAKE_ARGS="-DCMAKE_PREFIX_PATH=${{ github.workspace }}/Kokkos -DENABLE_PYTHON=ON -DCMAKE_CXX_COMPILER=$(which g++-$GCC_VERSION)" \
PL_BACKEND=${{ matrix.pl_backend }} python scripts/configure_pyproject_toml.py || true
PL_BACKEND=${{ matrix.pl_backend }} CMAKE_ARGS="-DCMAKE_PREFIX_PATH=${{ github.workspace }}/Kokkos" \
python -m pip install . -vv
- name: Run PennyLane-Lightning unit tests
Expand All @@ -267,13 +267,11 @@ jobs:
run: |
cd main
PL_BACKEND=lightning_qubit python scripts/configure_pyproject_toml.py
CMAKE_ARGS="-DENABLE_PYTHON=ON -DCMAKE_CXX_COMPILER=$(which g++-$GCC_VERSION)" \
python -m pip install . -vv
PL_BACKEND=lightning_qubit python scripts/configure_pyproject_toml.py || true
PL_BACKEND=lightning_qubit python -m pip install . -vv
PL_BACKEND="lightning_kokkos" python scripts/configure_pyproject_toml.py
CMAKE_ARGS="-DCMAKE_PREFIX_PATH=${{ github.workspace }}/Kokkos -DENABLE_PYTHON=ON -DCMAKE_CXX_COMPILER=$(which g++-$GCC_VERSION)" \
python -m pip install . -vv
PL_BACKEND="lightning_kokkos" python scripts/configure_pyproject_toml.py || true
PL_BACKEND="lightning_kokkos" CMAKE_ARGS="-DCMAKE_PREFIX_PATH=${{ github.workspace }}/Kokkos" python -m pip install . -vv
- name: Run PennyLane-Lightning unit tests for lightning.qubit with all devices installed
if: ${{ matrix.pl_backend == 'all' }}
Expand Down
32 changes: 16 additions & 16 deletions .github/workflows/tests_lqcpu_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,16 @@ jobs:
uses: actions/checkout@v4
with:
fetch-tags: true
path: main

- name: Switch to release build of Lightning
if: inputs.lightning-version == 'release'
run: |
cd main
git fetch --all
git checkout $(git branch -a --list "origin/v0.*rc*" | sort | tail -1)
- name: Switch to stable build of Lightning
if: inputs.lightning-version == 'stable'
run: |
cd main
git fetch --tags --force
git checkout latest_release
git log -1 --format='%H'
Expand All @@ -79,16 +76,25 @@ jobs:
- name: Get required Python packages
run: |
cd main
python -m pip install -r requirements-dev.txt
- name: Create device wheel
id: create_lq_wheel
# TODO: Update after Release 0.37
- name: Create device wheel ${{ inputs.lightning-version }}
if: inputs.lightning-version != 'stable'
run: |
cd main
PL_BACKEND=${{ matrix.pl_backend }} python scripts/configure_pyproject_toml.py
CMAKE_ARGS="-DENABLE_BLAS=${{ matrix.blas }} -DLQ_ENABLE_KERNEL_OMP=ON -DENABLE_PYTHON=ON -DCMAKE_CXX_COMPILER=$(which g++-$GCC_VERSION)" \
python -m build
CMAKE_ARGS="-DENABLE_BLAS=${{ matrix.blas }} -DLQ_ENABLE_KERNEL_OMP=ON -DENABLE_PYTHON=ON" python -m build
cd dist
WHEEL_NAME=$(ls *.whl)
cp $WHEEL_NAME ${{ github.workspace }}/wheel_${{ matrix.pl_backend }}-${{ matrix.blas }}.whl
echo $WHEEL_NAME > ${{ github.workspace }}/${{ matrix.pl_backend }}-${{ matrix.blas }}_name.txt
# TODO: Remove after Release 0.37
- name: Create device wheel (stable)
if: inputs.lightning-version == 'stable'
run: |
PL_BACKEND=${{ matrix.pl_backend }} CMAKE_ARGS="-DENABLE_BLAS=${{ matrix.blas }} -DLQ_ENABLE_KERNEL_OMP=ON -DENABLE_PYTHON=ON" \
python -m setup.py bdist_wheel
cd dist
WHEEL_NAME=$(ls *.whl)
cp $WHEEL_NAME ${{ github.workspace }}/wheel_${{ matrix.pl_backend }}-${{ matrix.blas }}.whl
Expand Down Expand Up @@ -132,7 +138,6 @@ jobs:
uses: actions/checkout@v4
with:
fetch-tags: true
path: main

- uses: actions/download-artifact@v4
with:
Expand All @@ -147,7 +152,6 @@ jobs:
- name: Get required Python packages
run: |
WHEEL_NAME=$(cat ${{ github.workspace }}/${{ matrix.pl_backend }}-${{ matrix.blas }}_name.txt)
cd main
mv ${{ github.workspace }}/wheel_${{ matrix.pl_backend }}-${{ matrix.blas }}.whl ${{ github.workspace }}/$WHEEL_NAME
python -m pip install -r requirements-dev.txt
python -m pip install openfermionpyscf
Expand All @@ -172,7 +176,6 @@ jobs:
- name: Install Stable PennyLane
if: inputs.pennylane-version == 'stable'
run: |
cd main
python -m pip uninstall -y pennylane && python -m pip install -U pennylane --no-deps
- name: Install ML libraries for interfaces
Expand All @@ -184,15 +187,13 @@ jobs:
- name: Switch to stable tag of Lightning
if: inputs.lightning-version == 'stable'
run: |
cd main
git fetch --tags --force
git checkout latest_release
git log -1 --format='%H'
git status
- name: Run PennyLane-Lightning unit tests
run: |
cd main/
DEVICENAME=`echo ${{ matrix.pl_backend }} | sed "s/_/./g"`
OMP_NUM_THREADS=1 PL_DEVICE=${DEVICENAME} python -m pytest -n auto tests/ -k "not unitary_correct" \
$COVERAGE_FLAGS --splits 4 --group ${{ matrix.group }} \
Expand All @@ -207,7 +208,7 @@ jobs:
with:
name: ubuntu-codecov-results-python
path: |
./main/.coverage-${{ github.job }}-${{ matrix.pl_backend }}-${{ matrix.group }}
./.coverage-${{ github.job }}-${{ matrix.pl_backend }}-${{ matrix.group }}
if-no-files-found: error

upload-to-codecov-linux-python:
Expand All @@ -219,7 +220,6 @@ jobs:
uses: actions/checkout@v4
with:
fetch-tags: true
path: main

- name: Download coverage reports
uses: actions/download-artifact@v3
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/tests_without_binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- name: Make disk space
run: |
for DIR in /usr/share/dotnet /usr/local/share/powershell /usr/share/swift; do
sudo du -sh $DIR || echo $DIR not found
sudo du -sh $DIR || echo $DIR not found
sudo rm -rf $DIR
done
Expand Down Expand Up @@ -101,19 +101,17 @@ jobs:
- name: Install the pennylane_lightning core package (lightning_qubit)
env:
SKIP_COMPILATION: True
PL_BACKEND: "lightning_qubit"
run: |
python scripts/configure_pyproject_toml.py
python -m pip install . -vv
PL_BACKEND="lightning_qubit" python scripts/configure_pyproject_toml.py || true
PL_BACKEND="lightning_qubit" python -m pip install . -vv
- name: Install extra backend device
if: matrix.pl_backend != 'lightning_qubit'
env:
SKIP_COMPILATION: True
PL_BACKEND: ${{ matrix.pl_backend }}
run: |
python scripts/configure_pyproject_toml.py
python -m pip install . -vv
PL_BACKEND=${{ matrix.pl_backend }} python scripts/configure_pyproject_toml.py || true
PL_BACKEND=${{ matrix.pl_backend }} python -m pip install . -vv
- name: Run PennyLane-Lightning unit tests for all backends
run: |
Expand Down
2 changes: 1 addition & 1 deletion pennylane_lightning/core/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
Version number (major.minor.patch[-label])
"""

__version__ = "0.38.0-dev32"
__version__ = "0.38.0-dev33"

0 comments on commit 8e85fce

Please sign in to comment.