Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
**Context:** The `qml.qinfo.quantum_fisher` transform was failing on non-`defualt.qubit` devices: ``` import pennylane as qml from pennylane import numpy as np from sklearn import datasets as ds NUM_WIRES = 4 def get_circuit(data, parameters): qml.IQPEmbedding(data, wires=range(NUM_WIRES), n_repeats=1) for i in range(NUM_WIRES): qml.RX(parameters[i], wires=i) for j in range(NUM_WIRES-1): qml.CNOT(wires=[j, j+1]) return qml.expval(qml.PauliZ(0)) # use different devices here, i.e. lightning.qubit, default.qubit, lightning.kokkos dev = qml.device("default.mixed", wires=NUM_WIRES) def qfim(X_train, parameters): circuit = qml.QNode(get_circuit, dev) data = np.array(X_train[0], requires_grad=False) return qml.qinfo.transforms.quantum_fisher(circuit)(data, parameters) X = ds.load_iris().data parameters = np.random.random(size=NUM_WIRES, requires_grad=True) print(qfim(X, parameters)) ``` **Description of the Change:** Use the `metric_tensor` instead of the `adjoint_metric_tensor` if the device is not `default.qubit`. **Benefits:** `quantum_fisher` works with more devices. **Possible Drawbacks:** **Related GitHub Issues:** Fixes #5381 [sc-58882]
- Loading branch information