Skip to content

Fix: BasisTranslator processing of nested ControlFlowOp (backport #15875)#15884

Merged
raynelfss merged 1 commit intostable/2.4from
mergify/bp/stable/2.4/pr-15875
Mar 26, 2026
Merged

Fix: BasisTranslator processing of nested ControlFlowOp (backport #15875)#15884
raynelfss merged 1 commit intostable/2.4from
mergify/bp/stable/2.4/pr-15875

Conversation

@mergify
Copy link
Copy Markdown
Contributor

@mergify mergify bot commented Mar 26, 2026

Summary

Inspired by #15797
The following PR fixes a long standing bug in BasisTranslator by allowing all calculated transformations to be applied within a ControlFlowOp.

Details and comments

Fixes #15734
Fixes #14025
Fixes #13162

  • Remove the bool output is_updated from apply_translation helper method in BasisTranslator. The removal of this argument ensures that when a translation is found it is always applied.
    • The is_modified boolean output, while intended as a way of optimizing the operation of the BasisTranslator did not achieve much as a new DAGCircuit would be created each time.
    • During the ControlFlowOp handling step of this method we relied on is_updated to determine whether to use the original DAGCircuit or not, which in the end would erroneously skip certain transformations in the Operation's blocks.
    • By removing this tracking value, which was already ignored by the main BasisTranslator process. We end up with a more correct processing of the instructions at hand.
  • Update test test_inner_wire_map_control_op from the TestCircuitControlFlowOps as better outcome is now found for said circuit.
    This is an automatic backport of pull request Fix: BasisTranslator processing of nested ControlFlowOp #15875 done by Mergify.

* Fix: `BasisTranslator` processing of `ControlFlowOp`
- Remove the bool output `is_updated` from `apply_translation` helper method in `BasisTranslator`.
    The removal of this argument ensures that when a translation is found it is always applied. The `is_modified` boolean output, while intended as a way of optimizing the operation of the `BasisTranslator` did not achieve much as a new `DAGCircuit would be created each time.
    During the `ControlFlowOp` handling step of this method we relied on `is_updated` to determine whether to use the original `DAGCircuit` or not, which in the end would erroneously skip certain transformations in the `Operation`'s blocks.
    By removing this tracking value, which was already ignored by the main `BasisTranslator` process. We end up with a more correct processing of the instructions at hand.
- Update test `test_inner_wire_map_control_op` from the `TestCircuitControlFlowOps` as better outcome is now found for said circuit.

* Test: Add test
- Inspired on [comment](#13162 (comment)) from @jakelishman.

* Docs: Add release note

* Address review comments:
- Add new test using a backend and the full transpiler pipeline.
- Add all issues to release note.
- Small language fix.

* Lint: formatting

* Fix: Make new test use aer

* Update releasenotes/notes/fix_basis_control_flow-033ecba233d5f9ed.yaml

Co-authored-by: Julien Gacon <gaconju@gmail.com>

---------

Co-authored-by: Julien Gacon <gaconju@gmail.com>
(cherry picked from commit 9c8f4fc)
@mergify mergify bot requested a review from a team as a code owner March 26, 2026 15:11
@qiskit-bot
Copy link
Copy Markdown
Collaborator

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

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

@github-actions github-actions bot added this to the 2.4.0rc2 milestone Mar 26, 2026
@github-actions github-actions bot added Changelog: Fixed Add a "Fixed" entry in the GitHub Release changelog. Rust This PR or issue is related to Rust code in the repository mod: transpiler Issues and PRs related to Transpiler labels Mar 26, 2026
@coveralls
Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 23601954718

Details

  • 5 of 5 (100.0%) changed or added relevant lines in 1 file are covered.
  • 23 unchanged lines in 6 files lost coverage.
  • Overall coverage decreased (-0.004%) to 87.262%

Files with Coverage Reduction New Missed Lines %
crates/circuit/src/parameter/parameter_expression.rs 1 86.99%
crates/transpiler/src/passes/unitary_synthesis/decomposers.rs 1 94.71%
crates/transpiler/src/passes/unitary_synthesis/mod.rs 2 96.89%
crates/qasm2/src/lex.rs 5 92.03%
crates/qasm2/src/parse.rs 6 97.15%
crates/circuit/src/parameter/symbol_expr.rs 8 74.06%
Totals Coverage Status
Change from base Build 23410488606: -0.004%
Covered Lines: 103549
Relevant Lines: 118664

💛 - Coveralls

@raynelfss raynelfss added this pull request to the merge queue Mar 26, 2026
Merged via the queue into stable/2.4 with commit a7f61cc Mar 26, 2026
26 checks passed
@raynelfss raynelfss deleted the mergify/bp/stable/2.4/pr-15875 branch March 26, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Changelog: Fixed Add a "Fixed" entry in the GitHub Release changelog. mod: transpiler Issues and PRs related to Transpiler Rust This PR or issue is related to Rust code in the repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants