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

Adding annotated argument to power methods #12101

Merged
merged 4 commits into from
Apr 23, 2024

Conversation

alexanderivrii
Copy link
Contributor

Summary

This commit adds the annotated argument to the power method of QuantumCircuit, AnnotatedOperation, Gate and its child classes, similarly to how it was added to inverse and control methods in #11433 and #11593. As before, for the basic gates which have their own power methods, this argument is ignored, e. g., SGate raised to a power is an instance of the PhaseGate ignoring the annotated argument. But for QuantumCircuit, Gate and its subclasses without a native power method, setting annotated to True would return an instance of AnnotatedOperation and not of UnitaryGate. This allows to delay the actual computation to the transpiler, and in principle allows additional optimizations.

Details and comments

@alexanderivrii alexanderivrii requested a review from a team as a code owner March 29, 2024 10:30
@qiskit-bot
Copy link
Collaborator

One or more of the the following people are requested to review this:

  • @Cryoris
  • @Qiskit/terra-core
  • @ajavadia

@coveralls
Copy link

coveralls commented Mar 29, 2024

Pull Request Test Coverage Report for Build 8804886395

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 30 of 33 (90.91%) changed or added relevant lines in 19 files are covered.
  • 888 unchanged lines in 83 files lost coverage.
  • Overall coverage increased (+0.1%) to 89.449%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/circuit/annotated_operation.py 1 4 25.0%
Files with Coverage Reduction New Missed Lines %
qiskit/synthesis/evolution/qdrift.py 1 93.55%
qiskit/circuit/store.py 1 94.29%
qiskit/primitives/containers/data_bin.py 1 97.92%
qiskit/circuit/parameter.py 1 98.39%
crates/accelerate/src/optimize_1q_gates.rs 1 98.41%
qiskit/synthesis/linear/cnot_synth.py 1 98.0%
qiskit/circuit/library/blueprintcircuit.py 2 95.16%
qiskit/primitives/backend_estimator_v2.py 2 97.84%
qiskit/circuit/library/generalized_gates/rv.py 2 85.71%
qiskit/transpiler/layout.py 2 94.71%
Totals Coverage Status
Change from base Build 8497269180: 0.1%
Covered Lines: 60331
Relevant Lines: 67447

💛 - Coveralls

@alexanderivrii alexanderivrii added this to the 1.1.0 milestone Mar 29, 2024
qiskit/circuit/library/standard_gates/i.py Outdated Show resolved Hide resolved
qiskit/circuit/library/standard_gates/iswap.py Outdated Show resolved Hide resolved
qiskit/circuit/library/standard_gates/p.py Outdated Show resolved Hide resolved
qiskit/circuit/library/standard_gates/p.py Outdated Show resolved Hide resolved
qiskit/circuit/library/standard_gates/r.py Outdated Show resolved Hide resolved
qiskit/circuit/library/standard_gates/xx_minus_yy.py Outdated Show resolved Hide resolved
qiskit/circuit/library/standard_gates/xx_plus_yy.py Outdated Show resolved Hide resolved
qiskit/circuit/library/standard_gates/z.py Outdated Show resolved Hide resolved
qiskit/circuit/gate.py Outdated Show resolved Hide resolved
qiskit/circuit/gate.py Outdated Show resolved Hide resolved
Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

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

LGTM, this is a fairly straightforward addition, and inline with what was done for inverse() and control(). I just pushed a small change to the docstrings to make it explicit that the return will not be a UnitaryGate or AnnotatedOperation in cases when the power is a defined standard gate; and then removed some docstring overloading from subclasses in the standard gate library.

@mtreinish mtreinish enabled auto-merge April 23, 2024 17:48
@mtreinish mtreinish added this pull request to the merge queue Apr 23, 2024
Merged via the queue into Qiskit:main with commit cf57a98 Apr 23, 2024
12 checks passed
@alexanderivrii alexanderivrii deleted the power-annotations branch April 30, 2024 07:51
@sbrandhsn sbrandhsn added the Changelog: New Feature Include in the "Added" section of the changelog label May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: New Feature Include in the "Added" section of the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants