Bosonic Backend and GKP qubit

Hi, I am working with GKP qubit, I was wondering if we can use the bosonic backend also for 2-mode systems,
can I do something like this?
def create_gkp(state_name, epsilon_input, shots_input):
prog_gkp = sf.Program(2)

with prog_gkp.context as q:
    sf.ops.GKP(state = state_name, epsilon=epsilon_input) | q[0]
    sf.ops.GKP(state = state_name, epsilon=epsilon_input) | q[1]
    sf.ops.CZgate | (q[0],q[1])
    sf.ops.MeasureX | q

eng = sf.Engine("bosonic")
gkp_samples = eng.run(prog_gkp, shots=shots_input).samples[:, 0]

return gkp_samples

I tried, but I guess it will take a lot of time to simulate, Is there any other way to simulate this? if we are looking for Wigner function characteristics?

Hi @mohadeseh,

Welcome to the Forum!

I tried your code for some test data and it runs pretty fast. I had to change some details in the CZgate and MeasureX but it does run.

def create_gkp(state_name, epsilon_input, shots_input):
    prog_gkp = sf.Program(2)
    
    with prog_gkp.context as q:
        sf.ops.GKP(state = state_name, epsilon=epsilon_input) | q[0]
        sf.ops.GKP(state = state_name, epsilon=epsilon_input) | q[1]
        sf.ops.CZgate(1) | (q[0],q[1])
        sf.ops.MeasureX  | q[0]
        sf.ops.MeasureX  | q[1]

    eng = sf.Engine("bosonic")
    gkp_samples = eng.run(prog_gkp, shots=shots_input).samples[:, 0]

    return gkp_samples

create_gkp([0,0], 0.2, 1)

I’m not sure about the validity of the results but I would think you could check with your actual data and let us know if you’re getting the results you expected or something different.

Please let me know if this resolves your question!

Hello @CatalinaAlbornoz,
Thank you so much for the response, It helped a lot.
I just have another follow-up question about this, I was wondering if I can simulate 4 qubit GKP graph using bosonic backend. Something like this:

 def cnot_graph_gkp(state_name_0, state_name_1, state_name_2, state_name_3, epsilon_input):
prog_gkp = sf.Program(4)
with prog_gkp.context as q:
  # initialize the node
  sf.ops.GKP(state = state_name_0, epsilon=epsilon_input) | q[0]
  sf.ops.GKP(state = state_name_1, epsilon=epsilon_input) | q[1]
  sf.ops.GKP(state = state_name_2, epsilon=epsilon_input) | q[2]
  sf.ops.GKP(state = state_name_3, epsilon=epsilon_input) | q[3]
  # apply the CZ gate, create the graph
  sf.ops.CZgate(1) | (q[0],q[2]) 
  sf.ops.CZgate(1) | (q[1],q[2]) 
  sf.ops.CZgate(1) | (q[2],q[3]) 
  # computational measurement 
  sf.ops.MeasureP | q[0]
  sf.ops.MeasureP | q[2] 
  sf.ops.MeasureX | q[1] 
  sf.ops.MeasureX | q[3] 

eng = sf.Engine("bosonic")
gkp_samples = eng.run(prog_gkp, shots=1).samples

return gkp_samples

What epsilon should I use in order to run this in a reasonable time?
Can you help me with this? Thanks a lot.
Best,