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

Deprecate PrimitivesV1 and their utils #11490

Closed
wants to merge 4 commits into from

Conversation

ikkoham
Copy link
Contributor

@ikkoham ikkoham commented Jan 4, 2024

Summary

Deprecate

  • BaseEstimator
  • BaseSampler
  • Estimator
  • Sampler
  • BackendEstimator
  • BackendSampler
  • Result classes for V1
  • init_circuit function
  • init_observable function
  • final_measurement_mapping function

Details and comments

@coveralls
Copy link

coveralls commented Jan 5, 2024

Pull Request Test Coverage Report for Build 7456794166

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.001%) to 87.557%

Totals Coverage Status
Change from base Build 7453493244: -0.001%
Covered Lines: 59488
Relevant Lines: 67942

💛 - Coveralls

@ikkoham ikkoham marked this pull request as ready for review January 9, 2024 04:51
@ikkoham ikkoham requested review from t-imamichi and a team as code owners January 9, 2024 04:51
@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

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.

I added a few comments that I think could help make the deprecation more straightforward for users, but I think that the most important thing here is to clearly understand the expected deprecation timeline. The deprecation policy is:

  1. introduce alternative to "old" code
  2. show deprecation warnings in "old" code
  3. (after period is over) remove "old" code

With a minimum period of 3 months or 2 releases (minor) in between steps.

I don't think a deprecation in 0.46 fits this flow, as the alternative (primitives V2) won't be introduced until 1.0. So a reasonable timeline would look like:

  1. introduce primitives V2 in qiskit 1.0
  2. show deprecation warnings for primitives V1 in a minor following 1.0 (not 100% sure, it might even need to be the next major, so correct me if I'm wrong)
  3. remove primitives V1 in qiskit 2.0 (earliest)

If we show deprecation warnings immediately, I think we might overload users with warnings and have a more negative effect than anything else. The idea is to give people some time to transition to the new interfaces.

warn(
"The class ``BasePrimitiveResult`` is deprecated as of qiskit 0.46.0. "
"It will be removed no earlier than 3 months after the release date. "
"Use PrimitiveResult in PrimitiveV2 instead.",
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would help to show the path of the new PrimitiveResult class. From #11227 I take that would be:

Suggested change
"Use PrimitiveResult in PrimitiveV2 instead.",
"Use PrimitiveResult class in `qiskit.primitives.containers` instead.",

@@ -51,6 +47,7 @@ class Estimator(BaseEstimator[PrimitiveJob[EstimatorResult]]):
this option is ignored.
"""

@deprecate_func(since="0.46.0", additional_msg="Use StatevectorEstimator instead.")
Copy link
Contributor

Choose a reason for hiding this comment

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

In the estimator V2 PR, it looks like the new class is also called Estimator, right? not StatevectorEstimator. But it can be told apart from the V1 estimator by the import path.

@@ -52,6 +53,7 @@ class Sampler(BaseSampler[PrimitiveJob[SamplerResult]]):
option is ignored.
"""

@deprecate_func(since="0.46.0", additional_msg="Use StatevectorSampler instead.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as with the Estimator.



@deprecate_func(since="0.46.0")
Copy link
Contributor

Choose a reason for hiding this comment

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

If the deprecation is with no replacement, we usually add a small message explaining it.

---
deprecations:
- |
PrimitivesV1 has been deprecated. Use PrimitivesV2 instead.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know if people would understand what "PrimitivesV1" are, adding a list of what the deprecated classes are would help.

@ikkoham ikkoham added this to the 1.1.0 milestone Jan 9, 2024
@ikkoham
Copy link
Contributor Author

ikkoham commented Feb 26, 2024

Since there are significant merge conflicts and it is not definite to deprecate these features at this time, I will close it once.

@ikkoham ikkoham closed this Feb 26, 2024
@1ucian0 1ucian0 mentioned this pull request Jun 4, 2024
@t-imamichi
Copy link
Member

Superseded by #12575

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants