PennyLaneAI/pennylane-qulacs

Incorrect state preparations for multiple qubits

Closed this issue · 4 comments

Some newly added test cases from the device test suite are failing when using BasisState and QubitStateVector for multiple qubits.

Example:

dev1 = qml.device('default.qubit', wires=3)
dev2 = qml.device('qulacs.simulator', wires=3)

par = np.array([0, 1, 0, 0, 0, 0, 0, 0])

def circuit():
    qml.QubitStateVector(par, wires=[2,1,0])
    return qml.expval(qml.PauliZ(0)), qml.expval(qml.PauliZ(1)), qml.expval(qml.PauliZ(2))

qnode1 = qml.QNode(circuit, dev1)
qnode2 = qml.QNode(circuit, dev2)

print("Default qubit: ", qnode1())
print("Qulacs simulator: ", qnode2())
Default qubit:  [-1.  1.  1.]
Qulacs simulator:  [ 1.  1. -1.]

See the following example and the log:
https://github.com/PennyLaneAI/plugin-test-matrix/runs/2476581306?check_suite_focus=true#step:7:77

These might be due to PennyLane and the plugin libraries using two different conventions for "endian-ness" of the qubit ordering?

These might be due to PennyLane and the plugin libraries using two different conventions for "endian-ness" of the qubit ordering?

Seems to be the case 🤔

Fixed in #25.

🎉