Probability() usage

Hi @Miguel_Fernandez, as odd as it looks, I believe PennyLane and Qiskit are returning the exact same result.

The disagreement results from Qiskit not implementing the same convention as commonly seen in quantum information papers and textbook; typically, the top qubit (labelled 0) in a circuit is the leftmost integer within the ket; |q_0 q_1 \cdots q_{n-1} q_n\rangle.

For example, for a 2-qubit system originally in the ground state |00\rangle, applying an X gate to qubit 0 in this convention gives |10\rangle.

This can be observed in PennyLane:

@qml.qnode(dev)
def func():
     qml.PauliX(wires=0)
     return qml.probs(wires=0)

>>> func()
array([0., 0., 1., 0.])

where we are using the ordering (|00\rangle, |01\rangle,|10\rangle,|11\rangle).

Qiskit instead uses the convention such that the top qubit (qubit 0) is now the rightmost integer within the ket: |q_{n-1}q_{n}\cdots q_1q_0\rangle. In this convention, applying an X gate to qubit 0 gives |01\rangle.

Running the exact same program in Qiskit, we can see this reversal:

>>> q = qiskit.QuantumRegister(2, 'q')
>>> c = qiskit.ClassicalRegister(2, 'c')
>>> qpe = qiskit.QuantumCircuit(q, c)
>>> qpe.x(q[0])
>>> backend = qiskit.BasicAer.get_backend('statevector_simulator')
>>> job = qiskit.execute(qpe, backend)
>>> result = job.result()
>>> result.get_statevector().real
array([0., 1., 0., 0.])

where we are again using the ordering (|00\rangle, |01\rangle,|10\rangle,|11\rangle).

To convert from the Qiskit convention to the more standard/textbook convention (as used by PennyLane), all that needs to be done is reverse the basis state or permute the statevector/probabilities :slightly_smiling_face: