In train_vqe in main.py, the optimizer options are given by argument optimizer_options. However, the description in the help documentation is unclear (without example code, a general user wouldn't know what to put there) and the default value for nepochs is unrealistic (100000) and tol does not help terminate the code.
For example, when optimizer='sgd', tol=1e-2 and we run the following code
niter = 3
# define the qibo loss function
objective_boost = partial(vqe_loss)
# logging history
params_history, loss_history, grads_history, fluctuations = [], [], [], []
# set optimizer
optimizer = 'sgd'
tol = 1e-2
# train vqe
(
partial_results,
partial_params_history,
partial_loss_history,
partial_grads_history,
partial_fluctuations,
vqe,
) = train_vqe(
deepcopy(ansatz_circ),
ham_boost, # Fixed hamiltonian
optimizer,
initial_params,
tol=tol,
niterations=1,
nmessage=1,
loss=objective_boost,
)
params_history = np.array(partial_params_history)
loss_history = np.array(partial_loss_history)
grads_history = np.array(partial_grads_history)
which does not specify optimizer_options, the code runs almost indefinitely, like so:

In the scenario where optimizer='cma' (backend='tensorflow'), the loss function fluctuates largely (changes sign)

In summary, the default value for nepochs in the optimizers.optimize function in ansazte.py may need to be more realistic for the general user. It may also be helpful if the help documentation has more detailed descriptions of the optimizer_options. Moreover, we may need to see if 'cma' is running correctly?
In
train_vqeinmain.py, the optimizer options are given by argumentoptimizer_options. However, the description in thehelpdocumentation is unclear (without example code, a general user wouldn't know what to put there) and the default value fornepochsis unrealistic (100000) andtoldoes not help terminate the code.For example, when
optimizer='sgd',tol=1e-2and we run the following codewhich does not specify

optimizer_options, the code runs almost indefinitely, like so:In the scenario where

optimizer='cma'(backend='tensorflow'), the loss function fluctuates largely (changes sign)In summary, the default value for
nepochsin theoptimizers.optimizefunction inansazte.pymay need to be more realistic for the general user. It may also be helpful if thehelpdocumentation has more detailed descriptions of theoptimizer_options. Moreover, we may need to see if 'cma' is running correctly?