-
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
Add Expr
support in DAGCircuit.substitute_node
#10382
Conversation
One or more of the the following people are requested to review this:
|
Pull Request Test Coverage Report for Build 5604254441
💛 - Coveralls |
As part of this minor refactor, this updates the logic to no longer silently override conditions on the replacement `op`. The method gains a `propagate_condition` argument analogous to the same argument in `substitute_node_with_dag`, which can be set `False` to specify that the caller is aware that the new operation should implement the same conditional logic.
e70058f
to
60cd949
Compare
Rebased on |
current_wires = {wire for _, _, wire in self.edges(node)} | ||
new_wires = set(node.qargs) | set(node.cargs) | ||
if (new_condition := getattr(op, "condition", None)) is not None: | ||
new_wires.update(condition_resources(new_condition).clbits) |
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.
Is there a mapping or check that needs to be done here to ensure op.condition
exists in the dag already?
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.
If you mean the wires, it happens lower down, I think: https://github.com/Qiskit/qiskit-terra/blob/60cd949fc41915c1a12fb8faa3e4c1ea3e6f94b5/qiskit/dagcircuit/dagcircuit.py#L1331-L1337.
(Looks like there might be a comment that's out of date there though haha!)
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.
Ah, yeah that'll do it. It just slipped my mental context that this would validate wires.
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.
LGTM
Summary
As part of this minor refactor, this updates the logic to no longer silently override conditions on the replacement
op
. The method gains apropagate_condition
argument analogous to the same argument insubstitute_node_with_dag
, which can be setFalse
to specify that the caller is aware that the new operation should implement the same conditional logic.Details and comments
Close #10380. Depends on #10377. This has a partial changelog of itself, but the rest is coming in #10331.