Skip to content
This repository has been archived by the owner on Aug 21, 2023. It is now read-only.

Gradient notebook #1053

Merged
merged 22 commits into from
Oct 21, 2020
Merged

Gradient notebook #1053

merged 22 commits into from
Oct 21, 2020

Conversation

Zoufalc
Copy link
Contributor

@Zoufalc Zoufalc commented Oct 16, 2020

Summary

This adds a tutorial for the new Gradient Module.

Details and comments

"Given a Hermitian operator $g$ with two unique eigenvalues $\\pm r$ which acts as generator for a parameterized quantum gate $$G(\\theta)= e^{-i\\theta g}.$$\n",
"Then, quantum gradients can be computed by using eigenvalue $r$ dependent shifts to parameters. \n",
"All [standard, parameterized Qiskit gates](https://github.com/Qiskit/qiskit-terra/tree/master/qiskit/circuit/library/standard_gates) can be shifted with $\\pi/2$, i.e.,\n",
" $$ \\frac{\\partial\\langle\\psi\\left(\\theta\\right)|\\hat{O}\\left(\\omega\\right)|\\psi\\left(\\theta\\right)\\rangle}{\\partial\\theta} = 2 \\left(\\langle\\psi\\left(\\theta+\\pi/2\\right)|\\hat{O}\\left(\\omega\\right)|\\psi\\left(\\theta+\\pi/2\\right)\\rangle -\\partial\\langle\\psi\\left(\\theta-\\pi/2\\right)|\\hat{O}\\left(\\omega\\right)|\\psi\\left(\\theta-\\pi/2\\right)\\rangle\\right).$$\n",
Copy link
Member

@t-imamichi t-imamichi Oct 20, 2020

Choose a reason for hiding this comment

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

Is rhs of param shift rule\left( ... \right) / 2 instead of 2 \left( ...\right) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right

"The entries of the QFI for a pure state reads\n",
"\n",
"$$\n",
"QFI_{kl} = 4 * \\text{Re}\\left[\\langle\\partial_k\\psi|\\partial_l|psi\\rangle-\\langle\\partial_k\\psi|\\psi\\rangle\\langle\\psi|\\partial_l\\psi\\rangle \\right].$$"
Copy link
Member

Choose a reason for hiding this comment

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

rhs remains |psi\\rangle. Need to replace it with |\psi\\rangle

Copy link
Member

Choose a reason for hiding this comment

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

It's also good to move $$ in the end of sense to the next line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Took care of it.

@nonhermitian
Copy link
Contributor

You are getting a 180 sec timeout isse:

Notebook error:
CellTimeoutError in tutorials/operators/02_gradients_framework.ipynb:
A cell timed out while it was being executed, after 180 seconds.
The message was: Cell execution timed out.

Perhaps going to Aer from BasicAer will help?

@nonhermitian nonhermitian self-requested a review October 21, 2020 15:01
@nonhermitian nonhermitian merged commit 4e122b4 into Qiskit:master Oct 21, 2020
manoelmarques pushed a commit to manoelmarques/qiskit-machine-learning that referenced this pull request Mar 11, 2021
* Update qgans_for_loading_random_distributions.ipynb

* move qGAN tutorial from legacy_tutorials to tutorials

* Update qgans_for_loading_random_distributions.ipynb

* Remove Torch import

* change Kernel

* Update qgans_for_loading_random_distributions.ipynb

* include gradient module tutorial

* update naming -> gradient framework

* update gradient tutorial

* update gradient framework, delete black picture

* fix typos

* Update 02_gradients_framework.ipynb

- minor fixes
- rename to `02_gradients...` to prepare for `01_operator_flow...`

* use circuit instead of circuitfactory

* Update 02_gradients_framework.ipynb

Co-authored-by: Paul Nation <nonhermitian@gmail.com>
Co-authored-by: Cryoris <jules.gacon@googlemail.com>
Co-authored-by: Stefan Woerner <WOR@zurich.ibm.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants