PennyLaneAI / pennylane

PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.
https://pennylane.ai
Apache License 2.0
2.38k stars 607 forks source link

Finalize CV gradients theory #7

Closed co9olguy closed 6 years ago

co9olguy commented 6 years ago

I'd like to set a deadline on this. For better or for worse, we need to know soon whether it is viable to add the CV gradients to v0.1 of openqml. I'm going to set the date of Aug 12 for this.

If we do not have a very clear picture about how the code for this would look by then, we will go forward with only numerical differentiation for CV circuits.

smite commented 6 years ago

Having read the discussion in the appendix of openqml_formalism.tex and after thinking about it myself, I would summarize our conclusion as

  1. If you only have gaussian gates and order-m polynomial observables (in x and p), in Heisenberg picture the gates act as linear transformations on (I, x, p) and thus the observables remain order-m. You can symbolically differentiate the transformation matrix and obtain an expression for the derivative which is another linear transformation on (I, x, p). Hence you should always be able to evaluate it in the lab by measuring a number of order-m observables and computing the proper linear combination of the results. This can be implemented in code.

  2. If you also have non-gaussian gates, things get much more complicated. The gates no longer act as mere linear transformations on (I, x, p) and thus observables may be mapped to higher-order observables by each non-gaussian gate. It could probably be handled in the code, but I'm not sure how you could easily evaluate the resulting expectation values in the lab. This makes sense, since gaussian optics is intuitively "easy", non-gaussian is "hard".

Since one important design principle of OpenQML is that it's not just a simulator but you can also run the gradient algorithms on quantum hardware, I would suggest adding analytic CV gradients for gaussian circuits only in v0.1.

mariaschuld commented 6 years ago

I fully support your summary. But I would implement analytic gradients for Gaussian circuits and operators up to quadratic in version 0.0 (is that the first one?). So we have something to also guide the attention to CV circuits.

We could check a circuit for non-Gaussianness and then choose the differentiation method...

mariaschuld commented 6 years ago

I created a new branch and will start to write up the theory we have so far in the main manuscript.

co9olguy commented 6 years ago

Still a couple days for inspiration to strike, but it's looking like we'll stick with Gaussian-only circuits for CV automatic differentiation :)

We need to start planning for how to implement this.

co9olguy commented 6 years ago

The research deadline has now passed. We will implement automatic gradients for Gaussian CV circuits: gates from the Gaussian set and measurements of x, p, xx, xp+px, and pp.

@smite can you make this your next task to implement this? Loop in @mariaschuld @cgogolin or myself as necessary to clear up anything