-
Notifications
You must be signed in to change notification settings - Fork 71
Description
Environment
- Qiskit Algorithms version: 0.4.0
- Python version: 3.11
- Operating system: MacOS & Windows
- Qiskit version: 1.2.4
What is happening?
Version 0.4.0 requires qiskit>=1.0
however adapt_vqe (which is required when importing SPSA from qiskit_algorithms.optimizers import SPSA
) requires the evolved_operator_ansatz function which is only available from qiskit>=1.3
.
For reference, this is the evolved_operator_ansatz function in qiskit version 1.3 compared to in qiskit version 1.2. Qiksit verison 1.2 only has the EvolvedOperatorAnsatz class while version 1.3 has both the EvolvedOperatorAnsatz class and evolved_operator_ansatz function that can be imported.
Downgrading qiskit-algorithms to version 0.3.1 fixes the error since in this version, the evolved_operator_ansatz is not being imported in adapt_vqe.
Here is the sample error: ImportError: cannot import name 'evolved_operator_ansatz' from 'qiskit.circuit.library'
How can we reproduce the issue?
-
Install
qiskit-algorithms==0.4.0
andqiskit==1.2.4
.pip install qiskit-algorithms==0.4.0 qiskit==1.2.4
-
Create a python file and try importing SPSA:
from typing import List
from scipy.optimize import minimize, dual_annealing, basinhopping, cobyla, BFGS
from qiskit_algorithms.optimizers import SPSA
from qiskit.result import CorrelatedReadoutMitigator
import scipy.linalg as la
- Run the python file
What should happen?
You should an error and the traceback should include:
from qiskit.circuit.library import EvolvedOperatorAnsatz, evolved_operator_ansatz
ImportError: cannot import name 'evolved_operator_ansatz' from 'qiskit.circuit.library'
Any suggestions?
Stricter requirements. Requiring qiskit>=1.3
for qiskit-algorithms>=0.4.0