Fix: BasisTranslator processing of nested ControlFlowOp (backport #15875)#15884
Merged
raynelfss merged 1 commit intostable/2.4from Mar 26, 2026
Merged
Fix: BasisTranslator processing of nested ControlFlowOp (backport #15875)#15884raynelfss merged 1 commit intostable/2.4from
BasisTranslator processing of nested ControlFlowOp (backport #15875)#15884raynelfss merged 1 commit intostable/2.4from
Conversation
* 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)
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:
|
Pull Request Test Coverage Report for Build 23601954718Details
💛 - Coveralls |
raynelfss
approved these changes
Mar 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Inspired by #15797
The following PR fixes a long standing bug in
BasisTranslatorby allowing all calculated transformations to be applied within aControlFlowOp.Details and comments
Fixes #15734
Fixes #14025
Fixes #13162
is_updatedfromapply_translationhelper method inBasisTranslator. The removal of this argument ensures that when a translation is found it is always applied.is_modifiedboolean output, while intended as a way of optimizing the operation of theBasisTranslatordid not achieve much as a newDAGCircuitwould be created each time.ControlFlowOphandling step of this method we relied onis_updatedto determine whether to use the originalDAGCircuitor not, which in the end would erroneously skip certain transformations in theOperation's blocks.BasisTranslatorprocess. We end up with a more correct processing of the instructions at hand.test_inner_wire_map_control_opfrom theTestCircuitControlFlowOpsas better outcome is now found for said circuit.This is an automatic backport of pull request Fix:
BasisTranslatorprocessing of nestedControlFlowOp#15875 done by Mergify.