Skip to content

Commit bffde19

Browse files
authored
Merge 99f073a into 451f2df
2 parents 451f2df + 99f073a commit bffde19

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,17 @@
1010

1111
### Bug fixes
1212

13+
* Fixes a bug where the `QNode` would swap `LightningQubit` to
14+
`DefaultQubitAutograd` on device execution due to the inherited
15+
`passthru_devices` entry of the `capabilities` dictionary.
16+
[(#61)](https://github.com/PennyLaneAI/pennylane-lightning/pull/61)
17+
1318
### Contributors
1419

1520
This release contains contributions from (in alphabetical order):
1621

22+
Josh Izaac, Antal Száva
23+
1724
---
1825

1926
# Release 0.14.0

pennylane_lightning/lightning_qubit.py

+1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ def capabilities(cls):
107107
supports_analytic_computation=True,
108108
returns_state=True,
109109
)
110+
capabilities.pop("passthru_devices", None)
110111
return capabilities
111112

112113
def apply(self, operations, rotations=None, **kwargs):

tests/test_apply.py

+23
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,29 @@ def test_load_default_qubit_device(self):
454454
assert dev.analytic
455455
assert dev.short_name == "lightning.qubit"
456456

457+
def test_no_backprop(self):
458+
"""Test that lightning.qubit does not support the backprop
459+
differentiation method."""
460+
461+
dev = qml.device("lightning.qubit", wires=2)
462+
def circuit():
463+
"""Simple quantum function."""
464+
return qml.expval(qml.PauliZ(0))
465+
466+
with pytest.raises(qml.QuantumFunctionError):
467+
qml.QNode(circuit, dev, diff_method="backprop")
468+
469+
def test_best_gets_lightning(self):
470+
"""Test that the best differentiation method returns lightning
471+
qubit."""
472+
dev = qml.device("lightning.qubit", wires=2)
473+
def circuit():
474+
"""Simple quantum function."""
475+
return qml.expval(qml.PauliZ(0))
476+
477+
qnode = qml.QNode(circuit, dev, diff_method="best")
478+
assert isinstance(qnode.device, LightningQubit)
479+
457480
def test_args(self):
458481
"""Test that the plugin requires correct arguments"""
459482

0 commit comments

Comments
 (0)