Skip to content

Fix VQE result, add ansatz#8816

Merged
mergify[bot] merged 12 commits into
Qiskit:mainfrom
ElePT:vqe-result-fix
Sep 30, 2022
Merged

Fix VQE result, add ansatz#8816
mergify[bot] merged 12 commits into
Qiskit:mainfrom
ElePT:vqe-result-fix

Conversation

@ElePT
Copy link
Copy Markdown
Contributor

@ElePT ElePT commented Sep 30, 2022

Summary

On #8702 and #8640, the eigenstate was removed from the eigen-result classes, which has affected certain workflows in qiskit-nature (@mrossinek).

This PR adds the ansatz to the eigensolver/minimum_eigensolver results so that the eigenstates can be retrieved from the result directly (in other words, making the result self-contained). The code would look like:

sampler = Sampler()
job = sampler.run(vqe_result.ansatz, vqe_result.optimal_point)
eigenstate = job.result().quasi_dists[0]

Details and comments

In the future, I believe the VariationalResult class should be reviewed, and potentially include this ansatz property. But so far the eigensolver result does not inherit from VariationalResult, and for the sake of including this fix into the upcoming 0.22 release, I have decided to add it to the Eigen-results directly.

@ElePT ElePT requested review from a team, manoelmarques and woodsp-ibm as code owners September 30, 2022 08:52
@qiskit-bot
Copy link
Copy Markdown
Collaborator

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:

Comment thread qiskit/algorithms/minimum_eigensolvers/vqe.py Outdated
Comment thread test/python/algorithms/minimum_eigensolvers/test_vqe.py Outdated
Comment thread qiskit/algorithms/minimum_eigensolvers/minimum_eigensolver.py Outdated
@coveralls
Copy link
Copy Markdown

coveralls commented Sep 30, 2022

Pull Request Test Coverage Report for Build 3161882352

  • 21 of 21 (100.0%) changed or added relevant lines in 4 files are covered.
  • 5 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.003%) to 84.654%

Files with Coverage Reduction New Missed Lines %
qiskit/extensions/quantum_initializer/squ.py 2 79.78%
qiskit/pulse/library/waveform.py 3 91.49%
Totals Coverage Status
Change from base Build 3161881839: -0.003%
Covered Lines: 61498
Relevant Lines: 72646

💛 - Coveralls

Comment thread qiskit/algorithms/minimum_eigensolvers/adapt_vqe.py
@woodsp-ibm woodsp-ibm added bug Something isn't working Changelog: None Do not include in the GitHub Release changelog. labels Sep 30, 2022
Comment thread qiskit/algorithms/eigensolvers/eigensolver.py Outdated
@woodsp-ibm woodsp-ibm added this to the 0.22 milestone Sep 30, 2022
@mergify mergify Bot merged commit 06b7b40 into Qiskit:main Sep 30, 2022
ElePT added a commit to ElePT/qiskit that referenced this pull request Jun 27, 2023
* Add ansatz to result

* Add ansatz to eigen. results

* Update qiskit/algorithms/minimum_eigensolvers/minimum_eigensolver.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Copy ansatz

* Apply comments

* Change name to optimal_circuit(s)

* add blank line

* move optimal circuit to variational result

* remove import

Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
ElePT added a commit to ElePT/qiskit-algorithms-test that referenced this pull request Jul 17, 2023
* Add ansatz to result

* Add ansatz to eigen. results

* Update qiskit/algorithms/minimum_eigensolvers/minimum_eigensolver.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Copy ansatz

* Apply comments

* Change name to optimal_circuit(s)

* add blank line

* move optimal circuit to variational result

* remove import

Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Changelog: None Do not include in the GitHub Release changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants