-
Notifications
You must be signed in to change notification settings - Fork 616
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
[BUG] WireError when computing quantum fisher info of mixed state #6059
Comments
Hi @joeybarreto , thank you for reporting this! We're looking into it and will get back to you soon. |
Hi @joeybarreto, tl;dr: Simplest fix: Add a wire to your device (see below for working code based on your MWE) I'll outline the function structure here to make the bug understandable:
Now the structure for your code is as follows:
I hope this helps! Let me know if you still encounter problems! And here is the working example based on your MWE: import pennylane as qml
from pennylane import numpy as np
def circuit(params):
qml.RX(params[0], wires=0)
qml.RX(params[1], wires=1)
qml.AmplitudeDamping(0.1, wires=0)
qml.AmplitudeDamping(0.1, wires=1)
qml.RX(params[0], wires=0)
qml.RX(params[1], wires=1)
return qml.expval(qml.PauliZ(0))
dev = qml.device("default.mixed", wires=3) # <<< Increased wire count to accomodate aux wire
parameters = 2*np.pi*np.random.random(size=2, requires_grad=True)
qml.qinfo.transforms.quantum_fisher(qml.QNode(circuit, dev))(parameters) Alternatively, using the approximate QFI: dev = qml.device("default.mixed", wires=2) # <<< No aux wire this time
parameters = 2*np.pi*np.random.random(size=2, requires_grad=True)
qml.qinfo.transforms.quantum_fisher(qml.QNode(circuit, dev), approx="block-diag")(parameters) # <<< Pick approximation |
**Context:** The documentation of `qinfo.quantum_fisher` was not quite precise on when `adjoint_metric_tensor` is being used (successfully), and did not mention potential auxiliary wire requirements. **Description of the Change:** Make the criterion on using default.qubit precise (because we catch other devices), and mention that for other settings, an auxiliary wire may be required. **Benefits:** **Possible Drawbacks:** **Related GitHub Issues:** #6059 [sc-70300]
Expected behavior
Execution without failure (i.e. the QFIM is returned)
Actual behavior
WireError: Did not find some of the wires <Wires = [2]> on device with wires <Wires = [0, 1]>.
Additional information
Removing the second layer of$RX$ gates removes the error, so something is going wrong when noise channels are applied mid-circuit as opposed to at the end of the circuit. This is a minimum working example of the error, after some troubleshooting (I would imagine even with 1 qubit it would still error).
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/joey/miniconda3/envs/lanl/lib/python3.12/site-packages Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, pennylane-lightning, requests, rustworkx, scipy, semantic-version, toml, typing-extensions Required-by: PennyLane_Lightning Platform info: macOS-14.4.1-arm64-arm-64bit Python version: 3.12.3 Numpy version: 1.26.4 Scipy version: 1.13.1 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) - lightning.qubit (PennyLane_Lightning-0.36.0)
Existing GitHub issues
The text was updated successfully, but these errors were encountered: