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
3 changes: 2 additions & 1 deletion .github/workflows/interface-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
6 changes: 6 additions & 0 deletions doc/development/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ Completed deprecation cycles
- Deprecated in v0.39
- Removed in v0.40


* The ``qml.QubitStateVector`` template has been removed. Instead, use :class:`~pennylane.StatePrep`.

- Deprecated in v0.39
- Removed in v0.40

* ``qml.broadcast`` has been removed. Users should use ``for`` loops instead.

- Deprecated in v0.39
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 @@ -78,6 +78,9 @@
process the diff method.
[(#6535)](https://github.com/PennyLaneAI/pennylane/pull/6535)

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

* `qml.broadcast` has been removed. Users should use `for` loops instead.
[(#6527)](https://github.com/PennyLaneAI/pennylane/pull/6527)

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
2 changes: 1 addition & 1 deletion tests/ops/functions/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
PowOpObs,
PowOperation,
PowObs,
qml.QubitStateVector,
qml.StatePrep,
}
"""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