Question on qml.measure

Hello! I have a question about qml.measure. When I use the code as follows:

for i in np.arange(0, nq, 2):
        qml.measure(wires=i, reset=True)

If I don’t care about the measurement result, and just apply quantum operations on qubits with odd indexes, then get the corresponding reduced density matrix for qubits with odd indexes. Then, when I calculate the gradients of the final state, how PennyLane treat this state? Is the state with a certain measurement result considered, or it equal to trace out qubits with even indexes?

Besides, if I only want the states with measurement result 0 (post-selection), how can I implement it?

Hi @jones ,

It’s good to see you back!
I think this will depend on the specific configuration and simulation technique that you use.
You can find a table here in the docs which mentions some of the options and limitations.

If you have a minimal reproducible example I can try to investigate further. I’ll still give it another thought to see if there’s any additional way of looking into how the gradients are being calculated.