-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Delegate BasePass.__call__
to PassManager.run
#13820
Conversation
This ensures that calling a pass directly will follow the same execution logic as a regular pass-manager construction. This particularly matters for passes that have `requires`. It also ensures that the conversion from a circuit and back to a DAG will follow the same rules, which is expected since it is a shorthand notation, but liable to get out of sync as they are complex.
One or more of the following people are relevant to this code:
|
perm = pass_.property_set["virtual_permutation_layout"].to_permutation(qc.qubits) | ||
res.append(PermutationGate(perm), [0, 1, 2, 3, 4]) | ||
res.append(PermutationGate(res.layout.routing_permutation()), [0, 1, 2, 3, 4]) |
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.
PassManager.run
explicitly clears out virtual_permutation_layout
from a property_set
after execution, since it updates the layout fields. This new version of the PermutationGate
is more properly the behaviour we want to test, though.
Oh whoops, I forgot I hadn't fixed that test error locally. |
Pull Request Test Coverage Report for Build 13687355258Details
💛 - Coveralls |
06e1753
to
390fa85
Compare
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.
This LGTM, it seems pretty straightforward and it'll be good to unify the logic between __call__
and PassManager.run()
@@ -462,6 +472,9 @@ def _replace_error(meth): | |||
def wrapper(*meth_args, **meth_kwargs): | |||
try: | |||
return meth(*meth_args, **meth_kwargs) | |||
except TranspilerError: | |||
# If it's already a `TranspilerError` subclass, don't erase the extra information. |
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 remember discussing this offline, but TranspilerError
being a subclass of PassManagerError
seems so weird. But it's hard to change this now so this makes sense.
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 assume it was intended as a backwards-compatibility shim for a move to PassManagerError
during the genericisation of PassManager
, but I don't really know.
This ensures that calling a pass directly will follow the same execution logic as a regular pass-manager construction. This particularly matters for passes that have
requires
. It also ensures that the conversion from a circuit and back to a DAG will follow the same rules, which is expected since it is a shorthand notation, but liable to get out of sync as they are complex.Summary
Details and comments
Fix #13444.
Requires #13821 to effect the warning on the future behaviour change.