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

[from qiskit] Unify callback signatures in qiskit_algorithms.optimizers #60

Open
ElePT opened this issue Aug 22, 2023 · 2 comments
Open

Comments

@ElePT
Copy link
Collaborator

ElePT commented Aug 22, 2023

What should we add?

As previously already discussed eg. in Qiskit/qiskit#8628 (comment), it would be great it all Qiskit Optimizers have the same signature for the callback function.

The callback function allows to pass back information on the state of the optimization to the user during the optimization. This is useful to track additional information like the optimization history or to check whether the optimization is converging. However, currently each optimizer has it's own signature on the callback, which makes it difficult to write modular code. It would be great it they had consistent signature, such as:

callback(current_parameters, optimizer_state)

The current parameters are known to each optimizer (also the SciPy optimizers) and additional information could be stored in an optimization state, such as introduced in https://github.com/Qiskit/qiskit-terra/blob/5177db6e09917809895fe37878422ba8fcb6321a/qiskit/algorithms/optimizers/gradient_descent.py#L28

@ElePT
Copy link
Collaborator Author

ElePT commented Aug 22, 2023

Opened by @Cryoris
Original issue & discussion: Qiskit/qiskit#10109

@woodsp-ibm woodsp-ibm changed the title [from qiskit] Unify callback signatures in qiskit.algorithms.optimizers [from qiskit] Unify callback signatures in qiskit_algorithms.optimizers Aug 24, 2023
@woodsp-ibm
Copy link
Member

In the issue linked talking about VQE callback, was brought up when using ADAM. I talked about using an optimizer callback in there to access more information that is not available to VQE. I note that ADAM does not have this - maybe this is something that can be added as part of the unification to make sure not only is the same format but its available everywhere. The snapshot_dir function ADAM has does give access to the same type of info - maybe that can be deprecated it we support a callback there - a user of such a callback can save it to file themselves etc.

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