Wigner Calculation unstable for the Fock backend

Hi all,

I am experimenting with strawberry field and I wanted to look at the effect of cutoff dimension on the representation of very squeezed states.8

I have a circuit to generate the squeezed state :

def fun_squeeze(n,p,cutoff_dim=50):
    prog = sf.Program(1)
    eng = sf.Engine("fock", backend_options={"cutoff_dim": cutoff_dim})
    with prog.context as q:
        Fock(n) | q[0]
        Sgate(p) | q[0]
    results = eng.run(prog)
    state = results.state
    return state

A function to plot the wigner function (copy pasted from strawberry field documentation):

def fun_wigner(state,qmode=0,lims = 5):
    fig = plt.figure()
    X = np.linspace(-lims, lims, 100)
    P = np.linspace(-lims, lims, 100)
    Z = state.wigner(qmode, X, P)
    return Z

And a script to look at how it evolves for different cut-off dimension :

ds = [10,20,50,100,200,500]
fig, axs = plt.subplots(1,len(ds),figsize=(3*len(ds),3*1), subplot_kw = {"projection":"3d"})
Zs = []
states = []
for k,ax in enumerate(axs.flat):
    state = fun_squeeze(0,2,cutoff_dim=ds[k])
    states.append(state)
    Zs.append(plot_wigner(state,ax=ax))

As can be seen for the 200 and 500 cutoff dimension the Wigner function starts to show instability (the data in the state is fine). Is that expected ? I could not find any maximum for the cutoff dimension or the Wigner function of the Fock backend in the documentation of strawberry fields.

I am using the Fock backend because I will need to use it for the next steps in my project.

Hi @alicewithoutbob! Charlie here.

Your state is very squeezed! It will have support on high-lying Fock states and will look almost like a delta function in the q quadrature. Can you try reducing the squeezing value or increasing the size of your limits?

I’m not aware of any instabilities of the Wigner function calculation but it well might be that for such a high cutoff (500 is a very high cutoff!) and small q and p limits it doesn’t capture very well your state.

The code used to calculate the Wigner function is here.