-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Sampler-based VQE for diagonal operators, plus QAOA #8669
Conversation
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:
|
@Cryoris See also my DM to you for some comments |
Pull Request Test Coverage Report for Build 3154881397
💛 - Coveralls |
This PR will also include a |
Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com>
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.
@declanmillar @Cryoris Thanks for the new function and primitive conversions. LGTM!
* plain optimization works * support for auxops * add first round of tests * cast to real * lint & more tests * add VariationalAlgo inheritance * batching and diagonal estimator as BaseEstimator * add gradient support * remove gradient support for now * fix test filename * fix old and new batching * fix broadcasting from a single long array * add slsqp batch test * Put Sampler first (no quote intended) * Add QAOA based on primitives. * Add QAOA based on primitives. * force kwargs; match function names with vqe * remove usused imports * formatting * remove usused imports * Apply suggestions from code review Remove redundant tests and gates Co-authored-by: ElePT <57907331+ElePT@users.noreply.github.com> * correct docs and typehints * Correct docstring and error text Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com> * update docstrings * add callback to samplingvqe * fix merge conflicts * remove edit to base estimator * formatting * update _run for DiagonalEstimator based on BaseEstimator updates * remove unused import * bring sampling vqe in line with vqe * fix docstring indentation * Correct copyright/ Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com> * Fix copyright. Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com> * Use QuasiDistribution typehint, rather than Mapping. * add callback test fro sampling vqe * Test initial point is used for QAOA * formatting * Test scipy optimizer callable * Test QAOA with random initial point * update samplingvqe and qaoa docstrings and add releasenote * add release note for SamplingVQE and QAOA * fix hyperlink in docstring * fix typehints, docstrings, errors * Convert baseoperator operators inside qaoa * repeat all SamplingVQE tests with BaseOperator and PauliSumOp instances Co-authored-by: Declan Millar <declan.millar@ibm.com> Co-authored-by: ElePT <57907331+ElePT@users.noreply.github.com> Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* plain optimization works * support for auxops * add first round of tests * cast to real * lint & more tests * add VariationalAlgo inheritance * batching and diagonal estimator as BaseEstimator * add gradient support * remove gradient support for now * fix test filename * fix old and new batching * fix broadcasting from a single long array * add slsqp batch test * Put Sampler first (no quote intended) * Add QAOA based on primitives. * Add QAOA based on primitives. * force kwargs; match function names with vqe * remove usused imports * formatting * remove usused imports * Apply suggestions from code review Remove redundant tests and gates Co-authored-by: ElePT <57907331+ElePT@users.noreply.github.com> * correct docs and typehints * Correct docstring and error text Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com> * update docstrings * add callback to samplingvqe * fix merge conflicts * remove edit to base estimator * formatting * update _run for DiagonalEstimator based on BaseEstimator updates * remove unused import * bring sampling vqe in line with vqe * fix docstring indentation * Correct copyright/ Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com> * Fix copyright. Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com> * Use QuasiDistribution typehint, rather than Mapping. * add callback test fro sampling vqe * Test initial point is used for QAOA * formatting * Test scipy optimizer callable * Test QAOA with random initial point * update samplingvqe and qaoa docstrings and add releasenote * add release note for SamplingVQE and QAOA * fix hyperlink in docstring * fix typehints, docstrings, errors * Convert baseoperator operators inside qaoa * repeat all SamplingVQE tests with BaseOperator and PauliSumOp instances Co-authored-by: Declan Millar <declan.millar@ibm.com> Co-authored-by: ElePT <57907331+ElePT@users.noreply.github.com> Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Summary
Add a VQE variant based on the sampler primitive, which only allows for optimization of diagonal ("classical") Hamiltonians.
Adds QAOA based on the above.
closes #8472
Details and comments
This differs from the estimator-based, standard VQE in that this version
BaseSampler
and not aBaseEstimator
Gradient support
In this PR, the gradient support has not yet been added. That's because it's not quite clear what's the best way to integrate the gradients. Here are the options we came up with, and we decided that we will first not support them and then directly implement option 4 if possible:
Option 1 The SamplingVQE takes a sampler and sampler gradient as input
pro: it is consistent as it takes a sampler and a sampler gradient
problem: I cannot support aggregation functions like CVaR, since I cannot easily compute the gradient if I have only access to the samples
Option 2 The SamplingVQE takes a sampler and an empty estimator gradient (i.e. without an estimator set)
pro: I build the diagonal estimator inside the SamplingVQE, and plug it into the estimator gradient
problem: consistency suffers, since I have to make the estimator in the gradients optional
Option 3 Make the SamplingVQE take a DiagonalEstimator and a EstimatorGradient equipped with said diagonal estimator
pro: consistent
problem: users have to build out the diagonal estimator, and the Sampling VQE will take an estimator
Option 4 Change how gradients work and introduce a general ParameterShift() (& co) which is not sampler or estimator specific
pro: makes my life easy
pro: makes users life easy as they don’t have to write out these nasty gradient names
problem: doesn’t exist yet
Todo