-
Notifications
You must be signed in to change notification settings - Fork 19
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
Remove printing that's specific to gradient-based VQE #262
Remove printing that's specific to gradient-based VQE #262
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have only one suggestion to improve the accuracy of the printing. Other than that, everything looks good to me.
"--------------------------------------------------------------------------------------------------" | ||
) | ||
header = "\n k iteration Energy dE" | ||
if self._use_analytic_grad: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a suggestion for future consideration. The decision to print gradient diagnostics should ideally depend on the type of optimizer being used, whether it is gradient-based or gradient-free. Even when numerical gradients are employed, gradient diagnostics should still be printed. However, scipy.optimize.minimize
does not directly expose numerical gradients to the callback function. Therefore, the current decision to report gradient diagnostics for numerical gradients is based on self._use_analytic_grad
.
"--------------------------------------------------------------------------------------------------" | ||
) | ||
header = "\n k iteration Energy dE" | ||
if self._use_analytic_grad: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at uccnvqe.py
, it appears that a user could potentially request optimizer = "Nelder-Mead"
and use_analytic_grad = True
. More or less the same applies to adaptvqe.py
. To ensure accurate printing of diagnostics, I suggest internally setting self._use_analytic_grad
to False
if a gradient-free optimizer is selected. Additionally, a warning message could be printed to inform the user of this change.
Description
Previously, UCCVQE would print out gradient diagnostics even for computations without a gradient. This is silly, so I removed them.
To clean up the printing, I also tried to unify the to-screen printing and to-file printing. For some reason I don't understand, to-file printing had more digits but not more space for them. There were also some inconsistencies with the amount of whitespace between the two versions. In both cases, I changed them to be more like the to-screen version. The initial
#
for to-file printing is retained.User Notes
Checklist