Closed nonhermitian closed 3 years ago
I am super interested in taking this issue as I have been studying about decomposition of gates for sometime now. But, it would be really great if you could tell me one thing, how do we know that two quantum circuits are same. At first I was checking if the net unitary is same but as global phase has effect on the unitary, this test fails. The only way I can think of is going through each possible state. How is this done in practice @nonhermitian
Thanks for your interest @singhmeet11 ! (and sorry I didn't see your comment earlier.) It looks like this bug was already resolved as part of #4837 :
>>> qc = qk.QuantumCircuit(1)
>>> qc.z(0)
>>> qc.barrier()
>>> qc.t(0)
>>> qc.barrier()
>>> qc.tdg(0)
>>> qc.barrier()
>>> qc.s(0)
>>> qc.barrier()
>>> qc.sdg(0)
>>> qk.transpile(qc, basis_gates=['rz'], optimization_level=0).draw()
global phase: π/2
┌───────┐ ░ ┌─────────┐ ░ ┌──────────┐ ░ ┌─────────┐ ░ ┌──────────┐
q_0: ┤ RZ(π) ├─░─┤ RZ(π/4) ├─░─┤ RZ(-π/4) ├─░─┤ RZ(π/2) ├─░─┤ RZ(-π/2) ├
└───────┘ ░ └─────────┘ ░ └──────────┘ ░ └─────────┘ ░ └──────────┘
As to your question on how to assert the input and output circuits are the same, this is in general a difficult problem to solve (see e.g. #5692 for a proposed equivalence checker interface ) but for single qubit circuits, asserting the unitary is the same is sufficient (including global phase).
Please feel free to re-open if you're still seeing this behavior.
No problem
Information
What is the current behavior?
As a follow on to #6411, no simple Z-rotations get properly decomposed into
rz
gates.becomes
Steps to reproduce the problem
What is the expected behavior?
Suggested solutions