Decoding SpeedΒΆ

[1]:
# This cell is tagged `parameters` and will be override by `papermill`
decoder: str = "mwpm"
json_filename: str = "speed-rsc-mwpm.json"  # where to save the result, must be provided

rounds: int = 200
kwargs = dict(
    min_time = 60,
    min_shots = 50,
    min_init_time = 0.1,
    min_init_shots = 1,
)
max_per_round_time: float = 0.1  # if each round takes more than 100ms to decode, then do not run the next `d`, since it is not meaningful anymore
[2]:
%load_ext autoreload
%autoreload 2
[3]:
# import psutil
# psutil.Process().nice(0)# if on *ux
# psutil.Process().nice(psutil.IDLE_PRIORITY_CLASS)# if on win
[4]:
from qec_lego_bench.cli.decoding_speed import decoding_speed, DecodingSpeedResult
from qec_lego_bench.hpc.job_store import Job, JobStore
from qec_lego_bench.hpc.plotter.logical_error_rate_plotter import *
[5]:
def generate_d_vec(ratio: float = 1.18, max_d: int = 51) -> list[int]:
    d = 3
    d_vec = [d]
    while d <= max_d:
        int_d = 2 * round(d / 2) + 1
        if int_d != d_vec[-1]:
            d_vec.append(int_d)
        d *= ratio
    return d_vec
d_vec = generate_d_vec()
print("d_vec:", d_vec)
p_vec = [0.00001, 0.0001, 0.001, 0.003, 0.01]

def evaluation_function(d: int, p: float, rounds: int, verbose: bool = True) -> DecodingSpeedResult:
    if verbose:
        print(f"d: {d}, p: {p}")
    return decoding_speed(decoder=decoder, code=f"rsc(d={d},p={p})", **kwargs, no_print=not verbose)

jobs = [Job(d=d, p=p, rounds=rounds) for p in p_vec for d in d_vec[:1]]  # only add the smallest d and dynamically add others
# evaluation_function(min(d_vec), min(p_vec), rounds)
d_vec: [3, 5, 7, 9, 11, 13, 15, 17, 19, 23, 27, 31, 37, 43, 51]

Define the plot functionality

[6]:
from decoding_time_plotter import DecodingTimePlotter

plotter = DecodingTimePlotter(p_vec=p_vec, d_vec=d_vec, rounds=rounds, max_per_round_time=max_per_round_time)
../../../_images/notebooks_evaluation_speed_decoding_speed_mwpm_7_0.png
<Figure size 640x480 with 0 Axes>
[7]:
job_store = JobStore(evaluation_function, jobs, result_type=DecodingSpeedResult, filename=json_filename)
job_store.execute(loop_callback=plotter)
<Figure size 640x480 with 0 Axes>
[ ]: