2
$\begingroup$

enter image description here

Why am I getting here a measurement outcome of $00$? I measure after the first $X$ gate in a separate output bit c[1] which should result in a $1$ and I measure again after a second $X$ gate in a separate output bit c[0] which should result in a $0$, so $10$ in total. Why do I get the output $00$ as if both measurements are performed after the whole circuit? And how can I do intermediate measurements as expected?

$\endgroup$
3
$\begingroup$

The problem is that IBM Q shows results of measurement of a final quantum state (I found this after some trial and error).

When you apply first $X$ gate, qubits switches from $|0\rangle$ to $|1\rangle$. The measurement result is of course 1 and this value is stored in classical register, hence you see 10 in Measurement probabilities window.

Now you apply another $X$ gate and this switches your qubit back to state $|0\rangle$. So, after measurement you see 0 in classical register. As I mentioned above, only final state probabilities is shown Measurement probabilities window. So, yes, the first measurement is really ignored and it seems that this is a feature of IBM Q environment, although logic says that if you save results to different classical bits, they should be preserved.

$\endgroup$
2
  • 2
    $\begingroup$ I think the IBM devices are not even capable of performing intermediary measurements... $\endgroup$ – JSdJ Dec 10 '20 at 9:57
  • $\begingroup$ Maybe getting the state vector after the quantum operation and then randomly pick one state(although there might be technical issues obstacle this strategy) according to the probability distribution to initialize another quantum register is a possible way to perform intermediary measurements. But this is a pureely coding job and seems more like "I do so"? $\endgroup$ – Yitian Wang Dec 16 '20 at 1:13
0
$\begingroup$

The first measurement is not being ignored.

Your quantum state started in the state $|0\rangle$ and after the $X$ gate, it is now in the state $|1\rangle$. Measuring the qubit collapsed it into the state $|1\rangle$ again... since $|1\rangle$ is already an eigenvector of the $Z$ Pauli operator.

So your state never changes after the first measurement, you still in the state $|1\rangle$. Thus, after applying another $X$ gate, you get back to $|0\rangle$. That is the reason why you only see $0$ is being measured.


Edit: My comment about the first measurement "not" being ignored when looking at the measurement probabilities is incorrect.

However, the first measurement is not being ignore in the experiment overall... That is, say you start in the state $|0\rangle$ then apply Hadamard gate $H$ to it, make a measurement, apply another Hadamard gate $H$ and then make another measurement. If the first measurement is being ignored, then you would get back $|0\rangle$.. but in fact we don't: enter image description here

Now, if you put the first measurement in the first cbit1 and the second measurement on the second cbit2 then you get something like:

enter image description here

This was being simulated on the qasm_simulator as current device is not capable of yet doing this intermediate measurement. So on the real hardware, you can't perform any additional operations after the first measurement.

Another note is that if you do this in the circuit composer environment, you get something like:

enter image description here

$\endgroup$
3
  • $\begingroup$ Still hard to understand why measurement result of clbit[1] is changed. $\endgroup$ – Yitian Wang Dec 10 '20 at 9:04
  • 1
    $\begingroup$ Actually, the measurement is ignored since first result (1) is stored in classical bit c1 and the second result(0) is stored in classical bit c0. But this is probably feature of IBM Q. See my answer below for details. $\endgroup$ – Martin Vesely Dec 10 '20 at 9:13
  • $\begingroup$ @YitianWang I didn't see that clearly. I was just reading the right hand graph... so yes, that was a mistake. $\endgroup$ – KAJ226 Dec 10 '20 at 15:53

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.