Is it possible to expand/merge different circuits?












2














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.










share|improve this question





























    2














    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.










    share|improve this question



























      2












      2








      2


      1





      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.










      share|improve this question















      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.







      programming qiskit ibm-q-experience






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 10 at 4:18









      Blue

      5,64521352




      5,64521352










      asked Dec 9 at 21:06









      tigerjack89

      2158




      2158






















          1 Answer
          1






          active

          oldest

          votes


















          4














          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





          share|improve this answer





















          • 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 at 22:45






          • 1




            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 at 10:58











          Your Answer





          StackExchange.ifUsing("editor", function () {
          return StackExchange.using("mathjaxEditing", function () {
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
          });
          });
          }, "mathjax-editing");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "694"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          noCode: true, onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fquantumcomputing.stackexchange.com%2fquestions%2f4897%2fis-it-possible-to-expand-merge-different-circuits%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          4














          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





          share|improve this answer





















          • 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 at 22:45






          • 1




            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 at 10:58
















          4














          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





          share|improve this answer





















          • 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 at 22:45






          • 1




            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 at 10:58














          4












          4








          4






          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





          share|improve this answer












          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






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 9 at 21:58









          James Wootton

          5,9851942




          5,9851942












          • 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 at 22:45






          • 1




            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 at 10:58


















          • 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 at 22:45






          • 1




            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 at 10:58
















          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 at 22:45




          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 at 22:45




          1




          1




          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 at 10:58




          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 at 10:58


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Quantum Computing Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fquantumcomputing.stackexchange.com%2fquestions%2f4897%2fis-it-possible-to-expand-merge-different-circuits%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Aardman Animations

          Are they similar matrix

          “minimization” problem in Euclidean space related to orthonormal basis