Skip to content

Commit

Permalink
Merge branch 'master' into doc-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
JerryChen97 authored Nov 12, 2024
2 parents f4fee57 + e218c91 commit 36787a8
Show file tree
Hide file tree
Showing 36 changed files with 50,718 additions and 51,523 deletions.
58,082 changes: 29,196 additions & 28,886 deletions .github/durations/core_tests_durations.json

Large diffs are not rendered by default.

32,215 changes: 16,331 additions & 15,884 deletions .github/durations/jax_tests_durations.json

Large diffs are not rendered by default.

9,872 changes: 5,115 additions & 4,757 deletions .github/durations/tf_tests_durations.json

Large diffs are not rendered by default.

52 changes: 30 additions & 22 deletions doc/development/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ Pending deprecations
- Deprecated in v0.40
- Will be removed in v0.41

* The ``'ancilla'`` argument for :func:`~pennylane.iterative_qpe` has been deprecated. Instead, use the ``'aux_wire'``
argument.

- Deprecated in v0.39
- Will be removed in v0.40

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

- Deprecated in v0.39
- Will be removed in v0.40

Expand All @@ -30,26 +22,13 @@ Pending deprecations

- Deprecated in v0.39
- Will be removed in v0.40

* ``Device``, ``QubitDevice``, and ``QutritDevice`` will no longer be imported top level in v0.40. They instead
will be available as ``qml.devices.LegacyDevice``, ``qml.devices.QubitDevice``, and ``qml.devices.QutritDevice``
respectively.

- Deprecated top level access in v0.39
- Top level access will be removed in v0.40

* ``QNode.gradient_fn`` is deprecated. Please use ``QNode.diff_method`` instead. ``QNode.get_gradient_fn`` can also be used to
process the diff method.

- Deprecated in v0.39
- Will be removed in v0.40

* The :class:`~pennylane.BasisStatePreparation` template is deprecated.
Instead, use :class:`~pennylane.BasisState`.

- Deprecated in v0.39
- Will be removed in v0.40

* The ``QubitStateVector`` template is deprecated.
Instead, use ``StatePrep``.

Expand Down Expand Up @@ -111,17 +90,46 @@ Other deprecations
Completed deprecation cycles
----------------------------

* The :class:`~pennylane.BasisStatePreparation` template has been removed.
Instead, use :class:`~pennylane.BasisState`.

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

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

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

* The ``max_expansion`` argument for :func:`~pennylane.transforms.decompositions.clifford_t_decomposition`
has been removed.

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

* The ``'ancilla'`` argument for :func:`~pennylane.iterative_qpe` has been removed. Instead, use the ``'aux_wire'``
argument.

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

* The ``expand_depth`` argument for :func:`~pennylane.transforms.compile` has been removed.

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

* The ``qml.workflow.set_shots`` helper function has been removed. We no longer interact with the legacy device interface in our code.
Instead, shots should be specified on the tape, and the device should use these shots.

- Deprecated in v0.38
- Removed in v0.40

* ``QNode.gradient_fn`` is removed. Please use ``QNode.diff_method`` instead. ``QNode.get_gradient_fn`` can also be used to
process the diff method.

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

* The ``qml.shadows.shadow_expval`` transform has been removed. Instead, please use the
``qml.shadow_expval`` measurement process.

Expand Down
52 changes: 0 additions & 52 deletions doc/introduction/templates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,6 @@ State preparation templates transform the zero state :math:`|0\dots 0 \rangle` t
state. In contrast to embeddings that can in principle be used anywhere in a circuit,
state preparation is typically used as the first operation.

.. gallery-item::
:description: :doc:`BasisStatePreparation <../code/api/pennylane.BasisStatePreparation>`
:figure: _static/templates/state_preparations/basis.png

.. gallery-item::
:description: :doc:`QutritBasisStatePreparation <../code/api/pennylane.QutritBasisStatePreparation>`
:figure: _static/templates/state_preparations/basis_qutrit.png
Expand Down Expand Up @@ -360,54 +356,6 @@ Other useful templates which do not belong to the previous categories can be fou

.. _intro_ref_temp_constr:

Broadcasting function
---------------------

PennyLane offers a broadcasting function to easily construct templates: :func:`~.broadcast`
takes either quantum gates or templates and applies them to wires in a specific pattern.

.. warning::

While the broadcasting function can make template construction very convenient, it
adds an overhead and is therefore not recommended when speed is a major concern.

.. gallery-item::
:description: :doc:`Broadcast (Single) <../code/api/pennylane.broadcast>`
:figure: _static/templates/broadcast_single.png

.. gallery-item::
:description: :doc:`Broadcast (Double) <../code/api/pennylane.broadcast>`
:figure: _static/templates/broadcast_double.png

.. gallery-item::
:description: :doc:`Broadcast (Double Odd) <../code/api/pennylane.broadcast>`
:figure: _static/templates/broadcast_double_odd.png

.. gallery-item::
:description: :doc:`Broadcast (Chain) <../code/api/pennylane.broadcast>`
:figure: _static/templates/broadcast_chain.png

.. gallery-item::
:description: :doc:`Broadcast (Ring) <../code/api/pennylane.broadcast>`
:figure: _static/templates/broadcast_ring.png

.. gallery-item::
:description: :doc:`Broadcast (Pyramid) <../code/api/pennylane.broadcast>`
:figure: _static/templates/broadcast_pyramid.png

.. gallery-item::
:description: :doc:`Broadcast (All-to-All) <../code/api/pennylane.broadcast>`
:figure: _static/templates/broadcast_alltoall.png

.. gallery-item::
:description: :doc:`Broadcast (Custom) <../code/api/pennylane.broadcast>`
:figure: _static/templates/broadcast_custom.png

.. raw:: html

<div style='clear:both'></div>

.. _intro_ref_temp_init:

Parameter initializations
-------------------------
Expand Down
24 changes: 23 additions & 1 deletion doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,23 @@

<h3>Breaking changes 💔</h3>

* The `'ancilla'` argument for `qml.iterative_qpe` has been removed. Instead, use the `'aux_wire'` argument.
[(#6532)](https://github.com/PennyLaneAI/pennylane/pull/6532)

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

* The `qml.workflow.set_shots` helper function has been removed. We no longer interact with the legacy device interface in our code.
Instead, shots should be specified on the tape, and the device should use these shots.
[(#6534)](https://github.com/PennyLaneAI/pennylane/pull/6534)

* `QNode.gradient_fn` has been removed. Please use `QNode.diff_method` instead. `QNode.get_gradient_fn` can also be used to
process the diff method.
[(#6535)](https://github.com/PennyLaneAI/pennylane/pull/6535)

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

* The `max_expansion` argument for `qml.transforms.clifford_t_decomposition` has been removed.
[(#6531)](https://github.com/PennyLaneAI/pennylane/pull/6531)

Expand Down Expand Up @@ -86,17 +103,22 @@

<h3>Bug fixes 🐛</h3>

* `qml.math.get_deep_interface` now works properly for autograd arrays.
[(#6557)](https://github.com/PennyLaneAI/pennylane/pull/6557)

* Fixed `Identity.__repr__` to return correct wires list.
[(#6506)](https://github.com/PennyLaneAI/pennylane/pull/6506)


<h3>Contributors ✍️</h3>

This release contains contributions from (in alphabetical order):

Shiwen An
Shiwen An,
Astral Cai,
Yushao Chen,
Pietropaolo Frisoni,
Austin Huang,
Christina Lee,
Andrija Paurevic,
Justin Pickering
2 changes: 1 addition & 1 deletion pennylane/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
)
from pennylane.ops import *
from pennylane.ops import adjoint, ctrl, cond, exp, sum, pow, prod, s_prod
from pennylane.templates import broadcast, layer
from pennylane.templates import layer
from pennylane.templates.embeddings import *
from pennylane.templates.layers import *
from pennylane.templates.tensornetworks import *
Expand Down
4 changes: 0 additions & 4 deletions pennylane/devices/legacy_facade.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ def _set_shots(device, shots):
>>> _set_shots(dev, shots=100)(lambda: dev.shots)()
100
"""
# note, this function duplicates qml.workflow.set_shots
# duplicated here to avoid circular dependency issues
# qml.workflow.set_shots can be independently deprecated soon
# this version of the function is private to LegacyDeviceFacade
shots = qml.measurements.Shots(shots)
shots = shots.shot_vector if shots.has_partitioned_shots else shots.total_shots
if shots == device.shots:
Expand Down
17 changes: 0 additions & 17 deletions pennylane/devices/tests/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,23 +225,6 @@ def circuit():
[math.fidelity_statevector(circuit(), exp_state)], [1.0], atol=tol(dev.shots)
)

@pytest.mark.filterwarnings(
"ignore:BasisStatePreparation is deprecated:pennylane.PennyLaneDeprecationWarning"
)
def test_BasisStatePreparation(self, device, tol):
"""Test the BasisStatePreparation template."""
dev = device(4)

@qml.qnode(dev)
def circuit(basis_state):
qml.BasisStatePreparation(basis_state, wires=range(4))
return [qml.expval(qml.Z(i)) for i in range(4)]

basis_state = [0, 1, 1, 0]
res = circuit(basis_state)
expected = [1.0, -1.0, -1.0, 1.0]
assert np.allclose(res, expected, atol=tol(dev.shots))

@pytest.mark.xfail(reason="most devices do not support CV")
def test_CVNeuralNetLayers(self, device):
"""Test the CVNeuralNetLayers template."""
Expand Down
4 changes: 2 additions & 2 deletions pennylane/math/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,9 @@ def get_deep_interface(value):
itr = value
while isinstance(itr, (list, tuple)):
if len(itr) == 0:
return "builtins"
return "numpy"
itr = itr[0]
return ar.infer_backend(itr)
return _get_interface_of_single_tensor(itr)


def is_abstract(tensor, like=None):
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 @@ -267,7 +267,6 @@ def check_commutation_two_non_simplified_rotations(operation1, operation2):
"BasisState",
# Templates
"ArbitraryStatePreparation",
"BasisStatePreparation",
"MottonenStatePreparation",
"QubitCarry",
"QubitSum",
Expand Down
31 changes: 1 addition & 30 deletions pennylane/ops/functions/iterative_qpe.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,22 @@
This module contains the qml.iterative_qpe function.
"""

from warnings import warn

import numpy as np

import pennylane as qml


def iterative_qpe(base, aux_wire="unset", iters="unset", ancilla="unset"):
def iterative_qpe(base, aux_wire, iters):
r"""Performs the `iterative quantum phase estimation <https://arxiv.org/pdf/quant-ph/0610214.pdf>`_ circuit.
Given a unitary :math:`U`, this function applies the circuit for iterative quantum phase
estimation and returns a list of mid-circuit measurements with qubit reset.
.. warning::
The ``ancilla`` argument below is deprecated and will be removed in v0.40. The ``aux_wire`` argument should be used instead. If both arguments
are provided, ``aux_wire`` will be used and ``ancilla`` will be ignored.
Args:
base (Operator): the phase estimation unitary, specified as an :class:`~.Operator`
aux_wire (Union[Wires, int, str]): the wire to be used for the estimation
iters (int): the number of measurements to be performed
ancilla (Union[Wires, int, str]): The wire to be used for the estimation. This argument
is deprecated.
Returns:
list[MidMeasureMP]: the list of measurements performed
Expand Down Expand Up @@ -83,27 +75,6 @@ def circuit():
╚══════════════════════╩═════════════════════════║═══════╡ ├Sample[MCM]
╚═══════╡ ╰Sample[MCM]
"""
missing = []
if aux_wire == "unset" and ancilla == "unset":
missing.append("'aux_wire'")
if iters == "unset":
missing.append("'iters'")

if missing:
missing_args = " and ".join(missing)
raise TypeError(
f"iterative_qpe() missing {len(missing)} required positional argument(s): {missing_args}"
)

if ancilla != "unset":
warn(
"The 'ancilla' argument for qml.iterative_qpe has been deprecated and will be removed in v0.40. "
"Please use the 'aux_wire' argument instead.",
qml.PennyLaneDeprecationWarning,
)
if aux_wire == "unset":
aux_wire = ancilla

measurements = []

for i in range(iters):
Expand Down
1 change: 0 additions & 1 deletion pennylane/templates/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
This module contains templates, which are pre-coded routines that can be used in a quantum node.
"""

from .broadcast import *
from .embeddings import *
from .layer import *
from .layers import *
Expand Down
Loading

0 comments on commit 36787a8

Please sign in to comment.