I'm aware that to randomly initialize a quantum circuit with Qiskit, we can simply write qc.initialize(rand_state, q[0]...). However, when drawing the circuit, I see that the "initialize" function is treated as one big gate that takes in an input and outputs the initialized state.

enter image description here

Is there a way to decompose this "initialization gate" through python/Qiskit and run a circuit that is composed of the individual smaller gates that actually make up this large gate?


1 Answer 1


In your example you can do


The method decompose decomposes every gate in the circuit. This will do a single level. If you want to do another level of decomposition, call the method again.

  • $\begingroup$ Works like magic, thank you @luciano $\endgroup$
    – quantum
    Commented Nov 18, 2021 at 0:01

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.