55from typing import Any , Dict , Generator
66
77import netsquid as ns
8- from netqasm .sdk .connection import BaseNetQASMConnection
9- from netqasm .sdk .futures import RegFuture
10- from netqasm .sdk .qubit import Qubit
118
129from pydynaa import EventExpression
1310from squidasm .run .stack .config import StackNetworkConfig
@@ -56,25 +53,16 @@ def run(
5653 conn = context .connection
5754 epr_socket = context .epr_sockets [self .PEER ]
5855
59- outcomes = conn .new_array (length = 2 )
60-
61- def post_create (_ : BaseNetQASMConnection , q : Qubit , index : RegFuture ):
62- q .measure (future = outcomes .get_future_index (index ))
63-
64- epr_socket .create_keep (
65- number = 2 ,
66- min_fidelity_all_at_end = 70 ,
67- max_tries = 20 ,
68- sequential = True ,
69- post_routine = post_create ,
56+ eprs = epr_socket .create_keep (
57+ number = 2 , min_fidelity_all_at_end = 70 , max_tries = 20
7058 )
7159
72- yield from conn .flush ()
60+ m0 = eprs [0 ].measure ()
61+ m1 = eprs [1 ].measure ()
7362
74- m0 = int (outcomes .get_future_index (0 ))
75- m1 = int (outcomes .get_future_index (1 ))
63+ yield from conn .flush ()
7664
77- return {"m0" : m0 , "m1" : m1 }
65+ return {"m0" : int ( m0 ) , "m1" : int ( m1 ) }
7866
7967
8068class ServerProgram (Program ):
@@ -95,25 +83,14 @@ def run(
9583 conn = context .connection
9684 epr_socket = context .epr_sockets [self .PEER ]
9785
98- outcomes = conn . new_array ( length = 2 )
86+ eprs = epr_socket . recv_keep ( number = 2 , min_fidelity_all_at_end = 70 , max_tries = 20 )
9987
100- def post_recv (_ : BaseNetQASMConnection , q : Qubit , index : RegFuture ):
101- q .measure (future = outcomes .get_future_index (index ))
102-
103- epr_socket .recv_keep (
104- number = 2 ,
105- min_fidelity_all_at_end = 70 ,
106- max_tries = 20 ,
107- sequential = True ,
108- post_routine = post_recv ,
109- )
88+ m0 = eprs [0 ].measure ()
89+ m1 = eprs [1 ].measure ()
11090
11191 yield from conn .flush ()
11292
113- m0 = int (outcomes .get_future_index (0 ))
114- m1 = int (outcomes .get_future_index (1 ))
115-
116- return {"m0" : m0 , "m1" : m1 }
93+ return {"m0" : int (m0 ), "m1" : int (m1 )}
11794
11895
11996PI = math .pi
0 commit comments