5
$\begingroup$

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?

$\endgroup$

1 Answer 1

5
$\begingroup$

In your example you can do

qc.decompose().draw()

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.

qc.decompose().decompose().draw()
$\endgroup$
1
  • $\begingroup$ Works like magic, thank you @luciano $\endgroup$
    – quantum
    Nov 18, 2021 at 0:01

Your Answer

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

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