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

qiskit_algorithms namespace is not supported. #535

Closed
airwoodix opened this issue Aug 17, 2023 · 2 comments
Closed

qiskit_algorithms namespace is not supported. #535

airwoodix opened this issue Aug 17, 2023 · 2 comments

Comments

@airwoodix
Copy link

airwoodix commented Aug 17, 2023

Environment

  • Qiskit Optimization version: 0.5.0
  • Python version: 3.11
  • Operating system: Linux

What is happening?

MinimumEigenOptimizer doesn't support algorithms from qiskit-algorithms.

The qiskit.algorithms namespace is deprecated since qiskit-terra v0.25.0. The qiskit_algorithms namespace from qiskit-algorithms should be a drop-in replacement (for the transition period).

How can we reproduce the issue?

For example:

from qiskit_algorithms.minimum_eigensolvers import QAOA
from qiskit_optimization.algorithms import MinimumEigenOptimizer

_ = MinimumEigenOptimizer(min_eigen_solver=QAOA(...))

fails with:

TypeError: MinimumEigenOptimizer supports qiskit.algorithms.minimum_eigensolvers.SamplingMinimumEigensolver, qiskit.algorithms.minimum_eigensolvers.NumPyMinimumEigensolver, and qiskit.algorithms.minimum_eigen_solvers.MinimumEigensolver. But <class 'qiskit_algorithms.minimum_eigensolvers.qaoa.QAOA'> is given.

raised at

What should happen?

It should be possible to use legacy qiskit.algorithms and qiskit_algorithms namespaces interchangeably (until the latter diverges).

Any suggestions?

To ease up the transition and keep the type annotations correct, one could prefer qiskit_algorithms if it is present:

try:
    from qiskit_algorithms.minimum_eigensolvers import ...
except ImportError:
    from qiskit.algorithms.minimum_eigensolvers import ...
)

The TypeError message should already now be informative enough to figure out what is happening.

@t-imamichi
Copy link
Collaborator

It has been resolved by #537

@airwoodix
Copy link
Author

Awesome, thanks!

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

No branches or pull requests

2 participants