@@ -12,7 +12,7 @@ def get_channel_error_from_link_werner_noise(fidelity, dist_in_km) -> float:
1212 """
1313 left : float = 0.0
1414 right : float = 0.3
15- l : float = 0.04500741397
15+ l : float = 0.04500741397 # this is the fixed loss probability per kilometer (coming from ~0.2 dB/km)
1616 iter_count = 0
1717 while left < right :
1818 p = (left + right ) / 2
@@ -26,23 +26,24 @@ def get_channel_error_from_link_werner_noise(fidelity, dist_in_km) -> float:
2626 [p , 1 - 3 * p - l , p , p , l ],
2727 [p , p , 1 - 3 * p - l , p , l ],
2828 [p , p , p , 1 - 3 * p - l , l ],
29- [0 , 0 , 0 , 0 , 1 ]
29+ [0 , 0 , 0 , 0 , 1 ],
3030 ]
3131 )
3232 Qt = Q ** dist_in_km
33- calculated_f = ( Qt [0 , 0 ] / (Qt [0 , 0 ] + Qt [0 , 1 ] + Qt [0 , 2 ] + Qt [0 , 3 ]) )
33+ calculated_f = Qt [0 , 0 ] / (Qt [0 , 0 ] + Qt [0 , 1 ] + Qt [0 , 2 ] + Qt [0 , 3 ])
3434 if calculated_f > fidelity :
3535 left = p
3636 else :
3737 right = p
3838 if round (calculated_f , 10 ) == round (fidelity , 10 ):
3939 break
40- print (f"we got p = { p } " )
41- print (f" expected: { fidelity } " )
42- print (f" obtained: { calculated_f } " )
40+ print (f"we got p (fiber error) = { p } " )
41+ print (f" expected fidelity (input) : { fidelity } " )
42+ print (f" obtained from calculation : { calculated_f } " )
4343 print (f" { Qt } " )
4444 return p
4545
46+
4647def get_fidelity_from_target_bsm_swap (f ):
4748 left : float = 0.0
4849 right : float = 1
@@ -53,7 +54,7 @@ def get_fidelity_from_target_bsm_swap(f):
5354 if iter_count > 100 :
5455 print ("exceed max iteration" )
5556 break
56- fn = p ** 2 + 3 * ((1 - p )/ 3 ) ** 2
57+ fn = p ** 2 + 3 * ((1 - p ) / 3 ) ** 2
5758 if fn > f :
5859 right = p
5960 else :
@@ -70,7 +71,9 @@ def bds_werner_swap(fa, fb):
7071 f = fa * fb + 3 * (1 - fa ) * (1 - fb )
7172 return f
7273
74+
7375def get_p_from_decoherence_time (decoherence_time_mu_s : int ) -> float :
76+ # Although QuISP allows for relaxation/excitation noise, we do not include it here.
7477 left : float = 0.0
7578 right : float = 0.3
7679 iter_count = 0
@@ -80,30 +83,41 @@ def get_p_from_decoherence_time(decoherence_time_mu_s: int) -> float:
8083 if iter_count > 100 :
8184 print ("exceed max iteration" )
8285 break
83- Q = np .matrix ([[1 - 3 * p , p , p , p ], [p , 1 - 3 * p , p , p ], [p , p , 1 - 3 * p , p ], [p , p , p , 1 - 3 * p ]])
86+ Q = np .matrix (
87+ [
88+ [1 - 3 * p , p , p , p ],
89+ [p , 1 - 3 * p , p , p ],
90+ [p , p , 1 - 3 * p , p ],
91+ [p , p , p , 1 - 3 * p ],
92+ ]
93+ )
8494 Qt = Q ** decoherence_time_mu_s
8595 if Qt [0 , 0 ] > 1 / np .e :
8696 left = p
8797 else :
8898 right = p
8999 if round (Qt [0 , 0 ], 10 ) == round (1 / np .e , 10 ):
90100 break
91- print (f"we got p = { p } " )
92- print (f" expected: { 1 / np .e } " )
93- print (f" obtained: { Qt [0 , 0 ]} " )
101+ print (f"we got p (memory) = { p } " )
102+ print (f" expected (fidelity has decohere) : { 1 / np .e } " )
103+ print (f" obtained after T time has passed : { Qt [0 , 0 ]} " )
94104 return p
95105
96- def get_error_param_balanced_mim_werner (link_fidelity , half_distance , coherence_time_mu_s ):
106+
107+ def get_error_param_balanced_mim_werner (
108+ link_fidelity , half_distance , coherence_time_mu_s
109+ ):
97110 p_mem_per_mu_s = get_p_from_decoherence_time (coherence_time_mu_s )
98111 mem_transition_mat = q = np .matrix (
99112 [
100113 [1 - 3 * p_mem_per_mu_s , p_mem_per_mu_s , p_mem_per_mu_s , p_mem_per_mu_s ],
101114 [p_mem_per_mu_s , 1 - 3 * p_mem_per_mu_s , p_mem_per_mu_s , p_mem_per_mu_s ],
102115 [p_mem_per_mu_s , p_mem_per_mu_s , 1 - 3 * p_mem_per_mu_s , p_mem_per_mu_s ],
103116 [p_mem_per_mu_s , p_mem_per_mu_s , p_mem_per_mu_s , 1 - 3 * p_mem_per_mu_s ],
104- ])
105- total_q = mem_transition_mat ** half_distance
106- gen_time = half_distance * 2 / 208189.206944 * 1_000_000 # to mu s
117+ ]
118+ )
119+ total_q = mem_transition_mat ** half_distance
120+ gen_time = half_distance * 2 / 208189.206944 * 1_000_000 # to mu s
107121
108122 left : float = 0.0
109123 right : float = 0.3
@@ -115,8 +129,15 @@ def get_error_param_balanced_mim_werner(link_fidelity, half_distance, coherence_
115129 print ("exceed max iteration" )
116130 break
117131 # channel transition matrix
118- Q = np .matrix ([[1 - 3 * p , p , p , p ], [p , 1 - 3 * p , p , p ], [p , p , 1 - 3 * p , p ], [p , p , p , 1 - 3 * p ]])
119- Qt = Q ** half_distance
132+ Q = np .matrix (
133+ [
134+ [1 - 3 * p , p , p , p ],
135+ [p , 1 - 3 * p , p , p ],
136+ [p , p , 1 - 3 * p , p ],
137+ [p , p , p , 1 - 3 * p ],
138+ ]
139+ )
140+ Qt = Q ** half_distance
120141 f = Qt [0 , 0 ]
121142 f = bds_werner_swap (f , f )
122143
@@ -142,7 +163,16 @@ def get_error_param_balanced_mim_werner(link_fidelity, half_distance, coherence_
142163- output: fidelity of purified Bell pair following a successful purification, total time to obtain 500 purified Bell pairs
143164- memory decoherence: 18ms, 55ms (Table 1 in QuNAP paper)
144165"""
145- def generate_purification_experiment_config (num_bellpairs : int , cnot_error_prob : float , measurement_error_prob : float , with_depolarizing : bool , coherence_time_in_mu_s : int ):
166+
167+
168+ def generate_purification_experiment_config (
169+ num_bellpairs : int ,
170+ cnot_error_prob : float ,
171+ measurement_error_prob : float ,
172+ with_depolarizing : bool ,
173+ coherence_time_in_mu_s : int ,
174+ ):
175+ """This function generates simulation config for experiment 4 in the paper with no memory decoherence."""
146176 # [Config mim_purification_20_20]
147177 # network = networks.cross_validation_mim_purification_20_20
148178 # **.qrsa.hm.link_tomography = true
@@ -197,12 +227,20 @@ def generate_purification_experiment_config(num_bellpairs: int, cnot_error_prob:
197227 "*.alice.is_initiator = true" ,
198228 "**.buffers = 2" ,
199229 f"**.app.number_of_bellpair = { num_bellpairs } " ,
200- f"**.qrsa.hm.num_measure = { num_bellpairs } "
230+ f"**.qrsa.hm.num_measure = { num_bellpairs } " ,
201231 ]
202232 return [config_name , network_name , * error_params , * other_params ]
203233
204234
205- def generate_purification_experiment_config_with_initial_fidelity (num_bellpairs : int , cnot_error_prob : float , measurement_error_prob : float , initial_fidelity : float , with_depolarizing : bool , coherence_time_in_mu_s : int ):
235+ def generate_purification_experiment_config_with_initial_fidelity (
236+ num_bellpairs : int ,
237+ cnot_error_prob : float ,
238+ measurement_error_prob : float ,
239+ initial_fidelity : float ,
240+ with_depolarizing : bool ,
241+ coherence_time_in_mu_s : int ,
242+ ):
243+ """This function generates simulation config for experiment 4 in the paper with no memory decoherence."""
206244 # [Config mim_purification_20_20]
207245 # network = networks.cross_validation_mim_purification_20_20
208246 # **.qrsa.hm.link_tomography = true
@@ -211,7 +249,9 @@ def generate_purification_experiment_config_with_initial_fidelity(num_bellpairs:
211249 # **.buffers = 1
212250
213251 # TODO: make this changeable
214- channel_error_single_prob = get_channel_error_from_link_werner_noise (get_fidelity_from_target_bsm_swap (initial_fidelity ), 20 )
252+ channel_error_single_prob = get_channel_error_from_link_werner_noise (
253+ get_fidelity_from_target_bsm_swap (initial_fidelity ), 20
254+ )
215255
216256 # round error probability to 3 decimal places
217257 cnot_error_prob = round (cnot_error_prob , 3 )
@@ -227,7 +267,6 @@ def generate_purification_experiment_config_with_initial_fidelity(num_bellpairs:
227267 if len (measurement_error_prob_str ) == 0 :
228268 measurement_error_prob_str = "0"
229269
230-
231270 if with_depolarizing :
232271 if num_bellpairs != 100_000 :
233272 config_name = f"[Config short_{ num_bellpairs } _purification_validation_cnot_{ cnot_error_prob_str } _meas_{ measurement_error_prob_str } _with_decoherence_{ coherence_time_in_mu_s } _ms_initial_fidelity_{ initial_fid_str } ]"
@@ -266,7 +305,7 @@ def generate_purification_experiment_config_with_initial_fidelity(num_bellpairs:
266305 "*.alice.is_initiator = true" ,
267306 "**.buffers = 2" ,
268307 f"**.app.number_of_bellpair = { num_bellpairs } " ,
269- f"**.qrsa.hm.num_measure = { num_bellpairs } "
308+ f"**.qrsa.hm.num_measure = { num_bellpairs } " ,
270309 ]
271310 return [config_name , network_name , * error_params , * other_params ]
272311
@@ -287,32 +326,52 @@ def write_config(filename: str, configs: list[list[str]]):
287326 the_file .write ("\n \n \n " )
288327
289328
290- memory_coherence_time_params = [18 * 1000 , 55 * 1000 ] # in milliseconds
329+ memory_coherence_time_params = [18 * 1000 , 55 * 1000 ] # in milliseconds
291330link_fidelities = list (np .linspace (0.6 , 1 , 21 ))
292331
293332config_no_error = generate_purification_experiment_config (100_000 , 0 , 0 , False , 0 )
294- config_no_error_short_time = generate_purification_experiment_config (500 , 0 , 0 , False , 0 )
333+ config_no_error_short_time = generate_purification_experiment_config (
334+ 500 , 0 , 0 , False , 0
335+ )
295336# config_only_depolarizing_error = [generate_purification_experiment_config(100_000, 0, 0, True, dp) for dp in memory_coherence_time_params]
296- config_purification_initial_fidelity_no_error = [generate_purification_experiment_config_with_initial_fidelity (100_000 , 0 , 0 , fid , False , 0 ) for fid in link_fidelities ]
297- config_purification_initial_fidelity_no_error_short_time = [generate_purification_experiment_config_with_initial_fidelity (500 , 0 , 0 , fid , False , 0 ) for fid in link_fidelities ]
298-
299- config_purification_initial_fidelity_18ms = [generate_purification_experiment_config_with_initial_fidelity (100_000 , 0 , 0 , fid , True , 18_000 ) for fid in link_fidelities ]
300- config_purification_initial_fidelity_55ms = [generate_purification_experiment_config_with_initial_fidelity (100_000 , 0 , 0 , fid , True , 55_000 ) for fid in link_fidelities ]
301-
302- config_purification_initial_fidelity_18ms_short = [generate_purification_experiment_config_with_initial_fidelity (500 , 0 , 0 , fid , True , 18_000 ) for fid in link_fidelities ]
303- config_purification_initial_fidelity_55ms_short = [generate_purification_experiment_config_with_initial_fidelity (500 , 0 , 0 , fid , True , 55_000 ) for fid in link_fidelities ]
304-
305-
306- # purification_config_no_operation_error = [generate_purification_experiment_config(gp, 0, False, coherence_time) for gp in np.arange(0, 1.00, 0.025)]
307-
308- # purification_config_gate_error = [generate_purification_experiment_config(gp, 0, False, coherence_time) for gp in np.arange(0, 1.00, 0.025)]
309- # purification_config_gate_error_with_depo = [generate_purification_experiment_config(gp, 0, True, coherence_time) for gp in np.arange(0, 1.00, 0.025)]
310- # purification_config_meas_error = [generate_purification_experiment_config(0, gp, False, coherence_time) for gp in np.arange(0, 1.00, 0.025)]
311- # purification_config_meas_error_with_depo = [generate_purification_experiment_config(0, gp, True, coherence_time) for gp in np.arange(0, 1.00, 0.025)]
312-
313- # delete the duplicate config in the lists, "purification_validation_cnot_0_meas_0_"
314- # purification_config_gate_error = purification_config_gate_error[1:]
315- # purification_config_gate_error_with_depo = purification_config_gate_error_with_depo[1:]
337+ config_purification_initial_fidelity_no_error = [
338+ generate_purification_experiment_config_with_initial_fidelity (
339+ 100_000 , 0 , 0 , fid , False , 0
340+ )
341+ for fid in link_fidelities
342+ ]
343+ config_purification_initial_fidelity_no_error_short_time = [
344+ generate_purification_experiment_config_with_initial_fidelity (
345+ 500 , 0 , 0 , fid , False , 0
346+ )
347+ for fid in link_fidelities
348+ ]
349+
350+ config_purification_initial_fidelity_18ms = [
351+ generate_purification_experiment_config_with_initial_fidelity (
352+ 100_000 , 0 , 0 , fid , True , 18_000
353+ )
354+ for fid in link_fidelities
355+ ]
356+ config_purification_initial_fidelity_55ms = [
357+ generate_purification_experiment_config_with_initial_fidelity (
358+ 100_000 , 0 , 0 , fid , True , 55_000
359+ )
360+ for fid in link_fidelities
361+ ]
362+
363+ config_purification_initial_fidelity_18ms_short = [
364+ generate_purification_experiment_config_with_initial_fidelity (
365+ 500 , 0 , 0 , fid , True , 18_000
366+ )
367+ for fid in link_fidelities
368+ ]
369+ config_purification_initial_fidelity_55ms_short = [
370+ generate_purification_experiment_config_with_initial_fidelity (
371+ 500 , 0 , 0 , fid , True , 55_000
372+ )
373+ for fid in link_fidelities
374+ ]
316375
317376write_config (
318377 "cross_validation_config_generated.ini" ,
@@ -334,15 +393,3 @@ def write_config(filename: str, configs: list[list[str]]):
334393 # *purification_config_meas_error_with_depo,
335394 ],
336395)
337-
338- # for tf in np.linspace(0.6, 1, 21):
339- # print('========================')
340- # print(f'target fidelity = {tf}')
341- # print(get_fidelity_from_target_bsm_swap(tf))
342- # print('========================\n\n')
343-
344- # for tf in np.linspace(0.76, 1, 21):
345- # print('========================')
346- # print(f'target fidelity = {tf}')
347- # print(get_channel_error_from_link_werner_noise(tf, 20))
348- # print('========================\n\n')
0 commit comments