Skip to content

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

Merged
ElePT merged 1 commit into
Qiskit:mainfrom
jakelishman:reinstate-no-deepcopy-transpile
Nov 2, 2023
Merged

Copy-in rather than copy-out in transpiler#11176
ElePT merged 1 commit into
Qiskit:mainfrom
jakelishman:reinstate-no-deepcopy-transpile

Conversation

@jakelishman
Copy link
Copy Markdown
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 Make Mergify open a backport PR to the most recent stable branch on merge. Changelog: None Do not include in the GitHub Release 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
Copy Markdown
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
Copy Markdown
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
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 the GitHub Release changelog. mod: transpiler Issues and PRs related to Transpiler stable backport potential Make Mergify open a backport PR to the most recent stable branch on merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants