Skip to content

Commit

Permalink
add coinflipping example
Browse files Browse the repository at this point in the history
  • Loading branch information
Bart van der Vecht committed Mar 17, 2022
1 parent ac3c9b7 commit 0013812
Show file tree
Hide file tree
Showing 72 changed files with 1,003 additions and 40 deletions.
398 changes: 365 additions & 33 deletions analysis/fidelity_constraint/bqc_nv_constraint.py

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions analysis/fidelity_constraint/config_nv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ link_cfg: &link_cfg
fidelity: 1
# prob_success: 5.e-5 # 1 / 20_000
# prob_success: 2.e-4 # 1 / 5_000
prob_success: 1
# prob_success: 0.0005
# prob_success: 1
prob_success: 0.0005
t_cycle: 5.e+3

links:
Expand Down
86 changes: 86 additions & 0 deletions analysis/fidelity_constraint/plot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import datetime
import json
import os
from pathlib import Path

import matplotlib.pyplot as plt

COMPILE_VERSIONS = ["nqasm_retry", "host_retry"]
FORMATS = {
"nqasm_retry": "-ro",
"host_retry": "-bs",
}
FORMATS_2 = {
"nqasm_retry": "--ro",
"host_retry": "--bo",
}
VERSION_LABELS = {
"nqasm_retry": "NetQASM retry",
"host_retry": "Host retry",
}

X_LABELS = {
"fidelity": "Fidelity",
"rate": "Success probability per entanglement attempt",
"t2": "T2 (ns)",
"gate_noise": "2-qubit gate depolarising probability",
"gate_noise_trap": "2-qubit gate depolarising probability",
"gate_time": "2-qubit gate duration (ms)",
"gate_time_trap": "2-qubit gate duration (ms)",
"latency": "Host <-> QNodeOS latency (ms)",
}


def create_png(param_name):
output_dir = os.path.join(os.path.dirname(__file__), "plots")
Path(output_dir).mkdir(parents=True, exist_ok=True)
timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
output_path = os.path.join(output_dir, f"bqc_sweep_{param_name}_{timestamp}.png")
plt.savefig(output_path)
print(f"plot written to {output_path}")


def plot_host_qnos_latency(data: Dict[float, SimulationOutput]):
param_name = "host_qnos_latency"

data_path = os.path.join(
os.path.dirname(__file__), f"sweep_data_bqc/sweep_{param_name}.json"
)

with open(data_path, "r") as f:
all_data = json.load(f)

fig, ax = plt.subplots()

ax.grid()
ax.set_xlabel(X_LABELS[param_name])
ax.set_ylabel("Error rate")

for version in COMPILE_VERSIONS:
data = all_data[version]
sweep_values = [v["sweep_value"] for v in data]
error_rates = [v["error_rate"] for v in data]
std_errs = [v["std_err"] for v in data]
ax.errorbar(
x=sweep_values,
y=error_rates,
yerr=std_errs,
fmt=FORMATS[version],
label=VERSION_LABELS[version],
)

ax.set_title(
"BQC trap round error rate vs two-qubit gate noise probability",
wrap=True,
)

# ax.set_ylim(0.10, 0.35)
# ax.axhline(y=0.25, color="red", label="BQC threshold")
ax.legend()
# plt.tight_layout()

create_png(param_name)


if __name__ == "__main__":
plot_gate_noise_trap()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
{
"nqasm_retry": {
"1000000": {
"error_rate": 0.0,
"duration": {
"mean": 28479400.0,
"std_error": 0.0
},
"attempt_coutn": {
"mean": 1.0,
"std_error": 0.0
}
},
"2000000": {
"error_rate": 0.0,
"duration": {
"mean": 34224400.0,
"std_error": 0.0
},
"attempt_coutn": {
"mean": 1.0,
"std_error": 0.0
}
},
"3000000": {
"error_rate": 1.0,
"duration": {
"mean": 107224400.0,
"std_error": 0.0
},
"attempt_coutn": {
"mean": 2.0,
"std_error": 0.0
}
},
"4000000": {
"error_rate": 0.0,
"duration": {
"mean": 40204400.0,
"std_error": 0.0
},
"attempt_coutn": {
"mean": 1.0,
"std_error": 0.0
}
},
"5000000": {
"error_rate": 0.0,
"duration": {
"mean": 54094400.0,
"std_error": 0.0
},
"attempt_coutn": {
"mean": 1.0,
"std_error": 0.0
}
},
"6000000": {
"error_rate": 0.0,
"duration": {
"mean": 55014400.0,
"std_error": 0.0
},
"attempt_coutn": {
"mean": 1.0,
"std_error": 0.0
}
},
"7000000": {
"error_rate": 0.0,
"duration": {
"mean": 64864400.0,
"std_error": 0.0
},
"attempt_coutn": {
"mean": 1.0,
"std_error": 0.0
}
},
"8000000": {
"error_rate": 1.0,
"duration": {
"mean": 77409400.0,
"std_error": 0.0
},
"attempt_coutn": {
"mean": 1.0,
"std_error": 0.0
}
},
"9000000": {
"error_rate": 0.0,
"duration": {
"mean": 73459400.0,
"std_error": 0.0
},
"attempt_coutn": {
"mean": 1.0,
"std_error": 0.0
}
}
},
"host_retry": {
"1000000": {
"error_rate": 0.0,
"duration": {
"mean": 132144400.0,
"std_error": 0.0
},
"attempt_coutn": {
"mean": 5.0,
"std_error": 0.0
}
},
"2000000": {
"error_rate": 0.0,
"duration": {
"mean": 89354400.0,
"std_error": 0.0
},
"attempt_coutn": {
"mean": 4.0,
"std_error": 0.0
}
},
"3000000": {
"error_rate": 1.0,
"duration": {
"mean": 94609400.0,
"std_error": 0.0
},
"attempt_coutn": {
"mean": 3.0,
"std_error": 0.0
}
},
"4000000": {
"error_rate": 0.0,
"duration": {
"mean": 82724400.0,
"std_error": 0.0
},
"attempt_coutn": {
"mean": 3.0,
"std_error": 0.0
}
},
"5000000": {
"error_rate": 0.0,
"duration": {
"mean": 36844400.0,
"std_error": 0.0
},
"attempt_coutn": {
"mean": 1.0,
"std_error": 0.0
}
},
"6000000": {
"error_rate": 1.0,
"duration": {
"mean": 193999400.0,
"std_error": 0.0
},
"attempt_coutn": {
"mean": 5.0,
"std_error": 0.0
}
},
"7000000": {
"error_rate": 0.0,
"duration": {
"mean": 210154400.0,
"std_error": 0.0
},
"attempt_coutn": {
"mean": 5.0,
"std_error": 0.0
}
},
"8000000": {
"error_rate": 0.0,
"duration": {
"mean": 133564400.0,
"std_error": 0.0
},
"attempt_coutn": {
"mean": 3.0,
"std_error": 0.0
}
},
"9000000": {
"error_rate": 0.0,
"duration": {
"mean": 198339400.0,
"std_error": 0.0
},
"attempt_coutn": {
"mean": 5.0,
"std_error": 0.0
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"nqasm_retry": {"1000000": {"error_rate": 0.0, "duration": {"mean": 20989400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 1.0, "std_error": 0.0}}, "2000000": {"error_rate": 0.0, "duration": {"mean": 28919400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 1.0, "std_error": 0.0}}, "3000000": {"error_rate": 0.0, "duration": {"mean": 130279400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 2.0, "std_error": 0.0}}, "4000000": {"error_rate": 0.0, "duration": {"mean": 49984400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 1.0, "std_error": 0.0}}, "5000000": {"error_rate": 1.0, "duration": {"mean": 62069400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 1.0, "std_error": 0.0}}, "6000000": {"error_rate": 0.0, "duration": {"mean": 64379400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 1.0, "std_error": 0.0}}, "7000000": {"error_rate": 0.0, "duration": {"mean": 68004400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 1.0, "std_error": 0.0}}, "8000000": {"error_rate": 0.0, "duration": {"mean": 63664400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 1.0, "std_error": 0.0}}, "9000000": {"error_rate": 0.0, "duration": {"mean": 76419400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 1.0, "std_error": 0.0}}}, "host_retry": {"1000000": {"error_rate": 0.0, "duration": {"mean": 100754400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 4.0, "std_error": 0.0}}, "2000000": {"error_rate": 0.0, "duration": {"mean": 174909400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 8.0, "std_error": 0.0}}, "3000000": {"error_rate": 0.0, "duration": {"mean": 119849400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 6.0, "std_error": 0.0}}, "4000000": {"error_rate": 0.0, "duration": {"mean": 36559400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 1.0, "std_error": 0.0}}, "5000000": {"error_rate": 0.0, "duration": {"mean": 81889400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 2.0, "std_error": 0.0}}, "6000000": {"error_rate": 0.0, "duration": {"mean": 187354400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 4.0, "std_error": 0.0}}, "7000000": {"error_rate": 0.0, "duration": {"mean": 329184400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 9.0, "std_error": 0.0}}, "8000000": {"error_rate": 0.0, "duration": {"mean": 58249400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 1.0, "std_error": 0.0}}, "9000000": {"error_rate": 1.0, "duration": {"mean": 62199400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 1.0, "std_error": 0.0}}}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"nqasm_retry": {"1000000": {"error_rate": 1.0, "duration": {"mean": 17829400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 1.0, "std_error": 0.0}}, "2000000": {"error_rate": 1.0, "duration": {"mean": 30239400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 1.0, "std_error": 0.0}}, "3000000": {"error_rate": 1.0, "duration": {"mean": 33969400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 1.0, "std_error": 0.0}}, "4000000": {"error_rate": 1.0, "duration": {"mean": 35859400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 1.0, "std_error": 0.0}}, "5000000": {"error_rate": 0.0, "duration": {"mean": 53734400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 1.0, "std_error": 0.0}}, "6000000": {"error_rate": 0.0, "duration": {"mean": 44344400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 1.0, "std_error": 0.0}}, "7000000": {"error_rate": 0.0, "duration": {"mean": 50769400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 1.0, "std_error": 0.0}}, "8000000": {"error_rate": 0.0, "duration": {"mean": 62449400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 1.0, "std_error": 0.0}}, "9000000": {"error_rate": 0.0, "duration": {"mean": 85859400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 1.0, "std_error": 0.0}}}, "host_retry": {"1000000": {"error_rate": 0.0, "duration": {"mean": 171189400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 6.0, "std_error": 0.0}}, "2000000": {"error_rate": 0.0, "duration": {"mean": 61444400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 2.0, "std_error": 0.0}}, "3000000": {"error_rate": 0.0, "duration": {"mean": 30694400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 1.0, "std_error": 0.0}}, "4000000": {"error_rate": 0.0, "duration": {"mean": 204884400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 6.0, "std_error": 0.0}}, "5000000": {"error_rate": 0.0, "duration": {"mean": 208064400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 6.0, "std_error": 0.0}}, "6000000": {"error_rate": 0.0, "duration": {"mean": 241539400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 7.0, "std_error": 0.0}}, "7000000": {"error_rate": 0.0, "duration": {"mean": 89484400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 2.0, "std_error": 0.0}}, "8000000": {"error_rate": 0.0, "duration": {"mean": 373339400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 8.0, "std_error": 0.0}}, "9000000": {"error_rate": 0.0, "duration": {"mean": 64884400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 1.0, "std_error": 0.0}}}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"nqasm_retry": {"1000000": {"error_rate": 0.0, "duration": {"mean": 38369400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 1.0, "std_error": 0.0}}, "2000000": {"error_rate": 1.0, "duration": {"mean": 28099400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 1.0, "std_error": 0.0}}, "3000000": {"error_rate": 0.0, "duration": {"mean": 39894400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 1.0, "std_error": 0.0}}, "4000000": {"error_rate": 0.0, "duration": {"mean": 57109400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 1.0, "std_error": 0.0}}, "5000000": {"error_rate": 0.0, "duration": {"mean": 167029400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 4.0, "std_error": 0.0}}, "6000000": {"error_rate": 0.0, "duration": {"mean": 53999400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 1.0, "std_error": 0.0}}, "7000000": {"error_rate": 0.0, "duration": {"mean": 64739400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 1.0, "std_error": 0.0}}, "8000000": {"error_rate": 0.0, "duration": {"mean": 69259400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 1.0, "std_error": 0.0}}, "9000000": {"error_rate": 0.0, "duration": {"mean": 77569400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 1.0, "std_error": 0.0}}}, "host_retry": {"1000000": {"error_rate": 1.0, "duration": {"mean": 139324400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 6.0, "std_error": 0.0}}, "2000000": {"error_rate": 1.0, "duration": {"mean": 27089400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 1.0, "std_error": 0.0}}, "3000000": {"error_rate": 0.0, "duration": {"mean": 216279400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 7.0, "std_error": 0.0}}, "4000000": {"error_rate": 0.0, "duration": {"mean": 130194400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 4.0, "std_error": 0.0}}, "5000000": {"error_rate": 0.0, "duration": {"mean": 193914400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 6.0, "std_error": 0.0}}, "6000000": {"error_rate": 0.0, "duration": {"mean": 252809400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 4.0, "std_error": 0.0}}, "7000000": {"error_rate": 0.0, "duration": {"mean": 116249400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 3.0, "std_error": 0.0}}, "8000000": {"error_rate": 1.0, "duration": {"mean": 98159400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 2.0, "std_error": 0.0}}, "9000000": {"error_rate": 0.0, "duration": {"mean": 67329400.0, "std_error": 0.0}, "attempt_coutn": {"mean": 1.0, "std_error": 0.0}}}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"nqasm_retry": {"1000000": {"error_rate": 0.16, "duration": {"mean": 39625200.0, "std_error": 5754911.673900826}, "attempt_coutn": {"mean": 1.36, "std_error": 0.1483778959279312}}, "2000000": {"error_rate": 0.12, "duration": {"mean": 53429600.0, "std_error": 5417459.932329911}, "attempt_coutn": {"mean": 1.48, "std_error": 0.12800000000000003}}, "3000000": {"error_rate": 0.2, "duration": {"mean": 47996200.0, "std_error": 4802116.3741000695}, "attempt_coutn": {"mean": 1.28, "std_error": 0.1061319932913728}}, "4000000": {"error_rate": 0.12, "duration": {"mean": 46876600.0, "std_error": 2417891.5621673362}, "attempt_coutn": {"mean": 1.12, "std_error": 0.06499230723708768}}, "5000000": {"error_rate": 0.16, "duration": {"mean": 66444000.0, "std_error": 6646353.309417127}, "attempt_coutn": {"mean": 1.32, "std_error": 0.12289833196589772}}, "6000000": {"error_rate": 0.2, "duration": {"mean": 64191600.0, "std_error": 2981201.9465980497}, "attempt_coutn": {"mean": 1.24, "std_error": 0.08541662601625047}}, "7000000": {"error_rate": 0.12, "duration": {"mean": 83242600.0, "std_error": 5583048.614368319}, "attempt_coutn": {"mean": 1.56, "std_error": 0.1505191017778142}}, "8000000": {"error_rate": 0.2, "duration": {"mean": 75013600.0, "std_error": 2903890.8613100457}, "attempt_coutn": {"mean": 1.2, "std_error": 0.08000000000000002}}, "9000000": {"error_rate": 0.16, "duration": {"mean": 83480600.0, "std_error": 3204245.674476288}, "attempt_coutn": {"mean": 1.16, "std_error": 0.07332121111929343}}}, "host_retry": {"1000000": {"error_rate": 0.12, "duration": {"mean": 93727600.0, "std_error": 12550372.918379758}, "attempt_coutn": {"mean": 3.92, "std_error": 0.4696211238860535}}, "2000000": {"error_rate": 0.2, "duration": {"mean": 99167800.0, "std_error": 15195224.01472252}, "attempt_coutn": {"mean": 3.72, "std_error": 0.5292107330733192}}, "3000000": {"error_rate": 0.08, "duration": {"mean": 124151000.0, "std_error": 20113731.08246205}, "attempt_coutn": {"mean": 3.92, "std_error": 0.5984513346964815}}, "4000000": {"error_rate": 0.2, "duration": {"mean": 125098000.0, "std_error": 21184741.812011775}, "attempt_coutn": {"mean": 3.56, "std_error": 0.6198838600899365}}, "5000000": {"error_rate": 0.2, "duration": {"mean": 134437000.0, "std_error": 20431521.16925218}, "attempt_coutn": {"mean": 3.84, "std_error": 0.6515949662175116}}, "6000000": {"error_rate": 0.28, "duration": {"mean": 157691000.0, "std_error": 19887369.812461376}, "attempt_coutn": {"mean": 3.8, "std_error": 0.4931531202375181}}, "7000000": {"error_rate": 0.32, "duration": {"mean": 201669600.0, "std_error": 32222393.786284707}, "attempt_coutn": {"mean": 4.84, "std_error": 0.8441421681209865}}, "8000000": {"error_rate": 0.04, "duration": {"mean": 271210000.0, "std_error": 48787847.42398049}, "attempt_coutn": {"mean": 5.8, "std_error": 1.0998181667894016}}, "9000000": {"error_rate": 0.28, "duration": {"mean": 168885800.0, "std_error": 23626786.841244407}, "attempt_coutn": {"mean": 3.28, "std_error": 0.5107484703843957}}}}
Loading

0 comments on commit 0013812

Please sign in to comment.