PennyLaneAI / qml

Introductions to key concepts in quantum programming, as well as tutorials and implementations from cutting-edge quantum computing research.
https://pennylane.ai/qml
Apache License 2.0
545 stars 188 forks source link

[DEMO] Perturbative Gadgets for Variational Quantum Algorithms #593

Closed SimonCichy closed 1 year ago

SimonCichy commented 2 years ago

General information

Name Simon Cichy.

Affiliation (optional) Dahlem Center for Complex Quantum Systems, Freie Universität Berlin, 14195 Berlin, Germany, Institute for Theoretical Physics, ETH Zürich, 8093 Zürich, Switzerland.

Twitter (optional) @sdcichy

Image (optional) FC_gadget-terms-tutorial


Demo information

Title Perturbative Gadgets for Variational Quantum Algorithms

Abstract In this tutorial, we will explore the application of perturbative gadgets in variational quantum algorithms. Substituting a global Hamiltonian with its gadgetized equivalent allows to train the algorithm on a local cost function and still finding the target minimum, thus avoiding the issue of cost function dependent barren plateaus.

Relevant links https://github.com/SimonCichy/barren-gadgets/tree/main/Pennylane-tutorial https://arxiv.org/pdf/2210.03099.pdf

isaacdevlugt commented 2 years ago

Thanks @SimonCichy ! Look forward to checking this out 👀

KetpuntoG commented 2 years ago

Hi @SimonCichy , great job! The demo is really well done 😄 If you like we could guide you to introduce it as a demo of the pennylane website with your name, instead of in the community demos section. This requires a bit more work and will take a bit more time but I wanted to tell you about the option in case you find it interesting 💪 If not, we will get on with the integration in the community section 🚀

SimonCichy commented 2 years ago

Hi @KetpuntoG, thanks a lot, it is nice to hear that 😄 And in principle, I would be happy to make it a demo of the pennylane website! If you can tell me a bit more about what it implies, what would have to be changed, etc, I could tell you if (or rather how quick) I can do it

KetpuntoG commented 2 years ago

The steps to write a demo in PennyLane can be found in the readme of the qml repo. The format of the demos are in .py using Sphinx. Having the notebook already made, we have a script (in the readme you will find it too) to facilitate the conversion. Then, it's just a matter of fixing small formatting details. Once you have it in demo format, we will do a more in-depth review of the content in which we will do a couple of interactions with you. Estimating more or less the time, from the moment you start building the demo until it goes through the review process, it could be a month. If you are in a hurry, we can always put the demo as a community demo and then, when you prefer, work on the PennyLane proper demo. How do you want to proceed? :)

josh146 commented 2 years ago

@SimonCichy something to note is that our demos are not in the form of notebooks. Instead:

But there are nice ways to convert a notebook to this format. For example, you can export a notebook in rst format (and then manually change it to a python script) directly from Jupyter:

image

Alternatively, we have a script linked in the readme for converting jupyter notebooks.

SimonCichy commented 2 years ago

Thank you both! I am not in a hurry, and it does not seem to be all too much work, so I'm in. I will get working on converting the file and will let you know when it is done, or if I am having issues.

SimonCichy commented 2 years ago

I believe I have done the necessary changes, but I would be happy if you could confirm the next steps. I have now the qml repo locally and have added my tutorial in .py format in demonstrations. It runs the way it is supposed to, but I didn't know where to put the other files (where I define things which I did not want to go into detail in the tutorial itself). For now, I put them in the subfolder corresponding to the tutorial (where I also put the image from the tutorial). Is it fine like that? To check that everything is in order, I tried to build the website locally (running only my demo, as explained in the readme) but I am having issued with that. Should I still do the pull request as is?

josh146 commented 2 years ago

@SimonCichy awesome to hear! Definitely feel free to open a PR, that is much easier than building the website locally.

When you create a PR, we have an automatic build system that will build the website, and create a link in the PR for you to view the changes. This preview will update with every push to the PR :)

SimonCichy commented 2 years ago

To be honest, it will be my first pull request, so could you confirm, that I am doing it right before I mess something up? (sorry) I cloned the repository, created a branch (local for now) and did my changes there. Do I push to make it a remote branch, and then proceed to making a PR from my (new) branch to the master branch? Thanks for the help...

isaacdevlugt commented 2 years ago

Yep! Just push your changes (git push --set-upstream origin <branch name>), then make a Pull Request 😄. The Pull Request will be for merging your branch with your demo into the master branch 🙂. See here for making a Pull Request! Let us know if you have any issues with that 🚀

SimonCichy commented 2 years ago

Thank you a lot. Apparently, I do not have the correct access rights, so I guess I am doing something wrong. When trying to set the upstream branch on the terminal, I get an error message

Permission denied (publickey).
fatal: Could not read from remote repository.      
Please make sure you have the correct access rights
and the repository exists

When doing it with my git GUI, after a few seconds the remote branch disappears and checking the status I get

Your branch is based on 'origin/demo_barren_gadgets', but the upstream is gone.

I will try to investigate what went wrong, but if it is a problem you are familiar with, I would appreciate some advice 😉

KetpuntoG commented 2 years ago

Hello @SimonCichy ! Probably, you tried to make a clone instead of the fork. In principle if you do the fork it shouldn't give you any problems and then you can do the PR in the same way :)

isaacdevlugt commented 2 years ago

🤦! Sorry about that @SimonCichy, should've known you wouldn't have had permissions.

As @KetpuntoG said, if you fork the repo, make your changes there, then make a PR from your fork, then you're all set!

Instructions here.

SimonCichy commented 2 years ago

Thank you a lot, again. Now there should be a pull request, but most of the checks were not successful. Does that mean something went wrong on my side?

josh146 commented 2 years ago

@SimonCichy perfect, now we can jump into the PR and help troubleshoot :)

KetpuntoG commented 1 year ago

I close this issue, we are already working with the proper demo