-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Use np.array_split instead of np.split to support uneven splits in spsa._batch_evaluate #8634
Conversation
…sa._batch_evaluate
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the the following people are requested to review this:
|
Pull Request Test Coverage Report for Build 2966979548
💛 - Coveralls |
@Cryoris can you take at look at this please. Since this is splitting multiple points to be evaluated there should never be an uneven split afaik since its a list of points each point being the same length. |
There can be uneven splits especially since SPSA does the calibration of the learning rate in the beginning, which uses 50 function evaluations. So if a user specifies e.g. |
Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
…sa._batch_evaluate (#8634) * Use np.array_split instead of np.split to support uneven splits in spsa._batch_evaluate * better testing Co-authored-by: Julien Gacon <gaconju@gmail.com> * Update test/python/algorithms/optimizers/test_spsa.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * len of a boolean * Apply suggestions from code review * Fix Sphinx ref Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit 69ad6c6)
…sa._batch_evaluate (#8634) (#8655) * Use np.array_split instead of np.split to support uneven splits in spsa._batch_evaluate * better testing Co-authored-by: Julien Gacon <gaconju@gmail.com> * Update test/python/algorithms/optimizers/test_spsa.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * len of a boolean * Apply suggestions from code review * Fix Sphinx ref Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit 69ad6c6) Co-authored-by: Luciano Bello <bel@zurich.ibm.com>
…sa._batch_evaluate (Qiskit#8634) * Use np.array_split instead of np.split to support uneven splits in spsa._batch_evaluate * better testing Co-authored-by: Julien Gacon <gaconju@gmail.com> * Update test/python/algorithms/optimizers/test_spsa.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * len of a boolean * Apply suggestions from code review * Fix Sphinx ref Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…sa._batch_evaluate (Qiskit/qiskit#8634) * Use np.array_split instead of np.split to support uneven splits in spsa._batch_evaluate * better testing Co-authored-by: Julien Gacon <gaconju@gmail.com> * Update test/python/algorithms/optimizers/test_spsa.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * len of a boolean * Apply suggestions from code review * Fix Sphinx ref Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Fixes qiskit-community/qiskit-nature#797
Summary
The internal function
qiskit.algorithms.optimizers.spsa._batch_evaluate
usesnp.split
instead ofnp.array_split
. This results in an exception as described here when the split is uneven.Details and comments
I used the static method
qiskit.algorithms.SPSA.estimate_stddev
for testing, since it was not directly tested and the method made it easier to parametrize in a way to cover the fix. However, I'm not sure if my input for that test is making any sense.