Skip to content
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

quantum_fisher transform on non-default.qubit devices #5423

Merged
merged 2 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@

<h3>Bug fixes 🐛</h3>

* `qml.qinfo.quantum_fisher` now works with non-`default.qubit` devices.
albi3ro marked this conversation as resolved.
Show resolved Hide resolved

* We no longer perform unwanted dtype promotion in the `pauli_rep` of `SProd` instances when using tensorflow.
[(#5246)](https://github.com/PennyLaneAI/pennylane/pull/5246)

Expand Down
2 changes: 1 addition & 1 deletion pennylane/qinfo/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ def circ(params):

"""

if device.shots and isinstance(device, (DefaultQubitLegacy, DefaultQubit)):
if device.shots or not isinstance(device, (DefaultQubitLegacy, DefaultQubit)):
tapes, processing_fn = metric_tensor(tape, *args, **kwargs)

def processing_fn_multiply(res):
Expand Down
11 changes: 9 additions & 2 deletions tests/qinfo/test_fisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,19 @@ def circ(params):
res = qml.qinfo.classical_fisher(circ)(params)
assert np.allclose(res, n_wires * np.ones((n_params, n_params)), atol=1)

def test_quantum_fisher_info(self):
@pytest.mark.parametrize(
"dev",
(
qml.device("default.qubit"),
qml.device("default.mixed", wires=3),
qml.device("lightning.qubit", wires=3),
),
)
def test_quantum_fisher_info(self, dev):
"""Integration test of quantum fisher information matrix CFIM. This is just calling ``qml.metric_tensor`` or ``qml.adjoint_metric_tensor`` and multiplying by a factor of 4"""

n_wires = 2

dev = qml.device("default.qubit", wires=n_wires)
dev_hard = qml.device("default.qubit", wires=n_wires + 1, shots=1000)

def qfunc(params):
Expand Down
Loading