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 BasicAer and introduce BasicProvider #11583

Merged
merged 35 commits into from
Jan 29, 2024

Conversation

ElePT
Copy link
Contributor

@ElePT ElePT commented Jan 17, 2024

Summary

This PR introduces BasicProvider in the 0.46 branch (analogous to #11422 in the main branch but up-to-date with 0.46 changes), and raises deprecation warnings for BasicAer.

The migration path from BasicAer to BasicProvider is summarized in both the release note and as a warning in the corresponding API doc entry.

Details and comments

The fact that most users access the basic aer provider via its global instance + get_backend made the deprecation trickier than usual. To make sure that a warning would always be seen, this PR inserts not only deprecation decorators in the class inits (to be raised when instantiated directly), but also a deprecation warning to be raised upon from qiskit import BasicAer.

@ElePT ElePT added this to the 0.46.0 milestone Jan 17, 2024
@ElePT ElePT added the Changelog: Deprecation Include in "Deprecated" section of changelog label Jan 17, 2024
@ElePT ElePT added the Changelog: New Feature Include in the "Added" section of the changelog label Jan 22, 2024
@ElePT ElePT marked this pull request as ready for review January 22, 2024 10:15
@qiskit-bot
Copy link
Collaborator

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

@mtreinish mtreinish self-assigned this Jan 23, 2024
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.

Overall this LGTM. It's very thorough especially on dealing with the deprecation warnings everywhere. I just left a few small comments inline it shouldn't be anything major though.

@ElePT ElePT requested a review from a team as a code owner January 25, 2024 10:22
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.

Thanks for the quick update. I think this is basically ready, I just had two super small comments that I caught on my final pass through, one small one about the docstring for the new simulator class and the other about the usage of rngs in numpy using the legacy interface.

self._configuration = None

# Internal simulator variables
self._local_random = np.random.RandomState()
Copy link
Member

Choose a reason for hiding this comment

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

This is actually the legacy interface for numpy random number generators. We probably should use the newer interface: https://numpy.org/doc/stable/reference/random/generator.html there are some small changes needed but it shouldn't be too bad.

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 was not sure about making this change because the number generation algorithm is different with the new interface. At least, I have not found a way to generate the same values with the same seed (I noticed this when migrating algorithm_globals). But I keep forgetting that this is technically a new class, so that is technically not a behavior change.

Copy link
Contributor Author

@ElePT ElePT Jan 26, 2024

Choose a reason for hiding this comment

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

I did have to increase the number of shots/threshold in 2 tests (c564cfe) after the random generator update from e9f1cc1. I think that the tests just happened to pass with the given seed before, and now they just happen not to, but I might be wrong.

mtreinish
mtreinish previously approved these changes Jan 26, 2024
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, thanks for the quick updates

@ElePT ElePT requested a review from mtreinish January 29, 2024 10:39
@mtreinish mtreinish added this pull request to the merge queue Jan 29, 2024
Merged via the queue into Qiskit:stable/0.46 with commit d71222f Jan 29, 2024
12 checks passed
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 Changelog: New Feature Include in the "Added" section of the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants