XanaduAI / thewalrus

A library for the calculation of hafnians, Hermite polynomials and Gaussian boson sampling.
https://the-walrus.readthedocs.io
Apache License 2.0
100 stars 55 forks source link

Add N-mode general gaussian transformation code #251

Closed sylviemonet closed 3 years ago

sylviemonet commented 3 years ago

This is the PR for our work of N-mode general gaussian transformation code with my supervisor @ziofil.

The main idea is to create the n-mode gaussian transformation and its gradient from the recursive parameters C, mu, Sigma in the paper.

Work in progress now.

nquesada commented 3 years ago

Hi @sylviemonet --- This is a very exciting contribution. If I understand correctly you implement both the transformation and the gradient. I'd suggest you have a look at the function fock_tensor which given a Symplectic matrix and vector of displacements calculates the Fock representation of the operation. Note that this function does not calculate the gradients.

ziofil commented 3 years ago

Hi @sylviemonet --- This is a very exciting contribution. If I understand correctly you implement both the transformation and the gradient. I'd suggest you have a look at the function fock_tensor which given a Symplectic matrix and vector of displacements calculates the Fock representation of the operation. Note that this function does not calculate the gradients.

What is the purpose of looking at fock_tensor?

nquesada commented 3 years ago

@ziofil : could be useful as a reference and to check things are being done correctly. fock_tensor does half the job of what @sylviemonet is implementing here. It is likely slower than a properly implemented jitted code.

sylviemonet commented 3 years ago

I have no idea why the ci/circleci: osx-wheels fails here...

josh146 commented 3 years ago

@sylviemonet it seems to be failing with a Segmentation Fault,

osx-wheels/thewalrus/tests/test_quantum.py Fatal Python error: Segmentation fault

Very odd 🤔

sylviemonet commented 3 years ago

@sylviemonet it seems to be failing with a Segmentation Fault,

osx-wheels/thewalrus/tests/test_quantum.py Fatal Python error: Segmentation fault

Very odd 🤔

And I haven't touched this test_quantum.py file...

codecov[bot] commented 3 years ago

Codecov Report

Merging #251 (957b2bc) into master (415e132) will not change coverage. The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master      #251   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           21        21           
  Lines         1381      1413   +32     
=========================================
+ Hits          1381      1413   +32     
Impacted Files Coverage Δ
thewalrus/__init__.py 100.00% <100.00%> (ø)
thewalrus/_hermite_multidimensional.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 415e132...957b2bc. Read the comment docs.

nquesada commented 3 years ago

Ok, so it seems that once the linting issues are fixed, this PR will be ready for review.

nquesada commented 3 years ago

It is really looking like this is close to ready for review! Great work @sylviemonet !

sylviemonet commented 3 years ago

As I mentioned before, the main idea is to create the n-mode gaussian transformation and its gradient from the recursive relation, which is parametrized by the parameters C, mu, Sigma in the paper.

We know that the gaussian transformation can also be parameterized by its symplectic matrix and displacement vector, which are S, d we are referring to. And we have also a choi_trick function inside the test file to transform from S, d to its corresponding C, mu, Sigma. However, except for the test, we would keep the C, mu, Sigma as the main parameters for the gaussian gate and its gradients inside TheWalrus.

We'll (for sure) work with S and d for further implementation in Strawberryfields.

ziofil commented 3 years ago

tests are all passing :D

sylviemonet commented 3 years ago

@ziofil Hi Filippo, maybe you could help me to solve this conflict? (It demands someone with wrtie access)

nquesada commented 3 years ago

Hi @sylviemonet --- I have solved the merge conflict. It also seems to me that, pending the test passing, this should be ready for review.

nquesada commented 3 years ago

Also, once it is ready, don't forget to update the .github/CHANGELOG.md