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

Deprecate the internal switching of a backpropagation device #6032

Merged
merged 49 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
e548bd9
added warnings for legacy devices and warning capture fixture
Shiro-Raven Jul 13, 2024
bd31a81
minor fixes to failing tests
Shiro-Raven Jul 13, 2024
8302975
Update pennylane/devices/default_qubit_autograd.py
Shiro-Raven Jul 15, 2024
dc89473
improved warnings messages for the deprecated devices
Shiro-Raven Jul 15, 2024
632c006
more fixes to failing tests
Shiro-Raven Jul 15, 2024
e98becb
update device to default.qubit in pulse examples
Shiro-Raven Jul 16, 2024
e803847
update tests to use default.qubit and add missing tests to new device…
Shiro-Raven Jul 16, 2024
11571c2
Merge branch 'master' into ad/deprecate-legacy-devices
Shiro-Raven Jul 16, 2024
13eeea3
add changelog and deprecation note
Shiro-Raven Jul 16, 2024
e257c29
printing failing warning checks
Shiro-Raven Jul 16, 2024
b9f405c
maybe this time
Shiro-Raven Jul 16, 2024
0a1f9f9
fix typo in deprecations doc
Shiro-Raven Jul 17, 2024
3a63fad
remove no longer needed comment
Shiro-Raven Jul 17, 2024
d145941
more robust classical control draw tests
Shiro-Raven Jul 17, 2024
a611917
what
Shiro-Raven Jul 17, 2024
ba6ff26
another one
Shiro-Raven Jul 17, 2024
836527d
Merge branch 'master' into ad/deprecate-legacy-devices
Shiro-Raven Jul 17, 2024
3e4dc46
fix
Shiro-Raven Jul 17, 2024
c4d4bb0
Merge branch 'master' into ad/deprecate-legacy-devices
Shiro-Raven Jul 17, 2024
c8d4475
fix
Shiro-Raven Jul 17, 2024
ca3ee22
Update doc/releases/changelog-dev.md
Shiro-Raven Jul 19, 2024
1b2bbfe
Update doc/releases/changelog-dev.md
Shiro-Raven Jul 19, 2024
5c30389
Update doc/development/deprecations.rst
Shiro-Raven Jul 19, 2024
85ed884
Merge branch 'master' into ad/deprecate-legacy-devices
Shiro-Raven Jul 19, 2024
7c14991
consolidate warning capture fixtures of devs and {ham,sum}_expand
Shiro-Raven Jul 19, 2024
5ced67f
consolidate warning capture fixtures of devs and tape_expand tests
Shiro-Raven Jul 19, 2024
4778f7f
minor typo in changelog
Shiro-Raven Jul 19, 2024
6339bea
test fix
Shiro-Raven Jul 19, 2024
624167a
fix tape_mpl test
Shiro-Raven Jul 19, 2024
c64ac29
Merge branch 'master' into ad/deprecate-legacy-devices
Shiro-Raven Jul 19, 2024
fd42815
more tape_mpl fixes
Shiro-Raven Jul 19, 2024
73d151a
more robust fixture setup and undoing draw test changes
Shiro-Raven Jul 21, 2024
0247cf7
fix minor formatting typo
Shiro-Raven Jul 21, 2024
7925f8f
revert changes to hardware_hamiltonian example
Shiro-Raven Jul 22, 2024
1b0ce0e
Update pennylane/devices/default_qubit_legacy.py
Shiro-Raven Jul 22, 2024
bfc3148
Merge branch 'master' into ad/deprecate-legacy-devices
Shiro-Raven Jul 23, 2024
4b10db6
restructuring and bringing back a test
Shiro-Raven Jul 23, 2024
43ceda8
Merge branch 'master' into ad/deprecate-legacy-devices
Shiro-Raven Jul 23, 2024
2d6784a
computationally less expensive shots for TF shots tests
Shiro-Raven Jul 23, 2024
a3150f4
Merge branch 'master' into ad/deprecate-legacy-devices
Shiro-Raven Jul 23, 2024
1043ed6
Merge branch 'master' into ad/deprecate-legacy-devices
Shiro-Raven Jul 23, 2024
074caea
deprecate backprop switching logic:
albi3ro Jul 23, 2024
182b8d0
modify message
albi3ro Jul 23, 2024
9a8b614
Update doc/releases/changelog-dev.md
albi3ro Jul 23, 2024
76cc527
Update pennylane/workflow/qnode.py
albi3ro Jul 23, 2024
fd3f7ab
merge conflicts
albi3ro Jul 26, 2024
f044911
Update tests/resource/test_specs.py
albi3ro Jul 26, 2024
87898ae
Update pennylane/workflow/qnode.py
albi3ro Jul 26, 2024
8d48d9e
black
albi3ro Jul 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/development/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ Pending deprecations
- Deprecated in v0.38
- Will be removed in v0.39

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

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

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

- Deprecated in v0.38
Expand Down
7 changes: 6 additions & 1 deletion doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
the circuit.
[(#5907)](https://github.com/PennyLaneAI/pennylane/pull/5907)

* `queue_idx` attribute has been removed from the `Operator`, `CompositeOp`, and `SymboliOp` classes.
* `queue_idx` attribute has been removed from the `Operator`, `CompositeOp`, and `SymbolicOp` classes.
[(#6005)](https://github.com/PennyLaneAI/pennylane/pull/6005)

* `qml.from_qasm` no longer removes measurements from the QASM code. Use
Expand Down Expand Up @@ -184,6 +184,11 @@
Instead, use `default.qubit` as it now supports backpropagation through the several backends.
[(#5997)](https://github.com/PennyLaneAI/pennylane/pull/5997)

* 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`.
albi3ro marked this conversation as resolved.
Show resolved Hide resolved
[(#6032)](https://github.com/PennyLaneAI/pennylane/pull/6032)

<h3>Documentation 📝</h3>

* Improves the docstring for `QuantumScript.expand` and `qml.tape.tape.expand_tape`.
Expand Down
8 changes: 8 additions & 0 deletions pennylane/workflow/qnode.py
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,14 @@ def _validate_backprop_method(device, interface, tape=None):
if backprop_devices[mapped_interface] == device.short_name:
return "backprop", {}, device

if device.short_name != "default.qubit.legacy":
albi3ro marked this conversation as resolved.
Show resolved Hide resolved
warnings.warn(
"The switching of devices for backpropagation is now deprecated in v0.38 and "
"will be removed in v0.39, as this behavior was developed purely for the "
"deprecated default.qubit.legacy.",
qml.PennyLaneDeprecationWarning,
)

# TODO: need a better way of passing existing device init options
# to a new device?
expand_fn = device.expand_fn
Expand Down
41 changes: 41 additions & 0 deletions tests/test_qnode_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,47 @@ def dummyfunc():
return None


def test_backprop_switching_deprecation():
"""Test that a PennyLaneDeprecationWarning is raised when a device is subtituted
for a different backprop device.
"""

class DummyDevice(qml.devices.LegacyDevice):
"""A minimal device that substitutes for a backprop device."""

author = "some string"
name = "my legacy device"
short_name = "something"
version = 0.0

observables = {"PauliX", "PauliY", "PauliZ"}
operations = {"Rot", "RX", "RY", "RZ", "PauliX", "PauliY", "PauliZ", "CNOT"}
pennylane_requires = 0.38

_debugger = None

def capabilities(self):
return {"passthru_devices": {"autograd": "default.mixed"}}

def reset(self):
pass

# pylint: disable=unused-argument
def apply(self, operation, wires, par):
return 0.0

# pylint: disable=unused-argument
def expval(self, observable, wires, par):
return 0.0

with pytest.warns(qml.PennyLaneDeprecationWarning):

@qml.qnode(DummyDevice(shots=None), interface="autograd")
def _(x):
qml.RX(x, 0)
return qml.expval(qml.Z(0))


# pylint: disable=too-many-public-methods
class TestValidation:
"""Tests for QNode creation and validation"""
Expand Down
Loading