Closed sduquemesa closed 2 years ago
This PR should only be merged after a release of The Walrus is made containing the requirements (MZgate and its gradients).
I've added a test file to check if the native implementation using the gate from The Walrus agrees with the gate decomposition.
Merging #617 (22cfaf5) into master (f5b5be6) will increase coverage by
0.00%
. The diff coverage is100.00%
.
@@ Coverage Diff @@
## master #617 +/- ##
=======================================
Coverage 98.54% 98.55%
=======================================
Files 77 77
Lines 8938 8985 +47
=======================================
+ Hits 8808 8855 +47
Misses 130 130
Impacted Files | Coverage Δ | |
---|---|---|
strawberryfields/compilers/fock.py | 100.00% <ø> (ø) |
|
strawberryfields/backends/base.py | 89.07% <100.00%> (+0.09%) |
:arrow_up: |
strawberryfields/backends/fockbackend/backend.py | 100.00% <100.00%> (ø) |
|
strawberryfields/backends/fockbackend/circuit.py | 98.41% <100.00%> (-0.01%) |
:arrow_down: |
strawberryfields/backends/fockbackend/ops.py | 95.26% <100.00%> (+0.09%) |
:arrow_up: |
strawberryfields/backends/tfbackend/backend.py | 100.00% <100.00%> (ø) |
|
strawberryfields/backends/tfbackend/circuit.py | 96.01% <100.00%> (+0.05%) |
:arrow_up: |
strawberryfields/backends/tfbackend/ops.py | 98.14% <100.00%> (+0.09%) |
:arrow_up: |
strawberryfields/ops.py | 98.99% <100.00%> (+<0.01%) |
: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 f5b5be6...22cfaf5. Read the comment docs.
@sduquemesa : It would be a nice if you could a simple benchmark of this new implementation. For example, check how long it takes to propagate the evolution of 4 (or any other number) of photon going into an interferometer with unitary drawn from the Haar measure. You could check how long it takes with your implementation and with the old one.
Regarding the documentation check, in order to get this passing, you will need to also update the Walrus link in
doc/requirements.txt
.
@josh146 I have updated the requirements but doc builds keep failing
@sduquemesa it looks like you have updated requirements.txt
, but doc/requirements.txt
(this is the file used to install the documentation requirements) will also need to be updated 🙂
@sduquemesa : seems like these lines of your PR are not being tested:
Can you add a new test?
Benchmark of native vs. decomposed MZ gate for different number of modes. See benchmark source code here
Context: The MZgate is the natural gate to decompose an arbitrary linear optical interferometer into single- and two-mode passive gates. Currently, interferometers are decomposed into MZgates and Rgates and then internally the MZgate is decomposed into two BSgates and two more rotation gates, leading to an increase by a factor of two in terms of the number of two mode gates needed to decompose and apply a given interferometer, making the process potentially less than optimal.
Description of the Change: This change implements the MZgate and its gradients natively on the Fock backends using the The Warus implementation (cf. XanaduAI/thewalrus#256).
Benefits: Reduces the number of two-mode gates needed to apply the given interferometer.
Possible Drawbacks: N/A
Related GitHub Issues: Native support in the Fock backends for the MZgate #610