-
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
Fix parameter order in VQE, if the ansatz is resized #7479
Conversation
In this test, the ansatz was resized and thus the parameters ASCII-sorted. Now they are sorted by vector, which leads to a slightly different optimization (since the params are in a different order).
Note that I had to change the |
Pull Request Test Coverage Report for Build 1692405590
💛 - Coveralls |
* fix VQE param order if ansatz is resized * add test, rm trailing comment * fix construct circuit for params != circuit params * fix test_max_evals_grouped In this test, the ansatz was resized and thus the parameters ASCII-sorted. Now they are sorted by vector, which leads to a slightly different optimization (since the params are in a different order). Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit d0b26c2)
* fix VQE param order if ansatz is resized * add test, rm trailing comment * fix construct circuit for params != circuit params * fix test_max_evals_grouped In this test, the ansatz was resized and thus the parameters ASCII-sorted. Now they are sorted by vector, which leads to a slightly different optimization (since the params are in a different order). Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit d0b26c2) Co-authored-by: Julien Gacon <[email protected]>
Merging this PR caused our nightly scheduled CI of Qiskit Nature to break: https://github.com/Qiskit/qiskit-nature/actions/runs/1695769065 I verified locally that this is indeed the offending commit. I assume this has to do with the fact that this fixes a bug related to using the Tagging some more people who are not already involved in this discussion:
|
* fix VQE param order if ansatz is resized * add test, rm trailing comment * fix construct circuit for params != circuit params * fix test_max_evals_grouped In this test, the ansatz was resized and thus the parameters ASCII-sorted. Now they are sorted by vector, which leads to a slightly different optimization (since the params are in a different order). Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
) * fix VQE param order if ansatz is resized * add test, rm trailing comment * fix construct circuit for params != circuit params * fix test_max_evals_grouped In this test, the ansatz was resized and thus the parameters ASCII-sorted. Now they are sorted by vector, which leads to a slightly different optimization (since the params are in a different order). Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Summary
Fix a bug in
VQE
where the parameters of the ansatz werestill explicitly ASCII-sorted by their name if the ansatz was resized. That led to a
mismatching order of the optimized values in the
optimal_point
attribute of the resultobject.
This should have been included in #7099, where the sorting was removed, but was missed.
Details and comments
For example, this led to a wrong optimal circuit if a user tried to construct it using
VQEResult.optimal_point
.Instead of the same statevectors, this yields
With this PR, these vectors are the same.