XanaduAI / strawberryfields

Strawberry Fields is a full-stack Python library for designing, simulating, and optimizing continuous variable (CV) quantum optical circuits.
https://strawberryfields.ai
Apache License 2.0
737 stars 187 forks source link

SU(n) decomposition #665

Closed sduquemesa closed 2 years ago

sduquemesa commented 2 years ago

Context: The paper "Simple factorization of unitary transformations" proposes a factorization scheme that decomposes elements of SU(n) as a sequence of SU(2) transformations. This sequence of SU(2) transformations can then be mapped to an operation on optical modes including two phase plates and one beam splitter.

Code in this PR is based on Olivia di Matteo's @glassnotes CASPAR implementation.

Description of the Change: This PR implements a new decomposition for unitary matrices U passed to ops.Interferometer by expressing them as U = det(U) S and then applying the decomposition here referenced to S.

The result is a circuit containing a Rgate on each mode (related to the determinant of the unitary U) in addition to the recursive decomposition of the operation.

image Decomposition of an unitary from U(4).

Benefits: This PR implements the factorization above mentioned, hence making all the known (to date) unitary factorizations available on strawberry fields.

Possible Drawbacks: None

Related GitHub Issues: None

codecov[bot] commented 2 years ago

Codecov Report

Merging #665 (77dbc29) into master (9e6eff1) will increase coverage by 0.00%. The diff coverage is 98.36%.

@@           Coverage Diff            @@
##           master     #665    +/-   ##
========================================
  Coverage   98.34%   98.34%            
========================================
  Files          75       75            
  Lines        9041     9163   +122     
========================================
+ Hits         8891     9011   +120     
- Misses        150      152     +2     
Impacted Files Coverage Δ
strawberryfields/decompositions.py 99.44% <98.11%> (-0.33%) :arrow_down:
strawberryfields/ops.py 98.35% <100.00%> (+0.03%) :arrow_up:

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 9e6eff1...77dbc29. Read the comment docs.

glassnotes commented 2 years ago

@sduquemesa this is very exciting! :tada: Happy to review if you need an extra pair of eyes.

sduquemesa commented 2 years ago

@sduquemesa this is very exciting! 🎉 Happy to review if you need an extra pair of eyes.

@glassnotes, that'd be wonderful!

nquesada commented 2 years ago

Almost there @sduquemesa : https://app.codecov.io/gh/XanaduAI/strawberryfields/compare/665/diff I think what is needed is to also permute the rows of the unitary...

nquesada commented 2 years ago

@sduquemesa : the changes in this PR were not updated in the CHANGELOG file. Worth adding them!