Closed sabrinaherbst closed 8 months ago
Thanks @sabrinaherbst! This does look like a potential bug which seems to be coming from the presence of qml.IQPEmbedding
. We'll get back to you soon on the best way to resolve this.
So I'm a little confused now. I see in the documentation that we say:
a device with finite shots is used, the hardware compatible transform :func:`~.pennylane.metric_tensor` is used.
but then is source-code we use the metric_tensor
when:
if device.shots and isinstance(device, (DefaultQubitLegacy, DefaultQubit)):
AKA only when it's a numpy simulator. Potentially we just mean not isinstance
instead?
@albi3ro yeah seems like a bug/typo 🤔
Although perhaps it should be
if (device.shots is not None) or (device is not defaultqubit):
or equivalently
if not (device.shots is None and device is defaultqubit):
since the adjoint metric tensor can only be used if:
shots is None
anddefault.qubit
Also, treating device.shots
(None or int) as a boolean could be problematic in edge cases?
On second thought, inverting the if statement would make this easier to read:
if device.shots is None and isinstance(device, defaultqubit):
return adjoint_metric_tensor
return hw_compatible_metric_tensor
Expected behavior
I was trying to calculate quantum fisher information matrices using different devices. As far as I understand the documentation (https://docs.pennylane.ai/en/stable/code/api/pennylane.qinfo.transforms.quantum_fisher.html), whether the function uses
adjoint_metric_tensor
andmetric_tensor
should automatically change depending on the exact hardware used and the respective available operations. I would expect the function to return the QFIM or at least a meaningful error message saying that the function is not supported with these devices for now.Actual behavior
I get a
MatrixUndefinedError
when using a different simulator thandefault.qubit
, which is what happens when you calladjoint_metric_tensor
with any other simulator thandefault.qubit
.Additional information
No response
Source code
Tracebacks
System information
Existing GitHub issues