# How to calculate the quantum Fisher information matrix in the middle of my circuit?

**URL:** <https://discuss.pennylane.ai/t/how-to-calculate-the-quantum-fisher-information-matrix-in-the-middle-of-my-circuit/4070>\
**Category:** PennyLane Help\
**Created:** [February 12, 2024, 6:28pm UTC](https://discuss.pennylane.ai/t/how-to-calculate-the-quantum-fisher-information-matrix-in-the-middle-of-my-circuit/4070 "2024-02-12T18:28:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![NickGut0711](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/nickgut0711/32/2137_2.png) [@NickGut0711](https://discuss.pennylane.ai/u/NickGut0711)\
**Post date:** [February 12, 2024, 6:28pm UTC](https://discuss.pennylane.ai/t/how-to-calculate-the-quantum-fisher-information-matrix-in-the-middle-of-my-circuit/4070/1 "2024-02-12T18:28:00Z")

</div>

Hello! I have a circuit that has “3 parts” one is a part that we can call `U1`, the other is some middle part, and the last is the `qml.adjoint(U1)`.

Let’s say that I want to use the [QFIM function in Pennylane](https://docs.pennylane.ai/en/stable/code/api/pennylane.qinfo.transforms.quantum_fisher.html) to calculate the QFIM after `U1` but before the middle part, and try to maximize the diagonal elements of the QFIM in my cost function (I want to optimize the parameters of my circuit such that the diagonal elements of the QFIM are maximal). How would I go about making this sort of loss function in Pennylane/calculating the QFIM mid-circuit?

Here’s my code for reference:

```python
def U1(params, L, num_trotter_steps = 10):

    start_index = 0
    n_params_in_layer = (2 + 2) * L

    for i in range(L):
        params_layer = params[start_index:start_index + n_params_in_layer]
        H = H_perceptron
        qml.evolve(perceptron.H)(params_layer[:2], t)
        for j in range(n_wires): # Single-qubit X rotations
            qml.RX(params_layer[2], wires=j)
        for k in range(n_wires): # Single-qubit Y rotations
            qml.RY(params_layer[3], wires=k)
        start_index += n_params_in_layer

def get_Sy(n_wires):
    S_0 = n_wires/2
    c = 0

    for i in range(n_wires):
        c += (1/(2*S_0))*qml.PauliY(wires=i)

    return c

@qml.qnode(dev, interface='jax')
def circuit(params, phi = 0.001, L = 1):

    for i in range(n_wires): # Making the initial CSS
        qml.Hadamard(wires=i)

    U1(params, L)

    qml.Barrier()

    for i in range(n_wires): # Perturbation
        qml.RY(phi, wires = i)

    qml.Barrier()

    qml.adjoint(U1)(params, L)

    return qml.expval(get_Sy(n_wires))

def my_model(params, phi, L):
    return circuit(params, phi = phi, L = L)

def calculate_QFI(circuit, params):
    qfim = qml.qinfo.quantum_fisher(circuit)(params)
    return qfim

```

Thanks! Sorry, I’m new to Pennylane!

---

<div class="post-metadata">

**Author:** ![isaacdevlugt](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/isaacdevlugt/32/1159_2.png) [@isaacdevlugt](https://discuss.pennylane.ai/u/isaacdevlugt)\
**Post date:** [February 13, 2024, 10:49pm UTC](https://discuss.pennylane.ai/t/how-to-calculate-the-quantum-fisher-information-matrix-in-the-middle-of-my-circuit/4070/2 "2024-02-13T22:49:55Z")

</div>

Hey @NickGut0711,

Is there a purpose to the gates/operations after you want to get the QFIM? 🤔

---

<div class="post-metadata">

**Author:** ![NickGut0711](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/nickgut0711/32/2137_2.png) [@NickGut0711](https://discuss.pennylane.ai/u/NickGut0711)\
**Post date:** [February 13, 2024, 10:51pm UTC](https://discuss.pennylane.ai/t/how-to-calculate-the-quantum-fisher-information-matrix-in-the-middle-of-my-circuit/4070/3 "2024-02-13T22:51:10Z")

</div>

@isaacdevlugt Yes! They’re part of a larger experimental scheme. As you can also see, `U1` depends on `L` which controls the number of layers I choose to do.

---

<div class="post-metadata">

**Author:** ![isaacdevlugt](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/isaacdevlugt/32/1159_2.png) [@isaacdevlugt](https://discuss.pennylane.ai/u/isaacdevlugt)\
**Post date:** [February 14, 2024, 12:07am UTC](https://discuss.pennylane.ai/t/how-to-calculate-the-quantum-fisher-information-matrix-in-the-middle-of-my-circuit/4070/4 "2024-02-14T00:07:36Z")

</div>

Okay! Then snapshots will probably be your golden ticket: [qml.Snapshot — PennyLane 0.34.0 documentation](https://docs.pennylane.ai/en/stable/code/api/pennylane.Snapshot.html). I was just answering another forum post and snapshots were also their golden ticket! Here’s that example:

```auto
import pennylane as qml
from pennylane import numpy as np

dev = qml.device("default.mixed", wires=2)

@qml.qnode(dev)
def circuit():
    qml.Snapshot(measurement=qml.density_matrix(wires=[0]))
    qml.Snapshot(measurement=qml.density_matrix(wires=[1]))
    qml.Hadamard(wires=0)
    qml.Snapshot(measurement=qml.density_matrix(wires=[0]))
    qml.Snapshot(measurement=qml.density_matrix(wires=[1]))
    qml.CNOT(wires=[0, 1])
    qml.Snapshot(measurement=qml.density_matrix(wires=[0]))
    qml.Snapshot(measurement=qml.density_matrix(wires=[1]))

    return qml.expval(qml.PauliX(0))

qml.snapshots(circuit)()

```

```auto
{0: array([[1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j],
        [0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j],
        [0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j],
        [0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j]]),
 1: array([[1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j],
        [0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j],
        [0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j],
        [0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j]]),
 2: array([[0.5+0.j, 0. +0.j, 0.5+0.j, 0. +0.j],
        [0. +0.j, 0. +0.j, 0. +0.j, 0. +0.j],
        [0.5+0.j, 0. +0.j, 0.5+0.j, 0. +0.j],
        [0. +0.j, 0. +0.j, 0. +0.j, 0. +0.j]]),
 3: array([[0.5+0.j, 0. +0.j, 0.5+0.j, 0. +0.j],
        [0. +0.j, 0. +0.j, 0. +0.j, 0. +0.j],
        [0.5+0.j, 0. +0.j, 0.5+0.j, 0. +0.j],
        [0. +0.j, 0. +0.j, 0. +0.j, 0. +0.j]]),
 4: array([[0.5+0.j, 0. +0.j, 0. +0.j, 0.5+0.j],
        [0. +0.j, 0. +0.j, 0. +0.j, 0. +0.j],
        [0. +0.j, 0. +0.j, 0. +0.j, 0. +0.j],
        [0.5+0.j, 0. +0.j, 0. +0.j, 0.5+0.j]]),
 5: array([[0.5+0.j, 0. +0.j, 0. +0.j, 0.5+0.j],
        [0. +0.j, 0. +0.j, 0. +0.j, 0. +0.j],
        [0. +0.j, 0. +0.j, 0. +0.j, 0. +0.j],
        [0.5+0.j, 0. +0.j, 0. +0.j, 0.5+0.j]]),
 'execution_results': tensor(0., requires_grad=True)}

```

Kinda nice! Let me know if that helps.

---

<div class="post-metadata">

**Author:** ![NickGut0711](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/nickgut0711/32/2137_2.png) [@NickGut0711](https://discuss.pennylane.ai/u/NickGut0711)\
**Post date:** [February 14, 2024, 7:11am UTC](https://discuss.pennylane.ai/t/how-to-calculate-the-quantum-fisher-information-matrix-in-the-middle-of-my-circuit/4070/5 "2024-02-14T07:11:32Z")

</div>

@isaacdevlugt, thank you for this! Snapshots are definitely a useful tool.

However, I’m trying to implement non-trivial measurements (which are just expectation values of non-trivial operators), and I’m getting an array with multiple entries instead of just one entry denoting the expectation value of my operator. The code I used is

```python
n_wires = 5
dev = qml.device('default.qubit', wires=n_wires, shots=None)

def layers(params, L):

    for i in range(L):
        qml.Snapshot(f"{i}-Sz2-twoPoint", measurement = qml.expval(qml.prod(qml.sum(*[qml.PauliZ(i) @ qml.PauliZ(j) for i in range(n_wires) for j in range(i+1, n_wires)]), qml.sum(*[qml.PauliZ(i) @ qml.PauliZ(j) for i in range(n_wires) for j in range(i+1, n_wires)]))))
        qml.Snapshot(f"{i}-Sz-expect", measurement = qml.expval(qml.sum(*[qml.PauliZ(i) @ qml.PauliZ(j) for i in range(n_wires) for j in range(i+1, n_wires)]))) # Need to square this

        qml.Snapshot(f"{i}-Rx-twoPoint", measurement = qml.expval(qml.prod(qml.sum(*[qml.PauliX(i) for i in range(n_wires)]), qml.sum(*[qml.PauliX(i) for i in range(n_wires)]))))
        qml.Snapshot(f"{i}-Rx-expect", measurement = qml.expval(qml.sum(*[qml.PauliX(i) for i in range(n_wires)]))) # Need to square this

        qml.Snapshot(f"{i}-Ry-twoPoint", measurement = qml.expval(qml.prod(qml.sum(*[qml.PauliY(i) for i in range(n_wires)]), qml.sum(*[qml.PauliY(i) for i in range(n_wires)]))))
        qml.Snapshot(f"{i}-Ry-expect", measurement = qml.expval(qml.sum(*[qml.PauliY(i) for i in range(n_wires)]))) # Need to square this

        qml.evolve(qml.sum(*[qml.PauliZ(i) @ qml.PauliZ(j) for i in range(n_wires) for j in range(i+1, n_wires)]), coeff = params[0]) # all-to-all interactions
        qml.evolve(qml.sum(*[qml.PauliX(i) for i in range(n_wires)]), coeff = params[1])
        qml.evolve(qml.sum(*[qml.PauliY(i) for i in range(n_wires)]), coeff = params[2])

@qml.qnode(dev, interface='jax')
def simplistic_circuit(params, phi=jnp.array([0.001]), L=1):

    S_0 = n_wires/2

    for i in range(n_wires): # Making the initial CSS
        qml.Hadamard(wires=i)

    qml.Barrier()

    layers(params, L)

    qml.Barrier()

    for i in range(n_wires): # Perturbation
        qml.RY(phi[0], wires = i)  

    qml.Barrier()

    qml.adjoint(layers)(params, L)

    return qml.expval(qml.sum(*[qml.PauliX(i) for i in range(n_wires)]))

params_normal = jnp.array([0.001,0.002,0.003])

qml.snapshots(simplistic_circuit)(params_normal, L = 3)

```

and my output is

```python
{'0-Sz2-twoPoint': Array([0.1763352 -5.32860759e-06j, 0.1765115 -3.16070305e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.17704184+3.20099337e-06j, 0.17721885+5.27554884e-06j], dtype=complex128),
 '0-Sz-expect': Array([0.1763352 -5.32860759e-06j, 0.1765115 -3.16070305e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.17704184+3.20099337e-06j, 0.17721885+5.27554884e-06j], dtype=complex128),
 '0-Rx-twoPoint': Array([0.1763352 -5.32860759e-06j, 0.1765115 -3.16070305e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.17704184+3.20099337e-06j, 0.17721885+5.27554884e-06j], dtype=complex128),
 '0-Rx-expect': Array([0.1763352 -5.32860759e-06j, 0.1765115 -3.16070305e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.17704184+3.20099337e-06j, 0.17721885+5.27554884e-06j], dtype=complex128),
 '0-Ry-twoPoint': Array([0.1763352 -5.32860759e-06j, 0.1765115 -3.16070305e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.17704184+3.20099337e-06j, 0.17721885+5.27554884e-06j], dtype=complex128),
 '0-Ry-expect': Array([0.1763352 -5.32860759e-06j, 0.1765115 -3.16070305e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.17704184+3.20099337e-06j, 0.17721885+5.27554884e-06j], dtype=complex128),
 '1-Sz2-twoPoint': Array([0.17367835-0.00350194j, 0.17490964-0.00211588j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17862179-0.00212649j, 0.17986509-0.00356912j], dtype=complex128),
 '1-Sz-expect': Array([0.17367835-0.00350194j, 0.17490964-0.00211588j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17862179-0.00212649j, 0.17986509-0.00356912j], dtype=complex128),
 '1-Rx-twoPoint': Array([0.17367835-0.00350194j, 0.17490964-0.00211588j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17862179-0.00212649j, 0.17986509-0.00356912j], dtype=complex128),
 '1-Rx-expect': Array([0.17367835-0.00350194j, 0.17490964-0.00211588j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17862179-0.00212649j, 0.17986509-0.00356912j], dtype=complex128),
 '1-Ry-twoPoint': Array([0.17367835-0.00350194j, 0.17490964-0.00211588j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17862179-0.00212649j, 0.17986509-0.00356912j], dtype=complex128),
 '1-Ry-expect': Array([0.17367835-0.00350194j, 0.17490964-0.00211588j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17862179-0.00212649j, 0.17986509-0.00356912j], dtype=complex128),
 '2-Sz2-twoPoint': Array([0.17099 -0.00692422j, 0.17328406-0.00420894j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.18017702-0.00427469j, 0.18247743-0.00721763j], dtype=complex128),
 '2-Sz-expect': Array([0.17099 -0.00692422j, 0.17328406-0.00420894j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.18017702-0.00427469j, 0.18247743-0.00721763j], dtype=complex128),
 '2-Rx-twoPoint': Array([0.17099 -0.00692422j, 0.17328406-0.00420894j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.18017702-0.00427469j, 0.18247743-0.00721763j], dtype=complex128),
 '2-Rx-expect': Array([0.17099 -0.00692422j, 0.17328406-0.00420894j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.18017702-0.00427469j, 0.18247743-0.00721763j], dtype=complex128),
 '2-Ry-twoPoint': Array([0.17099 -0.00692422j, 0.17328406-0.00420894j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.18017702-0.00427469j, 0.18247743-0.00721763j], dtype=complex128),
 '2-Ry-expect': Array([0.17099 -0.00692422j, 0.17328406-0.00420894j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.18017702-0.00427469j, 0.18247743-0.00721763j], dtype=complex128),
 'execution_results': Array(4.9999975, dtype=float64)}

```

where my Snapshots don’t make sense because the expectation value of these observables _must be_ scalars. Any help would be appreciated!

---

<div class="post-metadata">

**Author:** ![NickGut0711](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/nickgut0711/32/2137_2.png) [@NickGut0711](https://discuss.pennylane.ai/u/NickGut0711)\
**Post date:** [February 14, 2024, 6:39pm UTC](https://discuss.pennylane.ai/t/how-to-calculate-the-quantum-fisher-information-matrix-in-the-middle-of-my-circuit/4070/6 "2024-02-14T18:39:49Z")

</div>

@isaacdevlugt So, I just discovered something interesting…

When I format my Snapshots (without naming them something unique) like

```python
def layers(params, L):

    for i in range(L):
        # qml.Snapshot(f"{i}-Sz2-twoPoint", measurement = qml.expval(qml.prod(qml.sum(*[qml.PauliZ(i) @ qml.PauliZ(j) for i in range(n_wires) for j in range(i+1, n_wires)]), qml.sum(*[qml.PauliZ(i) @ qml.PauliZ(j) for i in range(n_wires) for j in range(i+1, n_wires)]))))
        # qml.Snapshot(f"{i}-Sz-expect", measurement = qml.expval(qml.sum(*[qml.PauliZ(i) @ qml.PauliZ(j) for i in range(n_wires) for j in range(i+1, n_wires)]))) # Need to square this

        qml.Snapshot(measurement = qml.expval(qml.prod(qml.sum(*[qml.PauliZ(i) @ qml.PauliZ(j) for i in range(n_wires) for j in range(i+1, n_wires)]), qml.sum(*[qml.PauliZ(i) @ qml.PauliZ(j) for i in range(n_wires) for j in range(i+1, n_wires)]))))
        qml.Snapshot(measurement = qml.expval(qml.sum(*[qml.PauliZ(i) @ qml.PauliZ(j) for i in range(n_wires) for j in range(i+1, n_wires)]))) # Need to square this
        

        # qml.Snapshot(f"{i}-Rx-twoPoint", measurement = qml.expval(qml.prod(qml.sum(*[qml.PauliX(i) for i in range(n_wires)]), qml.sum(*[qml.PauliX(i) for i in range(n_wires)]))))
        # qml.Snapshot(f"{i}-Rx-expect", measurement = qml.expval(qml.sum(*[qml.PauliX(i) for i in range(n_wires)]))) # Need to square this

        qml.Snapshot(measurement = qml.expval(qml.prod(qml.sum(*[qml.PauliX(i) for i in range(n_wires)]), qml.sum(*[qml.PauliX(i) for i in range(n_wires)]))))
        qml.Snapshot(measurement = qml.expval(qml.sum(*[qml.PauliX(i) for i in range(n_wires)]))) # Need to square this

        # qml.Snapshot(f"{i}-Ry-twoPoint", measurement = qml.expval(qml.prod(qml.sum(*[qml.PauliY(i) for i in range(n_wires)]), qml.sum(*[qml.PauliY(i) for i in range(n_wires)]))))
        # qml.Snapshot(f"{i}-Ry-expect", measurement = qml.expval(qml.sum(*[qml.PauliY(i) for i in range(n_wires)]))) # Need to square this

        qml.Snapshot(measurement = qml.expval(qml.prod(qml.sum(*[qml.PauliY(i) for i in range(n_wires)]), qml.sum(*[qml.PauliY(i) for i in range(n_wires)]))))
        qml.Snapshot(measurement = qml.expval(qml.sum(*[qml.PauliY(i) for i in range(n_wires)]))) # Need to square this

        # qml.evolve(qml.sum(*[qml.PauliZ(i) @ qml.PauliZ(i+1) for i in range(n_wires-1)]), coeff = params[0])
        qml.evolve(qml.sum(*[qml.PauliZ(i) @ qml.PauliZ(j) for i in range(n_wires) for j in range(i+1, n_wires)]), coeff = params[0]) # all-to-all interactions
        qml.evolve(qml.sum(*[qml.PauliX(i) for i in range(n_wires)]), coeff = params[1])
        qml.evolve(qml.sum(*[qml.PauliY(i) for i in range(n_wires)]), coeff = params[2])

```

the first 18 elements of `qml.snapshots(simplistic_circuit)(params_normal, L = 3)` are the measurements I want (I’m pretty sure? Although the expectation values look a bit funky), but the other 18 are random Snapshots I never asked for (I think these are the `qml.state()` of whenever I take the snapshot):

```python
{0: Array(10., dtype=float64),
 1: Array(0., dtype=float64),
 2: Array(23.46358909, dtype=float64),
 3: Array(5., dtype=float64),
 4: Array(5.30421289, dtype=float64),
 5: Array(0., dtype=float64),
 6: Array(10.00312002, dtype=float64),
 7: Array(0.00051998, dtype=float64),
 8: Array(23.46265533, dtype=float64),
 9: Array(4.99987, dtype=float64),
 10: Array(5.30266551, dtype=float64),
 11: Array(0., dtype=float64),
 12: Array(10.01152057, dtype=float64),
 13: Array(0.00191984, dtype=float64),
 14: Array(23.45985377, dtype=float64),
 15: Array(4.99948, dtype=float64),
 16: Array(5.30117699, dtype=float64),
 17: Array(-0.00011998, dtype=float64),
 18: Array([0.17099 -0.00692422j, 0.17328406-0.00420894j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.18017702-0.00427469j, 0.18247743-0.00721763j], dtype=complex128),
 19: Array([0.17099 -0.00692422j, 0.17328406-0.00420894j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.18017702-0.00427469j, 0.18247743-0.00721763j], dtype=complex128),
 20: Array([0.17099 -0.00692422j, 0.17328406-0.00420894j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.18017702-0.00427469j, 0.18247743-0.00721763j], dtype=complex128),
 21: Array([0.17099 -0.00692422j, 0.17328406-0.00420894j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.18017702-0.00427469j, 0.18247743-0.00721763j], dtype=complex128),
 22: Array([0.17099 -0.00692422j, 0.17328406-0.00420894j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.18017702-0.00427469j, 0.18247743-0.00721763j], dtype=complex128),
 23: Array([0.17099 -0.00692422j, 0.17328406-0.00420894j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17328406-0.00420894j, 0.17556322-0.00282616j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17556322-0.00282616j, 0.17786074-0.0028297j ,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.17786074-0.0028297j , 0.18017702-0.00427469j,
        0.18017702-0.00427469j, 0.18247743-0.00721763j], dtype=complex128),
 24: Array([0.17367835-0.00350194j, 0.17490964-0.00211588j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17862179-0.00212649j, 0.17986509-0.00356912j], dtype=complex128),
 25: Array([0.17367835-0.00350194j, 0.17490964-0.00211588j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17862179-0.00212649j, 0.17986509-0.00356912j], dtype=complex128),
 26: Array([0.17367835-0.00350194j, 0.17490964-0.00211588j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17862179-0.00212649j, 0.17986509-0.00356912j], dtype=complex128),
 27: Array([0.17367835-0.00350194j, 0.17490964-0.00211588j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17862179-0.00212649j, 0.17986509-0.00356912j], dtype=complex128),
 28: Array([0.17367835-0.00350194j, 0.17490964-0.00211588j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17862179-0.00212649j, 0.17986509-0.00356912j], dtype=complex128),
 29: Array([0.17367835-0.00350194j, 0.17490964-0.00211588j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17490964-0.00211588j, 0.17613978-0.00141484j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17613978-0.00141484j, 0.17737715-0.00141342j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17737715-0.00141342j, 0.17862179-0.00212649j,
        0.17862179-0.00212649j, 0.17986509-0.00356912j], dtype=complex128),
 30: Array([0.1763352 -5.32860759e-06j, 0.1765115 -3.16070305e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.17704184+3.20099337e-06j, 0.17721885+5.27554884e-06j], dtype=complex128),
 31: Array([0.1763352 -5.32860759e-06j, 0.1765115 -3.16070305e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.17704184+3.20099337e-06j, 0.17721885+5.27554884e-06j], dtype=complex128),
 32: Array([0.1763352 -5.32860759e-06j, 0.1765115 -3.16070305e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.17704184+3.20099337e-06j, 0.17721885+5.27554884e-06j], dtype=complex128),
 33: Array([0.1763352 -5.32860759e-06j, 0.1765115 -3.16070305e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.17704184+3.20099337e-06j, 0.17721885+5.27554884e-06j], dtype=complex128),
 34: Array([0.1763352 -5.32860759e-06j, 0.1765115 -3.16070305e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.17704184+3.20099337e-06j, 0.17721885+5.27554884e-06j], dtype=complex128),
 35: Array([0.1763352 -5.32860759e-06j, 0.1765115 -3.16070305e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.1765115 -3.16070305e-06j, 0.17668809-1.01674029e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.17668809-1.01674029e-06j, 0.1768649 +1.10369223e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.1768649 +1.10369223e-06j, 0.17704184+3.20099337e-06j,
        0.17704184+3.20099337e-06j, 0.17721885+5.27554884e-06j], dtype=complex128),
 'execution_results': Array(4.9999975, dtype=float64)}

```

This might be a bug!

---

<div class="post-metadata">

**Author:** ![NickGut0711](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/nickgut0711/32/2137_2.png) [@NickGut0711](https://discuss.pennylane.ai/u/NickGut0711)\
**Post date:** [February 14, 2024, 6:41pm UTC](https://discuss.pennylane.ai/t/how-to-calculate-the-quantum-fisher-information-matrix-in-the-middle-of-my-circuit/4070/7 "2024-02-14T18:41:30Z")

</div>

@isaacdevlugt Also, another quick question about Snapshots… Can I use the measurements that they give to train some optimization model with some loss function? I’m just wondering since they’re a little different than QNodes (I know that `qml.Snapshot()` creates an instance of a circuit in the backend though). Thanks!

---

<div class="post-metadata">

**Author:** ![isaacdevlugt](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/isaacdevlugt/32/1159_2.png) [@isaacdevlugt](https://discuss.pennylane.ai/u/isaacdevlugt)\
**Post date:** [February 15, 2024, 9:53pm UTC](https://discuss.pennylane.ai/t/how-to-calculate-the-quantum-fisher-information-matrix-in-the-middle-of-my-circuit/4070/8 "2024-02-15T21:53:47Z")

</div>

> Can I use the measurements that they give to train some optimization model with some loss function?

I would think so yes!

Interesting behaviour (scalars vs arrays example). Is it possible that you’re broadcasting in the one example and not broadcasting in the other?
