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')

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.


1 Answer 1


For the first question, you can use


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
  • $\begingroup$ 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. $\endgroup$
    – tigerjack
    Commented Dec 9, 2018 at 22:45
  • 1
    $\begingroup$ 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. $\endgroup$ Commented Dec 10, 2018 at 10:58

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.