-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Bug fix in HoareOptimizer
#13083
Merged
Merged
Bug fix in HoareOptimizer
#13083
Conversation
This file contains 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
alexanderivrii
added
the
Changelog: Bugfix
Include in the "Fixed" section of the changelog
label
Sep 4, 2024
One or more of the following people are relevant to this code:
|
Pull Request Test Coverage Report for Build 10701833297Details
💛 - Coveralls |
Cryoris
reviewed
Sep 4, 2024
Cryoris
added
the
stable backport potential
The bug might be minimal and/or import enough to be port to stable
label
Sep 4, 2024
Cryoris
approved these changes
Sep 4, 2024
mergify bot
pushed a commit
that referenced
this pull request
Sep 4, 2024
* bug fix, test, reno * suggestions from code review; lint (cherry picked from commit 576efcf)
github-merge-queue bot
pushed a commit
that referenced
this pull request
Sep 4, 2024
* bug fix, test, reno * suggestions from code review; lint (cherry picked from commit 576efcf) Co-authored-by: Alexander Ivrii <alexi@il.ibm.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in 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
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
Fixes #13079.
Detailed Comments
The problem was due to first simplifying a controlled-gate by removing its controls (in the example: the control qubit of a CX-gate is at
|1>
, allowing to replace the CX-gate by an X-gate), then incorrectly keeping track of the simplified gate (in order to store the new X-gate for later purposes, the code mutated the original CX-gate in some weird way).The code was already using
substitute_node_with_dag
to replace the controlled-gate by the base-gate (I don't really like this, but I don't think we can usesubstitute_node
as the simplified node has fewer qubits than the original node). To fix the problem, we can instead read off the simplified gate fromsubstitute_node_with_dag
's output.While this fixes the immediate problem, the code in
HoareOptimizer
is very messy and quite possibly contains many other sources of bugs (for instance, I did not like the idea of iterating over the DAG's topological nodes, while removing and simplifying some of the nodes in-place) and not optimized for performance. A complete rewrite while porting to Rust would be ideal :).