Skip to content
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 (backport #13083) #13087

Merged
merged 1 commit into from
Sep 4, 2024

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Sep 4, 2024

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 use substitute_node as the simplified node has fewer qubits than the original node). To fix the problem, we can instead read off the simplified gate from substitute_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 :).


This is an automatic backport of pull request #13083 done by [Mergify](https://mergify.com).

* bug fix, test, reno

* suggestions from code review; lint

(cherry picked from commit 576efcf)
@mergify mergify bot requested a review from a team as a code owner September 4, 2024 16:24
@qiskit-bot
Copy link
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:

  • @Qiskit/terra-core

@github-actions github-actions bot added the Changelog: Bugfix Include in the "Fixed" section of the changelog label Sep 4, 2024
@github-actions github-actions bot added this to the 1.2.1 milestone Sep 4, 2024
@coveralls
Copy link

Pull Request Test Coverage Report for Build 10705682221

Details

  • 7 of 7 (100.0%) changed or added relevant lines in 1 file are covered.
  • 45 unchanged lines in 4 files lost coverage.
  • Overall coverage decreased (-0.05%) to 89.784%

Files with Coverage Reduction New Missed Lines %
crates/circuit/src/dag_node.rs 6 81.5%
crates/qasm2/src/lex.rs 6 91.98%
crates/circuit/src/circuit_instruction.rs 9 88.51%
crates/qasm2/src/parse.rs 24 95.77%
Totals Coverage Status
Change from base Build 10687317978: -0.05%
Covered Lines: 66882
Relevant Lines: 74492

💛 - Coveralls

@Cryoris Cryoris added this pull request to the merge queue Sep 4, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Sep 4, 2024
@Cryoris Cryoris added this pull request to the merge queue Sep 4, 2024
Merged via the queue into stable/1.2 with commit 722eba2 Sep 4, 2024
18 checks passed
@mergify mergify bot deleted the mergify/bp/stable/1.2/pr-13083 branch September 4, 2024 21:22
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants