Skip to content

Commit

Permalink
Merge branch 'master' into tree_mcm_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
obliviateandsurrender committed Sep 19, 2024
2 parents 2a4bea2 + 170109b commit 875dbbd
Show file tree
Hide file tree
Showing 75 changed files with 1,335 additions and 1,077 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/install_deps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ inputs:
jax_version:
description: The version of JAX to install for any job that requires JAX
required: false
default: '0.4.23'
default: '0.4.28'
install_tensorflow:
description: Indicate if TensorFlow should be installed or not
required: false
Expand Down Expand Up @@ -86,7 +86,7 @@ runs:
if: inputs.install_jax == 'true'
env:
JAX_VERSION: ${{ inputs.jax_version != '' && format('=={0}', inputs.jax_version) || '' }}
run: pip install "jax${{ env.JAX_VERSION}}" "jaxlib${{ env.JAX_VERSION }}" scipy~=1.12.0
run: pip install "jax${{ env.JAX_VERSION}}" "jaxlib${{ env.JAX_VERSION }}"

- name: Install additional PIP packages
shell: bash
Expand Down
11 changes: 7 additions & 4 deletions doc/code/qml_qinfo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ qml.qinfo
Overview
--------

.. warning::

The ``qinfo`` module is deprecated and scheduled to be removed in v0.40. Most quantum information transforms
are available as measurement processes (see the :mod:`~pennylane.measurements` module for more details).
Additionally, the transforms are also available as standalone functions in the :mod:`~pennylane.math` and
:mod:`~pennylane.gradients` modules.

This module provides a collection of methods to return quantum information quantities from :class:`~.QNode`
returning :func:`~pennylane.state`.

Expand All @@ -15,8 +22,4 @@ Transforms
.. automodapi:: pennylane.qinfo.transforms
:no-heading:
:no-inherited-members:
:skip: metric_tensor
:skip: adjoint_metric_tensor
:skip: transform
:skip: classical_fisher
:skip: quantum_fisher
59 changes: 51 additions & 8 deletions doc/development/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,37 @@ deprecations are listed below.
Pending deprecations
--------------------

* 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

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

- 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

* The ``qml.qinfo`` module has been deprecated. Please see the respective functions in the ``qml.math`` and ``qml.measurements``
modules instead.

- 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
we be available as ``qml.devices.LegacyDevice``, ``qml.devices.QubitDevice``, and ``qml.devices.QutritDevice``
respectively.

- Deprecated top level access in v0.39
- Top level access removed in v0.40
- 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
* ``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
Expand All @@ -27,18 +50,21 @@ Pending deprecations
- Deprecated in v0.38
- Will be removed in v0.39

* The functions ``qml.qinfo.classical_fisher`` and ``qml.qinfo.quantum_fisher`` are deprecated since they are being migrated
to the ``qml.gradients`` module. Therefore, ``qml.gradients.classical_fisher`` and ``qml.gradients.quantum_fisher`` should be used instead.

- Deprecated and Duplicated in v0.38
- Will be removed in v0.39

* The ``simplify`` argument in ``qml.Hamiltonian`` and ``qml.ops.LinearCombination`` is deprecated.
Instead, ``qml.simplify()`` can be called on the constructed operator.

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

* 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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -83,6 +109,23 @@ Other deprecations
Completed deprecation cycles
----------------------------

* The ``simplify`` argument in ``qml.Hamiltonian`` and ``qml.ops.LinearCombination`` has been removed.
Instead, ``qml.simplify()`` can be called on the constructed operator.

- Deprecated in v0.37
- Removed in v0.39

* The ``decomp_depth`` argument in ``qml.device`` is removed.

- Deprecated in v0.38
- Removed in v0.39

* The functions ``qml.qinfo.classical_fisher`` and ``qml.qinfo.quantum_fisher`` have been removed and migrated to the ``qml.gradients``
module. Therefore, ``qml.gradients.classical_fisher`` and ``qml.gradients.quantum_fisher`` should be used instead.

- Deprecated in v0.38
- Removed in v0.39

* All of the legacy devices (any with the name ``default.qubit.{autograd,torch,tf,jax,legacy}``) are removed. Use ``default.qubit`` instead,
as it supports backpropagation for the many backends the legacy devices support.

Expand Down
6 changes: 3 additions & 3 deletions doc/news/new_opmath.rst
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,10 @@ To help identify a fix, select the option below that describes your situation.
>>> qml.Hamiltonian([0.5], [X(0) @ X(1)])
0.5 * (X(0) @ X(1))

The API of :class:`~.ops.op_math.LinearCombination` is identical to that of :class:`~.Hamiltonian`. We can group observables or simplify upon initialization.
The API of :class:`~.ops.op_math.LinearCombination` is identical to that of :class:`~.Hamiltonian`. We can group observables upon initialization.

>>> H1 = qml.Hamiltonian([0.5, 0.5, 0.5], [X(0) @ X(1), X(0), Y(0)], grouping_type="qwc", simplify=True)
>>> H2 = qml.ops.LinearCombination([0.5, 0.5, 0.5], [X(0) @ X(1), X(0), Y(0)], grouping_type="qwc", simplify=True)
>>> H1 = qml.Hamiltonian([0.5, 0.5, 0.5], [X(0) @ X(1), X(0), Y(0)], grouping_type="qwc")
>>> H2 = qml.ops.LinearCombination([0.5, 0.5, 0.5], [X(0) @ X(1), X(0), Y(0)], grouping_type="qwc")
>>> H1 == H2
True

Expand Down
54 changes: 50 additions & 4 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
[(#6061)](https://github.com/PennyLaneAI/pennylane/pull/6061)
[(#6258)](https://github.com/PennyLaneAI/pennylane/pull/6258)

* PennyLane is now compatible with Jax 0.4.28.
[(#6255)](https://github.com/PennyLaneAI/pennylane/pull/6255)

* `qml.qchem.excitations` now optionally returns fermionic operators.
[(#6171)](https://github.com/PennyLaneAI/pennylane/pull/6171)

Expand Down Expand Up @@ -37,6 +40,9 @@
`from pennylane.capture.primitives import *`.
[(#6129)](https://github.com/PennyLaneAI/pennylane/pull/6129)

* `FermiWord` class now has a method to apply anti-commutator relations.
[(#6196)](https://github.com/PennyLaneAI/pennylane/pull/6196)

* `FermiWord` and `FermiSentence` classes now have methods to compute adjoints.
[(#6166)](https://github.com/PennyLaneAI/pennylane/pull/6166)

Expand All @@ -51,12 +57,23 @@
unique representation of the object.
[(#6167)](https://github.com/PennyLaneAI/pennylane/pull/6167)

* A `ReferenceQubit` is introduced for testing purposes and as a reference for future plugin development.
[(#6181)](https://github.com/PennyLaneAI/pennylane/pull/6181)

* The `to_mat` methods for `FermiWord` and `FermiSentence` now optionally return
a sparse matrix.
[(#6173)](https://github.com/PennyLaneAI/pennylane/pull/6173)

<h3>Breaking changes 💔</h3>

* The `simplify` argument in `qml.Hamiltonian` and `qml.ops.LinearCombination` has been removed.
Instead, `qml.simplify()` can be called on the constructed operator.
[(#6279)](https://github.com/PennyLaneAI/pennylane/pull/6279)

* The functions `qml.qinfo.classical_fisher` and `qml.qinfo.quantum_fisher` have been removed and migrated to the `qml.gradients`
module. Therefore, `qml.gradients.classical_fisher` and `qml.gradients.quantum_fisher` should be used instead.
[(#5911)](https://github.com/PennyLaneAI/pennylane/pull/5911)

* Remove support for Python 3.9.
[(#6223)](https://github.com/PennyLaneAI/pennylane/pull/6223)

Expand All @@ -81,12 +98,36 @@
Please use `qml.transforms.split_non_commuting` instead.
[(#6204)](https://github.com/PennyLaneAI/pennylane/pull/6204)

* The `decomp_depth` keyword argument to `qml.device` is removed.
[(#6234)](https://github.com/PennyLaneAI/pennylane/pull/6234)

* `Operator.expand` is now removed. Use `qml.tape.QuantumScript(op.deocomposition())` instead.
[(#6227)](https://github.com/PennyLaneAI/pennylane/pull/6227)


<h3>Deprecations 👋</h3>

* The `qml.BasisStatePreparation` template is deprecated.
Instead, use `qml.BasisState`.
[(#6021)](https://github.com/PennyLaneAI/pennylane/pull/6021)

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

* `qml.shadows.shadow_expval` has been deprecated. Instead, use the `qml.shadow_expval` measurement
process.
[(#6277)](https://github.com/PennyLaneAI/pennylane/pull/6277)

* `qml.broadcast` has been deprecated. Please use `for` loops instead.
[(#6277)](https://github.com/PennyLaneAI/pennylane/pull/6277)

* The `qml.QubitStateVector` template is deprecated. Instead, use `qml.StatePrep`.
[(#6172)](https://github.com/PennyLaneAI/pennylane/pull/6172)

* The `qml.qinfo` module has been deprecated. Please see the respective functions in the `qml.math` and
`qml.measurements` modules instead.
[(#5911)](https://github.com/PennyLaneAI/pennylane/pull/5911)

* `Device`, `QubitDevice`, and `QutritDevice` will no longer be accessible via top-level import in v0.40.
They will still be accessible as `qml.devices.LegacyDevice`, `qml.devices.QubitDevice`, and `qml.devices.QutritDevice`
respectively.
Expand All @@ -97,24 +138,27 @@

<h3>Documentation 📝</h3>

* Add `work_wires` parameter to `qml.MultiControlledX` docstring signature.
[(#6271)](https://github.com/PennyLaneAI/pennylane/pull/6271)

<h3>Bug fixes 🐛</h3>

* Fix a bug where zero-valued JVPs were calculated wrongly in the presence of shot vectors.
[(#6219)](https://github.com/PennyLaneAI/pennylane/pull/6219)

* Fix `qml.PrepSelPrep` template to work with `torch`:
* Fix `qml.PrepSelPrep` template to work with `torch`.
[(#6191)](https://github.com/PennyLaneAI/pennylane/pull/6191)

* Now `qml.equal` compares correctly `qml.PrepSelPrep` operators.
[(#6182)](https://github.com/PennyLaneAI/pennylane/pull/6182)

* The ``qml.QSVT`` template now orders the ``projector`` wires first and the ``UA`` wires second, which is the expected order of the decomposition.
* The `qml.QSVT` template now orders the `projector` wires first and the `UA` wires second, which is the expected order of the decomposition.
[(#6212)](https://github.com/PennyLaneAI/pennylane/pull/6212)

* The ``qml.Qubitization`` template now orders the ``control`` wires first and the ``hamiltonian`` wires second, which is the expected according to other templates.
* The `qml.Qubitization` template now orders the `control` wires first and the `hamiltonian` wires second, which is the expected according to other templates.
[(#6229)](https://github.com/PennyLaneAI/pennylane/pull/6229)

* The ``qml.FABLE`` template now returns the correct value when JIT is enabled.
* The `qml.FABLE` template now returns the correct value when JIT is enabled.
[(#6263)](https://github.com/PennyLaneAI/pennylane/pull/6263)

* Fixes a bug where a circuit using the `autograd` interface sometimes returns nested values that are not of the `autograd` interface.
Expand All @@ -130,10 +174,12 @@ This release contains contributions from (in alphabetical order):
Guillermo Alonso,
Utkarsh Azad,
Astral Cai,
Isaac De Vlugt,
Lillian M. A. Frederiksen,
Pietropaolo Frisoni,
Emiliano Godinez,
Christina Lee,
William Maxwell,
Lee J. O'Riordan,
Mudit Pandey,
David Wierichs,
2 changes: 1 addition & 1 deletion pennylane/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
Version number (major.minor.patch[-label])
"""

__version__ = "0.39.0-dev16"
__version__ = "0.39.0-dev18"
3 changes: 3 additions & 0 deletions pennylane/devices/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
_qubit_device
_qutrit_device
null_qubit
reference_qubit
tests
Next generation devices
Expand All @@ -58,6 +59,7 @@
DefaultQubit
DefaultTensor
NullQubit
ReferenceQubit
DefaultQutritMixed
LegacyDeviceFacade
Expand Down Expand Up @@ -160,6 +162,7 @@ def execute(self, circuits, execution_config = qml.devices.DefaultExecutionConfi
from .default_clifford import DefaultClifford
from .default_tensor import DefaultTensor
from .null_qubit import NullQubit
from .reference_qubit import ReferenceQubit
from .default_qutrit import DefaultQutrit
from .default_qutrit_mixed import DefaultQutritMixed
from ._legacy_device import Device as LegacyDevice
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 @@ -1153,7 +1153,7 @@ def classical_shadow(self, obs, circuit):
def shadow_expval(self, obs, circuit):
r"""Compute expectation values using classical shadows in a differentiable manner.
Please refer to :func:`~.pennylane.shadow_expval` for detailed documentation.
Please refer to :func:`~pennylane.shadow_expval` for detailed documentation.
Args:
obs (~.pennylane.measurements.ClassicalShadowMP): The classical shadow expectation
Expand Down
2 changes: 1 addition & 1 deletion pennylane/devices/_qutrit_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def classical_shadow(self, obs, circuit):
def shadow_expval(self, obs, circuit):
r"""Compute expectation values using classical shadows in a differentiable manner.
Please refer to :func:`~.pennylane.shadow_expval` for detailed documentation.
Please refer to :func:`~pennylane.shadow_expval` for detailed documentation.
.. seealso:: :func:`~pennylane.shadow_expval`
Expand Down
5 changes: 3 additions & 2 deletions pennylane/devices/default_mixed.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,8 +763,9 @@ def execute(self, circuit, **kwargs):
self.measured_wires = self.wires
return super().execute(circuit, **kwargs)
if isinstance(m, (VnEntropyMP, MutualInfoMP)):
# VnEntropy, MutualInfo: Computed for the state prior to measurement. So, readout
# error need not be applied on the corresponding device wires.
# VnEntropy, MutualInfo: Computed for the state
# prior to measurement. So, readout error need not be applied to the
# corresponding device wires.
continue
wires_list.append(m.wires)
self.measured_wires = qml.wires.Wires.all_wires(wires_list)
Expand Down
Loading

0 comments on commit 875dbbd

Please sign in to comment.