-
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
Copy-in rather than copy-out in transpiler #11176
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This shifts the deepcopy of instructions in the transpiler to be at the input stage, rather than the output stage. This more closely matches our behaviour before the passmanager refactoring, but also has a performance benefit for circuits that require significant routing and is typically safer for transpiler passes. Output circuits are typically larger than input ones, so copy-in means less copying, and also makes the ownership model for tranpsiler passes clearer: a pass can assume the input operations are entirely owned by the circuit it receives, and that a pass must output a circuit that entirely owns its operations.
jakelishman
added
stable backport potential
The bug might be minimal and/or import enough to be port to stable
Changelog: None
Do not include in changelog
mod: transpiler
Issues and PRs related to Transpiler
labels
Nov 2, 2023
One or more of the the following people are requested to review this:
|
ElePT
approved these changes
Nov 2, 2023
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.
Given that this fixes an unintended behavioral change, I think that it makes a lot of sense to include it into 0.45.0. Thanks Jake!
mergify bot
pushed a commit
that referenced
this pull request
Nov 2, 2023
This shifts the deepcopy of instructions in the transpiler to be at the input stage, rather than the output stage. This more closely matches our behaviour before the passmanager refactoring, but also has a performance benefit for circuits that require significant routing and is typically safer for transpiler passes. Output circuits are typically larger than input ones, so copy-in means less copying, and also makes the ownership model for tranpsiler passes clearer: a pass can assume the input operations are entirely owned by the circuit it receives, and that a pass must output a circuit that entirely owns its operations. (cherry picked from commit eca3478)
github-merge-queue bot
pushed a commit
that referenced
this pull request
Nov 2, 2023
This shifts the deepcopy of instructions in the transpiler to be at the input stage, rather than the output stage. This more closely matches our behaviour before the passmanager refactoring, but also has a performance benefit for circuits that require significant routing and is typically safer for transpiler passes. Output circuits are typically larger than input ones, so copy-in means less copying, and also makes the ownership model for tranpsiler passes clearer: a pass can assume the input operations are entirely owned by the circuit it receives, and that a pass must output a circuit that entirely owns its operations. (cherry picked from commit eca3478) Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Changelog: None
Do not include in changelog
mod: transpiler
Issues and PRs related to Transpiler
stable backport potential
The bug might be minimal and/or import enough to be port to stable
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This shifts the deepcopy of instructions in the transpiler to be at the input stage, rather than the output stage. This more closely matches our behaviour before the passmanager refactoring, but also has a performance benefit for circuits that require significant routing and is typically safer for transpiler passes. Output circuits are typically larger than input ones, so copy-in means less copying, and also makes the ownership model for tranpsiler passes clearer: a pass can assume the input operations are entirely owned by the circuit it receives, and that a pass must output a circuit that entirely owns its operations.
Details and comments
The behaviour before #10127 was copy-in, as this PR reinstates, and I think it just got mistakenly swapped over in that - I didn't notice during the review either.
Ideally this goes into 0.45.0, so the behavioural change from #10127 doesn't get released, but it's not a big deal if it goes into 0.45.1 instead, I think.