Skip to content
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

Merged
merged 5 commits into from
Dec 10, 2024
Merged

Conversation

Cryoris
Copy link
Contributor

@Cryoris Cryoris commented Dec 10, 2024

Summary

This PR fixes two behaviors when decomposing control flow:

Details and comments

Even though c_if is deprecated we should still handle this case, but the logic for this can be removed once c_if is gone. There's a comment specifying which part is c_if-specific.

@Cryoris Cryoris added this to the 1.3.1 milestone Dec 10, 2024
@Cryoris Cryoris requested a review from a team as a code owner December 10, 2024 12:33
@qiskit-bot
Copy link
Collaborator

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core

@Cryoris Cryoris added stable backport potential The bug might be minimal and/or import enough to be port to stable Changelog: Bugfix Include in the "Fixed" section of the changelog labels Dec 10, 2024
Copy link
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.

Thanks for the fix! I left a few minor comments, but it mostly looks good.

qiskit/transpiler/passes/basis/decompose.py Outdated Show resolved Hide resolved
qiskit/transpiler/passes/basis/decompose.py Outdated Show resolved Hide resolved
@@ -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
Copy link
Contributor

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?

Copy link
Contributor Author

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 🙂

@coveralls
Copy link

coveralls commented Dec 10, 2024

Pull Request Test Coverage Report for Build 12256626824

Details

  • 14 of 14 (100.0%) changed or added relevant lines in 1 file are covered.
  • 4 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.01%) to 88.949%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 4 92.48%
Totals Coverage Status
Change from base Build 12236482718: 0.01%
Covered Lines: 79388
Relevant Lines: 89251

💛 - Coveralls

Cryoris and others added 2 commits December 10, 2024 13:57
Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>
Copy link
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.

LGTM! thanks for the fast action on my suggestions!

@ElePT ElePT added this pull request to the merge queue Dec 10, 2024
Merged via the queue into Qiskit:main with commit 4495c67 Dec 10, 2024
17 checks passed
mergify bot pushed a commit that referenced this pull request Dec 10, 2024
* 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)
github-merge-queue bot pushed a commit that referenced this pull request Dec 10, 2024
* 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>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Changelog: Bugfix Include in the "Fixed" section of the changelog stable backport potential The bug might be minimal and/or import enough to be port to stable
Projects
None yet
4 participants