[Python] KLM protocol - NS_{-1} gate in strawberryfields

Discussão em 'Python' iniciado por Stack, Fevereiro 12, 2025.

  1. Stack

    Stack Membro Participativo

    I'm new to strawberryfields and I'm trying to implement the gate in Fig. 1 of KLM's 2001 paper.

    This is my code:

    import numpy as np
    import strawberryfields as sf
    from strawberryfields import ops
    from thewalrus.quantum import state_vector

    prog = sf.Program(3)

    phi_1 = prog.params('phi_1')
    theta_1 = prog.params('theta_1')
    phi_2 = prog.params('phi_2')
    theta_2 = prog.params('theta_2')
    phi_3 = prog.params('phi_3')
    theta_3 = prog.params('theta_3')
    phi_4 = prog.params('phi_4')

    with prog.context as q:
    ops.Fock(2) | q[0]
    ops.Fock(1) | q[1]
    ops.Fock(0) | q[2]

    ops.Pgate(phi_4) | q[0]
    ops.BSgate(theta_1,phi_1) | (q[1], q[2])
    ops.BSgate(theta_2,phi_2) | (q[0], q[1])
    ops.BSgate(theta_3,phi_3) | (q[1], q[2])

    ops.MeasureFock(select=1) | q[1]
    ops.MeasureFock(select=0) | q[2]


    eng = sf.Engine("fock", backend_options={"cutoff_dim": 10})

    result = eng.run(prog,modes=[0],args={
    'theta_1': 22.5 * np.pi/180.0,
    'theta_2': 65.5302 * np.pi/180.0,
    'theta_3': -22.5 * np.pi/180.0,
    'phi_1': 0.0,
    'phi_2': 0.0,
    'phi_3': 0.0,
    'phi_4': 180.0 * np.pi/180.0,
    })

    state = result.state
    print(state)
    print(state.data)
    print(result.samples)


    I have a few questions:


    1. How can I start mode 0 on a superposition of Fock states? (i.e., alpha_0 |0> + alpha_1 |1> + alpha_2 |2>)


    2. How can I then get the success probability? (i.e., the heralding pattern I specify with select in MeasureFock).


    3. How can I then verify I get a minus sign in front of |2>?

    Continue reading...

Compartilhe esta Página