Skip to content
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 VQE result, add ansatz #8816

Merged
merged 12 commits into from
Sep 30, 2022
Merged

Fix VQE result, add ansatz #8816

merged 12 commits into from
Sep 30, 2022

Conversation

ElePT
Copy link
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.

@qiskit-bot
Copy link
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:

@coveralls
Copy link

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

@woodsp-ibm woodsp-ibm added the mod: algorithms Related to the Algorithms module label Sep 30, 2022
@woodsp-ibm woodsp-ibm added bug Something isn't working Changelog: None Do not include in changelog labels Sep 30, 2022
@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 changelog mod: algorithms Related to the Algorithms module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants