Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

Enhance Callback to Expose Grouped Energy Evaluations. #890

Open
dongreenberg opened this issue Apr 7, 2020 · 1 comment
Open

Enhance Callback to Expose Grouped Energy Evaluations. #890

dongreenberg opened this issue Apr 7, 2020 · 1 comment

Comments

@dongreenberg
Copy link
Contributor

dongreenberg commented Apr 7, 2020

I would like to change the VQE callback to the below, to allow one to access an accurate picture of the evaluation steps, and to distinguish between single energy and gradient evaluations. Right now we call the callback once for each energy calculated, so a 16-energy gradient calculation is not distinguishable to the callback from a single-energy evaluation. The code below calls the callback with a list of parameters, energies, and stds for all of the evaluations in that call to _energy_evaluation. This has caused me trouble in the past and I've been asked several times now to group this information in this way. This is a breaking change, to any existing callback usage, unless we can think of a way otherwise.

        if self._callback is not None:
            self._callback(self._eval_count, parameter_sets, means, stds)

Right now we do:

            for i, param_set in enumerate(parameter_sets):
                self._eval_count += 1
                self._callback(self._eval_count, param_set, means[i], stds[i])
@dongreenberg dongreenberg mentioned this issue Apr 7, 2020
15 tasks
@woodsp-ibm
Copy link
Member

woodsp-ibm commented Apr 7, 2020

I am not sure how that solves the problem - the issue is the optimizer using the same callback to compute the next point on the curve via gradient or whatever. Normally only one parameter set (point) is passed in at once, and even when grouped (which is not default) they are done so in order to potentially allow more parallellization on a simulator and the groupings are most likely just part of a gradient too, i.e. a subset of the set of points of the gradient computation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants