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

Avoid deepcopy in sabre_swap (bp #5316) #5334

Merged
merged 2 commits into from
Nov 3, 2020

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Nov 2, 2020

This is an automated backport of pull request #5316 done by Mergify

Mergify commands and options

More conditions and actions can be found in the documentation.

You can also trigger Mergify actions by commenting on this pull request:

  • @Mergifyio refresh will re-evaluate the rules
  • @Mergifyio rebase will rebase this PR on its base branch
  • @Mergifyio update will merge the base branch into this PR
  • @Mergifyio backport <destination> will backport this PR on <destination> branch

Additionally, on Mergify dashboard you can:

  • look at your merge queues
  • generate the Mergify configuration with the config editor.

Finally, you can contact us on https://mergify.io/

This commit changes the deepcopy usage in the sabreswap pass to a
shallow copy. In sabre_swap the deepcopy was run on the DAGCircuit node
when remapping it, however this was not necessary because it's not
actually used where shared references matter. The output from the
remapper is not used directly and instead a copy of the DAGNode object
is just used as a container for the required args in
apply_operation_back() where a new DAGNode is always created from the
op, qargs, etc. The remapping just replaces the qargs parameter with the
remapped one. So this commit changes the deepcopy to a shallow copy
which won't have the performance overhead.

Fixes #5197

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
(cherry picked from commit a506ba9)
@mergify mergify bot requested a review from a team as a code owner November 2, 2020 15:59
@mergify mergify bot merged commit 34addf1 into stable/0.16 Nov 3, 2020
@mergify mergify bot deleted the mergify/bp/stable/0.16/pr-5316 branch November 3, 2020 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants