I have a quantum circuit with a number of gates, and some of them are labeled by some letters without showing the details inside. I have known the quantumcircuit.decompose() would help, but it would decompose all the gates. I am wondering whether we can choose only a subset of gates to decompose. How to write the code? Really appreciate it if some examples can be provided.
You can just pass the gate label to
op1 = random_unitary(4) op2 = random_unitary(4) op3 = random_unitary(4) circ = QuantumCircuit(2) circ.unitary(op1, [0, 1], 'label_1') circ.unitary(op2, [0, 1], 'label_2') circ.unitary(op3, [0, 1], 'label_3') circ.decompose(gates_to_decompose = 'label_2').draw('mpl')
gates_to_decompose can be a list such as