Skip to content

Commit

Permalink
No backprop devices (#61)
Browse files Browse the repository at this point in the history
* Getting lighting

* revert test hack

* formatting

* Revert "formatting"

This reverts commit b2a082c.

* formatting

* Revert "revert test hack"

This reverts commit e410e3b.

* test no backprop

* qfunc

* Update tests/test_apply.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* test best diff method

* changelog

Co-authored-by: Josh Izaac <josh146@gmail.com>
  • Loading branch information
antalszava and josh146 committed Feb 9, 2021
1 parent 451f2df commit 35d8d18
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@

### Bug fixes

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

### Contributors

This release contains contributions from (in alphabetical order):

Josh Izaac, Antal Száva

---

# Release 0.14.0
Expand Down
1 change: 1 addition & 0 deletions pennylane_lightning/lightning_qubit.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def capabilities(cls):
supports_analytic_computation=True,
returns_state=True,
)
capabilities.pop("passthru_devices", None)
return capabilities

def apply(self, operations, rotations=None, **kwargs):
Expand Down
23 changes: 23 additions & 0 deletions tests/test_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,29 @@ def test_load_default_qubit_device(self):
assert dev.analytic
assert dev.short_name == "lightning.qubit"

def test_no_backprop(self):
"""Test that lightning.qubit does not support the backprop
differentiation method."""

dev = qml.device("lightning.qubit", wires=2)
def circuit():
"""Simple quantum function."""
return qml.expval(qml.PauliZ(0))

with pytest.raises(qml.QuantumFunctionError):
qml.QNode(circuit, dev, diff_method="backprop")

def test_best_gets_lightning(self):
"""Test that the best differentiation method returns lightning
qubit."""
dev = qml.device("lightning.qubit", wires=2)
def circuit():
"""Simple quantum function."""
return qml.expval(qml.PauliZ(0))

qnode = qml.QNode(circuit, dev, diff_method="best")
assert isinstance(qnode.device, LightningQubit)

def test_args(self):
"""Test that the plugin requires correct arguments"""

Expand Down

0 comments on commit 35d8d18

Please sign in to comment.