Bell state measurement strange behaviour

Hi, I was exploring some of the experimental parts of PennyLane and found something strange happening!

When creating a Bell state, the outcomes of running a quantum circuit on the tensor device are not as expected. As we are either sampling the |00> or the |11> states, I’d expect to get the same outcomes each time! This is not the case here:

import pennylane as qml

def circuit():
    qml.Hadamard(wires=0)
    qml.CNOT(wires=[0, 1])
    return [qml.sample(qml.PauliZ(i)) for i in range(2)]

dev = qml.device("default.tensor", wires=2, shots=10)
qnode = qml.QNode(circuit, dev)
qnode()
array([[ 1., -1.,  1., -1.,  1., -1., -1.,  1., -1.,  1.],
       [-1., -1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.]])

Note: I was using tensornetwork==0.4.0 and PennyLane==0.16.0.

It is bug found recently, and has not been fixed to date.

Tensor network simulation method in qml.beta - PennyLane Help - Xanadu Discussion Forum

1 Like