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

Remove deprecated methods and args in Primitives #9480

Merged
merged 7 commits into from
Apr 12, 2023

Conversation

ikkoham
Copy link
Contributor

@ikkoham ikkoham commented Jan 30, 2023

Summary

Remove methods and args in primitives deprecated from Terra 0.22.

Details and comments

@ikkoham ikkoham added Changelog: Removal Include in the Removed section of the changelog mod: primitives Related to the Primitives module labels Jan 30, 2023
@ikkoham ikkoham added this to the 0.24.0 milestone Jan 30, 2023
@qiskit-bot
Copy link
Collaborator

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

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

@ikkoham ikkoham marked this pull request as draft January 30, 2023 10:51
@coveralls
Copy link

coveralls commented Jan 30, 2023

Pull Request Test Coverage Report for Build 4674756685

  • 30 of 32 (93.75%) changed or added relevant lines in 7 files are covered.
  • 2289 unchanged lines in 172 files lost coverage.
  • Overall coverage increased (+0.05%) to 85.413%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/primitives/base/base_estimator.py 7 8 87.5%
qiskit/primitives/base/base_sampler.py 5 6 83.33%
Files with Coverage Reduction New Missed Lines %
crates/accelerate/src/dense_layout.rs 1 95.3%
qiskit/algorithms/eigen_solvers/eigen_solver.py 1 97.78%
qiskit/algorithms/evolvers/real_evolver.py 1 92.31%
qiskit/algorithms/phase_estimators/hamiltonian_phase_estimation_result.py 1 96.43%
qiskit/algorithms/phase_estimators/phase_estimation_result.py 1 96.36%
qiskit/algorithms/time_evolvers/variational/solvers/ode/abstract_ode_function.py 1 93.33%
qiskit/algorithms/time_evolvers/variational/var_qite.py 1 94.74%
qiskit/circuit/add_control.py 1 97.2%
qiskit/circuit/library/arithmetic/adders/vbe_ripple_carry_adder.py 1 98.55%
qiskit/circuit/library/standard_gates/p.py 1 98.9%
Totals Coverage Status
Change from base Build 4379887393: 0.05%
Covered Lines: 67544
Relevant Lines: 79079

💛 - Coveralls

hhorii added a commit to Qiskit/qiskit-aer that referenced this pull request Jan 31, 2023
`BaseSampler` and `BaseEstimator` in terra deprecated circuits, observables and
parameters as arguments for their constructors. They will be reduced in the next
release of terra (0.24). Because it took three months since terra started warning of
deprecation for these arguments, Aer reduces them from their arguments before
terra's PR (Qiskit/qiskit#9480) is released.

* Remove deprecated methods and args in Primitives
* add reno

Co-authored-by: Hiroshi Horii <[email protected]>
@ikkoham ikkoham marked this pull request as ready for review March 10, 2023 04:44
@@ -239,8 +189,7 @@ def run(
**run_opts.__dict__,
)

# This will be comment out after 0.22. (This is necessary for the compatibility.)
# @abstractmethod
@abstractmethod
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure if you want to do anything about the raise in the body here (same in base_sampler) - python now will not let you instantiate any class without it implemented right so the only time you might see this is looking in this source code if some subclass you created was failing and you had not dealt with the deprecation yet. So if its more documenting that this was changed to abstract that did not (will not) happen until 0.24 right - not 0.22.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am late in removing my comment because of the delay in updating the other libraries. Well, 0.24 would also be after 0.22.

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like we need to at least update the error message in the NotImplementedError here, correct? It mentions 0.22.

This method can still be called by a concrete subclass, so IMO we should still raise NotImplementedError with a more suitable message.

super().__init__(options)

################################################################################
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this removal is related to this deprecation. I'm not a fan of this type of comment to indicate sections, but we need to discuss the removal carefully.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. This is my bad. This was mistakenly approved during the review at the time of introduction.
Let's discuss here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there more discussion needed here? Personally, it seems like the section headings are less useful now that many of the things under Deprecations have been removed.

Copy link
Contributor

@kevinhartman kevinhartman left a comment

Choose a reason for hiding this comment

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

Hi @ikkoham! Looks good so far.

If you have time, please address these comments so we can get this merged before the upcoming release.

qiskit/primitives/base/base_estimator.py Outdated Show resolved Hide resolved
super().__init__(options)

################################################################################
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there more discussion needed here? Personally, it seems like the section headings are less useful now that many of the things under Deprecations have been removed.

@@ -239,8 +189,7 @@ def run(
**run_opts.__dict__,
)

# This will be comment out after 0.22. (This is necessary for the compatibility.)
# @abstractmethod
@abstractmethod
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like we need to at least update the error message in the NotImplementedError here, correct? It mentions 0.22.

This method can still be called by a concrete subclass, so IMO we should still raise NotImplementedError with a more suitable message.

qiskit/primitives/base/base_sampler.py Outdated Show resolved Hide resolved
qiskit/primitives/base/base_sampler.py Outdated Show resolved Hide resolved
@@ -58,358 +58,6 @@ def setUp(self):
[1, 2, 3, 4, 5, 6],
)

def test_estimator(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to double check, is there anything we're removing here that should be ported to use whatever the proper new code paths are? In other words, are we inadvertently reducing code coverage?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you. I checked all tests. I readded three tests: test_run_with_operator and test_run_with_shots_option_none for Estimator and test_run_reverse_meas_order for Sampler.

  1. I removed duplicated tests.
  2. We don't test e2e test for PauliSumOp, instead we added the conversion test (test_validate_observables).
  3. No tests corresponding to test_estimator_param_reverse since we do not have this feature (Passing parameters, not parameter_values).

Copy link
Contributor Author

@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.

@kevinhartman Thank you very much for your review. I improved the code now. Could you check again, please?

qiskit/primitives/base/base_estimator.py Outdated Show resolved Hide resolved
@@ -58,358 +58,6 @@ def setUp(self):
[1, 2, 3, 4, 5, 6],
)

def test_estimator(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you. I checked all tests. I readded three tests: test_run_with_operator and test_run_with_shots_option_none for Estimator and test_run_reverse_meas_order for Sampler.

  1. I removed duplicated tests.
  2. We don't test e2e test for PauliSumOp, instead we added the conversion test (test_validate_observables).
  3. No tests corresponding to test_estimator_param_reverse since we do not have this feature (Passing parameters, not parameter_values).

@ikkoham
Copy link
Contributor Author

ikkoham commented Apr 12, 2023

I added the label priority: high since this blocks development of other primitives.

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

Copy link
Contributor

@kevinhartman kevinhartman 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 the updates!

LGTM

@kevinhartman kevinhartman added this pull request to the merge queue Apr 12, 2023
Merged via the queue into Qiskit:main with commit 75673c7 Apr 12, 2023
@ikkoham ikkoham deleted the primitives/rm-in-primitives branch April 13, 2023 03:20
giacomoRanieri pushed a commit to giacomoRanieri/qiskit-terra that referenced this pull request Apr 16, 2023
* Remove deprecated methods and args in Primitives

* rm unnecessary comments

* add reno

* Update qiskit/primitives/base/base_sampler.py

* From review comments
king-p3nguin pushed a commit to king-p3nguin/qiskit-terra that referenced this pull request May 22, 2023
* Remove deprecated methods and args in Primitives

* rm unnecessary comments

* add reno

* Update qiskit/primitives/base/base_sampler.py

* From review comments
ElePT pushed a commit to ElePT/qiskit that referenced this pull request Jun 27, 2023
* Remove deprecated methods and args in Primitives

* rm unnecessary comments

* add reno

* Update qiskit/primitives/base/base_sampler.py

* From review comments
ElePT pushed a commit to ElePT/qiskit-algorithms-test that referenced this pull request Jul 17, 2023
* Remove deprecated methods and args in Primitives

* rm unnecessary comments

* add reno

* Update qiskit/primitives/base/base_sampler.py

* From review comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Removal Include in the Removed section of the changelog mod: primitives Related to the Primitives module priority: high
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants