this is a question so basic that I can’t even believe it.
Can you build a quantum circuit with a Fock state via the sf.ops.Fock() method? Even downloading demos from SF where it was used. Then I want to get the ket output vector (no measurements on a 2 mode program). It works fine if I do not use the Fock command, even if i manually implement it via Ket() method.
Hi, @zephir!
Thank you for your question.
I am not fully sure that I understand the application you are trying to build. However, there is a demo on Boson sampling and the permanent where they use the sf.ops.Fock() method to build a four mode interferometry. I ran their code just now and it works like a charm.
I want to add a comment by my colleague that Strawberry Fields was designed specifically to run experiments on our old Gaussian Boson Sampling devices. It’s not being actively developed at the moment. In addition, you might want to take a look at PennyLane and see if you can implement your application on it.
You can also provide more details on what you are trying to build and I can try to provide more context about PennyLane regarding your specific needs.
Hi there,
thanks for the quick response!
Well my question is, why when i use the Fock operation in my example, it doesn’t seem to have a ket state. It is kind of confusing me.In teh example you mentioned, it behaves the same - you get measurements and Fock amplitudes, but a ket state object that is None.
Ah! I understand your question now.
I think I can provide you with an answer, or at least an alternative to extract the information about the state when you use the Fock method.
Try using the density matrix instead results.state.dm(). I used it with your code and was able to get an output. I ran the following code.
import numpy as np
import strawberryfields as sf
from strawberryfields.ops import *
prog = sf.Program(2)
eng = sf.Engine("fock", backend_options={"cutoff_dim": 3})
with prog.context as q:
Fock(2) | q[1]
#sf.ops.Ket(np.array([0,0,0,0,0,0,0,0,2]))| (q[0], q[1])
BSgate(np.pi/4) | (q[0], q[1])
#MeasureFock() | q[0]
results = eng.run(prog)
print(results.state.dm())
I found a line in the documentation that made me think of considering density matrices instead: The prepared mode is traced out and replaced with the Fock state. As a result the state of the other subsystems may have to be described using a density matrix.
Was this of any help? Let me know if you have any questions.
Hey @daniela.murcillo !
Fantastic answer. In fact, I also read over it. Back in the days, when I used Coherent(), I observed that the system changed to dm-based description, should have remembered that one. Thx I hope I can bother you with other questions I probably will have in the future!