-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanuscript_data.py
More file actions
166 lines (126 loc) · 4.07 KB
/
manuscript_data.py
File metadata and controls
166 lines (126 loc) · 4.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
"""
generate all data used in https://arxiv.org/abs/2603.03263
"""
import numpy as np
import os
from utils import Fock_cutoff_calc
from channel import channel_tensor_f1
from performance import (
channel_fidelity,
performance_scan,
mean_error_probability_scan_Hastrup,
target_channel_fidelity_scan,
composite_Pauli_maps,
)
from deformation import (
deformation_correction_scan,
deformation_correction_stats,
biased_probability,
)
"""
export flag
"""
export = True
def save_wrapper(fname, data, export):
if export:
directory = os.path.join(os.getcwd(), "data")
np.save(os.path.join(directory, fname + ".npy"), data)
"""
channel fidelity
"""
L_ = (1, 2, 3)
alpha_ = np.linspace(0.1, 7.5, 75)
Gamma_ = (0.206, 0.684)
N_ = (1, 10, 100)
tolerance = 15
channel_fidelities = np.zeros((len(L_), len(alpha_), len(Gamma_), len(N_)), dtype=float)
for l, L in enumerate(L_):
channel_fidelities[l] = performance_scan(channel_fidelity, L, alpha_, Gamma_, N_, tolerance)
save_wrapper("channel_fidelities", channel_fidelities, export)
"""
target channel fidelity
"""
fidelity_targets = (0.95, 0.99, 0.999)
Gamma = 0.206
alpha_bounds_ = (
((2.5, 3.2), (3.1, 4.0), (4.0, 4.5)),
((3.0, 4.0), (4.5, 5.5), (6.0, 7.0)),
((4.5, 6.0), (5.5, 6.5), (8.0, 8.5)),
)
alpha_step = 0.1
N_bounds_ = (
((35, 50), (490, 501), (10000, 10050)),
((10, 15), (60, 70), (400, 450)),
((9, 15), (30, 40), (120, 150)),
)
tolerance_targets = 20
special_type = [("fidelity", float), ("segments", int), ("amplitude", float)]
target_scan = np.zeros(
(
len(L_),
len(fidelity_targets),
),
dtype=special_type,
)
for l, L in enumerate(L_):
max_count = Fock_cutoff_calc(max(alpha_bounds_[l])[1], tolerance_targets)
channel_f1 = channel_tensor_f1(L, max_count)
X_map, Z_map = composite_Pauli_maps(L, 0.1, 1, max_count, 10)
for f, fidelity_target in enumerate(fidelity_targets):
sub_cutoff = Fock_cutoff_calc(max(alpha_bounds_[l][f]), tolerance_targets) + 1
f1 = channel_f1[:sub_cutoff, :sub_cutoff]
X = X_map[:sub_cutoff, :sub_cutoff]
Z = Z_map[:sub_cutoff, :sub_cutoff]
alpha_search = (*alpha_bounds_[l][f], alpha_step)
target_scan[l, f] = np.array(
target_channel_fidelity_scan(
fidelity_target, f1, (X, Z), alpha_search, Gamma, N_bounds_[l][f]
),
dtype=special_type,
)
save_wrapper("target_scan", target_scan, export)
"""
perfect deformation correction
"""
alpha_opt = (2.5, 3.7, 5.1)
alpha_points = 6
Gamma = 0.206
N = 10
total_transmissions = 1000
seed = 1
shape_tuple = (len(L_), alpha_points)
deformation_stats = np.zeros((*shape_tuple, 3), dtype=float)
total_failure = np.zeros(shape_tuple, dtype=int)
f_diff_mean_nofail = np.zeros(shape_tuple, dtype=float)
f_diff_opt = np.zeros(shape_tuple, dtype=float)
for l, L in enumerate(L_):
alpha_opt_frac = np.linspace(alpha_opt[l] / 2, alpha_opt[l], alpha_points)
total_failure[l], f_diff_mean_nofail[l], f_diff_opt[l] = deformation_correction_stats(
*deformation_correction_scan(
L, alpha_opt_frac, [Gamma], N, total_transmissions, tolerance, seed
)
)
deformation_stats[:, :, 0] = f_diff_mean_nofail
deformation_stats[:, :, 1] = f_diff_opt
deformation_stats[:, :, 2] = total_failure / (6 * total_transmissions)
save_wrapper("deformation_stats", deformation_stats, export)
"""
outcome probabilities with bias
"""
L = 1
alpha = 4
Gamma = 0
biases = [1, 1 / 2, 1 / 3, 1 / 4, 1 / 5]
precision = 2
biased_probabilities = biased_probability(L, alpha, Gamma, biases, precision, tolerance)
save_wrapper("biased_probabilities", biased_probabilities, export)
"""
mean error probability with extra loss segment
"""
L = 1
alpha_ = np.linspace(0.1, 5, 50)
Gamma_ = (0, 0.206, 0.684)
N_ = (0, 1, 10, 100, 1000)
mean_error_probabilities = np.zeros((len(alpha_), len(Gamma_), len(N_)), dtype=float)
mean_error_probabilities = mean_error_probability_scan_Hastrup(L, alpha_, Gamma_, N_, tolerance)
save_wrapper("mean_error_probabilities", mean_error_probabilities, export)