Skip to content

Commit

Permalink
Merge branch 'master' into deprecate_QubitStateVector
Browse files Browse the repository at this point in the history
  • Loading branch information
KetpuntoG committed Sep 17, 2024
2 parents d38fa2f + 805d4cf commit e3f1b19
Show file tree
Hide file tree
Showing 150 changed files with 2,604 additions and 25,869 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/install_deps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ 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.23'
install_tensorflow:
description: Indicate if TensorFlow should be installed or not
required: false
default: 'true'
tensorflow_version:
description: The version of TensorFlow to install for any job that requires TensorFlow
required: false
default: 2.16.0
default: '2.16.0'
install_pytorch:
description: Indicate if PyTorch should be installed or not
required: false
default: 'true'
pytorch_version:
description: The version of PyTorch to install for any job that requires PyTorch
required: false
default: 2.3.0
default: '2.3.0'
install_pennylane_lightning_master:
description: Indicate if PennyLane-Lightning should be installed from the master branch
required: false
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/interface-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,7 @@ jobs:
# catalyst requires the latest version of pennylane that is about to be released.
# Installing catalyst after pennylane to make sure that the latest catalyst is used.
install_catalyst_nightly: true
# using lightning master does not work for the tests with external libraries
install_pennylane_lightning_master: false
install_pennylane_lightning_master: true
pytest_coverage_flags: ${{ inputs.pytest_coverage_flags }}
pytest_markers: external
additional_pip_packages: pyzx matplotlib stim quimb mitiq pennylane-qiskit ply
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests-gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ concurrency:
cancel-in-progress: true

env:
TORCH_VERSION: 2.2.0
TORCH_VERSION: 2.3.0

jobs:
gpu-tests:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ config.toml
qml_debug.log
datasets/*
.benchmarks/*
*.h5
*.hdf5
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,10 @@ clean-docs:

test:
$(PYTHON) $(TESTRUNNER)
$(PYTHON) $(PLUGIN_TESTRUNNER) --device=default.qubit.autograd

coverage:
@echo "Generating coverage report..."
$(PYTHON) $(TESTRUNNER) $(COVERAGE)
$(PYTHON) $(PLUGIN_TESTRUNNER) --device=default.qubit.autograd $(COVERAGE) --cov-append

.PHONY:format
format:
Expand Down
34 changes: 26 additions & 8 deletions doc/development/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ deprecations are listed below.
Pending deprecations
--------------------

* All of the legacy devices (any with the name ``default.qubit.{autograd,torch,tf,jax,legacy}``) are deprecated. Use ``default.qubit`` instead,
as it supports backpropagation for the many backends the legacy devices support.
* ``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 in v0.38
- Will be removed in v0.39
- Deprecated top level access in v0.39
- Top level access removed in v0.40

* The logic for internally switching a device for a different backpropagation
compatible device is now deprecated, as it was in place for the deprecated ``default.qubit.legacy``.
* `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.38
- Will be removed in v0.39
- Deprecated in v0.39
- Will be removed in v0.40

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

Expand Down Expand Up @@ -88,6 +89,23 @@ Other deprecations
Completed deprecation cycles
----------------------------

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

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

* The logic for internally switching a device for a different backpropagation
compatible device is removed, as it was in place for removed ``default.qubit.legacy``.

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

* `Operator.expand` is now removed. Use `qml.tape.QuantumScript(op.deocomposition())` instead.

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

* The ``expansion_strategy`` attribute of ``qml.QNode`` is removed.
Users should make use of ``qml.workflow.construct_batch``, should they require fine control over the output tape(s).

Expand Down
2 changes: 1 addition & 1 deletion doc/development/guide/logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ process, and surrounding operations:
# Get logger for use by this script only.
logger = logging.getLogger(__name__)
dev_name = "default.qubit.jax"
dev_name = "default.qubit"
num_wires = 2
num_shots = None
Expand Down
2 changes: 2 additions & 0 deletions doc/development/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ This page contains the release notes for PennyLane.

.. mdinclude:: ../releases/changelog-dev.md

.. mdinclude:: ../releases/changelog-0.38.1.md

.. mdinclude:: ../releases/changelog-0.38.0.md

.. mdinclude:: ../releases/changelog-0.37.0.md
Expand Down
8 changes: 4 additions & 4 deletions doc/introduction/interfaces/jax.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ a JAX-capable QNode in PennyLane. Simply specify the ``interface='jax'`` keyword

.. code-block:: python
dev = qml.device('default.qubit.jax', wires=2)
dev = qml.device('default.qubit', wires=2)
@qml.qnode(dev, interface='jax')
def circuit1(phi, theta):
Expand Down Expand Up @@ -85,7 +85,7 @@ For example:

.. code-block:: python
dev = qml.device('default.qubit.jax', wires=2)
dev = qml.device('default.qubit', wires=2)
@qml.qnode(dev, interface='jax')
def circuit3(phi, theta):
Expand Down Expand Up @@ -119,7 +119,7 @@ the ``@jax.jit`` decorator can be directly applied to the QNode.

.. code-block:: python
dev = qml.device('default.qubit.jax', wires=2)
dev = qml.device('default.qubit', wires=2)
@jax.jit # QNode calls will now be jitted, and should run faster.
@qml.qnode(dev, interface='jax')
Expand Down Expand Up @@ -176,7 +176,7 @@ Example:
# Device construction should happen inside a `jax.jit` decorated
# method when using a PRNGKey.
dev = qml.device('default.qubit.jax', wires=2, prng_key=key, shots=100)
dev = qml.device('default.qubit', wires=2, prng_key=key, shots=100)
@qml.qnode(dev, interface='jax', diff_method=None)
Expand Down
2 changes: 1 addition & 1 deletion doc/releases/changelog-0.38.0.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
:orphan:

# Release 0.38.0 (current release)
# Release 0.38.0

<h3>New features since last release</h3>

Expand Down
14 changes: 14 additions & 0 deletions doc/releases/changelog-0.38.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
:orphan:

# Release 0.38.1 (current release)

<h3>Bug fixes 🐛</h3>

* Fix float-to-complex casting in various places across PennyLane.
[(#6260)](https://github.com/PennyLaneAI/pennylane/pull/6260)

<h3>Contributors ✍️</h3>

This release contains contributions from (in alphabetical order):

Mudit Pandey
67 changes: 62 additions & 5 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,30 @@
<h3>New features since last release</h3>

<h3>Improvements 🛠</h3>

* PennyLane is now compatible with NumPy 2.0.
[(#6061)](https://github.com/PennyLaneAI/pennylane/pull/6061)
[(#6258)](https://github.com/PennyLaneAI/pennylane/pull/6258)

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

* The `diagonalize_measurements` transform now uses a more efficient method of diagonalization
when possible, based on the `pauli_rep` of the relevant observables.
[#6113](https://github.com/PennyLaneAI/pennylane/pull/6113/)

* The `Hermitian` operator now has a `compute_sparse_matrix` implementation.
[(#6225)](https://github.com/PennyLaneAI/pennylane/pull/6225)

<h4>Capturing and representing hybrid programs</h4>

* Differentiation of hybrid programs via `qml.grad` can now be captured into plxpr.
When evaluating a captured `qml.grad` instruction, it will dispatch to `jax.grad`,
which differs from the Autograd implementation of `qml.grad` itself.
* Differentiation of hybrid programs via `qml.grad` and `qml.jacobian` can now be captured
into plxpr. When evaluating a captured `qml.grad` (`qml.jacobian`) instruction, it will
dispatch to `jax.grad` (`jax.jacobian`), which differs from the Autograd implementation
without capture. Pytree inputs and outputs are supported.
[(#6120)](https://github.com/PennyLaneAI/pennylane/pull/6120)
[(#6127)](https://github.com/PennyLaneAI/pennylane/pull/6127)
[(#6134)](https://github.com/PennyLaneAI/pennylane/pull/6134)

* Improve unit testing for capturing of nested control flows.
[(#6111)](https://github.com/PennyLaneAI/pennylane/pull/6111)
Expand All @@ -23,6 +37,9 @@
`from pennylane.capture.primitives import *`.
[(#6129)](https://github.com/PennyLaneAI/pennylane/pull/6129)

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

* The `SampleMP.process_samples` method is updated to support using JAX tracers
for samples, allowing compatiblity with Catalyst workflows.
[(#6211)](https://github.com/PennyLaneAI/pennylane/pull/6211)
Expand All @@ -34,14 +51,24 @@
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>

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

* `DefaultQubitTF` is removed. Please use `default.qubit` for all interfaces.
* `DefaultQubitTF`, `DefaultQubitTorch`, `DefaultQubitJax`, and `DefaultQubitAutograd` are removed.
Please use `default.qubit` for all interfaces.
[(#6207)](https://github.com/PennyLaneAI/pennylane/pull/6207)
[(#6208)](https://github.com/PennyLaneAI/pennylane/pull/6208)
[(#6209)](https://github.com/PennyLaneAI/pennylane/pull/6209)
[(#6210)](https://github.com/PennyLaneAI/pennylane/pull/6210)

* `expand_fn`, `max_expansion`, `override_shots`, and `device_batch_transform` are removed from the
signature of `qml.execute`.
Expand All @@ -57,16 +84,31 @@
Please use `qml.transforms.split_non_commuting` instead.
[(#6204)](https://github.com/PennyLaneAI/pennylane/pull/6204)

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


<h3>Deprecations 👋</h3>

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

* `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.
[(#6238)](https://github.com/PennyLaneAI/pennylane/pull/6238/)

* `QNode.gradient_fn` is deprecated. Please use `QNode.diff_method` and `QNode.get_gradient_fn` instead.
[(#6244)](https://github.com/PennyLaneAI/pennylane/pull/6244)

<h3>Documentation 📝</h3>

<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`:
[(#6191)](https://github.com/PennyLaneAI/pennylane/pull/6191)

Expand All @@ -75,14 +117,29 @@

* 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.
[(#6229)](https://github.com/PennyLaneAI/pennylane/pull/6229)

* 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.
[(#6225)](https://github.com/PennyLaneAI/pennylane/pull/6225)

* Fixes a bug where a simple circuit with no parameters or only builtin/numpy arrays as parameters returns autograd tensors.
[(#6225)](https://github.com/PennyLaneAI/pennylane/pull/6225)

* <h3>Contributors ✍️</h3>
<h3>Contributors ✍️</h3>

This release contains contributions from (in alphabetical order):

Guillermo Alonso,
Utkarsh Azad,
Astral Cai,
Lillian M. A. Frederiksen,
Pietropaolo Frisoni,
Emiliano Godinez,
Christina Lee,
William Maxwell,
Lee J. O'Riordan,
Expand Down
19 changes: 17 additions & 2 deletions pennylane/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
PennyLane can be directly imported.
"""

import numpy as _np


from pennylane.boolean_fn import BooleanFn
import pennylane.numpy
Expand Down Expand Up @@ -180,13 +178,30 @@ def __getattr__(name):
if name == "plugin_devices":
return pennylane.devices.device_constructor.plugin_devices

from warnings import warn # pylint: disable=import-outside-toplevel

if name == "QubitDevice":
warn(
"QubitDevice will no longer be accessible top level. Please access "
" the class as pennylane.devices.QubitDevice",
PennyLaneDeprecationWarning,
)
return pennylane.devices._qubit_device.QubitDevice # pylint:disable=protected-access

if name == "QutritDevice":
warn(
"QutritDevice will no longer be accessible top level. Please access "
" the class as pennylane.devices.QutritDevice",
PennyLaneDeprecationWarning,
)
return pennylane.devices._qutrit_device.QutritDevice # pylint:disable=protected-access

if name == "Device":
warn(
"Device will no longer be accessible top level. Please access "
" the class as pennylane.devices.LegacyDevice",
PennyLaneDeprecationWarning,
)
return pennylane.devices._legacy_device.Device # pylint:disable=protected-access

raise AttributeError(f"module 'pennylane' has no attribute '{name}'")
Expand Down
Loading

0 comments on commit e3f1b19

Please sign in to comment.