dlyongemallo / qiskit-zx-transpiler

A transpiler pass for Qiskit which uses ZX-Calculus for circuit optimization, implemented using PyZX.
Apache License 2.0
1 stars 0 forks source link

Transpiler optimization_method="zxpass" gives wrong result #44

Closed BankNatchapol closed 8 hours ago

BankNatchapol commented 2 weeks ago

Environment

What is happening?

Circuits after Transpilation should give similar result, but not.

How can we reproduce the issue?

from qiskit.quantum_info import Statevector
from qiskit.compiler import transpile

with open('acircuit.qpy', 'rb') as handle:
    qc = qpy.load(handle)
wo = transpile(qc, basis_gates=['cz', 'swap', 'cx', 'tdg', 's', 'sdg', 'h', 'rz'], optimization_level=1)[0]
w = transpile(wo, basis_gates=['cz', 'swap', 'cx', 'tdg', 's', 'sdg', 'h', 'rz'], optimization_method="zxpass")

print(Statevector(wo))
print(Statevector(w))

ill attach acircuit.qpy acircuit.zip

What should happen?

the statevector should be the same.

Any suggestions?

If it's correct, please guide me how to make the statevector output to be the same. Thank you in advance.

dlyongemallo commented 2 weeks ago

The state vectors produced by your program appear to be equivalent.

What's the output of the following for you?

print(Statevector(wo).equiv(Statevector(w)))

This results in the output True for me.

dlyongemallo commented 1 day ago

@BankNatchapol Can this issue be closed?

dlyongemallo commented 8 hours ago

I'm going to close this issue as your repro case works perfectly fine for me. Please let me know if there's anything that's unclear or I could help you with.