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

Fix QuantumCircuit.decompose for high-level objects #13311

Merged
merged 3 commits into from
Oct 12, 2024

Conversation

Cryoris
Copy link
Contributor

@Cryoris Cryoris commented Oct 11, 2024

Summary

Fixed some problems with QuantumCircuit.decompose when dealing with high-level objects (i.e. that can get synthesized by HighLevelSynthesis).

Blocks #13295 and #13301.

Details and comments

Previously, running decompose would first run HighLevelSynthesis (in case no specific gates to decompose are set) and the Decompose. This would end up decomposing high-level objects twice instead of once. In addition, specifying high-level objects by name, could end up not decomposing them at all.

For example

Circuit at hand:
   ┌──────────┐
q: ┤ Clifford ├
   └──────────┘
Expected result when decomposing:
   ┌───┐
q: ┤ H ├
   └───┘
.decompose(['clifford']) gives:
   ┌──────────┐
q: ┤ Clifford ├
   └──────────┘
.decompose() gives:
   ┌─────────┐
q: ┤ U2(0,π) ├
   └─────────┘
where's my H gate? :(

This is now fixed by pulling HLS into Decompose, which iterates over each node and only applies HLS if an operation does not have a definition.

@Cryoris Cryoris added Changelog: New Feature Include in the "Added" section of the changelog Changelog: Bugfix Include in the "Fixed" section of the changelog labels Oct 11, 2024
@Cryoris Cryoris added this to the 1.3.0 milestone Oct 11, 2024
@Cryoris Cryoris requested a review from a team as a code owner October 11, 2024 08:20
@qiskit-bot
Copy link
Collaborator

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

  • @Qiskit/terra-core

@coveralls
Copy link

Pull Request Test Coverage Report for Build 11288875324

Details

  • 23 of 23 (100.0%) changed or added relevant lines in 2 files are covered.
  • 3 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.01%) to 88.666%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 3 92.73%
Totals Coverage Status
Change from base Build 11277520565: 0.01%
Covered Lines: 73138
Relevant Lines: 82487

💛 - Coveralls

Copy link
Contributor

@alexanderivrii alexanderivrii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Cryoris for making these fixes!

@alexanderivrii alexanderivrii added this pull request to the merge queue Oct 12, 2024
Merged via the queue into Qiskit:main with commit 2e67cec Oct 12, 2024
15 checks passed
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 Changelog: New Feature Include in the "Added" section of the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants