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 qiskit.Aer and qiskit.providers.aer #11439

Merged
merged 5 commits into from
Jan 12, 2024

Conversation

jakelishman
Copy link
Member

Summary

These were intended to be deprecated after the release of Aer 0.11, but we apparently never actually got around to it. This fully deprecates the qiskit.Aer object, along with imports from qiskit.providers.aer, as we will be removing those completely in Qiskit 1.0.

The namespace loaders in qiskit.namespace will also be removed in Qiskit 1.0, but I have not marked these with deprecation warnings because:

  • we need to continue using them to effect the deprecations of the imports.
  • they have never been documented as public interface, so are a private implementation detail.

All the use of qiskit.providers.aer in Terra and its tests is replaced with qiskit_aer. This name is only available from Aer 0.11, but in practice, Aer 0.10 already does not work with Qiskit 0.46 (fails during import), so this change does not affect the working set of Aer versions.

I haven't touched old imports of IBMQ, because that package is already completely deprecated and we should be removing all attempted use of it from Qiskit 1.0, because that code would never be able to succeed.

Details and comments

See #5089 for the history of these deprecations.

These were intended to be deprecated after the release of Aer 0.11, but
we apparently never actually got around to it.  This fully deprecates
the `qiskit.Aer` object, along with imports from `qiskit.providers.aer`,
as we will be removing those completely in Qiskit 1.0.

The namespace loaders in `qiskit.namespace` will also be removed in
Qiskit 1.0, but I have not marked these with deprecation warnings
because:
- we need to continue using them to effect the deprecations of the
  imports.
- they have never been documented as public interface, so are a private
  implementation detail.

All the use of `qiskit.providers.aer` in Terra and its tests is replaced
with `qiskit_aer`.  This name is only available from Aer 0.11, but in
practice, Aer 0.10 already does not work with Qiskit 0.46 (fails during
import), so this change does not affect the working set of Aer versions.

I haven't touched old imports of IBMQ, because that package is already
completely deprecated and we should be removing all attempted use of it
from Qiskit 1.0, because that code would never be able to succeed.
@jakelishman jakelishman added the Changelog: Deprecation Include in "Deprecated" section of changelog label Dec 20, 2023
@jakelishman jakelishman added this to the 0.46.0 milestone Dec 20, 2023
@qiskit-bot
Copy link
Collaborator

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

  • @Cryoris
  • @ElePT
  • @Qiskit/terra-core
  • @woodsp-ibm

With Aer 0.13 removing the capability, this is not something we will be
able to support moving forwards.  This deprecates the functionality, in
preparation for its full removal in Qiskit 1.0.
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. At the time we added the namespace import redirect I think we discussed just leaving qiskit.providers.aer -> qiskit_aer in perpetuity because it didn't have any real cost just the qiskit.namespace module. I think removing it for Qiskit 1.0.0 makes sense though if we're going to do it.

Just a couple small comments inline.

@@ -55,14 +54,7 @@ def is_aer_provider_available():
Returns:
bool: True if simulator executable is available
"""
# TODO: HACK FROM THE DEPTHS OF DESPAIR AS AER DOES NOT WORK ON MAC
Copy link
Member

Choose a reason for hiding this comment

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

How long as this been here? Aer has worked on mac for a really long time now...

Copy link
Member Author

Choose a reason for hiding this comment

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

commit b2bbb3f05968f3cadc2993ed66123077d80026ef
Author: Jay M. Gambetta <jay.gambetta@us.ibm.com>
Date:   Fri Dec 28 17:32:27 2018 -0500

    Remove legacy simulators  (#1615)

so not too long, you know

should instead use the same object from the ``qiskit_aer`` namespace, which is a drop-in
replacement.
- |
Importing from ``qiskit.providers.aer`` is deprecated and will stop working in Qiskit 1.0. You
Copy link
Member

Choose a reason for hiding this comment

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

Did we have a deprecation warning for the namespace hooks in general? Not that it hurts to do this explicitly because we're deprecating the backwards compat import machinery in this PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

What kind of statements do you mean, sorry?

If you mean the objects in qiskit.namespace themselves, I haven't put deprecations on them a) we need to use them for the whole length of their existence so would trigger warnings by our regular use of them (or we'd have to wait another cycle to deprecate), and b) they're not public per our policy (there's no documentation of qiskit.namespace).

Copy link
Member Author

Choose a reason for hiding this comment

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

For linking purposes: at the time, we discussed whether to make qiskit.namespace explicitly private, but equally didn't make a positive decision that it would be public per the deprecation policy, we just didn't call it qiskit._namespace. By the intended current terms of the deprecation policy, it doesn't count as public because it's not documented, though caveat: we never merged #11205 on Terra, and then the deprecation policy got moved to DEPRECATIONS.md on Terra in #11218 in its old form, so we need to resurrect #11205 here.

Copy link
Member

Choose a reason for hiding this comment

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

I meant #11223 which implicitly covered qiskit.providers.aer at least in my head, the qiskit.namespace machinery was just an explicit exception to that.

tools/find_optional_imports.py Show resolved Hide resolved
@jakelishman
Copy link
Member Author

I'm keen to get rid of qiskit.namespace because I'm not convinced it's going to be maintainable properly through new Python versions - I think some of the methods we implement are already removed in Python 3.12 (pylint throws new exceptions due to missing docstrings that were previously inherited on 3.12), and I know there's more changes planned for importlib in 3.13/3.14.

@mtreinish
Copy link
Member

That does raise a concern for me in rustworkx where we use the same basic code to redirect imports from retworkx for backwards compatibility there. We're not ready to remove that redirect since we're planning to drop it in an eventual rustworkx 1.0.0 release (which is only being loosely planned for at this point).

@jakelishman
Copy link
Member Author

To be fair, I'm 100% certain it'll still be possible to do this, I just think we'll have to go look at the importlib documentation and work out the new preferred way of doing it. I was keen to avoid doing that unless we needed to on Qiskit, but if you need it on Rustworkx, I guess it's a little unavoidable.

Fixed the dodgy deprecation message in 4add053.

@jakelishman jakelishman requested a review from mtreinish January 10, 2024 14:56
@mtreinish mtreinish added this pull request to the merge queue Jan 12, 2024
Merged via the queue into Qiskit:stable/0.46 with commit 1528eb7 Jan 12, 2024
12 checks passed
@jakelishman jakelishman deleted the deprecate-aer-hook branch January 12, 2024 17:54
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants