A simple circuit to produce the The circuit proposed when first initialising and then using Decompose()
the different unitaries done by the 2 different processes Normally, in order to prepare the Bell state $\frac{1}{\sqrt{2}}(|00\rangle+|11\rangle)$, we can simply make a circuit with a Hadamard gate on $|0\rangle$ followed by a CNOT gate on $|1\rangle$. However, initializing the Bell state and then using Decompose() will give a different circuit. We can also check the unitaries of the 2 different scenarios and realize that they are different. Thus, how does Qiskit select the state preparation unitary when the initialize function is used?

  • $\begingroup$ Could you please post the two circuits and unitaries? Also note that in preparation of your Bell states, both qubits are initially in state $|0\rangle$. Having the second qubit in state $|1\rangle$ would lead to another Bell state - $|01\rangle + |10\rangle$, up to normalization constant. $\endgroup$ Jul 17, 2021 at 9:50

1 Answer 1


As stated in this tutorial, qiskit relies on a method from this paper from implementing the initialize function.

Note that this algorithm is generic: it does not assume anything on the state one wants to prepare. However, it is not known how good this algorithm is in terms of CNOT gates for the initializing circuit. The example you took actually proves that the algorithm may yield sub-optimal circuits according to this metric.

Tha algorithm works as follows: first, we create a circuit that yields the state $|0\rangle^{\otimes n}$ from the $n$-qubit state we want, and then we reverse this circuit. In order to do the first step, the idea is the following:

  1. Untangle the last qubit from the rest of the state
  2. Apply the desired rotations to put it in a $|0\rangle$ state
  3. Repeat on the $n-1$-qubit remaining state

In fact, looking at the article, you can see that the operation used for such a task is a controlled $R_Y$ and a controlled $R_Z$: Circuit description On this figure, the last wire represents the qubit to be untangled (this is reversed when compared to qiskit's little-endian convention). They then proceed to upper-bound the number of CNOT gates required to implement these controlled gates to prove that their algorithm yields near-optimal circuits in terms of CNOT gates for initializing arbitrary states.

This explains the difference between both implementations: in the first one, you know using previous knowledge that applying an Hadamard gate on the first qubit and then a CNOT gate on the second one yields the desired state. The initialize function does not have this previous knowledge and entirely relies on the aforementioned algorithm, which yields the rightmost circuit.

Note that the fact that the associated unitaries are not the same doesn't matter, since we assume the input state to be $|00\rangle$. Thus, the only thing that matters in this case is that their first columns match, which is the case.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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