-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Circuit composition wraps per default #6227
Conversation
@@ -643,7 +643,7 @@ def extend(self, rhs): | |||
|
|||
return self | |||
|
|||
def compose(self, other, qubits=None, clbits=None, front=False, inplace=False): | |||
def compose(self, other, qubits=None, clbits=None, wrap=True, front=False, inplace=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jaygambetta (I need a message to send you a link to the code)
thanks looking forward to seeing this but if we dont wrap by default this does not close the issue we need a second pr for the libraries. |
yes, I'll refactor this one and open a new one for wrapping the library circuits 👍🏻 |
Summary
Add a
wrap
keyword argument toQuantumCircuit.compose
to set whether the composed circuit should be wrapped in an instruction or not.Per default, wrap the other circuit, to allow a better overview of the individual circuit blocks (especially if attaching library circuits) and be closer to the behavior of
append
so that in long-term we can remove that one and keep onlycompose
. Note that this changes how the default of howcircuit.compose(other)
looks like, but it's no functional change.Closes #6147 (but does a bit more, see also the discussion in that issue).
Details and comments
compose
get's a newwrap
argument that'sTrue
by defaultappend
also get's afront
argument to append infront of a circuit to streamline the usage with compose (but mainly to simplify the logic in the code)QuantumVolume
,Permute
andIQP
don't return a circuit with a single wrapped instruction, since compose now wraps and to improve consistency with the rest of the library