-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix .decompose
on control flow
#13545
Conversation
One or more of the following people are relevant to this code:
|
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 for the fix! I left a few minor comments, but it mostly looks good.
@@ -58,20 +60,28 @@ def run(self, dag: DAGCircuit) -> DAGCircuit: | |||
output dag where ``gate`` was expanded. | |||
""" | |||
# We might use HLS to synthesize objects that do not have a definition | |||
hls = HighLevelSynthesis() if self.apply_synthesis else None | |||
hls = HighLevelSynthesis(qubits_initially_zero=False) if self.apply_synthesis else 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.
Was this a previous oversight?
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.
Yeah, we should not assume the initial qubit state since HLS here is called on individual blocks inside the circuit. However, technically, it didn't really matter since this argument only makes a difference if there are auxiliary qubits involved and the way we build the node_as_dag
here won't have any auxiliary qubits. But still it's likely better to have the correct setting here 🙂
Pull Request Test Coverage Report for Build 12256626824Details
💛 - Coveralls |
Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>
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! thanks for the fast action on my suggestions!
* decompose control flow ops * add reno and test * trailing print * thou shall support Python 3.9 * Fix comments & reno Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com> --------- Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com> (cherry picked from commit 4495c67)
* decompose control flow ops * add reno and test * trailing print * thou shall support Python 3.9 * Fix comments & reno Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com> --------- Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com> (cherry picked from commit 4495c67) Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>
Summary
This PR fixes two behaviors when decomposing control flow:
c_if
on an operation without definition (i.e.None
) would failQuantumCircuit.decompose
raises an error with a conditional U gate for Qiskit 1.3.0 and the main branch #13493).decompose
(Control flow operations are not.decompose
d #13544)Details and comments
Even though
c_if
is deprecated we should still handle this case, but the logic for this can be removed oncec_if
is gone. There's a comment specifying which part isc_if
-specific.