You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
where it sets the qnode's interface to tf. We could potentially remove this line and replace it with a validation check that ensures the interface is in auto/ tf.
**Context:**
Since `KerasLayer` and `TorchLayer` both update the input QNode's
interface, this was causing trouble if the same QNode was used for
constructing both a `KerasLayer` and `TorchLayer`.
**Description of the Change:**
* Instead of mutating the QNode's interface, check that the interface of
the QNode is expected (`"tf"` or equivalent for `KerasLayer`, and
`"torch"` or equivalent for `TorchLayer`)
* Tests
**Benefits:**
* QNodes are no longer sneakily mutated.
**Possible Drawbacks:**
* New error, potential breaking change, but it might be minor enough for
us to not worry about it.
**Related GitHub Issues:**
#5723
https://app.shortcut.com/xanaduai/story/63723/bug-keraslayer-has-unintended-side-effects-on-its-qnode
Expected behavior
Defining a Keras layer from a QNode has no side effects on the QNode itself.
Actual behavior
QNodes in a
KerasLayer
are mutated.Additional information
No response
Source code
Tracebacks
System information
Name: PennyLane Version: 0.36.0 Summary: PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network. Home-page: https://github.com/PennyLaneAI/pennylane Author: Author-email: License: Apache License 2.0 Location: /Users/isaac/.virtualenvs/pl-qiskit-1.0/lib/python3.11/site-packages Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, pennylane-lightning, requests, rustworkx, scipy, semantic-version, toml, typing-extensions Required-by: PennyLane-qiskit, PennyLane_Lightning Platform info: macOS-14.5-arm64-arm-64bit Python version: 3.11.8 Numpy version: 1.26.4 Scipy version: 1.13.0 Installed devices: - default.clifford (PennyLane-0.36.0) - default.gaussian (PennyLane-0.36.0) - default.mixed (PennyLane-0.36.0) - default.qubit (PennyLane-0.36.0) - default.qubit.autograd (PennyLane-0.36.0) - default.qubit.jax (PennyLane-0.36.0) - default.qubit.legacy (PennyLane-0.36.0) - default.qubit.tf (PennyLane-0.36.0) - default.qubit.torch (PennyLane-0.36.0) - default.qutrit (PennyLane-0.36.0) - default.qutrit.mixed (PennyLane-0.36.0) - null.qubit (PennyLane-0.36.0) - qiskit.aer (PennyLane-qiskit-0.36.0) - qiskit.basicaer (PennyLane-qiskit-0.36.0) - qiskit.basicsim (PennyLane-qiskit-0.36.0) - qiskit.ibmq (PennyLane-qiskit-0.36.0) - qiskit.ibmq.circuit_runner (PennyLane-qiskit-0.36.0) - qiskit.ibmq.sampler (PennyLane-qiskit-0.36.0) - qiskit.remote (PennyLane-qiskit-0.36.0) - lightning.qubit (PennyLane_Lightning-0.36.0)
Existing GitHub issues
The text was updated successfully, but these errors were encountered: