qiskit-community / qiskit-ionq

Qiskit provider for IonQ backends
https://qiskit-community.github.io/qiskit-ionq/
Apache License 2.0
41 stars 22 forks source link

MS gate matrix is wrong #162

Closed fvoichick closed 3 months ago

fvoichick commented 5 months ago

Information

What is the current behavior?

The MS gate matrix is incorrect. The phi0 parameter affects qubit 1, and the phi1 parameter affects qubit 0.

Steps to reproduce the problem

Run this code:

target = QuantumCircuit(2)
target.rz(-pi / 2, 0)
target.append(MSGate(0, 0), (0, 1))
target.rz(pi / 2, 0)

c0 = QuantumCircuit(2)
c0.append(MSGate(0.25, 0), (0, 1))

c1 = QuantumCircuit(2)
c1.append(MSGate(0, 0.25), (0, 1))

print(process_fidelity(Operator(c0), Operator(target)))
print(process_fidelity(Operator(c1), Operator(target)))

Output:

0.2500000000000001
1.0

What is the expected behavior?

Circuit target should be equivalent to c0. Changing the phi0 parameter should be equivalent to RZ gates on qubit 0, not qubit 1.

Suggested solutions

Fix the gate matrix to adhere to Qiskit's unusual bit ordering conventions.