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

Add VQE estimator tutorial #235

Merged
merged 21 commits into from
Apr 8, 2022
Merged

Add VQE estimator tutorial #235

merged 21 commits into from
Apr 8, 2022

Conversation

lockwo
Copy link
Contributor

@lockwo lockwo commented Mar 24, 2022

Short tutorial showing integration with Qiskit (and Qiskit nature) for optimizing molecular hamiltonians. Feedback welcome, it is a first draft.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@CLAassistant
Copy link

CLAassistant commented Mar 24, 2022

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@frankharkins frankharkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I had trouble running the main experiement, but could be something I'm doing wrong either in the notebook or on cloud.ibm.com. Otherwise, just found a couple of name errors.

docs/tutorials/estimator_vqe.ipynb Outdated Show resolved Hide resolved
docs/tutorials/estimator_vqe.ipynb Outdated Show resolved Hide resolved
docs/tutorials/estimator_vqe.ipynb Outdated Show resolved Hide resolved
@lockwo
Copy link
Contributor Author

lockwo commented Mar 24, 2022

The code does take awhile to run. I am open to suggestions to accelerate it (I am not super familiar with cloud interactions, so perhaps there are simple things to greatly accelerate it). If that is a problem I can make it not do PES and just one bond length.

@frankharkins
Copy link
Member

frankharkins commented Mar 24, 2022

No idea about the cloud interactions, but if there's a way to trade off accuracy for speed, I would personally opt for that.

Could also add print updates in evaluate_expectation() and when starting each iteration so the user can see something is happening and can guess how long it'll take.

@lockwo
Copy link
Contributor Author

lockwo commented Mar 24, 2022

Updating the optimizer I could get it down to ~20-30 minutes runtime with ok results. I also added an iteration logger. (and accidentally leaked my token whoops, had to regenerate that).

Copy link
Contributor

Great job for figuring out how to use VQE with new estimator! It must be a lot of work to figure things out, I know it would be for me, because the code look so different from the old way. I haven't looked the the tutorials in details yet, but I think it might be better to simply it to only calculate one energy (at equilibrium bond distance?) instead of 26? I think that will make the code a lot easier to follow for beginners and it will also speed up the code a lot more.

@lockwo
Copy link
Contributor Author

lockwo commented Mar 25, 2022

I was considering that as an option (I just started with a PES curve because they are so ubiquitous). That would certainly accelerate the code. I don't have a strong opinion one way or the other, so however you think is best I can change it.

@HuangJunye
Copy link
Contributor

@frankharkins What do you think?

@frankharkins
Copy link
Member

I think either is fine, my worry was that the user would be waiting 30mins for any feedback so might not know if things are working or not.

docs/tutorials/estimator_vqe.ipynb Outdated Show resolved Hide resolved
docs/tutorials/estimator_vqe.ipynb Outdated Show resolved Hide resolved
@lockwo
Copy link
Contributor Author

lockwo commented Mar 31, 2022

I have made the (major) change of converting it to be a single convergence curve, which should help accelerate things. I had to change optimizers because COBYLA doesn't allow callbacks (not sure why that is the case in scipy), but it still gives a nice convergence graph.

@lockwo
Copy link
Contributor Author

lockwo commented Apr 6, 2022

Are the changes we were told about "Rename IBMRuntimeService -> QiskitRuntimeService
Deprecate IBMEstimator/IBMSampler" things that we need to incorporate or is that on a different version? If so I will make that change.

@rathishcholarajan
Copy link
Member

Are the changes we were told about "Rename IBMRuntimeService -> QiskitRuntimeService Deprecate IBMEstimator/IBMSampler" things that we need to incorporate or is that on a different version? If so I will make that change.

Yes needs to be incorporated, that change will be released tomorrow or Friday.

@lockwo
Copy link
Contributor Author

lockwo commented Apr 7, 2022

Ok, I made those changes (pretty simple, just updating those function/class names).

Copy link
Member

@rathishcholarajan rathishcholarajan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lockwo Could you please add this cell as well which shows the version of qiskit-ibm-runtime? 0.4.0 was released this morning. So please make sure it shows 0.4.0.

@lockwo
Copy link
Contributor Author

lockwo commented Apr 8, 2022

Ok, I added the Qiskit runtime version (0.4.0). I also added the VQE to the tutorial.rst file

Copy link
Member

@rathishcholarajan rathishcholarajan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@rathishcholarajan rathishcholarajan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks a lot @lockwo!

@rathishcholarajan rathishcholarajan merged commit f814dd4 into Qiskit:main Apr 8, 2022
blakejohnson pushed a commit to blakejohnson/qiskit-ibm-runtime that referenced this pull request May 26, 2023
frankharkins added a commit to Qiskit/documentation that referenced this pull request Apr 9, 2024
Co-authored-by: ElePT <epenatap@gmail.com>
Co-authored-by: Frank Harkins <frankharkins@hotmail.co.uk>
Co-authored-by: Ikko Hamamura <ikkoham@users.noreply.github.com>
Co-authored-by: Jessie Yu <jessieyu@us.ibm.com>
Co-authored-by: Jim Garrison <garrison@ibm.com>
Co-authored-by: Junye Huang <h.jun.ye@gmail.com>
Co-authored-by: Kevin Tian <kt474@cornell.edu>
Co-authored-by: Paul Nation <nonhermitian@gmail.com>
Co-authored-by: Rathish Cholarajan <rathish.c@ibm.com>
Co-authored-by: Rebecca Dimock <66339736+beckykd@users.noreply.github.com>
Co-authored-by: Sanket Panda <pandasa123@gmail.com>
Co-authored-by: jspark971 <jspark971@gmail.com>
Co-authored-by: kevin-tian <kevin.tian@ibm.com>
Co-authored-by: lerongil <leron_1234@yahoo.com>
frankharkins added a commit to Qiskit/documentation that referenced this pull request Apr 9, 2024
Originally created in Qiskit/qiskit-ibm-runtime#235

Co-authored-by: ElePT <epenatap@gmail.com>
Co-authored-by: Frank Harkins <frankharkins@hotmail.co.uk>
Co-authored-by: Ikko Hamamura <ikkoham@users.noreply.github.com>
Co-authored-by: Jessie Yu <jessieyu@us.ibm.com>
Co-authored-by: Jim Garrison <garrison@ibm.com>
Co-authored-by: Junye Huang <h.jun.ye@gmail.com>
Co-authored-by: Kevin Tian <kt474@cornell.edu>
Co-authored-by: Paul Nation <nonhermitian@gmail.com>
Co-authored-by: Rathish Cholarajan <rathish.c@ibm.com>
Co-authored-by: Rebecca Dimock <66339736+beckykd@users.noreply.github.com>
Co-authored-by: Sanket Panda <pandasa123@gmail.com>
Co-authored-by: jspark971 <jspark971@gmail.com>
Co-authored-by: kevin-tian <kevin.tian@ibm.com>
Co-authored-by: lerongil <leron_1234@yahoo.com>
frankharkins added a commit to Qiskit/documentation that referenced this pull request Apr 9, 2024
Originally created in Qiskit/qiskit-ibm-runtime#235

Co-authored-by: ElePT <epenatap@gmail.com>
Co-authored-by: Frank Harkins <frankharkins@hotmail.co.uk>
Co-authored-by: Ikko Hamamura <ikkoham@users.noreply.github.com>
Co-authored-by: Jessie Yu <jessieyu@us.ibm.com>
Co-authored-by: Jim Garrison <garrison@ibm.com>
Co-authored-by: Junye Huang <h.jun.ye@gmail.com>
Co-authored-by: Kevin Tian <kt474@cornell.edu>
Co-authored-by: Paul Nation <nonhermitian@gmail.com>
Co-authored-by: Rathish Cholarajan <rathish.c@ibm.com>
Co-authored-by: Rebecca Dimock <66339736+beckykd@users.noreply.github.com>
Co-authored-by: Sanket Panda <pandasa123@gmail.com>
Co-authored-by: jspark971 <jspark971@gmail.com>
Co-authored-by: kevin-tian <kevin.tian@ibm.com>
Co-authored-by: lerongil <leron_1234@yahoo.com>
frankharkins added a commit to frankharkins/documentation that referenced this pull request Jul 22, 2024
Originally created in Qiskit/qiskit-ibm-runtime#235

Co-authored-by: ElePT <epenatap@gmail.com>
Co-authored-by: Frank Harkins <frankharkins@hotmail.co.uk>
Co-authored-by: Ikko Hamamura <ikkoham@users.noreply.github.com>
Co-authored-by: Jessie Yu <jessieyu@us.ibm.com>
Co-authored-by: Jim Garrison <garrison@ibm.com>
Co-authored-by: Junye Huang <h.jun.ye@gmail.com>
Co-authored-by: Kevin Tian <kt474@cornell.edu>
Co-authored-by: Paul Nation <nonhermitian@gmail.com>
Co-authored-by: Rathish Cholarajan <rathish.c@ibm.com>
Co-authored-by: Rebecca Dimock <66339736+beckykd@users.noreply.github.com>
Co-authored-by: Sanket Panda <pandasa123@gmail.com>
Co-authored-by: jspark971 <jspark971@gmail.com>
Co-authored-by: kevin-tian <kevin.tian@ibm.com>
Co-authored-by: lerongil <leron_1234@yahoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants