Skip to content
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

Closed
wants to merge 17 commits into from
Closed

Conversation

Cryoris
Copy link
Contributor

@Cryoris Cryoris commented Apr 14, 2021

Summary

Add a wrap keyword argument to QuantumCircuit.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 only compose. Note that this changes how the default of how circuit.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 new wrap argument that's True by default
  • append also get's a front argument to append infront of a circuit to streamline the usage with compose (but mainly to simplify the logic in the code)
  • the library circuits QuantumVolume, Permute and IQP don't return a circuit with a single wrapped instruction, since compose now wraps and to improve consistency with the rest of the library

@@ -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):
Copy link
Contributor Author

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)

@jaygambetta
Copy link
Member

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.

@Cryoris
Copy link
Contributor Author

Cryoris commented Jun 23, 2021

yes, I'll refactor this one and open a new one for wrapping the library circuits 👍🏻

@Cryoris
Copy link
Contributor Author

Cryoris commented Jun 29, 2021

Closing in favor of #6634 and #6659.

@Cryoris Cryoris closed this Jun 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

compose should not unroll (by default) when using the circuit library
2 participants