From b940f4048a0e6f4fd9ddabfef35c7aa637ad1187 Mon Sep 17 00:00:00 2001 From: "Lee J. O'Riordan" Date: Tue, 22 Aug 2023 10:24:43 -0400 Subject: [PATCH 01/12] Pin lightning.qubit dep to v0.31.0 --- .github/workflows/build_wheel_manylinux2014.yml | 2 +- .github/workflows/tests_linux_x86.yml | 6 +++--- .github/workflows/tests_linux_x86_mpich.yml | 6 +++--- .github/workflows/tests_linux_x86_openmpi.yml | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build_wheel_manylinux2014.yml b/.github/workflows/build_wheel_manylinux2014.yml index 3e71b409..443cbe79 100644 --- a/.github/workflows/build_wheel_manylinux2014.yml +++ b/.github/workflows/build_wheel_manylinux2014.yml @@ -56,7 +56,7 @@ jobs: CIBW_SKIP: "*-musllinux*" - CIBW_CONFIG_SETTINGS: --global-option=build_ext --global-option=--define="CMAKE_CXX_COMPILER=$(which g++-11);CMAKE_C_COMPILER=$(which gcc-11);LIGHTNING_RELEASE_TAG=master" + CIBW_CONFIG_SETTINGS: --global-option=build_ext --global-option=--define="CMAKE_CXX_COMPILER=$(which g++-11);CMAKE_C_COMPILER=$(which gcc-11);LIGHTNING_RELEASE_TAG=v0.31.0" # Python build settings CIBW_BEFORE_BUILD: | diff --git a/.github/workflows/tests_linux_x86.yml b/.github/workflows/tests_linux_x86.yml index 36674a51..ec78aa5e 100644 --- a/.github/workflows/tests_linux_x86.yml +++ b/.github/workflows/tests_linux_x86.yml @@ -138,7 +138,7 @@ jobs: -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DPLLGPU_BUILD_TESTS=ON \ -DCMAKE_CXX_COMPILER="$(which g++-${{ env.GCC_VERSION }})" \ - -DLIGHTNING_RELEASE_TAG="master" \ + -DLIGHTNING_RELEASE_TAG="v0.31.0" \ -DCMAKE_CUDA_COMPILER="/usr/local/cuda/bin/nvcc" \ -DCMAKE_CUDA_ARCHITECTURES="86" \ -DPython_EXECUTABLE:FILE="${{ steps.python_path.outputs.python }}" \ @@ -162,7 +162,7 @@ jobs: -DPLLGPU_BUILD_TESTS=ON \ -DPLLGPU_ENABLE_COVERAGE=ON \ -DCMAKE_CXX_COMPILER="$(which g++-${{ env.GCC_VERSION }})" \ - -DLIGHTNING_RELEASE_TAG="master" \ + -DLIGHTNING_RELEASE_TAG="v0.31.0" \ -DCMAKE_CUDA_COMPILER="/usr/local/cuda/bin/nvcc" \ -DCMAKE_CUDA_ARCHITECTURES="86" \ -DPython_EXECUTABLE:FILE="${{ steps.python_path.outputs.python }}" \ @@ -265,7 +265,7 @@ jobs: env: CUQUANTUM_SDK: $(python -c "import site; print( f'{site.getsitepackages()[0]}/cuquantum/lib')") run: | - python setup.py build_ext -i --define="CMAKE_CXX_COMPILER=$(which g++-${{ env.GCC_VERSION }});LIGHTNING_RELEASE_TAG=master;CMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc;CMAKE_CUDA_ARCHITECTURES=${{ env.CI_CUDA_ARCH }};Python_EXECUTABLE=${{ steps.python_path.outputs.python }}" + python setup.py build_ext -i --define="CMAKE_CXX_COMPILER=$(which g++-${{ env.GCC_VERSION }});LIGHTNING_RELEASE_TAG=v0.31.0;CMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc;CMAKE_CUDA_ARCHITECTURES=${{ env.CI_CUDA_ARCH }};Python_EXECUTABLE=${{ steps.python_path.outputs.python }}" python -m pip install -e . --verbose - name: Run PennyLane-Lightning-GPU unit tests diff --git a/.github/workflows/tests_linux_x86_mpich.yml b/.github/workflows/tests_linux_x86_mpich.yml index bd77c326..8707b277 100644 --- a/.github/workflows/tests_linux_x86_mpich.yml +++ b/.github/workflows/tests_linux_x86_mpich.yml @@ -136,7 +136,7 @@ jobs: -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DPLLGPU_BUILD_TESTS=ON \ -DCMAKE_CXX_COMPILER="$(which g++-${{ env.GCC_VERSION }})" \ - -DLIGHTNING_RELEASE_TAG="master" \ + -DLIGHTNING_RELEASE_TAG="v0.31.0" \ -DCMAKE_CUDA_COMPILER="/usr/local/cuda/bin/nvcc" \ -DCMAKE_CUDA_ARCHITECTURES="86" \ -DPython_EXECUTABLE:FILE="${{ steps.python_path.outputs.python }}" \ @@ -168,7 +168,7 @@ jobs: -DPLLGPU_BUILD_TESTS=ON \ -DPLLGPU_ENABLE_COVERAGE=ON \ -DCMAKE_CXX_COMPILER="$(which g++-${{ env.GCC_VERSION }})" \ - -DLIGHTNING_RELEASE_TAG="master" \ + -DLIGHTNING_RELEASE_TAG="v0.31.0" \ -DCMAKE_CUDA_COMPILER="/usr/local/cuda/bin/nvcc" \ -DCMAKE_CUDA_ARCHITECTURES="86" \ -DPython_EXECUTABLE:FILE="${{ steps.python_path.outputs.python }}" \ @@ -281,7 +281,7 @@ jobs: env: CUQUANTUM_SDK: $(python -c "import site; print( f'{site.getsitepackages()[0]}/cuquantum/lib')") run: | - python setup.py build_ext -i --define="CMAKE_CXX_COMPILER=$(which g++-${{ env.GCC_VERSION }});CMAKE_PREFIX_PATH=/opt/mpi/mpich;PLLGPU_ENABLE_MPI=On;LIGHTNING_RELEASE_TAG=master;CMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc;CMAKE_CUDA_ARCHITECTURES=${{ env.CI_CUDA_ARCH }};Python_EXECUTABLE=${{ steps.python_path.outputs.python }}" + python setup.py build_ext -i --define="CMAKE_CXX_COMPILER=$(which g++-${{ env.GCC_VERSION }});CMAKE_PREFIX_PATH=/opt/mpi/mpich;PLLGPU_ENABLE_MPI=On;LIGHTNING_RELEASE_TAG=v0.31.0;CMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc;CMAKE_CUDA_ARCHITECTURES=${{ env.CI_CUDA_ARCH }};Python_EXECUTABLE=${{ steps.python_path.outputs.python }}" python -m pip install -e . --verbose - name: Run PennyLane-Lightning-GPU unit tests (MPICH backend) diff --git a/.github/workflows/tests_linux_x86_openmpi.yml b/.github/workflows/tests_linux_x86_openmpi.yml index 941ed3ee..efd41822 100644 --- a/.github/workflows/tests_linux_x86_openmpi.yml +++ b/.github/workflows/tests_linux_x86_openmpi.yml @@ -115,7 +115,7 @@ jobs: -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DPLLGPU_BUILD_TESTS=ON \ -DCMAKE_CXX_COMPILER="$(which g++-${{ env.GCC_VERSION }})" \ - -DLIGHTNING_RELEASE_TAG="master" \ + -DLIGHTNING_RELEASE_TAG="v0.31.0" \ -DCMAKE_CUDA_COMPILER="/usr/local/cuda/bin/nvcc" \ -DCMAKE_CUDA_ARCHITECTURES="86" \ -DPython_EXECUTABLE:FILE="${{ steps.python_path.outputs.python }}" \ @@ -147,7 +147,7 @@ jobs: -DPLLGPU_BUILD_TESTS=ON \ -DPLLGPU_ENABLE_COVERAGE=ON \ -DCMAKE_CXX_COMPILER="$(which g++-${{ env.GCC_VERSION }})" \ - -DLIGHTNING_RELEASE_TAG="master" \ + -DLIGHTNING_RELEASE_TAG="v0.31.0" \ -DCMAKE_CUDA_COMPILER="/usr/local/cuda/bin/nvcc" \ -DCMAKE_CUDA_ARCHITECTURES="86" \ -DPython_EXECUTABLE:FILE="${{ steps.python_path.outputs.python }}" \ @@ -253,7 +253,7 @@ jobs: env: CUQUANTUM_SDK: $(python -c "import site; print( f'{site.getsitepackages()[0]}/cuquantum/lib')") run: | - python setup.py build_ext -i --define="CMAKE_CXX_COMPILER=$(which g++-${{ env.GCC_VERSION }});CMAKE_PREFIX_PATH=/opt/mpi/openmpi;PLLGPU_ENABLE_MPI=On;LIGHTNING_RELEASE_TAG=master;CMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc;CMAKE_CUDA_ARCHITECTURES=${{ env.CI_CUDA_ARCH }};Python_EXECUTABLE=${{ steps.python_path.outputs.python }}" + python setup.py build_ext -i --define="CMAKE_CXX_COMPILER=$(which g++-${{ env.GCC_VERSION }});CMAKE_PREFIX_PATH=/opt/mpi/openmpi;PLLGPU_ENABLE_MPI=On;LIGHTNING_RELEASE_TAG=v0.31.0;CMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc;CMAKE_CUDA_ARCHITECTURES=${{ env.CI_CUDA_ARCH }};Python_EXECUTABLE=${{ steps.python_path.outputs.python }}" python -m pip install -e . --verbose - name: Run PennyLane-Lightning-GPU unit tests (OpenMPI backend) From 54d406164a9f5307b02531f8ed41ff1bb05dd92a Mon Sep 17 00:00:00 2001 From: "Lee J. O'Riordan" Date: Tue, 22 Aug 2023 10:26:48 -0400 Subject: [PATCH 02/12] Trigger CI From e686cdb3d513099fb79db85b9d4bf1f225797009 Mon Sep 17 00:00:00 2001 From: "Lee J. O'Riordan" Date: Tue, 22 Aug 2023 10:37:54 -0400 Subject: [PATCH 03/12] Remove python 3.8 --- .github/workflows/build_wheel_manylinux2014.yml | 6 +++--- .github/workflows/format.yml | 2 +- .github/workflows/tests_linux_x86.yml | 4 ++-- .github/workflows/tests_linux_x86_mpich.yml | 4 ++-- .github/workflows/tests_linux_x86_openmpi.yml | 4 ++-- .readthedocs.yml | 2 +- Makefile | 2 +- README.rst | 4 ++-- setup.py | 1 - 9 files changed, 14 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build_wheel_manylinux2014.yml b/.github/workflows/build_wheel_manylinux2014.yml index 443cbe79..5b25031a 100644 --- a/.github/workflows/build_wheel_manylinux2014.yml +++ b/.github/workflows/build_wheel_manylinux2014.yml @@ -1,7 +1,7 @@ name: Wheel::Linux::x86_64 # **What it does**: Builds python wheels for Linux (ubuntu-latest) architecture x86_64 and store it as artifacts. -# Python versions: 3.8, 3.9, 3.10, 3.11. +# Python versions: 3.9, 3.10, 3.11. # **Why we have it**: To build wheels for pennylane-lightning-gpu installation. # **Who does it impact**: Wheels to be uploaded to PyPI. @@ -27,7 +27,7 @@ jobs: os: [ubuntu-latest] arch: [x86_64] cibw_build: ${{ fromJson(needs.set_wheel_build_matrix.outputs.python_version) }} - name: ${{ matrix.os }} (Python ${{ fromJson('{"cp38-*":"3.8","cp39-*":"3.9","cp310-*":"3.10","cp311-*":"3.11" }')[matrix.cibw_build] }}) + name: ${{ matrix.os }} (Python ${{ fromJson('{"cp39-*":"3.9","cp310-*":"3.10","cp311-*":"3.11" }')[matrix.cibw_build] }}) runs-on: ${{ matrix.os }} steps: @@ -42,7 +42,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v4 with: - python-version: '3.8' + python-version: '3.9' - name: Install cibuildwheel run: python -m pip install cibuildwheel~=2.11.0 diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index d4d21f29..17b42c50 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -17,7 +17,7 @@ jobs: - uses: actions/setup-python@v4 name: Install Python with: - python-version: '3.8' + python-version: '3.9' - name: Install dependencies run: diff --git a/.github/workflows/tests_linux_x86.yml b/.github/workflows/tests_linux_x86.yml index ec78aa5e..bd07c6f6 100644 --- a/.github/workflows/tests_linux_x86.yml +++ b/.github/workflows/tests_linux_x86.yml @@ -69,7 +69,7 @@ jobs: id: setup_python name: Install Python with: - python-version: '3.8' + python-version: '3.9' # Since the self-hosted runner can be re-used. It is best to set up all package # installations in a virtual environment that gets cleaned at the end of each workflow run @@ -215,7 +215,7 @@ jobs: id: setup_python name: Install Python with: - python-version: '3.8' + python-version: '3.9' # Since the self-hosted runner can be re-used. It is best to set up all package # installations in a virtual environment that gets cleaned at the end of each workflow run diff --git a/.github/workflows/tests_linux_x86_mpich.yml b/.github/workflows/tests_linux_x86_mpich.yml index 8707b277..9a9bf2b4 100644 --- a/.github/workflows/tests_linux_x86_mpich.yml +++ b/.github/workflows/tests_linux_x86_mpich.yml @@ -55,7 +55,7 @@ jobs: id: setup_python name: Install Python with: - python-version: '3.8' + python-version: '3.9' # Since the self-hosted runner can be re-used. It is best to set up all package # installations in a virtual environment that gets cleaned at the end of each workflow run @@ -225,7 +225,7 @@ jobs: id: setup_python name: Install Python with: - python-version: '3.8' + python-version: '3.9' # Since the self-hosted runner can be re-used. It is best to set up all package # installations in a virtual environment that gets cleaned at the end of each workflow run diff --git a/.github/workflows/tests_linux_x86_openmpi.yml b/.github/workflows/tests_linux_x86_openmpi.yml index efd41822..d19345e7 100644 --- a/.github/workflows/tests_linux_x86_openmpi.yml +++ b/.github/workflows/tests_linux_x86_openmpi.yml @@ -38,7 +38,7 @@ jobs: id: setup_python name: Install Python with: - python-version: '3.8' + python-version: '3.9' # Since the self-hosted runner can be re-used. It is best to set up all package # installations in a virtual environment that gets cleaned at the end of each workflow run @@ -197,7 +197,7 @@ jobs: id: setup_python name: Install Python with: - python-version: '3.8' + python-version: '3.9' # Since the self-hosted runner can be re-used. It is best to set up all package # installations in a virtual environment that gets cleaned at the end of each workflow run diff --git a/.readthedocs.yml b/.readthedocs.yml index b56da350..feb1195e 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -15,7 +15,7 @@ python: build: os: ubuntu-20.04 tools: - python: "3.8" + python: "3.9" apt_packages: - cmake - build-essential diff --git a/Makefile b/Makefile index 84b6ef84..c36ece88 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ ifndef CUQUANTUM_SDK @test $(CUQUANTUM_SDK) endif ifndef PYTHON3 - @echo "To install PennyLane-Lightning-GPU you must have Python 3.8+ installed." + @echo "To install PennyLane-Lightning-GPU you must have Python 3.9+ installed." endif $(PYTHON) setup.py build_ext --cuquantum=$(CUQUANTUM_SDK) --verbose $(PYTHON) setup.py install diff --git a/README.rst b/README.rst index de2c8e04..76cc8677 100644 --- a/README.rst +++ b/README.rst @@ -37,7 +37,7 @@ Features Installation ============ -PennyLane-Lightning-GPU requires Python version 3.8 and above. It can be installed using ``pip``: +PennyLane-Lightning-GPU requires Python version 3.9 and above. It can be installed using ``pip``: .. code-block:: console @@ -82,7 +82,7 @@ To build using Docker, run the following from the project root directory: docker build . -f ./docker/Dockerfile -t "lightning-gpu-wheels" -This will build a Python wheel for Python 3.8 up to 3.11 inclusive, and be manylinux2014 (glibc 2.17) compatible. +This will build a Python wheel for Python 3.9 up to 3.11 inclusive, and be manylinux2014 (glibc 2.17) compatible. To acquire the built wheels, use: .. code-block:: console diff --git a/setup.py b/setup.py index c4711633..94ee520a 100644 --- a/setup.py +++ b/setup.py @@ -132,7 +132,6 @@ def build_extension(self, ext: CMakeExtension): "Operating System :: POSIX :: Linux", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", From 5d10a1202c9d9c3f171f6c8ff14256a667493cc2 Mon Sep 17 00:00:00 2001 From: "Lee J. O'Riordan" Date: Tue, 22 Aug 2023 10:39:34 -0400 Subject: [PATCH 04/12] Update changelog --- .github/CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index 846cb74b..ff71776f 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -7,6 +7,9 @@ ### Breaking changes +* Remove suport for Python 3.9. + [(#135)](https://github.com/PennyLaneAI/pennylane-lightning-gpu/pull/135) + ### Improvements * Optimizes the single qubit rotation gate by using a single cuStateVector API call instead of separate Pauli gate applications. @@ -15,6 +18,10 @@ ### Documentation ### Bug fixes + +* Pin `lightning.qubit` build version to v0.31.0 due to new package architecture. + [(#135)](https://github.com/PennyLaneAI/pennylane-lightning-gpu/pull/135) + * `apply` no longer mutates the inputted list of operations and add the missing `_dp` to the LightningGPU class with single GPU backend. [(#133)] (https://github.com/PennyLaneAI/pennylane-lightning-gpu/pull/133) From 5ce4f70006e23746382908473f59f4e08cb6a6be Mon Sep 17 00:00:00 2001 From: Shuli Shu <08cnbj@gmail.com> Date: Mon, 21 Aug 2023 07:34:20 -0700 Subject: [PATCH 05/12] rename qubitstatevector to stateprep --- doc/devices.rst | 2 +- mpitests/test_adjoint_jacobian.py | 6 +- mpitests/test_apply.py | 18 +++--- pennylane_lightning_gpu/_serialize.py | 4 +- pennylane_lightning_gpu/lightning_gpu.py | 10 ++-- .../src/algorithms/AdjointDiffGPU.hpp | 2 +- .../src/algorithms/AdjointDiffGPUMPI.hpp | 4 +- tests/test_adjoint_jacobian.py | 6 +- tests/test_apply.py | 60 +++++++++---------- tests/test_comparison.py | 2 +- tests/test_gates.py | 4 +- 11 files changed, 59 insertions(+), 59 deletions(-) diff --git a/doc/devices.rst b/doc/devices.rst index 533ddd3e..7919a972 100644 --- a/doc/devices.rst +++ b/doc/devices.rst @@ -46,7 +46,7 @@ Supported operations and observables ~pennylane.PauliZ ~pennylane.PhaseShift ~pennylane.ControlledPhaseShift - ~pennylane.QubitStateVector + ~pennylane.StatePrep ~pennylane.Rot ~pennylane.RX ~pennylane.RY diff --git a/mpitests/test_adjoint_jacobian.py b/mpitests/test_adjoint_jacobian.py index b42f9e71..63229c80 100644 --- a/mpitests/test_adjoint_jacobian.py +++ b/mpitests/test_adjoint_jacobian.py @@ -188,7 +188,7 @@ def test_pauli_rotation_gradient(self, G, theta, tol, isBatch_obs, request): dev_cpu = qml.device("default.qubit", wires=3) with qml.tape.QuantumTape() as tape: - qml.QubitStateVector(np.array([1.0, -1.0]) / np.sqrt(2), wires=0) + qml.StatePrep(np.array([1.0, -1.0]) / np.sqrt(2), wires=0) G(theta, wires=[0]) qml.expval(qml.PauliZ(0)) @@ -218,7 +218,7 @@ def test_Rot_gradient(self, theta, tol, isBatch_obs, request): params = np.array([theta, theta**3, np.sqrt(2) * theta]) with qml.tape.QuantumTape() as tape: - qml.QubitStateVector(np.array([1.0, -1.0]) / np.sqrt(2), wires=0) + qml.StatePrep(np.array([1.0, -1.0]) / np.sqrt(2), wires=0) qml.Rot(*params, wires=[0]) qml.expval(qml.PauliZ(0)) @@ -760,7 +760,7 @@ def circuit_2(params, wires): def circuit_ansatz(params, wires): """Circuit ansatz containing all the parametrized gates""" - qml.QubitStateVector(unitary_group.rvs(2**6, random_state=0)[0], wires=wires) + qml.StatePrep(unitary_group.rvs(2**6, random_state=0)[0], wires=wires) qml.RX(params[0], wires=wires[0]) qml.RY(params[1], wires=wires[1]) qml.adjoint(qml.RX(params[2], wires=wires[2])) diff --git a/mpitests/test_apply.py b/mpitests/test_apply.py index 211469b1..146081a5 100644 --- a/mpitests/test_apply.py +++ b/mpitests/test_apply.py @@ -72,7 +72,7 @@ def apply_operation_gates_qnode_param(tol, operation, par, Wires): ) def circuit(*params): - qml.QubitStateVector(state_vector, wires=range(num_wires)) + qml.StatePrep(state_vector, wires=range(num_wires)) operation(*params, wires=Wires) return qml.state() @@ -105,7 +105,7 @@ def apply_operation_gates_apply_param(tol, operation, par, Wires): @qml.qnode(dev_cpu) def circuit(*params): - qml.QubitStateVector(state_vector, wires=range(num_wires)) + qml.StatePrep(state_vector, wires=range(num_wires)) operation(*params, wires=Wires) return qml.state() @@ -153,7 +153,7 @@ def apply_operation_gates_qnode_nonparam(tol, operation, Wires): ) def circuit(): - qml.QubitStateVector(state_vector, wires=range(num_wires)) + qml.StatePrep(state_vector, wires=range(num_wires)) operation(wires=Wires) return qml.state() @@ -186,7 +186,7 @@ def apply_operation_gates_apply_nonparam(tol, operation, Wires): @qml.qnode(dev_cpu) def circuit(): - qml.QubitStateVector(state_vector, wires=range(num_wires)) + qml.StatePrep(state_vector, wires=range(num_wires)) operation(wires=Wires) return qml.state() @@ -225,7 +225,7 @@ def expval_single_wire_no_param(tol, obs): dev_gpumpi = qml.device("lightning.gpu", wires=num_wires, mpi=True, c_dtype=np.complex128) def circuit(): - qml.QubitStateVector(state_vector, wires=range(num_wires)) + qml.StatePrep(state_vector, wires=range(num_wires)) return qml.expval(obs) cpu_qnode = qml.QNode(circuit, dev_cpu) @@ -252,7 +252,7 @@ def apply_probs_nonparam(tol, operation, GateWires, Wires): dev_gpumpi = qml.device("lightning.gpu", wires=num_wires, mpi=True, c_dtype=np.complex128) def circuit(): - qml.QubitStateVector(state_vector, wires=range(num_wires)) + qml.StatePrep(state_vector, wires=range(num_wires)) operation(wires=GateWires) return qml.probs(wires=Wires) @@ -292,7 +292,7 @@ def apply_probs_param(tol, operation, par, GateWires, Wires): dev_gpumpi = qml.device("lightning.gpu", wires=num_wires, mpi=True, c_dtype=np.complex128) def circuit(): - qml.QubitStateVector(state_vector, wires=range(num_wires)) + qml.StatePrep(state_vector, wires=range(num_wires)) operation(*par, wires=GateWires) return qml.probs(wires=Wires) @@ -501,7 +501,7 @@ def test_qubit_state_prep(self, tol, par, Wires): dev_gpumpi = qml.device("lightning.gpu", wires=num_wires, mpi=True, c_dtype=np.complex128) def circuit(): - qml.QubitStateVector(par, wires=Wires) + qml.StatePrep(par, wires=Wires) return qml.state() cpu_qnode = qml.QNode(circuit, dev_cpu) @@ -1152,7 +1152,7 @@ def test_prob_four_wire_param(self, tol, operation, par, GateWires, Wires): def circuit_ansatz(params, wires): """Circuit ansatz containing all the parametrized gates""" - qml.QubitStateVector(unitary_group.rvs(2**numQubits, random_state=0)[0], wires=wires) + qml.StatePrep(unitary_group.rvs(2**numQubits, random_state=0)[0], wires=wires) qml.RX(params[0], wires=wires[0]) qml.RY(params[1], wires=wires[1]) qml.adjoint(qml.RX(params[2], wires=wires[2])) diff --git a/pennylane_lightning_gpu/_serialize.py b/pennylane_lightning_gpu/_serialize.py index e989ed49..f6e630d4 100644 --- a/pennylane_lightning_gpu/_serialize.py +++ b/pennylane_lightning_gpu/_serialize.py @@ -24,7 +24,7 @@ PauliY, PauliZ, Identity, - QubitStateVector, + StatePrep, Rot, ) from pennylane.operation import Tensor @@ -286,7 +286,7 @@ def _serialize_ops( sv_py = LightningGPU_C64 if use_csingle else LightningGPU_C128 for o in tape.operations: - if isinstance(o, (BasisState, QubitStateVector)): + if isinstance(o, (BasisState, StatePrep)): uses_stateprep = True continue elif isinstance(o, Rot): diff --git a/pennylane_lightning_gpu/lightning_gpu.py b/pennylane_lightning_gpu/lightning_gpu.py index 2c88ea67..3313a77e 100644 --- a/pennylane_lightning_gpu/lightning_gpu.py +++ b/pennylane_lightning_gpu/lightning_gpu.py @@ -27,7 +27,7 @@ math, QubitDevice, BasisState, - QubitStateVector, + StatePrep, DeviceError, Projector, Hermitian, @@ -141,7 +141,7 @@ def _mebibytesToBytes(mebibytes): allowed_operations = { "Identity", "BasisState", - "QubitStateVector", + "StatePrep", "QubitUnitary", "ControlledQubitUnitary", "MultiControlledX", @@ -554,7 +554,7 @@ def apply_cq(self, operations, **kwargs): def apply(self, operations, **kwargs): # State preparation is currently done in Python if operations: # make sure operations[0] exists - if isinstance(operations[0], QubitStateVector): + if isinstance(operations[0], StatePrep): self._apply_state_vector_GPU( operations[0].parameters[0].copy(), operations[0].wires ) @@ -564,7 +564,7 @@ def apply(self, operations, **kwargs): operations = operations[1:] for operation in operations: - if isinstance(operation, (QubitStateVector, BasisState)): + if isinstance(operation, (StatePrep, BasisState)): raise DeviceError( "Operation {} cannot be used after other Operations have already been " "applied on a {} device.".format(operation.name, self.short_name) @@ -678,7 +678,7 @@ def adjoint_jacobian(self, tape, starting_state=None, use_device_state=False, ** # get op_idx-th operator among differentiable operators op, _, _ = tape.get_operation(op_idx) - if isinstance(op, Operation) and not isinstance(op, (BasisState, QubitStateVector)): + if isinstance(op, Operation) and not isinstance(op, (BasisState, StatePrep)): # We now just ignore non-op or state preps tp_shift.append(tp) record_tp_rows.append(all_params) diff --git a/pennylane_lightning_gpu/src/algorithms/AdjointDiffGPU.hpp b/pennylane_lightning_gpu/src/algorithms/AdjointDiffGPU.hpp index f1502c27..2088cde3 100644 --- a/pennylane_lightning_gpu/src/algorithms/AdjointDiffGPU.hpp +++ b/pennylane_lightning_gpu/src/algorithms/AdjointDiffGPU.hpp @@ -560,7 +560,7 @@ template class AdjointJacobianGPU { PL_ABORT_IF(ops.getOpsParams()[op_idx].size() > 1, "The operation is not supported using the adjoint " "differentiation method"); - if ((ops_name[op_idx] == "QubitStateVector") || + if ((ops_name[op_idx] == "StatePrep") || (ops_name[op_idx] == "BasisState")) { continue; } diff --git a/pennylane_lightning_gpu/src/algorithms/AdjointDiffGPUMPI.hpp b/pennylane_lightning_gpu/src/algorithms/AdjointDiffGPUMPI.hpp index 0e3ec4b1..95481e56 100644 --- a/pennylane_lightning_gpu/src/algorithms/AdjointDiffGPUMPI.hpp +++ b/pennylane_lightning_gpu/src/algorithms/AdjointDiffGPUMPI.hpp @@ -300,7 +300,7 @@ class AdjointJacobianGPUMPI { PL_ABORT_IF(ops.getOpsParams()[op_idx].size() > 1, "The operation is not supported using the adjoint " "differentiation method"); - if ((ops_name[op_idx] == "QubitStateVector") || + if ((ops_name[op_idx] == "StatePrep") || (ops_name[op_idx] == "BasisState")) { continue; } @@ -396,7 +396,7 @@ class AdjointJacobianGPUMPI { PL_ABORT_IF(ops.getOpsParams()[op_idx].size() > 1, "The operation is not supported using the adjoint " "differentiation method"); - if ((ops_name[op_idx] == "QubitStateVector") || + if ((ops_name[op_idx] == "StatePrep") || (ops_name[op_idx] == "BasisState")) { continue; } diff --git a/tests/test_adjoint_jacobian.py b/tests/test_adjoint_jacobian.py index 40d464fc..2e9f46b9 100644 --- a/tests/test_adjoint_jacobian.py +++ b/tests/test_adjoint_jacobian.py @@ -196,7 +196,7 @@ def test_pauli_rotation_gradient(self, G, theta, tol, dev_cpu, dev_gpu): """Tests that the automatic gradients of Pauli rotations are correct.""" with qml.tape.QuantumTape() as tape: - qml.QubitStateVector(np.array([1.0, -1.0]) / np.sqrt(2), wires=0) + qml.StatePrep(np.array([1.0, -1.0]) / np.sqrt(2), wires=0) G(theta, wires=[0]) qml.expval(qml.PauliZ(0)) @@ -214,7 +214,7 @@ def test_Rot_gradient(self, theta, tol, dev_cpu, dev_gpu): params = np.array([theta, theta**3, np.sqrt(2) * theta]) with qml.tape.QuantumTape() as tape: - qml.QubitStateVector(np.array([1.0, -1.0]) / np.sqrt(2), wires=0) + qml.StatePrep(np.array([1.0, -1.0]) / np.sqrt(2), wires=0) qml.Rot(*params, wires=[0]) qml.expval(qml.PauliZ(0)) @@ -687,7 +687,7 @@ def circuit_2(params, wires): def circuit_ansatz(params, wires): """Circuit ansatz containing all the parametrized gates""" - qml.QubitStateVector(unitary_group.rvs(2**4, random_state=0)[0], wires=wires) + qml.StatePrep(unitary_group.rvs(2**4, random_state=0)[0], wires=wires) qml.RX(params[0], wires=wires[0]) qml.RY(params[1], wires=wires[1]) qml.adjoint(qml.RX(params[2], wires=wires[2])) diff --git a/tests/test_apply.py b/tests/test_apply.py index df481f55..5f44ba30 100644 --- a/tests/test_apply.py +++ b/tests/test_apply.py @@ -223,16 +223,16 @@ def test_apply_operation_three_wires_no_parameters( (qml.BasisState, [0, 0, 1, 0], [1, 0]), (qml.BasisState, [0, 0, 1, 0], [1, 0]), (qml.BasisState, [0, 0, 0, 1], [1, 1]), - (qml.QubitStateVector, [0, 0, 1, 0], [0, 0, 1, 0]), - (qml.QubitStateVector, [0, 0, 1, 0], [0, 0, 1, 0]), - (qml.QubitStateVector, [0, 0, 0, 1], [0, 0, 0, 1]), + (qml.StatePrep, [0, 0, 1, 0], [0, 0, 1, 0]), + (qml.StatePrep, [0, 0, 1, 0], [0, 0, 1, 0]), + (qml.StatePrep, [0, 0, 0, 1], [0, 0, 0, 1]), ( - qml.QubitStateVector, + qml.StatePrep, [1 / math.sqrt(3), 0, 1 / math.sqrt(3), 1 / math.sqrt(3)], [1 / math.sqrt(3), 0, 1 / math.sqrt(3), 1 / math.sqrt(3)], ), ( - qml.QubitStateVector, + qml.StatePrep, [1 / math.sqrt(3), 0, -1 / math.sqrt(3), 1 / math.sqrt(3)], [1 / math.sqrt(3), 0, -1 / math.sqrt(3), 1 / math.sqrt(3)], ), @@ -480,24 +480,24 @@ def test_apply_operation_two_wires_with_parameters( def test_apply_errors_qubit_state_vector(self, qubit_device_2_wires): """Test that apply fails for incorrect state preparation, and > 2 qubit gates""" with pytest.raises(ValueError, match="Sum of amplitudes-squared does not equal one."): - qubit_device_2_wires.apply([qml.QubitStateVector(np.array([1, -1]), wires=[0])]) + qubit_device_2_wires.apply([qml.StatePrep(np.array([1, -1]), wires=[0])]) with pytest.raises( ValueError, match=r"State vector must have shape \(2\*\*wires,\) or \(batch_size, 2\*\*wires\).", ): p = np.array([1, 0, 1, 1, 0]) / np.sqrt(3) - qubit_device_2_wires.apply([qml.QubitStateVector(p, wires=[0, 1])]) + qubit_device_2_wires.apply([qml.StatePrep(p, wires=[0, 1])]) with pytest.raises( DeviceError, - match="Operation QubitStateVector cannot be used after other Operations have already been applied ", + match="Operation StatePrep cannot be used after other Operations have already been applied ", ): qubit_device_2_wires.reset() qubit_device_2_wires.apply( [ qml.RZ(0.5, wires=[0]), - qml.QubitStateVector(np.array([0, 1, 0, 0]), wires=[0, 1]), + qml.StatePrep(np.array([0, 1, 0, 0]), wires=[0, 1]), ] ) @@ -554,7 +554,7 @@ def test_expval_single_wire_no_parameters( qubit_device_1_wire.reset() qubit_device_1_wire.apply( - [qml.QubitStateVector(np.array(input), wires=[0])], + [qml.StatePrep(np.array(input), wires=[0])], rotations=obs.diagonalizing_gates(), ) res = qubit_device_1_wire.expval(obs) @@ -594,7 +594,7 @@ def test_var_single_wire_no_parameters( qubit_device_1_wire.reset() qubit_device_1_wire.apply( - [qml.QubitStateVector(np.array(input), wires=[0])], + [qml.StatePrep(np.array(input), wires=[0])], rotations=obs.diagonalizing_gates(), ) res = qubit_device_1_wire.var(obs) @@ -759,7 +759,7 @@ def test_supported_gate_two_wires_no_parameters( @qml.qnode(qubit_device_2_wires) def circuit(): - qml.QubitStateVector(np.array([1 / 2, 0, 0, math.sqrt(3) / 2]), wires=[0, 1]) + qml.StatePrep(np.array([1 / 2, 0, 0, math.sqrt(3) / 2]), wires=[0, 1]) op(wires=[0, 1]) return qml.expval(qml.PauliZ(0)), qml.expval(qml.PauliZ(1)) @@ -799,9 +799,9 @@ def circuit(): ("BasisState", [0, 0], [1, 1]), ("BasisState", [1, 0], [-1, 1]), ("BasisState", [0, 1], [1, -1]), - ("QubitStateVector", [1, 0, 0, 0], [1, 1]), - ("QubitStateVector", [0, 0, 1, 0], [-1, 1]), - ("QubitStateVector", [0, 1, 0, 0], [1, -1]), + ("StatePrep", [1, 0, 0, 0], [1, 1]), + ("StatePrep", [0, 0, 1, 0], [-1, 1]), + ("StatePrep", [0, 1, 0, 0], [1, -1]), ], ) def test_supported_state_preparation( @@ -847,11 +847,11 @@ def circuit(): @pytest.mark.parametrize( "name,par,wires,expected_output", [ - ("QubitStateVector", [0, 1], [1], [1, -1]), - ("QubitStateVector", [0, 1], [0], [-1, 1]), - ("QubitStateVector", [1.0 / np.sqrt(2), 1.0 / np.sqrt(2)], [1], [1, 0]), - ("QubitStateVector", [1j / 2.0, np.sqrt(3) / 2.0], [1], [1, -0.5]), - ("QubitStateVector", [(2 - 1j) / 3.0, 2j / 3.0], [0], [1 / 9.0, 1]), + ("StatePrep", [0, 1], [1], [1, -1]), + ("StatePrep", [0, 1], [0], [-1, 1]), + ("StatePrep", [1.0 / np.sqrt(2), 1.0 / np.sqrt(2)], [1], [1, 0]), + ("StatePrep", [1j / 2.0, np.sqrt(3) / 2.0], [1], [1, -0.5]), + ("StatePrep", [(2 - 1j) / 3.0, 2j / 3.0], [0], [1 / 9.0, 1]), ], ) def test_state_vector_2_qubit_subset( @@ -875,7 +875,7 @@ def circuit(): "name,par,wires,expected_output", [ ( - "QubitStateVector", + "StatePrep", [ 1j / np.sqrt(10), (1 - 2j) / np.sqrt(10), @@ -890,32 +890,32 @@ def circuit(): [1 / 5.0, 1.0, -4 / 5.0], ), ( - "QubitStateVector", + "StatePrep", [1 / np.sqrt(2), 0, 0, 1 / np.sqrt(2)], [0, 2], [0.0, 1.0, 0.0], ), ( - "QubitStateVector", + "StatePrep", [1 / np.sqrt(2), 0, 0, 1 / np.sqrt(2)], [0, 1], [0.0, 0.0, 1.0], ), - ("QubitStateVector", [0, 1, 0, 0, 0, 0, 0, 0], [2, 1, 0], [-1.0, 1.0, 1.0]), + ("StatePrep", [0, 1, 0, 0, 0, 0, 0, 0], [2, 1, 0], [-1.0, 1.0, 1.0]), ( - "QubitStateVector", + "StatePrep", [0, 1j, 0, 0, 0, 0, 0, 0], [0, 2, 1], [1.0, -1.0, 1.0], ), ( - "QubitStateVector", + "StatePrep", [0, 1 / np.sqrt(2), 0, 1 / np.sqrt(2)], [1, 0], [-1.0, 0.0, 1.0], ), ( - "QubitStateVector", + "StatePrep", [0, 1 / np.sqrt(2), 0, 1 / np.sqrt(2)], [0, 1], [0.0, -1.0, 1.0], @@ -1032,7 +1032,7 @@ def test_supported_gate_two_wires_with_parameters( @qml.qnode(qubit_device_2_wires) def circuit(): - qml.QubitStateVector(np.array([1 / 2, 0, 0, math.sqrt(3) / 2]), wires=[0, 1]) + qml.StatePrep(np.array([1 / 2, 0, 0, math.sqrt(3) / 2]), wires=[0, 1]) op(*par, wires=[0, 1]) return qml.expval(qml.PauliZ(0)), qml.expval(qml.PauliZ(1)) @@ -1066,7 +1066,7 @@ def test_supported_observable_single_wire_no_parameters( @qml.qnode(qubit_device_1_wire) def circuit(): - qml.QubitStateVector(np.array(state), wires=[0]) + qml.StatePrep(np.array(state), wires=[0]) return qml.expval(obs(wires=[0])) assert np.isclose(circuit(), expected_output, atol=tol, rtol=0) @@ -1090,7 +1090,7 @@ def test_supported_observable_single_wire_with_parameters( @qml.qnode(qubit_device_1_wire) def circuit(): - qml.QubitStateVector(np.array(state), wires=[0]) + qml.StatePrep(np.array(state), wires=[0]) return qml.expval(obs(*par, wires=[0])) assert np.isclose(circuit(), expected_output, atol=tol, rtol=0) diff --git a/tests/test_comparison.py b/tests/test_comparison.py index dda4a89c..5ccc11f8 100644 --- a/tests/test_comparison.py +++ b/tests/test_comparison.py @@ -248,7 +248,7 @@ def test_n_qubit_circuit(self, wires, lightning_qubit_dev, lightning_gpu_qubit_d def circuit(): """Prepares the equal superposition state and then applies StronglyEntanglingLayers and concludes with a simple PauliZ measurement""" - qml.QubitStateVector(vec, wires=range(wires)) + qml.StatePrep(vec, wires=range(wires)) qml.StronglyEntanglingLayers(w, wires=range(wires)) return qml.expval(qml.PauliZ(0)) diff --git a/tests/test_gates.py b/tests/test_gates.py index 254ac5ee..cb970937 100644 --- a/tests/test_gates.py +++ b/tests/test_gates.py @@ -96,7 +96,7 @@ def test_gate_unitary_correct(op, op_name): """Test if lightning.gpu correctly applies gates by reconstructing the unitary matrix and comparing to the expected version""" - if op_name in ("BasisState", "QubitStateVector"): + if op_name in ("BasisState", "StatePrep"): pytest.skip("Skipping operation because it is a state preparation") if op == None: @@ -131,7 +131,7 @@ def test_inverse_unitary_correct(op, op_name): """Test if lightning.gpu correctly applies inverse gates by reconstructing the unitary matrix and comparing to the expected version""" - if op_name in ("BasisState", "QubitStateVector"): + if op_name in ("BasisState", "StatePrep"): pytest.skip("Skipping operation because it is a state preparation") if op == None: pytest.skip("Skipping operation.") From fa4269b2792f8456b2b54e6775490c7b26a7b28c Mon Sep 17 00:00:00 2001 From: Shuli Shu <08cnbj@gmail.com> Date: Mon, 21 Aug 2023 10:09:43 -0700 Subject: [PATCH 06/12] default.qubit as bench --- tests/test_comparison.py | 54 ++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/tests/test_comparison.py b/tests/test_comparison.py index 5ccc11f8..75f3c90a 100644 --- a/tests/test_comparison.py +++ b/tests/test_comparison.py @@ -67,7 +67,7 @@ def one_qubit_block(wires=None): qml.PauliX(wires=wires) -@pytest.mark.usefixtures("lightning_qubit_dev", "lightning_gpu_qubit_dev") +@pytest.mark.usefixtures("default_qubit_dev", "lightning_gpu_qubit_dev") class TestComparison: """A test that compares the output states of ``lightning.gpu`` and ``default.qubit`` for a variety of different circuits. This uses ``default.qubit`` as a gold standard to compare @@ -76,7 +76,7 @@ class TestComparison: @pytest.mark.parametrize("basis_state", itertools.product(*[(0, 1)] * 1)) @pytest.mark.parametrize("wires", [1]) def test_one_qubit_circuit( - self, wires, lightning_qubit_dev, lightning_gpu_qubit_dev, basis_state + self, wires, default_qubit_dev, lightning_gpu_qubit_dev, basis_state ): """Test a single-qubit circuit""" @@ -87,11 +87,11 @@ def circuit(): one_qubit_block(wires=0) return qml.expval(qml.PauliZ(0)) - lightning = qml.QNode(circuit, lightning_qubit_dev) + default = qml.QNode(circuit, default_qubit_dev) lightninggpu = qml.QNode(circuit, lightning_gpu_qubit_dev) - lightning() - lightning_state = lightning_qubit_dev.state + default() + default_state = default_qubit_dev.state lightninggpu() @@ -100,12 +100,12 @@ def circuit(): ) lightning_gpu_qubit_dev.syncD2H(lightninggpu_state) # Copy GPU data to CPU - assert np.allclose(lightning_state, lightninggpu_state) + assert np.allclose(default_state, lightninggpu_state) @pytest.mark.parametrize("basis_state", itertools.product(*[(0, 1)] * 2)) @pytest.mark.parametrize("wires", [2]) def test_two_qubit_circuit( - self, wires, lightning_qubit_dev, lightning_gpu_qubit_dev, basis_state + self, wires, default_qubit_dev, lightning_gpu_qubit_dev, basis_state ): """Test a two-qubit circuit""" @@ -126,11 +126,11 @@ def circuit(): qml.CRot(0.2, 0.3, 0.7, wires=[0, 1]) return qml.expval(qml.PauliZ(0)) - lightning = qml.QNode(circuit, lightning_qubit_dev) + default = qml.QNode(circuit, default_qubit_dev) lightninggpu = qml.QNode(circuit, lightning_gpu_qubit_dev) - lightning() - lightning_state = lightning_qubit_dev.state + default() + default_state = default_qubit_dev.state lightninggpu() lightninggpu_state = np.zeros(2**lightning_gpu_qubit_dev.num_wires).astype( @@ -138,12 +138,12 @@ def circuit(): ) lightning_gpu_qubit_dev.syncD2H(lightninggpu_state) # Copy GPU data to CPU - assert np.allclose(lightning_state, lightninggpu_state) + assert np.allclose(default_state, lightninggpu_state) @pytest.mark.parametrize("basis_state", itertools.product(*[(0, 1)] * 3)) @pytest.mark.parametrize("wires", [3]) def test_three_qubit_circuit( - self, wires, lightning_qubit_dev, lightning_gpu_qubit_dev, basis_state + self, wires, default_qubit_dev, lightning_gpu_qubit_dev, basis_state ): """Test a three-qubit circuit""" @@ -172,11 +172,11 @@ def circuit(): qml.Toffoli(wires=[2, 1, 0]) return qml.expval(qml.PauliZ(0)) - lightning = qml.QNode(circuit, lightning_qubit_dev) + default = qml.QNode(circuit, default_qubit_dev) lightninggpu = qml.QNode(circuit, lightning_gpu_qubit_dev) - lightning() - lightning_state = lightning_qubit_dev.state + default() + default_state = default_qubit_dev.state lightninggpu() lightninggpu_state = np.zeros(2**lightning_gpu_qubit_dev.num_wires).astype( @@ -184,12 +184,12 @@ def circuit(): ) lightning_gpu_qubit_dev.syncD2H(lightninggpu_state) # Copy GPU data to CPU - assert np.allclose(lightning_state, lightninggpu_state) + assert np.allclose(default_state, lightninggpu_state) @pytest.mark.parametrize("basis_state", itertools.product(*[(0, 1)] * 4)) @pytest.mark.parametrize("wires", [4]) def test_four_qubit_circuit( - self, wires, lightning_qubit_dev, lightning_gpu_qubit_dev, basis_state + self, wires, default_qubit_dev, lightning_gpu_qubit_dev, basis_state ): """Test a four-qubit circuit""" @@ -223,11 +223,11 @@ def circuit(): qml.Toffoli(wires=[2, 1, 0]) return qml.expval(qml.PauliZ(0)) - lightning = qml.QNode(circuit, lightning_qubit_dev) + default = qml.QNode(circuit, default_qubit_dev) lightninggpu = qml.QNode(circuit, lightning_gpu_qubit_dev) - lightning() - lightning_state = lightning_qubit_dev.state + default() + default_state = default_qubit_dev.state lightninggpu() lightninggpu_state = np.zeros(2**lightning_gpu_qubit_dev.num_wires).astype( @@ -235,13 +235,13 @@ def circuit(): ) lightning_gpu_qubit_dev.syncD2H(lightninggpu_state) # Copy GPU data to CPU - assert np.allclose(lightning_state, lightninggpu_state) + assert np.allclose(default_state, lightninggpu_state) @pytest.mark.parametrize("wires", range(1, 17)) - def test_n_qubit_circuit(self, wires, lightning_qubit_dev, lightning_gpu_qubit_dev): + def test_n_qubit_circuit(self, wires, default_qubit_dev, lightning_gpu_qubit_dev): """Test an n-qubit circuit""" - vec = np.array([1] * (2**wires)) / np.sqrt(2**wires) + vec = np.array([1 + 0.0j] * (2**wires)) / np.sqrt(2**wires) shape = qml.StronglyEntanglingLayers.shape(2, wires) w = np.random.uniform(high=2 * np.pi, size=shape) @@ -252,11 +252,11 @@ def circuit(): qml.StronglyEntanglingLayers(w, wires=range(wires)) return qml.expval(qml.PauliZ(0)) - lightning = qml.QNode(circuit, lightning_qubit_dev) + default = qml.QNode(circuit, default_qubit_dev) lightninggpu = qml.QNode(circuit, lightning_gpu_qubit_dev) - lightning() - lightning_state = lightning_qubit_dev.state + default() + default_state = default_qubit_dev.state lightninggpu() lightninggpu_state = np.zeros(2**lightning_gpu_qubit_dev.num_wires).astype( @@ -264,4 +264,4 @@ def circuit(): ) lightning_gpu_qubit_dev.syncD2H(lightninggpu_state) # Copy GPU data to CPU - assert np.allclose(lightning_state, lightninggpu_state) + assert np.allclose(default_state, lightninggpu_state) From 03ba200cb7b00d4f7e6d51ec7960ba649b4cdbfb Mon Sep 17 00:00:00 2001 From: Shuli Shu <08cnbj@gmail.com> Date: Mon, 21 Aug 2023 10:21:05 -0700 Subject: [PATCH 07/12] add changelog --- .github/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index ff71776f..7435e63b 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -6,6 +6,9 @@ [(#127)] (https://github.com/PennyLaneAI/pennylane-lightning-gpu/pull/127) ### Breaking changes + + * Rename `QubistStateVector` to `StatePrep` in the `LightningGPU` class. + [#134] (https://github.com/PennyLaneAI/pennylane-lightning-gpu/pull/134) * Remove suport for Python 3.9. [(#135)](https://github.com/PennyLaneAI/pennylane-lightning-gpu/pull/135) From 590fcdfb9d29cbb7976624d9bc193c05c8b8198e Mon Sep 17 00:00:00 2001 From: Lee James O'Riordan Date: Tue, 22 Aug 2023 13:49:09 -0400 Subject: [PATCH 08/12] Update .github/CHANGELOG.md Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com> --- .github/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index 7435e63b..2ef077c2 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -10,7 +10,7 @@ * Rename `QubistStateVector` to `StatePrep` in the `LightningGPU` class. [#134] (https://github.com/PennyLaneAI/pennylane-lightning-gpu/pull/134) -* Remove suport for Python 3.9. +* Remove support for Python 3.8. [(#135)](https://github.com/PennyLaneAI/pennylane-lightning-gpu/pull/135) ### Improvements From 5cc5921cd7fd94867f71ef998b09ba5f312391d5 Mon Sep 17 00:00:00 2001 From: Lee James O'Riordan Date: Tue, 22 Aug 2023 13:49:16 -0400 Subject: [PATCH 09/12] Update .github/CHANGELOG.md Co-authored-by: Vincent Michaud-Rioux --- .github/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index 2ef077c2..fa0f3158 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -7,7 +7,7 @@ ### Breaking changes - * Rename `QubistStateVector` to `StatePrep` in the `LightningGPU` class. + * Rename `QubitStateVector` to `StatePrep` in the `LightningGPU` class. [#134] (https://github.com/PennyLaneAI/pennylane-lightning-gpu/pull/134) * Remove support for Python 3.8. From bb1733743bc7e34f5dc547e33416e0e193ac9ff2 Mon Sep 17 00:00:00 2001 From: "Lee J. O'Riordan" Date: Tue, 22 Aug 2023 13:50:20 -0400 Subject: [PATCH 10/12] Ensure QSB still remains in ops --- pennylane_lightning_gpu/lightning_gpu.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pennylane_lightning_gpu/lightning_gpu.py b/pennylane_lightning_gpu/lightning_gpu.py index 3313a77e..8112d569 100644 --- a/pennylane_lightning_gpu/lightning_gpu.py +++ b/pennylane_lightning_gpu/lightning_gpu.py @@ -27,6 +27,7 @@ math, QubitDevice, BasisState, + QubitStateVector, StatePrep, DeviceError, Projector, From 6121c1bc8c0544d0057f355c4c331bf1d38854ba Mon Sep 17 00:00:00 2001 From: "Lee J. O'Riordan" Date: Tue, 22 Aug 2023 14:23:22 -0400 Subject: [PATCH 11/12] Attempt to force PL 0.32-dev5 for testing --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a2bd7e95..ed78872d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,7 +99,7 @@ FetchContent_MakeAvailable(pybind11) # Add PennyLane-Lightning if (NOT DEFINED LIGHTNING_RELEASE_TAG) - set(LIGHTNING_RELEASE_TAG "latest_release") + set(LIGHTNING_RELEASE_TAG "v0.31.0") endif() # Disable non-required lengthy build-steps from PennyLane Lightning From 07dfa3f56d59d083e78898ae461649ec6955e567 Mon Sep 17 00:00:00 2001 From: "Lee J. O'Riordan" Date: Tue, 22 Aug 2023 14:35:00 -0400 Subject: [PATCH 12/12] Attempt to force PL 0.32-dev5 for testing --- .github/workflows/tests_linux_x86.yml | 2 +- .github/workflows/tests_linux_x86_mpich.yml | 2 +- .github/workflows/tests_linux_x86_openmpi.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests_linux_x86.yml b/.github/workflows/tests_linux_x86.yml index bd07c6f6..90015fb4 100644 --- a/.github/workflows/tests_linux_x86.yml +++ b/.github/workflows/tests_linux_x86.yml @@ -259,7 +259,7 @@ jobs: python -m pip install pip~=22.0 python -m pip install ninja cmake custatevec-cu11 pytest pytest-mock flaky pytest-cov # Sync with latest master branches - python -m pip install --index-url https://test.pypi.org/simple/ pennylane-lightning --pre --force-reinstall --no-deps + python -m pip install --index-url https://test.pypi.org/simple/ pennylane-lightning==0.32.0.dev5 --pre --force-reinstall --no-deps - name: Build and install package env: diff --git a/.github/workflows/tests_linux_x86_mpich.yml b/.github/workflows/tests_linux_x86_mpich.yml index 9a9bf2b4..d8ae0782 100644 --- a/.github/workflows/tests_linux_x86_mpich.yml +++ b/.github/workflows/tests_linux_x86_mpich.yml @@ -275,7 +275,7 @@ jobs: python -m pip install pip~=22.0 python -m pip install ninja cmake custatevec-cu11 pytest pytest-mock flaky pytest-cov mpi4py # Sync with latest master branches - python -m pip install --index-url https://test.pypi.org/simple/ pennylane-lightning --pre --force-reinstall --no-deps + python -m pip install --index-url https://test.pypi.org/simple/ pennylane-lightning==0.32.0.dev5 --pre --force-reinstall --no-deps - name: Build and install package (MPICH backend) env: diff --git a/.github/workflows/tests_linux_x86_openmpi.yml b/.github/workflows/tests_linux_x86_openmpi.yml index d19345e7..916f0d93 100644 --- a/.github/workflows/tests_linux_x86_openmpi.yml +++ b/.github/workflows/tests_linux_x86_openmpi.yml @@ -247,7 +247,7 @@ jobs: python -m pip install pip~=22.0 python -m pip install ninja cmake custatevec-cu11 pytest pytest-mock flaky pytest-cov mpi4py # Sync with latest master branches - python -m pip install --index-url https://test.pypi.org/simple/ pennylane-lightning --pre --force-reinstall --no-deps + python -m pip install --index-url https://test.pypi.org/simple/ pennylane-lightning==0.32.0.dev5 --pre --force-reinstall --no-deps - name: Build and install package (OpenMPI backend) env: