0
$\begingroup$

I want to do a feedforward on a quantum circuit using the simulator of Qiskit.

For example, measure qubit_1 to bit 1 and do some operator on qubit_2 if the result of measuring qubit_1 is 0 and if the result is 0, then another operator. Then measure qubit 3 and do some operator on qubit_4 if the result of measuring qubit_3 is 1.

so far I know that I could use

QuantumCurcuit.operator(Quantumregister[index]).c_if(classicalRegister, value)

But the condition of c_if is depended on all value of all bit of classical register. I want to do feedforward depend on an individual bit just 0 or 1.

I think it is not the right way to solve the issue by adding another addition qubit to be $|0\rangle$ and project it on the classical bit. Just to reset that bit to 0 again this way.

So is there any way to reset the classical register?

$\endgroup$
1
$\begingroup$

The c_if in Qiskit only operates on a full classical register, following the OpenQASM spec. If you would like to condition on individual bits, you have to create a new ClassicalRegister for each bit. Then you can condition on each bit separately.

$\endgroup$
  • $\begingroup$ I think it would be a problem when I have to plot the circuit. but yes, this is one of the solutions. $\endgroup$ – Poramet Pathumsoot Jul 15 at 12:06
0
$\begingroup$

You dont have to reset classical registers they store the current measurment result of the quantum bits. I.e. the value of the classical register is not the matter what it matter is that the value they hold after the measurment.

$\endgroup$
  • $\begingroup$ But I need a value of the classical register to do a feed-forward. The first feed-forward is not gonna be a problem but the second one is, the conditional value will grow exponentially. What I want is to reset all of the classical register and use just one condition per feed-forward. $\endgroup$ – Poramet Pathumsoot Jul 15 at 12:11
  • $\begingroup$ do you want to apply some gate on some qubit based on the value of the classical register? $\endgroup$ – Aman Jul 15 at 13:58
  • $\begingroup$ Yes, that is a reason why I use c_if to do this job. $\endgroup$ – Poramet Pathumsoot Jul 15 at 14:39
  • $\begingroup$ Then you need another quantum bit to hold the value of classical register as a black box and apply X gate on it if the value of the classical register is 1. $\endgroup$ – Aman Jul 15 at 17:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.