Comments (15)
Added two working examples on VQEs (need to be adapted once final API is out)
Added one pseudocode example on CV quantum neural net.
from pennylane.
Had a quick conversation with @mariaschuld, this was the consensus:
-
OpenQML shouldn't depend on any of the plugins, to avoid pulling in libraries the user might not want.
-
The docs should have a page(under 'Getting Started') that lists all 'official' plugins, and describes the plugin ecosystem for the user (i.e. OpenQML is designed to be used with plugins, these need to be pip installed, etc).
-
All tutorials for the 'official' plugins should be in the main OpenQML docs, with a disclaimer at the top (i.e.
.. note::
or.. warning::
or.. info::
) which saysTo run this tutorial, you must install
pennylane-sf
viapip install pennylane-sf
'This keeps everything centralised (for the user) and easier to keep track of (for us).
-
The actual plugins will have their own docs, but bare bones and just to describe their API via Sphinx. These will be linked in the main OpenQML docs, and vice versa.
from pennylane.
There are 3 qubit and 2 CV examples on branch examples_maria. I will try to code up a CV GAN to have 6 in total.
However, none of the examples except one does what it is supposed to do and I think I need some help here.
Tut Q1 - works
Tut Q2 - does not work with project Q backend
Tut Q3 - does not work with regularizer (see #56), cost INCREASES, classifier always seems to predict either all -1 or all 1
Tut CV1 - gradient is always zero, although it clearly should not be
Tut CV2 - does not learn much, although Juan Miguel's code in tensorflow with exactly the same settings learns nicely.
I have an inkling that we have a mix of bugs here.
from pennylane.
You can use the .py file for convenience, or the jupyter notebook.
from pennylane.
Does Tut Q2 work with the default.qubit backend? That's odd.
For Tut CV1, that sounds like the same issue that currently causes photon redirection to fail, which likely won't be fixed until @smite merges his next feature branch.
So definitely a mix of bugs!
from pennylane.
Yes it seems to work with the default backend. Can the redirection bug be also responsible for the CV2 to fail?
from pennylane.
I am going through T2 to see why it doesn't work with ProjectQ.
The first problem is definitely the preparation with QubitStateVector
. This is not a bug in the plugin but a "shortcoming" of ProjectQ. They don't know how to decompose the manually specified state into an elementary gate sequence that would prepare it. I don't think I can do anything about it. We could use a manually specified gate sequence instead of the initial state given as a vector. They do know ho to decompose arbitrary single qubit initial states.
For example, if I simply use qm.Hadamard([0])
instead of qm.QubitStateVector(initial_state, wires=[0, 1])
in ansatz()
. ProjectQ produces the same result for the optimization than the default plugin.
Maybe it is also good to not start with the weights initialized to zero? For some initial states I get stuck with both the default and the ProjectQ plugin. People might modify the example when they play around and get frustrated...
from pennylane.
Waiting to update the examples when the new structure is out. I think Josh wanted to put the examples into the plugin repo and only keep two very minimal default templates for openqml itself. We can then make sure the ProjectQ examples do not use QubiStateVector hacks.
from pennylane.
[This is more for myself as reminder]
Testing the examples with latest merge. Issues:
- np and onp?
PQ:
1 Different behaviour of ProjectQ and default.qubit - PQ gets stuck on saddle point!
3a - Test state prep script. Does not learn. [KWARGS BUG]
3b - Does not learn [KWARGS BUG]
SF:
3 QNN Does not learn [KWARGS BUG]
from pennylane.
I just realised that we're missing a Tutorials section in the docs sidebar, as we have with Strawberry Fields. I've added that in the latest master, it just needs to be populated now.
@mariaschuld, we could kill two birds with one stone, and embed the Jupyter notebooks for the examples directly in the docs? See https://strawberryfields.readthedocs.io/en/latest/gallery/state_learner/StateLearning.html for an example of what this looks like.
The advantages of this approach are:
- it is a bit of a time saver
- it is easier to directly include images and plots
- it is easier to quickly see that the code is correct and runs
- I can auto-insert a link at the bottom for users to download the notebook of the tutorial.
Downsides, however, are
- Since Jupyter notebook uses markdown rather than ReST, you sometimes need to be really vigilant that it is formatting quickly once it has been converted to display in the docs.
- Likewise, cross-referencing between notebooks and ReST pages is slightly stricter.
- The sphinx compilation stage is significantly slower.
The docs for Notebook/Spinx plugin is available here: https://nbsphinx.readthedocs.io/en/0.3.5/
from pennylane.
The alternative would be to convert the notebook to a rst file and make it static, right?
Will the docs tutorial section be distinguished into the different plugins? Is it not confusing that one needs different repos to run the tutorials?
from pennylane.
Just checking in on the status of examples.
-
As stated above, we want all examples/tutorials to be placed in the main library. This is so that users can find them easiest (it will not affect the dependencies of the library). We can also have copies in other repos, but we don't want them to be missing from the core docs
-
So far there are two tutorials ("Basic tutorial: qubit rotation" and "Photon redirection and hybrid computation") present in the main library documentation. These look great! (one todo still to take care of)
-
I added a QGAN example last night (worked right away, really cool :) ), but it'll need a bit more polishing
-
@mariaschuld where can we find the remaining examples/tutorials? Can we get these placed in the core library
master
branch now?
from pennylane.
Sure. My last bit of information was that we put them into the documentation of the main library but in the repo of the plugins to not to have code for plugins in the main repo. But we broke this rule anyways in the mini-demos by using SF for the Fock State preparation.
I can easily move the notebooks and .py files to the main repo. My suggestion is that I do this after the 3 PRs are merged, to avoid lots of work merging.
from pennylane.
Examples are on add_examples... branch in the main repo and refactored.
Last things to do:
- TutQ3: stateprep sign bug
- Test TutCVs (currently not sure how to load plugin)
from pennylane.
All running
from pennylane.
Related Issues (20)
- [BUG] Cannot run qnode with sum that contains `I()` (Identity with empty wires) HOT 6
- [BUG] `qml.equal` does not work with `qml.HilbertSchmidt`
- [BUG] `qml.counts` returns bad counts for measurements outcomes HOT 5
- [BUG] `jax.grad` + `jax.jit` does not work with `AmplitudeEmbedding` and finite shots HOT 12
- [BUG] kron incompatibility with `numpy @ torch`
- [BUG] Grouping is not automatically used in qnode execution (or tracker is wrong) HOT 3
- [BUG] Output keys `counts` depend on MCM simulation technique
- Support for Hermitian observables when used with qml.shadow_expval() HOT 4
- [BUG] `qml.draw`, `qml.draw_mpl` do no work with `qml.defer_measurements` when collecting MCM statistics
- [BUG] `param_shift` with `broadcast=True` does not work properly with shot vectors
- [BUG] `ValueError: Unrecognized keyword arguments passed to KerasLayer: {'dynamic': True}` HOT 1
- [BUG] Various `Operator.pow` methods with a batched exponent fail
- [BUG] `param_shift` with `broadcast=True` does not work with zero-length recipes HOT 1
- Add `StateMeasurement.process_density_matrix` method
- [BUG] Issues with `metric_tensor` and trainable params causing errors with jax
- Improve operator support for new `assert_equal` function: Group 1
- Improve measurement support in from_qasm
- Support native measurement-based snapshots in Default Clifford
- Improve operator support for new `assert_equal` function: Group 2
- Add a QutritChannel operation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pennylane.