Skip to content

Deprecate implicit Estimator conversion to SparsePauliOp #11535

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

Merged
merged 7 commits into from
Jan 12, 2024

Conversation

chriseclectic
Copy link
Member

Summary

Port of #11056 to stable/0.46 branch

Details and comments

Deprecate implicit conversion from a dense operator to a SpasePauliOp in Esimtator
@chriseclectic chriseclectic requested review from ikkoham, t-imamichi and a team as code owners January 10, 2024 15:13
@qiskit-bot
Copy link
Collaborator

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

  • @Qiskit/terra-core
  • @ajavadia
  • @ikkoham
  • @levbishop
  • @t-imamichi

@chriseclectic chriseclectic added Changelog: Deprecation Include in "Deprecated" section of changelog mod: primitives Related to the Primitives module labels Jan 10, 2024
@chriseclectic chriseclectic added this to the 0.46.0 milestone Jan 10, 2024
@ikkoham
Copy link
Contributor

ikkoham commented Jan 11, 2024

@chriseclectic Can you make a PR to the main branch as well?

Sorry, for main, we should remove these features.

ikkoham
ikkoham previously approved these changes Jan 11, 2024
Copy link
Contributor

@ikkoham ikkoham left a comment

Choose a reason for hiding this comment

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

LGTM

t-imamichi
t-imamichi previously approved these changes Jan 11, 2024
Copy link
Member

@t-imamichi t-imamichi left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -70,7 +68,7 @@ def setUp(self):
self.fidelity = ComputeUncompute(Sampler())
self.betas = [50, 50]

@data(H2_PAULI, H2_OP, H2_SPARSE_PAULI)
@data(H2_PAULI, H2_SPARSE_PAULI)
Copy link
Contributor

@ElePT ElePT Jan 11, 2024

Choose a reason for hiding this comment

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

I am not too happy with not testing Operator here (adding these tests unvelied a series of bugs in the eigensolver classes post-primitives-migration). What we do in these cases is not remove the test that raises deprecation warnings, but assert that the warnings are raised when using deprecated classes. This is to confirm that the deprecation warning is raised where it is expected (and the motivation behind making tests fail with deprecation warnings).

In this case, you would need to do a type check of "op" to make sure that you are only asserting the warning when it is of type Operator.

I know that these are deprecated classes, but until they are removed, people are still able to use them, and making sure they work I think is still important.

@woodsp-ibm
Copy link
Member

For the VQD tests etc, that are not directly testing an Estimator, I would have thought swallowing the DeprecationWarning would have sufficed. Asserting you see a warning is more testing the underlying function is emitting it or not. At the VQD test level arguably all we care is it works (for now). Since all this lot is removed already in main and this is just for the one release maybe it does not matter so much.

@ikkoham ikkoham dismissed stale reviews from t-imamichi and themself via 2201c75 January 12, 2024 06:24
@t-imamichi
Copy link
Member

Seems to need to add assertRaise(DeprecationWarning) to test_vqd

@ikkoham ikkoham self-assigned this Jan 12, 2024
@ikkoham
Copy link
Contributor

ikkoham commented Jan 12, 2024

Something is not going well with my local testing and CI. I will fix it until the error goes away.

Done

@ikkoham ikkoham requested a review from ElePT January 12, 2024 13:10
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.

Thanks for applying my suggestion @ikkoham. Annoyingly, sampling vqe is not really using the Estimator but still raises the warning because it inherits from BaseEstimator. Technically the ideal thing would be to keep the test and filter the warnings, but I don't think this particular class did any special handling of the operator depending on the type, so it's probably not the worst not to have that test (given the deprecated status). I'll approve and leave some time for final opinions before adding to the merge queue.

@ikkoham ikkoham added this pull request to the merge queue Jan 12, 2024
Merged via the queue into Qiskit:stable/0.46 with commit 6dd36e4 Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Deprecation Include in "Deprecated" section of changelog mod: primitives Related to the Primitives module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants