I am trying to implement the Iterative Phase Estimation algorithm on one of Qiskit's labs. I can do it for a 'nice' phase, such as 1/4 :
But if I want to implement the algo generally (as a subroutine for other algorithms, etc), the R_z gates will have to be conditioned on the values of the classical bits I measure (first gate conditioned on c_3 = 1, second gate conditioned on c_3 = 1, third gate conditioned on c_2 = 1).
I know that by the Deferred Measurement Principle, I can get a circuit with the same outcome by changing the conditioned R_z's in some way and measuring everything at the end. The question is how? Is there a general rule / set of principles on how to do this for a given circuit?
I'm asking for two reasons. First is that if I keep the c_if's, they have to be conditioned on individual bits, which isn't supported by Qiskit unless I go around it by saying that c3 = 1 if c = 4,5,6,7, etc.; and that's just not nice. Second is that I would like to execute the circuit on a real quantum computer and IBM computers don't support c_if.