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

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 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:

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!

Hey @NickGut0711,

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

@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.

Okay! Then snapshots will probably be your golden ticket: qml.Snapshot — PennyLane 0.34.0 documentation. I was just answering another forum post and snapshots were also their golden ticket! Here’s that example:

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)()
{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.

@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

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

{'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!

@isaacdevlugt So, I just discovered something interesting…

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

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):

{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!

@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!

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?