From ca59371ee331af92694e2aee173fb4343a7cf31a Mon Sep 17 00:00:00 2001 From: andrijapau Date: Tue, 5 Nov 2024 16:44:18 -0500 Subject: [PATCH 1/7] remove code instances and update changelogs --- doc/development/deprecations.rst | 11 +++++------ doc/releases/changelog-dev.md | 3 +++ pennylane/data/attributes/operator/operator.py | 1 - pennylane/devices/_qubit_device.py | 2 +- pennylane/devices/default_mixed.py | 1 - pennylane/devices/tests/test_gates.py | 1 - pennylane/ops/functions/is_commuting.py | 1 - pennylane/ops/qubit/__init__.py | 1 - pennylane/ops/qubit/attributes.py | 1 - pennylane/ops/qubit/state_preparation.py | 17 ----------------- tests/default_qubit_legacy.py | 1 - tests/ops/functions/conftest.py | 1 - tests/ops/qubit/test_attributes.py | 1 - tests/ops/qubit/test_state_prep.py | 6 ------ 14 files changed, 9 insertions(+), 39 deletions(-) diff --git a/doc/development/deprecations.rst b/doc/development/deprecations.rst index bcf937dd6bd..b5ccf983a09 100644 --- a/doc/development/deprecations.rst +++ b/doc/development/deprecations.rst @@ -70,12 +70,6 @@ Pending deprecations * The :class:`~pennylane.BasisStatePreparation` template is deprecated. Instead, use :class:`~pennylane.BasisState`. -* The ``QubitStateVector`` template is deprecated. - Instead, use ``StatePrep``. - - - Deprecated in v0.39 - - Will be removed in v0.40 - New operator arithmetic deprecations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -131,6 +125,11 @@ Other deprecations Completed deprecation cycles ---------------------------- +* The ``QubitStateVector`` template has been removed. Instead, use ``StatePrep``. + + - Deprecated in v0.39 + - Will be removed in v0.40 + * The ``simplify`` argument in ``qml.Hamiltonian`` and ``qml.ops.LinearCombination`` has been removed. Instead, ``qml.simplify()`` can be called on the constructed operator. diff --git a/doc/releases/changelog-dev.md b/doc/releases/changelog-dev.md index 227a622e833..759d772deaa 100644 --- a/doc/releases/changelog-dev.md +++ b/doc/releases/changelog-dev.md @@ -28,6 +28,9 @@

Breaking changes 💔

+* The ``QubitStateVector`` template has been removed. Instead, use ``StatePrep``. + [(#)]() +

Deprecations 👋

Documentation 📝

diff --git a/pennylane/data/attributes/operator/operator.py b/pennylane/data/attributes/operator/operator.py index 9929c839d9f..1a048c0c280 100644 --- a/pennylane/data/attributes/operator/operator.py +++ b/pennylane/data/attributes/operator/operator.py @@ -127,7 +127,6 @@ def supported_ops(cls) -> frozenset[Type[Operator]]: qml.SpecialUnitary, # pennylane/ops/state_preparation.py qml.BasisState, - qml.QubitStateVector, qml.StatePrep, qml.QubitDensityMatrix, # pennylane/ops/qutrit/matrix_obs.py diff --git a/pennylane/devices/_qubit_device.py b/pennylane/devices/_qubit_device.py index 2a61d22679d..1bb2be4e4de 100644 --- a/pennylane/devices/_qubit_device.py +++ b/pennylane/devices/_qubit_device.py @@ -1706,7 +1706,7 @@ def adjoint_jacobian( ) ops = op.decomposition() expanded_ops.extend(reversed(ops)) - elif op.name not in ("StatePrep", "QubitStateVector", "BasisState", "Snapshot"): + elif op.name not in ("StatePrep", "BasisState", "Snapshot"): expanded_ops.append(op) trainable_params = [] diff --git a/pennylane/devices/default_mixed.py b/pennylane/devices/default_mixed.py index 7253884a4e7..0cbd4cc72a7 100644 --- a/pennylane/devices/default_mixed.py +++ b/pennylane/devices/default_mixed.py @@ -96,7 +96,6 @@ class DefaultMixed(QubitDevice): "Identity", "Snapshot", "BasisState", - "QubitStateVector", "StatePrep", "QubitDensityMatrix", "QubitUnitary", diff --git a/pennylane/devices/tests/test_gates.py b/pennylane/devices/tests/test_gates.py index 7c38f9b1938..34e85d2ec8c 100644 --- a/pennylane/devices/tests/test_gates.py +++ b/pennylane/devices/tests/test_gates.py @@ -68,7 +68,6 @@ "CPhaseShift00": qml.CPhaseShift00(0, wires=[0, 1]), "CPhaseShift01": qml.CPhaseShift01(0, wires=[0, 1]), "CPhaseShift10": qml.CPhaseShift10(0, wires=[0, 1]), - "QubitStateVector": qml.QubitStateVector(np.array([1.0, 0.0]), wires=[0]), "StatePrep": qml.StatePrep(np.array([1.0, 0.0]), wires=[0]), "QubitDensityMatrix": qml.QubitDensityMatrix(np.array([[0.5, 0.0], [0, 0.5]]), wires=[0]), "QubitUnitary": qml.QubitUnitary(np.eye(2), wires=[0]), diff --git a/pennylane/ops/functions/is_commuting.py b/pennylane/ops/functions/is_commuting.py index 97367963b9a..737f3221492 100644 --- a/pennylane/ops/functions/is_commuting.py +++ b/pennylane/ops/functions/is_commuting.py @@ -262,7 +262,6 @@ def check_commutation_two_non_simplified_rotations(operation1, operation2): ] non_commuting_operations = [ # StatePrepBase - "QubitStateVector", "StatePrep", "BasisState", # Templates diff --git a/pennylane/ops/qubit/__init__.py b/pennylane/ops/qubit/__init__.py index ac9e7be546c..9c0172c7384 100644 --- a/pennylane/ops/qubit/__init__.py +++ b/pennylane/ops/qubit/__init__.py @@ -82,7 +82,6 @@ "IsingXY", "BasisState", "StatePrep", - "QubitStateVector", "QubitDensityMatrix", "QubitUnitary", "BlockEncode", diff --git a/pennylane/ops/qubit/attributes.py b/pennylane/ops/qubit/attributes.py index 7690ca0cf78..401c81b155e 100644 --- a/pennylane/ops/qubit/attributes.py +++ b/pennylane/ops/qubit/attributes.py @@ -247,7 +247,6 @@ def __contains__(self, obj): "DoubleExcitationMinus", "OrbitalRotation", "FermionicSWAP", - "QubitStateVector", "StatePrep", "AmplitudeEmbedding", "AngleEmbedding", diff --git a/pennylane/ops/qubit/state_preparation.py b/pennylane/ops/qubit/state_preparation.py index cdecebe515e..04a4ac8cc66 100644 --- a/pennylane/ops/qubit/state_preparation.py +++ b/pennylane/ops/qubit/state_preparation.py @@ -15,8 +15,6 @@ This submodule contains the discrete-variable quantum operations concerned with preparing a certain state on the device. """ -import warnings - # pylint:disable=too-many-branches,abstract-method,arguments-differ,protected-access,no-member from typing import Optional @@ -443,21 +441,6 @@ def _preprocess(state, wires, pad_with, normalize, validate_norm): return state -class QubitStateVector(StatePrep): - r""" - ``QubitStateVector`` is deprecated and will be removed in version 0.40. Instead, please use ``StatePrep``. - """ - - # pylint: disable=too-many-arguments - def __init__(self, state, wires, pad_with=None, normalize=False, validate_norm=True): - warnings.warn( - "QubitStateVector is deprecated and will be removed in version 0.40. " - "Instead, please use StatePrep.", - qml.PennyLaneDeprecationWarning, - ) - super().__init__(state, wires, pad_with, normalize, validate_norm) - - class QubitDensityMatrix(Operation): r"""QubitDensityMatrix(state, wires) Prepare subsystems using the given density matrix. diff --git a/tests/default_qubit_legacy.py b/tests/default_qubit_legacy.py index 66212c2b7a9..183f56c3df5 100644 --- a/tests/default_qubit_legacy.py +++ b/tests/default_qubit_legacy.py @@ -115,7 +115,6 @@ class DefaultQubitLegacy(QubitDevice): "Snapshot", "BasisState", "StatePrep", - "QubitStateVector", "QubitUnitary", "ControlledQubitUnitary", "BlockEncode", diff --git a/tests/ops/functions/conftest.py b/tests/ops/functions/conftest.py index 49a0dd02e8a..5e06a1c8e59 100644 --- a/tests/ops/functions/conftest.py +++ b/tests/ops/functions/conftest.py @@ -147,7 +147,6 @@ PowOpObs, PowOperation, PowObs, - qml.QubitStateVector, } """Types that should not have actual instances created.""" diff --git a/tests/ops/qubit/test_attributes.py b/tests/ops/qubit/test_attributes.py index fd20efacc13..9808c07d71d 100644 --- a/tests/ops/qubit/test_attributes.py +++ b/tests/ops/qubit/test_attributes.py @@ -137,7 +137,6 @@ def test_tensor_check(self): "SpecialUnitary", "PauliRot", "MultiRZ", - "QubitStateVector", "StatePrep", "AmplitudeEmbedding", "AngleEmbedding", diff --git a/tests/ops/qubit/test_state_prep.py b/tests/ops/qubit/test_state_prep.py index e6da832a8eb..342aaff5df0 100644 --- a/tests/ops/qubit/test_state_prep.py +++ b/tests/ops/qubit/test_state_prep.py @@ -36,12 +36,6 @@ def test_adjoint_error_exception(op): op.adjoint() -def test_QubitStateVector_is_deprecated(): - """Test that QubitStateVector is deprecated.""" - with pytest.warns(qml.PennyLaneDeprecationWarning, match="QubitStateVector is deprecated"): - _ = qml.QubitStateVector([1, 0, 0, 0], wires=[0, 1]) - - @pytest.mark.parametrize( "op, mat, base", [ From bd183fcb97becdfdbd01a927972dba982770cd0e Mon Sep 17 00:00:00 2001 From: andrijapau Date: Tue, 5 Nov 2024 17:06:31 -0500 Subject: [PATCH 2/7] update changelog and wording --- doc/development/deprecations.rst | 2 +- doc/releases/changelog-dev.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/development/deprecations.rst b/doc/development/deprecations.rst index b5ccf983a09..590e6118822 100644 --- a/doc/development/deprecations.rst +++ b/doc/development/deprecations.rst @@ -128,7 +128,7 @@ Completed deprecation cycles * The ``QubitStateVector`` template has been removed. Instead, use ``StatePrep``. - Deprecated in v0.39 - - Will be removed in v0.40 + - Removed in v0.40 * The ``simplify`` argument in ``qml.Hamiltonian`` and ``qml.ops.LinearCombination`` has been removed. Instead, ``qml.simplify()`` can be called on the constructed operator. diff --git a/doc/releases/changelog-dev.md b/doc/releases/changelog-dev.md index 759d772deaa..04a00d4af82 100644 --- a/doc/releases/changelog-dev.md +++ b/doc/releases/changelog-dev.md @@ -29,7 +29,7 @@

Breaking changes 💔

* The ``QubitStateVector`` template has been removed. Instead, use ``StatePrep``. - [(#)]() + [(#6525)](https://github.com/PennyLaneAI/pennylane/pull/6525)

Deprecations 👋

From 4b558478845e0bfdd6ea5c4e1db75df097bad34e Mon Sep 17 00:00:00 2001 From: Andrija Paurevic <46359773+andrijapau@users.noreply.github.com> Date: Fri, 8 Nov 2024 09:26:55 -0500 Subject: [PATCH 3/7] Update doc/releases/changelog-dev.md Co-authored-by: Mudit Pandey --- doc/releases/changelog-dev.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/releases/changelog-dev.md b/doc/releases/changelog-dev.md index 4b66a992f4e..7d79e71b0ec 100644 --- a/doc/releases/changelog-dev.md +++ b/doc/releases/changelog-dev.md @@ -39,7 +39,7 @@

Breaking changes 💔

-* The ``QubitStateVector`` template has been removed. Instead, use ``StatePrep``. +* The `qml.QubitStateVector` template has been removed. Instead, use `qml.StatePrep`. [(#6525)](https://github.com/PennyLaneAI/pennylane/pull/6525)

Deprecations 👋

From 2e1618777c4fa6b29ddf5328b913838cb7de3cbd Mon Sep 17 00:00:00 2001 From: Andrija Paurevic <46359773+andrijapau@users.noreply.github.com> Date: Fri, 8 Nov 2024 09:27:03 -0500 Subject: [PATCH 4/7] Update doc/development/deprecations.rst Co-authored-by: Mudit Pandey --- doc/development/deprecations.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/development/deprecations.rst b/doc/development/deprecations.rst index 66af0c9cfa9..acee4973b8a 100644 --- a/doc/development/deprecations.rst +++ b/doc/development/deprecations.rst @@ -123,7 +123,7 @@ Other deprecations Completed deprecation cycles ---------------------------- -* The ``QubitStateVector`` template has been removed. Instead, use ``StatePrep``. +* The ``qml.QubitStateVector`` template has been removed. Instead, use :class:`~pennylane.StatePrep`. - Deprecated in v0.39 - Removed in v0.40 From aa3f6c310fb3b7ee5afa5ac9a43ba51748340f0c Mon Sep 17 00:00:00 2001 From: andrijapau Date: Tue, 12 Nov 2024 16:05:12 -0500 Subject: [PATCH 5/7] oops forgot to remove qubitstatevector from pending dep --- doc/development/deprecations.rst | 6 ------ 1 file changed, 6 deletions(-) diff --git a/doc/development/deprecations.rst b/doc/development/deprecations.rst index f0a38646ab1..199d023b1ee 100644 --- a/doc/development/deprecations.rst +++ b/doc/development/deprecations.rst @@ -45,12 +45,6 @@ Pending deprecations - Deprecated in v0.39 - Will be removed in v0.40 -* The ``QubitStateVector`` template is deprecated. - Instead, use ``StatePrep``. - - - Deprecated in v0.39 - - Will be removed in v0.40 - New operator arithmetic deprecations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From 8ec7ed8434637aa158e1b31773a34b0b5e5ed19b Mon Sep 17 00:00:00 2001 From: andrijapau Date: Tue, 12 Nov 2024 16:07:21 -0500 Subject: [PATCH 6/7] add back qml.StatePrep --- tests/ops/functions/conftest.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/ops/functions/conftest.py b/tests/ops/functions/conftest.py index 5e06a1c8e59..6f174cafb51 100644 --- a/tests/ops/functions/conftest.py +++ b/tests/ops/functions/conftest.py @@ -147,6 +147,7 @@ PowOpObs, PowOperation, PowObs, + qml.StatePrep, } """Types that should not have actual instances created.""" From 257b2fe869e1bc4bc1799946ff14cf9833e310e3 Mon Sep 17 00:00:00 2001 From: andrijapau Date: Thu, 14 Nov 2024 14:12:00 -0500 Subject: [PATCH 7/7] update interface-unit-tests to use latest pennylane-qiskit --- .github/workflows/interface-unit-tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/interface-unit-tests.yml b/.github/workflows/interface-unit-tests.yml index 4ab324b7471..814772a5d6b 100644 --- a/.github/workflows/interface-unit-tests.yml +++ b/.github/workflows/interface-unit-tests.yml @@ -470,7 +470,8 @@ jobs: pytest_markers: external pytest_additional_args: --disable-opmath=${{ inputs.disable_new_opmath }} -W ${{ inputs.python_warning_level }} ${{ inputs.python_warning_level != 'default' && '--continue-on-collection-errors' || '' }} additional_pip_packages: | - pyzx matplotlib stim quimb mitiq pennylane-qiskit ply + pyzx matplotlib stim quimb mitiq ply + git+https://github.com/PennyLaneAI/pennylane-qiskit.git@master ${{ needs.default-dependency-versions.outputs.jax-version }} ${{ needs.default-dependency-versions.outputs.tensorflow-version }} ${{ inputs.additional_python_packages }}