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 QubitStateVector class #6525

Merged
merged 11 commits into from
Nov 14, 2024
5 changes: 5 additions & 0 deletions doc/development/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ Other deprecations
Completed deprecation cycles
----------------------------

* The ``QubitStateVector`` template has been removed. Instead, use ``StatePrep``.
andrijapau marked this conversation as resolved.
Show resolved Hide resolved

- Deprecated in v0.39
- 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.

Expand Down
3 changes: 3 additions & 0 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@

<h3>Breaking changes 💔</h3>

* The ``QubitStateVector`` template has been removed. Instead, use ``StatePrep``.
andrijapau marked this conversation as resolved.
Show resolved Hide resolved
[(#6525)](https://github.com/PennyLaneAI/pennylane/pull/6525)

<h3>Deprecations 👋</h3>

<h3>Documentation 📝</h3>
Expand Down
1 change: 0 additions & 1 deletion pennylane/data/attributes/operator/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pennylane/devices/_qubit_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
1 change: 0 additions & 1 deletion pennylane/devices/default_mixed.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ class DefaultMixed(QubitDevice):
"Identity",
"Snapshot",
"BasisState",
"QubitStateVector",
"StatePrep",
"QubitDensityMatrix",
"QubitUnitary",
Expand Down
1 change: 0 additions & 1 deletion pennylane/devices/tests/test_gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]),
Expand Down
1 change: 0 additions & 1 deletion pennylane/ops/functions/is_commuting.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ def check_commutation_two_non_simplified_rotations(operation1, operation2):
]
non_commuting_operations = [
# StatePrepBase
"QubitStateVector",
"StatePrep",
"BasisState",
# Templates
Expand Down
1 change: 0 additions & 1 deletion pennylane/ops/qubit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
"IsingXY",
"BasisState",
"StatePrep",
"QubitStateVector",
"QubitDensityMatrix",
"QubitUnitary",
"BlockEncode",
Expand Down
1 change: 0 additions & 1 deletion pennylane/ops/qubit/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ def __contains__(self, obj):
"DoubleExcitationMinus",
"OrbitalRotation",
"FermionicSWAP",
"QubitStateVector",
"StatePrep",
"AmplitudeEmbedding",
"AngleEmbedding",
Expand Down
17 changes: 0 additions & 17 deletions pennylane/ops/qubit/state_preparation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion tests/default_qubit_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ class DefaultQubitLegacy(QubitDevice):
"Snapshot",
"BasisState",
"StatePrep",
"QubitStateVector",
"QubitUnitary",
"ControlledQubitUnitary",
"BlockEncode",
Expand Down
1 change: 0 additions & 1 deletion tests/ops/functions/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@
PowOpObs,
PowOperation,
PowObs,
qml.QubitStateVector,
}
"""Types that should not have actual instances created."""

Expand Down
1 change: 0 additions & 1 deletion tests/ops/qubit/test_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ def test_tensor_check(self):
"SpecialUnitary",
"PauliRot",
"MultiRZ",
"QubitStateVector",
"StatePrep",
"AmplitudeEmbedding",
"AngleEmbedding",
Expand Down
6 changes: 0 additions & 6 deletions tests/ops/qubit/test_state_prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
[
Expand Down
Loading