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

Copy-in rather than copy-out in transpiler #11176

Merged
merged 1 commit into from
Nov 2, 2023

Conversation

jakelishman
Copy link
Member

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.

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 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
@jakelishman jakelishman added this to the 0.45.0 milestone Nov 2, 2023
@jakelishman jakelishman requested a review from a team as a code owner November 2, 2023 15:14
@qiskit-bot
Copy link
Collaborator

One or more of the the following people are requested to review this:

  • @Qiskit/terra-core

@ElePT ElePT mentioned this pull request Nov 2, 2023
13 tasks
Copy link
Contributor

@ElePT ElePT left a 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!

@ElePT ElePT enabled auto-merge November 2, 2023 16:03
@ElePT ElePT added this pull request to the merge queue Nov 2, 2023
Merged via the queue into Qiskit:main with commit eca3478 Nov 2, 2023
14 checks passed
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)
@jakelishman jakelishman deleted the reinstate-no-deepcopy-transpile branch November 2, 2023 19:20
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants