Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove CPhase + Tidy up src #717

Merged
merged 20 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@

### Improvements

* Update C++ and Python GitHub actions names to include the matrix info.
[(#717)](https://github.com/PennyLaneAI/pennylane-lightning/pull/717)

* Remove `CPhase` in favour of `CPhaseShift` in Lightning devices.
[(#717)](https://github.com/PennyLaneAI/pennylane-lightning/pull/717)

* The various OpenMP configurations of Lightning-Qubit are tested in parallel on different Github Actions runners.
[(#712)](https://github.com/PennyLaneAI/pennylane-lightning/pull/712)

* Update Linux wheels to use manylinux_2_28 images.
* Update Linux wheels to use `manylinux_2_28` images.
[(#667)](https://github.com/PennyLaneAI/pennylane-lightning/pull/667)

* Add support for `qml.expval` and `qml.var` in the `lightning.tensor` device for the `quimb` interface and the MPS method.
Expand All @@ -23,7 +29,7 @@

This release contains contributions from (in alphabetical order):

Amintor Dusko, Pietropaolo Frisoni, Vincent Michaud-Rioux
Ali Asadi, Amintor Dusko, Pietropaolo Frisoni, Vincent Michaud-Rioux

---

Expand Down
34 changes: 23 additions & 11 deletions .github/workflows/dev_version_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import re
import argparse
import re
from pathlib import Path

try:
from semver import Version
except ImportError as exc:
raise ImportError("Unable to import semver. Install semver by running `pip install semver`") from exc
raise ImportError(
"Unable to import semver. Install semver by running `pip install semver`"
) from exc

DEV_PRERELEASE_TAG_PREFIX = "dev"
DEV_PRERELEASE_TAG_START = "dev0"
Expand All @@ -45,10 +47,14 @@ def extract_version(repo_root_path: Path) -> Version:
if line.startswith("__version__"):
if (m := rgx_ver.match(line.strip())) is not None:
if not m.groups():
raise ValueError(f"Unable to find valid semver for __version__. Got: '{line}'")
raise ValueError(
f"Unable to find valid semver for __version__. Got: '{line}'"
)
parsed_semver = m.group(1)
if not Version.is_valid(parsed_semver):
raise ValueError(f"Invalid semver for __version__. Got: '{parsed_semver}' from line '{line}'")
raise ValueError(
f"Invalid semver for __version__. Got: '{parsed_semver}' from line '{line}'"
)
return Version.parse(parsed_semver)
raise ValueError(f"Unable to find valid semver for __version__. Got: '{line}'")
raise ValueError("Cannot parse version")
Expand All @@ -67,10 +73,7 @@ def update_prerelease_version(repo_root_path: Path, version: Version):
raise FileNotFoundError(f"Unable to find version file at location {version_file_path}")

with version_file_path.open() as f:
lines = [
rgx_ver.sub(f"__version__ = \"{str(version)}\"", line)
for line in f
]
lines = [rgx_ver.sub(f'__version__ = "{str(version)}"', line) for line in f]

with version_file_path.open("w") as f:
f.write("".join(lines))
Expand Down Expand Up @@ -98,8 +101,14 @@ def update_prerelease_version(repo_root_path: Path, version: Version):
# If a PR is of a higher version AND the prerelease tag is reset, then do nothing
# This captures the case during release where we might bump the release version
# within a PR and reset tag back to dev0
if pr_version > master_version and pr_version.prerelease and pr_version.prerelease == DEV_PRERELEASE_TAG_START:
print("This Pull Request is upgrading the package version to next release ... skipping bumping!")
if (
pr_version > master_version
and pr_version.prerelease
and pr_version.prerelease == DEV_PRERELEASE_TAG_START
):
print(
"This Pull Request is upgrading the package version to next release ... skipping bumping!"
)
print("If this is happening in error, please report it to the PennyLane team!")
elif pr_version.prerelease and pr_version.prerelease.startswith(DEV_PRERELEASE_TAG_PREFIX):
# If master branch does not have a prerelease (for any reason) OR does not have an ending number
Expand All @@ -109,7 +118,10 @@ def update_prerelease_version(repo_root_path: Path, version: Version):
else:
# If master branch does not have a prerelease (for any reason) OR does not have an ending number
# Then default to the starting tag
if not master_version.prerelease or master_version.prerelease == DEV_PRERELEASE_TAG_PREFIX:
if (
not master_version.prerelease
or master_version.prerelease == DEV_PRERELEASE_TAG_PREFIX
):
next_prerelease_version = DEV_PRERELEASE_TAG_START
else:
# Generate the next prerelease version (eg: dev1 -> dev2). Sourcing from master version.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests_lgpu_cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
pl_backend: ["lightning_gpu"]
cuda_version: ["12"]

name: C++ tests (Lightning-GPU)
name: C++ Tests (${{ matrix.pl_backend }}, cuda-${{ matrix.cuda_version }})
runs-on:
- ubuntu-22.04
- self-hosted
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/tests_lgpu_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
default_backend: ["lightning_qubit"]
cuda_version: ["12"]

name: Python tests with LGPU
name: Python Tests (${{ matrix.pl_backend }}, cuda-${{ matrix.cuda_version }})
runs-on:
- ubuntu-22.04
- self-hosted
Expand Down Expand Up @@ -132,7 +132,7 @@ jobs:
py_path=$(which python)
echo "Python Interpreter Path => $py_path"
echo "python=$py_path" >> $GITHUB_OUTPUT

pip_path=$(which python)
echo "PIP Path => $pip_path"
echo "pip=$pip_path" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -165,7 +165,7 @@ jobs:
python -m pip uninstall -y pennylane && python -m pip install -U pennylane

- name: Build and install package
env:
env:
CUQUANTUM_SDK: $(python -c "import site; print( f'{site.getsitepackages()[0]}/cuquantum')")
run: |
cd main
Expand All @@ -180,34 +180,34 @@ jobs:

- name: Run PennyLane-Lightning-GPU unit tests
if: ${{ matrix.pl_backend != 'all'}}
env:
env:
OMP_NUM_THREADS: 1
OMP_PROC_BIND: false
run: |
cd main/
DEVICENAME=`echo ${{ matrix.pl_backend }} | sed "s/_/./g"`
pl-device-test --device ${DEVICENAME} --skip-ops --shots=20000 $COVERAGE_FLAGS --cov-append
pl-device-test --device ${DEVICENAME} --skip-ops --shots=20000 $COVERAGE_FLAGS --cov-append
pl-device-test --device ${DEVICENAME} --shots=None --skip-ops $COVERAGE_FLAGS --cov-append
PL_DEVICE=${DEVICENAME} python -m pytest tests/ $COVERAGE_FLAGS
PL_DEVICE=${DEVICENAME} python -m pytest tests/ $COVERAGE_FLAGS
mv coverage.xml coverage-${{ github.job }}-${{ matrix.pl_backend }}.xml

- name: Install all backend devices
if: ${{ matrix.pl_backend == 'all' }}
env:
env:
CUQUANTUM_SDK: $(python -c "import site; print( f'{site.getsitepackages()[0]}/cuquantum')")
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
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

- name: Run PennyLane-Lightning unit tests for lightning.qubit with all devices installed
if: ${{ matrix.pl_backend == 'all' }}
env:
env:
OMP_NUM_THREADS: 1
OMP_PROC_BIND: false
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests_lgpumpi_cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ jobs:
fail_ci_if_error: true
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Cleanup
if: always()
run: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/tests_linux_cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- enable_kernel_omp: OFF
enable_kernel_avx_stream: ON
timeout-minutes: 60
name: C++ tests
name: C++ Tests (${{ matrix.pl_backend }}, ENABLE_KERNEL_OMP=${{ matrix.enable_kernel_omp }}, ENABLE_KERNEL_AVX_STREAM=${{ matrix.enable_kernel_avx_stream }})
runs-on: ${{ needs.determine_runner.outputs.runner_group }}

steps:
Expand Down Expand Up @@ -113,7 +113,7 @@ jobs:
matrix:
pl_backend: ["lightning_qubit"]
timeout-minutes: 60
name: C++ tests (OpenBLAS)
name: C++ Tests (${{ matrix.pl_backend }}, blas-ON)
runs-on: ${{ needs.determine_runner.outputs.runner_group }}

steps:
Expand Down Expand Up @@ -181,7 +181,7 @@ jobs:
exec_model: ${{ fromJson(needs.build_and_cache_Kokkos.outputs.exec_model) }}
kokkos_version: ${{ fromJson(needs.build_and_cache_Kokkos.outputs.kokkos_version) }}
timeout-minutes: 60
name: C++ tests (Kokkos)
name: C++ Tests (${{ matrix.pl_backend }}, kokkos-${{ matrix.kokkos_version }}, model-${{ matrix.exec_model }})
runs-on: ${{ needs.determine_runner.outputs.runner_group }}

steps:
Expand Down Expand Up @@ -275,7 +275,7 @@ jobs:
exec_model: ${{ fromJson(needs.build_and_cache_Kokkos.outputs.exec_model) }}
kokkos_version: ${{ fromJson(needs.build_and_cache_Kokkos.outputs.kokkos_version) }}
timeout-minutes: 60
name: C++ tests (multiple backends)
name: C++ Tests (multiple-backends, kokkos-${{ matrix.kokkos_version }}, model-${{ matrix.exec_model }})
runs-on: ${{ needs.determine_runner.outputs.runner_group }}

steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests_lkcpu_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
exec_model: ${{ fromJson(needs.build_and_cache_Kokkos.outputs.exec_model) }}
kokkos_version: ${{ fromJson(needs.build_and_cache_Kokkos.outputs.kokkos_version) }}
timeout-minutes: 60
name: Python tests with Kokkos
name: Build (${{ matrix.pl_backend }}, kokkos-${{ matrix.kokkos_version }}, model-${{ matrix.exec_model }})
runs-on: ${{ needs.determine_runner.outputs.runner_group }}

steps:
Expand Down Expand Up @@ -152,7 +152,7 @@ jobs:
exec_model: ${{ fromJson(needs.build_and_cache_Kokkos.outputs.exec_model) }}
kokkos_version: ${{ fromJson(needs.build_and_cache_Kokkos.outputs.kokkos_version) }}
timeout-minutes: 60
name: Python tests with Kokkos
name: Python Tests (${{ matrix.pl_backend }}, kokkos-${{ matrix.kokkos_version }}, model-${{ matrix.exec_model }}, test-group-${{ matrix.group }})
runs-on: ${{ needs.determine_runner.outputs.runner_group }}

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests_lkcuda_cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:
exec_model: ["CUDA"]
kokkos_version: ["4.2.00"]

name: C++ tests (Kokkos)
name: C++ Tests (${{ matrix.pl_backend }}, kokkos-${{ matrix.kokkos_version }}, model-${{ matrix.exec_model }})
runs-on:
- ${{ matrix.os }}
- self-hosted
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests_lkcuda_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:
exec_model: ["CUDA"]
kokkos_version: ["4.2.00"]

name: Python tests with Kokkos
name: Python Tests (${{ matrix.pl_backend }}, kokkos-${{ matrix.kokkos_version }}, model-${{ matrix.exec_model }})
runs-on:
- ${{ matrix.os }}
- self-hosted
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests_lqcpu_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
pl_backend: ["lightning_qubit"]
blas: ["OFF", "ON"]
timeout-minutes: 60
name: Python tests
name: Build (${{ matrix.pl_backend }}, blas-${{ matrix.blas }})
runs-on: ${{ needs.determine_runner.outputs.runner_group }}

steps:
Expand Down Expand Up @@ -125,7 +125,7 @@ jobs:
blas: ["OFF", "ON"]
group: [1, 2, 3, 4]
timeout-minutes: 60
name: Python tests
name: Python Tests (${{ matrix.pl_backend }}, blas-${{ matrix.blas }}, test-group-${{ matrix.group }})
runs-on: ${{ needs.determine_runner.outputs.runner_group }}

steps:
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/tests_windows_cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
exec_model: ${{ fromJson(needs.win-set-matrix-x86.outputs.exec_model) }}
kokkos_version: ${{ fromJson(needs.win-set-matrix-x86.outputs.kokkos_version) }}
timeout-minutes: 30
name: Kokkos core (${{ matrix.exec_model }})
name: Build Kokkos core (kokkos-${{ matrix.kokkos_version }}, model-${{ matrix.exec_model }})
runs-on: ${{ matrix.os }}

steps:
Expand Down Expand Up @@ -100,12 +100,13 @@ jobs:
cpptests:
if: ${{ !contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }}
timeout-minutes: 30
name: C++ tests (Windows)
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest]
pl_backend: ["lightning_qubit"]
name: C++ Tests (${{ matrix.pl_backend }}, on-${{ matrix.os }})

steps:
- uses: actions/setup-python@v4
name: Install Python
Expand All @@ -114,7 +115,7 @@ jobs:

- name: Checkout PennyLane-Lightning
uses: actions/checkout@v3

- name: Install dependencies
run: |
python -m pip install cmake build ninja scipy
Expand Down Expand Up @@ -155,7 +156,7 @@ jobs:
name: windows-test-report-${{ github.job }}-${{ matrix.pl_backend }}
path: .\Build\tests\results\
if-no-files-found: error

- name: Upload coverage results
uses: actions/upload-artifact@v3
with:
Expand All @@ -174,7 +175,7 @@ jobs:
kokkos_version: ${{ fromJson(needs.win-set-matrix-x86.outputs.kokkos_version) }}

timeout-minutes: 30
name: C++ tests (Windows, Kokkos)
name: C++ Tests (${{matrix.pl_backend}}, on-${{ matrix.os }}, kokkos-${{ matrix.kokkos_version }}, model-${{ matrix.exec_model }})
runs-on: ${{ matrix.os }}

steps:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/tests_without_binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ jobs:
pythontests:
needs: [determine_runner]
timeout-minutes: 30
name: Python tests
runs-on: ${{ needs.determine_runner.outputs.runner_group }}
strategy:
matrix:
pl_backend: ["lightning_qubit", "lightning_kokkos", "lightning_gpu"]

name: Python Tests without Binary (${{ matrix.pl_backend }})

steps:
- name: Checkout PennyLane-Lightning
uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/vb_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse

import pennylane as qml

pl_version = '"' + qml.version() + '"'
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ test-builtin:
PL_DEVICE=$(if $(device:-=),$(device),lightning.qubit) $(PYTHON) -I $(TESTRUNNER)

test-suite:
pl-device-test --device $(if $(device:-=),$(device),lightning.qubit) --skip-ops --shots=20000
pl-device-test --device $(if $(device:-=),$(device),lightning.qubit) --shots=None --skip-ops
pl-device-test --device $(if $(device:-=),$(device),lightning.qubit) --skip-ops --shots=20000 -n auto
pl-device-test --device $(if $(device:-=),$(device),lightning.qubit) --shots=None --skip-ops -n auto

test-cpp:
rm -rf ./BuildTests
Expand Down
2 changes: 1 addition & 1 deletion doc/docker.rst → doc/dev/docker.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.. include:: ../README.rst
.. include:: ../../README.rst
:start-after: docker-start-inclusion-marker-do-not-remove
:end-before: docker-end-inclusion-marker-do-not-remove
Loading
Loading