-
Notifications
You must be signed in to change notification settings - Fork 191
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
Random failure with measure_fock
method
#670
Comments
measure_fock
methodmeasure_fock
method
Folks I did a little further digging and it turns out that this crash is being caused by the vector But, the question now is why is the probability distribution a zero vector? > /Users/Sayan/.pyenv/versions/3.9.7/lib/python3.9/site-packages/strawberryfields/backends/fockbackend/circuit.py(684)measure_fock()
-> if sum(dist) != 1:
(Pdb) p dist
array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])
(Pdb) Could this be a side-effect of the fixes introduced as a response to #354 (and #364)? |
Thanks for digging into this a bit further @say4n! When you are debugging, is the line where the crash is occurring at the bugfix? strawberryfields/strawberryfields/backends/fockbackend/circuit.py Lines 767 to 770 in 4de1d46
|
@josh146 happy to help! The crash occurs in these lines: strawberryfields/strawberryfields/backends/fockbackend/circuit.py Lines 682 to 689 in 4de1d46
Particulary, it crashes because of |
Hi folks, any updates on triaging the issue? |
Hi @say4n. Could you provide a minimal non-working example of your code? Specifically, I'd like to know which parameter values that you're using in the circuit, how many modes you are using (or does it fail no matter how many modes the circuit has?), the cutoff-value that you're passing to the Fock backend, and any other backend or run options that you might have. This could help me replicating the issue and solve it. |
Hi @thisac I haven't had the time to prepare a MWE for the code yet, but I found that replacing the line strawberryfields/strawberryfields/backends/fockbackend/circuit.py Lines 681 to 682 in 4de1d46
to the following seems to have solved my crash - dist = dist * ~np.isclose(dist, 0.0)
+ dist = np.abs(dist) Once, I have a little more time at hand I will craft the MWE to reproduce the crash and post it here. |
Thank you @say4n. I can see why that could solve the issue with tiny negative values, although I'm still a bit curious why your
That would be fantastic. Thank you! |
Hi folks, while working with a very simple quantum circuit with the fock backend, I came across an issue where the script crashes and this stacktrace shows up sporadically.
The quantum circuit that I am simulating is
Any pointers as to what might be the issue here?
Other relevant details
Platform: macOS Monetery 12.1
Python Version: 3.9.7
Strawberry Fields Version: 0.21.0
The text was updated successfully, but these errors were encountered: