Is it possible to expand/merge different circuits?
up vote
2
down vote
favorite
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
New contributor
tigerjack89 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
2
down vote
favorite
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
New contributor
tigerjack89 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
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
New contributor
tigerjack89 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
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
programming qiskit ibm-q-experience
New contributor
tigerjack89 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
tigerjack89 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited Dec 10 at 4:18
Blue♦
5,63511352
5,63511352
New contributor
tigerjack89 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked Dec 9 at 21:06
tigerjack89
1906
1906
New contributor
tigerjack89 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
tigerjack89 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
tigerjack89 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
4
down vote
accepted
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 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
add a comment |
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',
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
});
}
});
tigerjack89 is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
up vote
4
down vote
accepted
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 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
add a comment |
up vote
4
down vote
accepted
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 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
add a comment |
up vote
4
down vote
accepted
up vote
4
down vote
accepted
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
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
answered Dec 9 at 21:58
James Wootton
5,9901941
5,9901941
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
add a comment |
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
add a comment |
tigerjack89 is a new contributor. Be nice, and check out our Code of Conduct.
tigerjack89 is a new contributor. Be nice, and check out our Code of Conduct.
tigerjack89 is a new contributor. Be nice, and check out our Code of Conduct.
tigerjack89 is a new contributor. Be nice, and check out our Code of Conduct.
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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