-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Fix final_layout when VF2PostLayout finds a better layout #10466
Fix final_layout when VF2PostLayout finds a better layout #10466
Conversation
This commit fixes a bug in the preset pass managers when VF2PostLayout is run and finds a better layout to use. In these cases the ApplyLayout was updating the layout but we never updated the final layout to reflect these changes. This would result in an incorrect final layout because the input positions of the qubits were incorrect after re-applying the layout. This commit fixes this by adding code to ApplyLayout to also update final_layout, if one is set, to reflect the new initial layout found by VF2PostLayout. Fixes Qiskit#10457
One or more of the the following people are requested to review this:
|
Pull Request Test Coverage Report for Build 5648970491
💛 - Coveralls |
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.
Thanks!
@@ -94,6 +96,13 @@ def run(self, dag): | |||
qargs = [q[new_virtual_to_physical[qarg]] for qarg in node.qargs] | |||
new_dag.apply_operation_back(node.op, qargs, node.cargs) | |||
self.property_set["layout"] = full_layout | |||
if (final_layout := self.property_set["final_layout"]) is not None: |
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.
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.
Heh, I was wondering if you'd notice, figured I'd give it a try :D
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.
I apparently didn't notice it the first time I read it, but saw it when I was checking the changes haha.
* Fix final_layout when VF2PostLayout finds a better layout This commit fixes a bug in the preset pass managers when VF2PostLayout is run and finds a better layout to use. In these cases the ApplyLayout was updating the layout but we never updated the final layout to reflect these changes. This would result in an incorrect final layout because the input positions of the qubits were incorrect after re-applying the layout. This commit fixes this by adding code to ApplyLayout to also update final_layout, if one is set, to reflect the new initial layout found by VF2PostLayout. Fixes #10457 * Remove stray debug print * Use a list instead of a dict * Add assertion on vf2postlayout being used in compiler.transpile tests * Actually assert a post layout is set (cherry picked from commit 42a0ee8)
…10493) * Fix final_layout when VF2PostLayout finds a better layout This commit fixes a bug in the preset pass managers when VF2PostLayout is run and finds a better layout to use. In these cases the ApplyLayout was updating the layout but we never updated the final layout to reflect these changes. This would result in an incorrect final layout because the input positions of the qubits were incorrect after re-applying the layout. This commit fixes this by adding code to ApplyLayout to also update final_layout, if one is set, to reflect the new initial layout found by VF2PostLayout. Fixes #10457 * Remove stray debug print * Use a list instead of a dict * Add assertion on vf2postlayout being used in compiler.transpile tests * Actually assert a post layout is set (cherry picked from commit 42a0ee8) Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
* Fix final_layout when VF2PostLayout finds a better layout This commit fixes a bug in the preset pass managers when VF2PostLayout is run and finds a better layout to use. In these cases the ApplyLayout was updating the layout but we never updated the final layout to reflect these changes. This would result in an incorrect final layout because the input positions of the qubits were incorrect after re-applying the layout. This commit fixes this by adding code to ApplyLayout to also update final_layout, if one is set, to reflect the new initial layout found by VF2PostLayout. Fixes Qiskit#10457 * Remove stray debug print * Use a list instead of a dict * Add assertion on vf2postlayout being used in compiler.transpile tests * Actually assert a post layout is set
Summary
This commit fixes a bug in the preset pass managers when VF2PostLayout is run and finds a better layout to use. In these cases the ApplyLayout was updating the layout but we never updated the final layout to reflect these changes. This would result in an incorrect final layout because the input positions of the qubits were incorrect after re-applying the layout. This commit fixes this by adding code to ApplyLayout to also update final_layout, if one is set, to reflect the new initial layout found by VF2PostLayout.
Details and comments
Fixes #10457