Hi @Miguel_Fernandez, I’ve tried the following minimal example,
dev = qml.device("default.qubit", wires=2)
@qml.qnode(dev)
def circuit():
qml.Hadamard(wires=1)
qml.CNOT(wires=[0, 1])
return prob(wires=[0, 1])
# expected probability, using [00, 01, 10, 11]
# ordering, is [0.5, 0.5, 0, 0]
res = circuit()
expected = np.array([0.5, 0.5, 0, 0])
assert np.allclose(res, expected, atol=tol, rtol=0)
and it seems to agree with [00, 01, 10, 11]
ordering:
>>> import numpy as np
>>> H = np.array([[1, 1], [1, -1]])/np.sqrt(2)
>>> CNOT = np.array([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]])
>>> state = CNOT @ np.kron(np.eye(2), H) @ np.array([1, 0, 0, 0])
>>> expected = np.abs(state)**2
>>> expected
array([0.5, 0.5, 0. , 0. ])
Could you share a small example that shows {00,10,01,11}
? It might be a edge-case related bug in the code that we are not taking into account.