# Is it possible to expand/merge different circuits?

Suppose I have created a circuit composed of some registers with the usual

qc = QuantumCircuit(qr, cr)


where qr and cr are a quantum register and a classical register respectively.

Now, suppose that at this point I want to invoke a subroutine. This subroutine, however, uses some ancillas. Is there any functions to append this new set of qubits to the original circuit? Something like

ancillas = QuantumRegister(n, 'ancillas')
#qc.append(ancillas)


An equivalent problem (maybe) is the following one. Suppose I have a quantum circuit qcn composed of n qubits and a subroutine which returns another quantum circuit qck operating on k qubits, with k > n. Is it possible to compose the two circuits in such a way that the first n qubits on which the subroutine operates are the same of the original circuit?

At the moment, the only solution to me seems to declare in advance all the total number of qubits required (k in the previous case) and then passing around them to the various functions.

For the first question, you can use

qc.add(ancillas)


Note that this will change to add_registers in Qiskit Terra 0.7.0.

Some more guidance on how to combine and extend circuits, you can see this guide. Note that this is for the upcoming 0.7.0 release, but you can already get the functionality with

pip install git+https://github.com/Qiskit/qiskit-terra.git

• Thanks, just what I needed. Btw, there are any planes on when the 0.7.0 version will be officially out? Together with a list of major breaks wrt the 0.6 version. – tigerjack89 Dec 9 '18 at 22:45
• I think it should be out in the next few weeks, but the holidays may lead to a slight delay. The 0.7 releases shouldn't differ too much from the 0.6 releases. They'll mainly differ to the integration of some tools from outside of Terra. – James Wootton Dec 10 '18 at 10:58