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

Do not unroll gates in basis in add_control #13475

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Cryoris
Copy link
Contributor

@Cryoris Cryoris commented Nov 21, 2024

Summary

The add_control mechanism currently does some redundant unrolling and re-wrapping of gates that are already in the basis of gates we know how to control. This has knock-on effects and causes #13473, by translating an RZ operation (already supported) to a Phase gate.

This PR avoids this unrolling. As discussed with @alexanderivrii, in the longer term we should consider rewriting this logic entirely and have a controlled gate plugin, which also allows users to supply their own control mechanism.

Details and comments

@Cryoris Cryoris marked this pull request as ready for review November 21, 2024 21:50
@Cryoris Cryoris requested a review from a team as a code owner November 21, 2024 21:50
@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 11962255098

Details

  • 49 of 51 (96.08%) changed or added relevant lines in 1 file are covered.
  • 7 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.005%) to 88.94%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/circuit/add_control.py 49 51 96.08%
Files with Coverage Reduction New Missed Lines %
crates/accelerate/src/unitary_synthesis.rs 1 92.2%
qiskit/circuit/add_control.py 2 95.69%
crates/qasm2/src/lex.rs 4 91.98%
Totals Coverage Status
Change from base Build 11957091507: 0.005%
Covered Lines: 79414
Relevant Lines: 89289

💛 - Coveralls

@Cryoris Cryoris linked an issue Nov 22, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The multi-controlled gate by RZGate().control() is less optimized.
3 participants