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

docs(notebooks): add ADAPT-VQE tutorial #22

Merged
merged 18 commits into from
Mar 30, 2024
Merged

docs(notebooks): add ADAPT-VQE tutorial #22

merged 18 commits into from
Mar 30, 2024

Conversation

MeltemTolunay
Copy link
Contributor

Summary

Add ADAPT-VQE tutorial.

Details and comments

This tutorial uses Qiskit Pattern formalism and does not rely on any application packages such as Qiskit Nature. LiH ground state computation is chosen as an example in this tutorial. Functions to build the problem Hamiltonian, the initial Hartree-Fock state, the single and double excitation operators under the Jordan-Wigner transform and the gradient are all explicitly written.

@coveralls
Copy link

coveralls commented Mar 12, 2024

Pull Request Test Coverage Report for Build 8489904237

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 8481137071: 0.0%
Covered Lines: 290
Relevant Lines: 290

💛 - Coveralls

@pedrorrivero pedrorrivero changed the title add ADAPT-VQE tutorial docs(notebooks): add ADAPT-VQE tutorial Mar 13, 2024
@pedrorrivero pedrorrivero added PL-3 Priority level 3/5 → Medium notebook Notebook improvements or additions labels Mar 13, 2024
@pedrorrivero
Copy link
Member

pedrorrivero commented Mar 26, 2024

@haimeng-zhang let's try to have this reviewed by end of day tomorrow so that @MeltemTolunay can act on the feedback and we can merge by Friday.

@haimeng-zhang
Copy link
Contributor

The notebook looks great! Here are a few suggestions:

  1. update to EstimatorV2
  2. Not sure if this is the latest version, but cell 32, which runs VQE on the hardware, does not terminate with the full results.

Some more thoughts below (I think we can discuss and address them in a later version)

  • For readability
  1. I think it is worthwhile to spend 1-2 more sentences explaining technical terms, e.g., the UCC ansatz and Cholesky decomposition, to help guide readers with less background knowledge.
  2. I found the printout messages helpful, e.g., the accuracy of Cholesky decomposition, the number of opeators in the opool. I think it will be helpful to add 1-2 sentences explaining to the readers how the information is relevant to the VQE implementation.
  • For VQE implementation
  1. It will be helpful to call out the considerations for setting the Options() class for the Estimator() (for example, noise resilience level and shots). Side question: are 2000 shots enough for this type of task?
  • Minor styling
  1. For places that use URLs, I found it more readable to use markdown [link discriptor](https://link-url-here.org) instead of displaying the plain URL.
  2. In cell 8, try hf_circuit.draw(output="mpl", style="iqp"); it may suppress the warning message.

Copy link
Member

@pedrorrivero pedrorrivero left a comment

Choose a reason for hiding this comment

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

@MeltemTolunay please apply @haimeng-zhang suggestions at your own discretion.

@MeltemTolunay
Copy link
Contributor Author

I made the following changes per @haimeng-zhang's review:

  1. updated to EstimatorV2 for hardware runs
  2. set options to EstimatorV2 and increased the number of shots to 10000
  3. cleaned the URLs
  4. insert style="iqp" to suppress the error messages for circuit drawings

Later we can also discuss inserting more explanation for the chemistry background. Since a regular VQE tutorial will soon be made available on the Learning Platform where these information are already available, I think we can omit these in this tutorial for now.

Copy link
Member

@pedrorrivero pedrorrivero left a comment

Choose a reason for hiding this comment

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

Thanks so much for putting this together @MeltemTolunay ! The notebook is looking great. Just a couple of things and we will merge:

  • You are using pyscf which is an external dependency.
    • There is approval to use it but generally we need to add those to the repo as a notebook dependency.
    • Nonetheless, I believe pyscf has some compatibility issues with different operating systems, can you confirm?
    • If the issues do exist, instead of adding it as a dependency could we just add a link and a written warning in the notebook saying that people need to install it independently?
  • We should use V2 primitives instead of V1.
    • This means using StatevectorEstimator instead of Estimator as imported from qiskit.primitives
    • I think this will uncover some code errors in compute_gradients regarding the unpacking of results, possibly somewhere else too
  • There might be some latex error in the first paragraph under "Expand the Ansatz"
  • I see that you are doing the optimization process "manually", it would be valuable to indicate what kind of optimization you are performing —I see that it is one of the many gradient based methods.

@MeltemTolunay
Copy link
Contributor Author

Thank you for the comments @pedrorrivero! I made the requested changes.

  1. I currently added pyscf as a dependency. I'm actually not familiar with issues on other operating systems, I can confirm with quantum chemistry colleagues.
  2. All estimator primitives are V2, gradient and cost functions are updated accordingly.
  3. Latex typo is now fixed.
  4. There are multiple optimizers that we can indeed use. I didn't explain this in detail here, because it has been covered in the regular VQE tutorial that will be made public on the Learning Platform. In that sense, this notebook complements that course.

pedrorrivero
pedrorrivero previously approved these changes Mar 30, 2024
pedrorrivero
pedrorrivero previously approved these changes Mar 30, 2024
@pedrorrivero pedrorrivero merged commit c9f45ae into main Mar 30, 2024
11 checks passed
@pedrorrivero pedrorrivero deleted the adapt-vqe branch March 30, 2024 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
notebook Notebook improvements or additions PL-3 Priority level 3/5 → Medium
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants