If you're just getting started in quantum computing, it might sometimes feel a little overwhelming to dive straight into understanding the Variational Quantum Eigensolver (VQE).
I'm here to tell you it can be done! Although for me, I found it a little difficult to learn about the actual quantum computing concepts with a framework obscuring what's actually happening under the hood.
So this is a very down-to-earth tutorial that will take you through a toy example of VQE using only generic python packages. I'll do my very best not to introduce new concepts without either explaining them or pointing you to a reference.
The purpose of this tutorial is actually threefold:
- Learn the basics of VQE
- Get hands-on with basic concepts from quantum computation. This is why we would bother coding from scratch instead of using a quantum simulation library.
- Get some sense of how our toy example relates (and doesn't relate) to real VQE.
As such, the following points best describe someone who'd benefit from this tutorial:
- You're familiar with Python and widespread packages such as numpy.
- You're newly familiar with the basics of quantum computing, but you'd like to get a more hands-on feel for it all.
- The following terms aren't new or (overly) intimidating to you: Wavefunction; Qubit; Hamiltonian; State preparation; Pauli operator; Bloch sphere; Quantum gate; Projection measurement; Observable.
- Not super important: You're familiar with the concept of computational optimisation. If you're not, it should take you 15-30 mins of googling to get a good enough idea.
Everything should take you 2 hours or more (depending on how many side quests you decide to go on).
-
Clone into your local machine. (skip to step 3 if you want to use Google Colab)
git clone https://github.com/alexander-soare/framework-agnostic-vqe-tutorial.git
-
Install requirements. (skip to step 3 if you want to use Google Colab)
pip install -r requirements.txt
-
Start with the prereading.
-
Then open up the 02_Tutorial.ipynb notebook in your favorite environment, or:
(a) click here to open it in Google Colab
(b) or preview it on Jupyter nbviewer
Note that the Github previewer lacks full markdown support for equations so I would recommend using one of the above methods instead.
-
Feel free to make use of this repo's Github Issues as a questions and discussions forum!
-
Share this with others by linking to the current page: https://github.com/alexander-soare/framework-agnostic-vqe-tutorial.
I've acquired most of my knowledge from the following resources. This work is a reflection of that.
- Insightful blog post with deep dives into ansatzes and the variation principle: https://www.mustythoughts.com/variational-quantum-eigensolver-explained (would definitely recommend reading more posts from this site)
- Excellent notebook tutorial. Nice and concise. Similar narrative to this one but using the qiskit library: https://github.com/DavitKhach/quantum-algorithms-tutorials/blob/master/variational_quantum_eigensolver.ipynb
- Official qiskit tutorial: https://qiskit.org/textbook/ch-applications/vqe-molecules.html
- VQE paper: A variational eigenvalue solver on a quantum processer
Also, a very appreciative thankyou to the following people who have helped me review this tutorial: