Hello! I am trying to simulate a 4-mode Scattershot Boson Sampling (SBS) using lossy channels. This is similar to the code for the SBS tutorial in the Strawberry fields website.
The code that I am executing is below:
r_squeezing = 0.5 # squeezing parameter for the S2gate
cutoff = 7 # max number of photons computed per mode
# 4X4 Random Unitary Matrix
theta1 = 0.5
theta2 = 1
U = np.array([[np.cos(theta1), -np.sin(theta1), 0, 0 ],
[np.sin(theta1), np.cos(theta1), 0, 0 ],
[0, 0, np.cos(theta2), -np.sin(theta2)],
[0, 0, np.sin(theta2), np.cos(theta2)]])
# 4 mode Scattershot Boson Sampling
prog = sf.Program(8)
with prog.context as q:
S2gate(r_squeezing) | (q[0], q[4])
S2gate(r_squeezing) | (q[1], q[5])
S2gate(r_squeezing) | (q[2], q[6])
S2gate(r_squeezing) | (q[3], q[7])
# introducing loss in the channels
LossChannel(0.060) | q[4]
LossChannel(0.070) | q[5]
LossChannel(0.065) | q[6]
LossChannel(0.066) | q[7]
Interferometer(U) | (q[4], q[5], q[6], q[7])
# Initializing the engine
eng = sf.Engine("fock", backend_options={"cutoff_dim":cutoff})
# Executing the program with the engine
state = eng.run(prog).state
After executing the code, I am getting the following error:
MemoryError: Unable to allocate 484. TiB for an array with shape (7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7) and data type complex128
- My question is even if there is no enough memory in my computer for the simulation why the shape of the array is showing (7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7) instead of (7, 7, 7, 7, 7, 7, 7, 7), as there are 8 qumodes, instead of 16. Is my understanding incorrect here?
- Secondly, when I am executing the same code without the lossy channels with the same cutoff dimension, then the code is getting executed without any errors. Introducing losses should decrease the mean photon number and hence there shouldn’t be this memory allocation error. Right?
Thanks for the help in advance.