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

Pending-deprecate library circuits with gate representations #13232

Merged
merged 8 commits into from
Nov 5, 2024

Conversation

Cryoris
Copy link
Contributor

@Cryoris Cryoris commented Sep 27, 2024

Summary

Part of #13046: Library circuits that already have a gate/instruction version are pending-deprecated. These includes:

  • QFT
  • Diagonal
  • Permutation
  • GMS

Details and comments

As part of this cleanup, LinearFunction is streamlined with all other gates by deprecating the custom synthesize method in favor of calling definition (or compiling the circuit).

No reno as all deprecation are only pending.

@Cryoris Cryoris added the mod: circuit Related to the core of the `QuantumCircuit` class or the circuit library label Sep 27, 2024
@Cryoris Cryoris added this to the 1.3.0 milestone Sep 27, 2024
@qiskit-bot
Copy link
Collaborator

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

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

which is pending deprecation, but that's fine as GroverOperator will also pend deprecation in the same timeframe for 1.3
@coveralls
Copy link

coveralls commented Oct 25, 2024

Pull Request Test Coverage Report for Build 11688246257

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

  • 62 of 67 (92.54%) changed or added relevant lines in 9 files are covered.
  • 25 unchanged lines in 7 files lost coverage.
  • Overall coverage increased (+0.02%) to 88.787%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/circuit/library/generalized_gates/gms.py 13 14 92.86%
qiskit/circuit/library/generalized_gates/linear_function.py 4 5 80.0%
qiskit/circuit/library/generalized_gates/diagonal.py 25 28 89.29%
Files with Coverage Reduction New Missed Lines %
crates/accelerate/src/unitary_synthesis.rs 1 92.2%
crates/qasm2/src/expr.rs 1 94.02%
qiskit/circuit/library/basis_change/qft.py 1 87.5%
qiskit/primitives/backend_sampler_v2.py 2 98.53%
crates/qasm2/src/lex.rs 5 92.48%
crates/qasm2/src/parse.rs 6 97.62%
qiskit/primitives/backend_estimator.py 9 96.12%
Totals Coverage Status
Change from base Build 11669445061: 0.02%
Covered Lines: 76801
Relevant Lines: 86500

💛 - Coveralls

@raynelfss raynelfss assigned raynelfss and ElePT and unassigned raynelfss Oct 29, 2024
Copy link
Contributor

@ElePT ElePT left a comment

Choose a reason for hiding this comment

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

In principle the PR looks good, I only wonder if the test with the warning filter was an oversight, and left a few tiny comments.

qiskit/circuit/library/basis_change/qft.py Show resolved Hide resolved
qc = QuantumCircuit(q, name=self.name)
for i in range(self.num_qubits):
for j in range(i + 1, self.num_qubits):
# if theta was just a single angle, use that, otherwise use the correct index
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# if theta was just a single angle, use that, otherwise use the correct index
# if theta is just a single angle, use that, otherwise use the correct index

@@ -196,10 +196,12 @@ def __init__(self, *_args, **_kwargs):
module=r"qiskit\..*",
message=r".*precision loss in QFT.*",
)
warnings.filterwarnings("ignore", category=PendingDeprecationWarning)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we fail on pending deprecation warnings? I am surprised, I thought we didn't.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, no we don't but here we have a context that catches all warnings and checks that none are emitted (to check that there is no precision loss) -- so we have to filter out the pending deprecation warning 🙂

qc = QuantumCircuit(q, name=self.name)
for i in range(self.num_qubits):
for j in range(i + 1, self.num_qubits):
# if theta was just a single angle, use that, otherwise use the correct index
theta = thetas if isinstance(thetas, ParameterValueType) else thetas[i][j]
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe that it's this line that is currently failing in the unit tests. The error raised is:

TypeError: Subscripted generics cannot be used with class and instance checks
Maybe you can check the shape of the input instead?

Copy link
Contributor

@ElePT ElePT left a comment

Choose a reason for hiding this comment

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

Allright, LGTM!

@ElePT ElePT enabled auto-merge November 5, 2024 17:25
@ElePT ElePT added the Changelog: None Do not include in changelog label Nov 5, 2024
@ElePT ElePT added this pull request to the merge queue Nov 5, 2024
Merged via the queue into Qiskit:main with commit 3fe73d9 Nov 5, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: None Do not include in changelog mod: circuit Related to the core of the `QuantumCircuit` class or the circuit library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants