qiskit-algorithms icon indicating copy to clipboard operation
qiskit-algorithms copied to clipboard

[from qiskit] Unify callback signatures in `qiskit_algorithms.optimizers`

Open ElePT opened this issue 1 year ago • 2 comments

What should we add?

As previously already discussed eg. in https://github.com/Qiskit/qiskit-terra/pull/8628#issuecomment-1323924490, 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 avatar Aug 22 '23 09:08 ElePT