1
$\begingroup$

I am trying to simulate quantum teleportation on ProjectQ using simulaqron (enabling me to use quantum internet for teleportation) however I am not sure if my approach is right. In the working paper of simulaqron its written that programming via another backend like ProjectQ is very much possible. However when I am testing quantum teleporation I am not getting any output

[Alice's code] followed by [Bob's code]

  from projectq.ops import All, CNOT, H, Measure, Rz, X, Z
    from projectq import MainEngine
    from projectq.meta import Dagger, Control
    from cqc.pythonLib import CQCConnection, qubit
    import simulaqron

def main():

    with CQCConnection("Alice") as Alice:
        eng = MainEngine()
        c1, c2 = create_bell_pair(eng)
        tel1 = eng.allocate_qubit()
        Alice.sendQubit((c1, "Bob"))
        H | tel1
        CNOT | (tel1, c2)
        H | tel1
        Measure | tel1
        Measure | c2
        to_print = "App {}: Measurement outcomes are: a={}, b={}".format(Alice.name, int(tel1), int(c2))
        print("|" + "-" * (len(to_print) + 2) + "|")
        print("| " + to_print + " |")
        print("|" + "-" * (len(to_print) + 2) + "|")

        # Send corrections to Bob
        Alice.sendClassical("Bob", int(tel1), int(c2))


def create_bell_pair(eng):
    b1 = eng.allocate_qubit()
    b2 = eng.allocate_qubit()

    H | b1
    CNOT | (b1, b2)

    return b1, b2

main()    

// new file for bob
from projectq.ops import All, CNOT, H, Measure, Rz, X, Z
from projectq import MainEngine
from projectq.meta import Dagger, Control
from cqc.pythonLib import CQCConnection, qubit
import simulaqron

#####################################################################################################
#
# main
#
def main():

        # Initialize the connection
        with CQCConnection("Bob") as Bob:

            # Make an EPR pair with Alice
            qB=Bob.recvQubit(c1, "Alice")

            # Receive info about corrections
            data=Bob.recvClassical()
            message=list(data)
            a=message[0]
            b=message[1]

            # Apply corrections
            if b==1:
                    X | qB
            if a==1:
                    Z | qB

            # Measure qubit
            Measure | qB
            to_print="App {}: Measurement outcome is:  {}".format(Bob.name,int(qB))
            print("|"+"-"*(len(to_print)+2)+"|")
            print("| "+to_print+" |")
            print("|"+"-"*(len(to_print)+2)+"|")

##################################################################################################
main()
$\endgroup$
2
$\begingroup$

Be sure you have executed the command "simulaqron set backend projectq" in your shell, in order to set the projectq backend.

Moreover, in your Bob's code there is a reference to c1 which is undefined, in:

qB=Bob.recvQubit(c1, "Alice")

$\endgroup$
  • $\begingroup$ Hi @Oldville ! Thank you so much for the help. I have already done that ( simulaqron set backend projectq ), yet I am not getting any output. Is the wrong syntax of recvQubit causing this? if so what is the right syntax? $\endgroup$ – invalidexplorer Jul 23 '19 at 5:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.