Skip to content

Commit 5d0d28c

Browse files
author
Bart van der Vecht
committed
add coinflipping example
1 parent b7ba2da commit 5d0d28c

File tree

72 files changed

+1003
-40
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1003
-40
lines changed

analysis/fidelity_constraint/bqc_nv_constraint.py

Lines changed: 365 additions & 33 deletions
Large diffs are not rendered by default.

analysis/fidelity_constraint/config_nv.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ link_cfg: &link_cfg
2727
fidelity: 1
2828
# prob_success: 5.e-5 # 1 / 20_000
2929
# prob_success: 2.e-4 # 1 / 5_000
30-
prob_success: 1
31-
# prob_success: 0.0005
30+
# prob_success: 1
31+
prob_success: 0.0005
3232
t_cycle: 5.e+3
3333

3434
links:
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import datetime
2+
import json
3+
import os
4+
from pathlib import Path
5+
6+
import matplotlib.pyplot as plt
7+
8+
COMPILE_VERSIONS = ["nqasm_retry", "host_retry"]
9+
FORMATS = {
10+
"nqasm_retry": "-ro",
11+
"host_retry": "-bs",
12+
}
13+
FORMATS_2 = {
14+
"nqasm_retry": "--ro",
15+
"host_retry": "--bo",
16+
}
17+
VERSION_LABELS = {
18+
"nqasm_retry": "NetQASM retry",
19+
"host_retry": "Host retry",
20+
}
21+
22+
X_LABELS = {
23+
"fidelity": "Fidelity",
24+
"rate": "Success probability per entanglement attempt",
25+
"t2": "T2 (ns)",
26+
"gate_noise": "2-qubit gate depolarising probability",
27+
"gate_noise_trap": "2-qubit gate depolarising probability",
28+
"gate_time": "2-qubit gate duration (ms)",
29+
"gate_time_trap": "2-qubit gate duration (ms)",
30+
"latency": "Host <-> QNodeOS latency (ms)",
31+
}
32+
33+
34+
def create_png(param_name):
35+
output_dir = os.path.join(os.path.dirname(__file__), "plots")
36+
Path(output_dir).mkdir(parents=True, exist_ok=True)
37+
timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
38+
output_path = os.path.join(output_dir, f"bqc_sweep_{param_name}_{timestamp}.png")
39+
plt.savefig(output_path)
40+
print(f"plot written to {output_path}")
41+
42+
43+
def plot_host_qnos_latency(data: Dict[float, SimulationOutput]):
44+
param_name = "host_qnos_latency"
45+
46+
data_path = os.path.join(
47+
os.path.dirname(__file__), f"sweep_data_bqc/sweep_{param_name}.json"
48+
)
49+
50+
with open(data_path, "r") as f:
51+
all_data = json.load(f)
52+
53+
fig, ax = plt.subplots()
54+
55+
ax.grid()
56+
ax.set_xlabel(X_LABELS[param_name])
57+
ax.set_ylabel("Error rate")
58+
59+
for version in COMPILE_VERSIONS:
60+
data = all_data[version]
61+
sweep_values = [v["sweep_value"] for v in data]
62+
error_rates = [v["error_rate"] for v in data]
63+
std_errs = [v["std_err"] for v in data]
64+
ax.errorbar(
65+
x=sweep_values,
66+
y=error_rates,
67+
yerr=std_errs,
68+
fmt=FORMATS[version],
69+
label=VERSION_LABELS[version],
70+
)
71+
72+
ax.set_title(
73+
"BQC trap round error rate vs two-qubit gate noise probability",
74+
wrap=True,
75+
)
76+
77+
# ax.set_ylim(0.10, 0.35)
78+
# ax.axhline(y=0.25, color="red", label="BQC threshold")
79+
ax.legend()
80+
# plt.tight_layout()
81+
82+
create_png(param_name)
83+
84+
85+
if __name__ == "__main__":
86+
plot_gate_noise_trap()
38.4 KB
40.7 KB
35.4 KB
28.4 KB
39.4 KB
27.6 KB
37.8 KB

0 commit comments

Comments
 (0)