Skip to content

Commit

Permalink
Remove QubitStateVector class (#6525)
Browse files Browse the repository at this point in the history
**Context:**

Completing the deprecation cycle of `QubitStateVector`.

**Description of the Change:**

1. Update `deprecations.rst`
2. Update `changelog-dev.md`
3. Remove all deprecated source code

Also, updated CI to install *latest* `pennylane-qiskit` rather than
stable.

References found in,
- Catalyst:  PennyLaneAI/catalyst#1289
- Lightning: PennyLaneAI/pennylane-lightning#985
- AQT: PennyLaneAI/pennylane-aqt#77
- Qulacs: PennyLaneAI/pennylane-qulacs#83
- Qiskit: PennyLaneAI/pennylane-qiskit#601
- Cirq: PennyLaneAI/pennylane-cirq#203

No references found in,
- QML


[sc-77482]

---------

Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
  • Loading branch information
andrijapau and mudit2812 authored Nov 14, 2024
1 parent d27be75 commit 51c1436
Show file tree
Hide file tree
Showing 15 changed files with 13 additions and 34 deletions.
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

0 comments on commit 51c1436

Please sign in to comment.