Skip to content
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

Number of shots in Fock and Gaussian spaces #333

Open
kareem1925 opened this issue Mar 24, 2020 · 2 comments
Open

Number of shots in Fock and Gaussian spaces #333

kareem1925 opened this issue Mar 24, 2020 · 2 comments

Comments

@kareem1925
Copy link

@kareem1925 kareem1925 commented Mar 24, 2020

Issue description

import strawberryfields as sf
from strawberryfields.ops import *
import numpy as np
sf.__version__  
>> '0.12.1'

#### create random points

x1 = 1
x2 = 0

eng = sf.Engine(
    backend="fock",
    backend_options={"cutoff_dim": 8,'shots':5000}
)
dist = sf.Program(4)

with dist.context as q:
    Fock(1) |q[0]
    Vacuum() | q[1]
    Dgate(a=x1) | q[2]
    Dgate(a=x2) | q[3]
    BSgate() | (q[0],q[1])
    BSgate() | (q[2],q[3])
    CZgate(np.pi) | (q[1],q[3])
    BSgate() | (q[0],q[1])
    BSgate() | (q[2],q[3])
    MeasureFock() | q[0]
    MeasureFock() | q[1]

results = eng.run(dist)
print(results.samples)

>> [0, 0, None, None]

The code above is an implementation of this figure:
image

I just want to know if I’m correct with my code and also how I can interpret the outcome as stated in the paper. I also want to know why the number of the samples is just one and I set the shots to 5000

According to this discussion I am requesting an explanation for the number of shots in both the gaussian and fock spaces.
This is the paper I'm trying to implement

@co9olguy

This comment has been minimized.

Copy link
Member

@co9olguy co9olguy commented Mar 24, 2020

Thanks @kareem1925. This is a good spot for us to discuss any potential bugs in the SF code (i.e., if you're not seeing the right number of shots that you expect). We can't guarantee any support for research questions here though. For the benefit of future viewers, can you edit your issue to focus up-front on the potential observed bug? Thanks 😄

@josh146

This comment has been minimized.

Copy link
Member

@josh146 josh146 commented Mar 25, 2020

Hi @kareem1925, the number of shots to run a program with are runtime options, so they are passed in eng.run(), not when creating the backend:

results = eng.run(dist, run_options={"shots": 5000})

Unfortunately, the Fock backend does not currently support multiple shots! This is something we are working to support, and hopefully should have this available soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.