Closed qcabepsilon closed 2 years ago
Thanks for reporting this @qcabepsilon! I have a feeling this might be related to this question as well: https://quantumcomputing.stackexchange.com/questions/28399/difference-between-qiskit-spsa-optimize-and-minimize-in-runtime-program
Hi @qcabepsilon, thanks for pointing this issue. I don't know why the success attribute of Cobyla OptimizerResult
is a numpy bool which is not serializable. I created a PR that convert that to a conventional bool. It should fix the issue. https://github.com/PennyLaneAI/pennylane-qiskit/pull/231
Thanks for reporting this @qcabepsilon! I have a feeling this might be related to this question as well: https://quantumcomputing.stackexchange.com/questions/28399/difference-between-qiskit-spsa-optimize-and-minimize-in-runtime-program
It might be. Should I create a new issue for that, so this one can be closed?
I can answer your question here you don't need to open another one. The SPSA class used is not from Scipy but from Qiskit: https://qiskit.org/documentation/stubs/qiskit.algorithms.optimizers.SPSA.html#qiskit.algorithms.optimizers.SPSA . It does not contain a minimize
method and does not store the result in the scipy OptimizerResult
. Therefore we have to create this object with the result of Qiskit SPSA method optimize
.
The documentation at the link you shared states that the SPSA of qiskit has the method minimize
which returns its results as OptimizerResult
object. What are the differences between this class and the SciPy class of the same name? The optimize
method uses minimize
itself, but returns the result as single values instead of the object. I do not understand why one of them lead to problems in the vqe_runtime_program.py and vqe_runtime_runner.py
I don't know the exact details on why but Qiskit decided to implement its own SPSA
optimizer, it is probably because they wanted some flexibility in the argument. For the vqe_runtime
we decided to have only one type of result which is a scipy OptimizerResult
that contains not only the results but the parameters, success, and other attributes. Therefore for SPSA
and QNSPSA
(Qiskit implemented) we have to take create the scipy OptimizerResult
.
I assumed that the qiskit OptimizerResult
class and the one from SciPy are the same. Thank you for resolving this misconception. One more question: Why does the conversion to the SciPy OptimizerResult
for NFT not work as the one for the SPSA optimizer? (see stackexchange question)
The only qiskit optimizers that we currently support are SPSA and QNSPSA but you should able to adapt it like we did for the those two. Potentially some arguments are different and it does not work because of that, or maybe some output are different. It is also possible that NFT is not adapted for your problem. You can share your code and error messages as well here.
I figured the problem out. Thank you very much for your help.
Expected behavior
When using this tutorial for using pennylane-qiskit vqe_runtime_runner.py to run vqe_runtime_program.py I would expect all optimizers of SciPy can be used.
Actual behavior
When specifying 'COBYLA' as optimizer the job fails with the message
TypeError: Object of type bool_ is not JSON serializable
.Additional information
No response
Source code
Tracebacks
System information
Existing GitHub issues