-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fock backend of localsimulator and thewalrus decomposition not giving the desirable result #742
Comments
Hey @minseok1999! Apologies for the delayed response. Can you distill your code down to something minimal that still reproduces the behaviour? It would help me greatly 😄 |
Thank you for considering my issue again! I have edited with the distilled source code as you requested. |
@minseok1999 can you surround your code with three backticks? It will render it like this, which github will let me copy-paste.
You can also get rid of the notebook block stuff (e.g., |
I have removed notebook blocks and wrapped my code using backticks as you requested! |
Awesome thanks! It might be something to do with |
I have raised the cutoff dimension up to 5 and 6 and it clearly gave higher photon 'mean_count' (average photon number at the output port out of 1000 samples) as 1.46 and 1.54. This is better but clearly not good enough cause I have aimed my mean photon number at 4 when I decomposed my graph into experimental setup of beam splitters and single mode squeezed states. But the problem is, I cannot raise this cutoff dimension above 7 because of memory deficiency of my MacBook Air. Is there a way to reliably simulate 6 mode Gaussian Boson Sampling experiment without this memory issue other than the local Fock basis simulator? I know hafnian_sample_graph gives gaussian boson sampling pattern but what I want is to simulate this from the experimental setup of beam splitters so that I can simulate in the future how this sampling pattern is affected upon attaching some other components. |
These demos are worth checking out:
Let us know if those help you get anywhere! |
The first link you provided helped me with postselection stage after getting all the samples(tidier code than the one I wrote myself) but it didn't have much to do with full path optical simulation of Gaussian boson sampling(simulation done by writing out components manually and can be varied by attaching components myself) I am intending. And for the second one, I didn't scrutinize all the details yet but it looked like it was about some more sophisticated Gaussian boson sampling scheme of training the machine real time, which I don't need much at this stage. I appreciate your advice though! If there is no such reliable simulator provided that is fit for me then I think I should build one myself or consider buying some gpu for more local kernel memory🙂 |
It would definitely be worth it to see if raising the cutoff higher and higher helps you achieve the desired result. We can leave this issue open until the solution is determined 😄 |
Before posting a bug report
Expected behavior
I wanted to follow the full steps of encoding an adjacency matrix of a graph into an interferometric setup and single mode squeezed states for Gaussian boson sampling experiment. To do this, I first used thewalrus library to decompose the adjacency matrix using Takagi decomposition. After I have decomposed the matrix, I have then used rectangular_phase_end from the strawberry fields library to convert my unitary gate into a set of beam splitters. Finally, I have used the Fock backend of the local simulator engine and fed in the squeezing parameters and Beam splitter setup I have generated to get the photo count result corresponding to my specific adjacency matrix.
I expected the photocount pattern of [111100] to appear for the largest number of times since that pattern corresponds to the 4 dimensional subgraph choice of maximum Hafnium value to my 6 dimensional adjacency matrix. (Hafnium value of 3, Hafnium squared value of 9 whereas other choices such as [110011] only has single perfect matching) I have tested my graph using hafnium_sample_graph from thewalrus library as well, and I got 231 samples of [111100] among 10000 samples, which is quite desirable.
Actual behavior
What I got after postselecting only those with ones and zeros (subspace used for the estimation of hafnian) was something like this,
[1 1 1 0 0 1]
[1 0 0 1 1 1]
[1 0 1 0 1 1]
[0 1 1 1 0 1]
[1 1 0 1 1 0]
[1 1 1 0 1 0]
[0 0 1 1 1 1]
[1 1 1 0 0 1]
only 8 cases out of 1000 samples and I could not see the answer case,i.e, [111100] ,to the maximum hafnian problem at all.
What's more, mean photon number at the output was around 0.97 whereas I aimed it at 4 to best see the 4 dimensional subgraph among my 6 dimensional adjacency matrix.
Reproduces how often
Reproduces nearly every time.
System information
Strawberry Fields: a Python library for continuous-variable quantum circuits. Copyright 2018-2020 Xanadu Quantum Technologies Inc. Python version: 3.10.9 Platform info: macOS-13.4.1-arm64-arm-64bit Installation path: /Users/ryuminseok/anaconda3/lib/python3.10/site-packages/strawberryfields Strawberry Fields version: 0.23.0 Numpy version: 1.23.5 Scipy version: 1.10.0 SymPy version: 1.12 NetworkX version: 3.1 The Walrus version: 0.20.0 Blackbird version: 0.5.0 XCC version: 0.3.0 TensorFlow version: None
Source code
Tracebacks
No response
Additional information
The text was updated successfully, but these errors were encountered: