Running a threshold simulation¶
-
qsurface.threshold.run_many(Code, Decoder, iterations=1, sizes=[], enabled_errors=[], error_rates=[], faulty_measurements=False, methods_to_benchmark={}, output='', mp_processes=1, recursion_limit=100000, **kwargs)¶ Runs a series of simulations of varying sizes and error rates.
A series of simulations are run without plotting for all combinations of
sizesanderror_rates. The results are returned as a Pandas DataFrame and saved to the working directory as a csv file. If an existing csv file with the same file name is found, the existing file is loaded and new results are appended to the existing data. Amain.BenchmarkDecoderobject is attached to each simulation to log the seed and other information.- Parameters
Code (
Union[module,str]) – Any surface code module or module name from codes.Decoder (
Union[module,str]) – Any decoder module or module name from decodersiterations (
int) – Number of iterations to run per configuration.sizes (
List[Union[int,Tuple[int,int]]]) – The sizes of the surface configurations.enabled_errors (
List[Union[str,Sim]]) – List of error modules fromerrors.error_rates (
List[Dict]) – List of dictionaries for error rates per configuration (seeerrors).faulty_measurements (
bool) – Enable faulty measurements (decode in a 3D lattice).methods_to_benchmark (
dict) – Decoder class methods to benchmark.output (
str) – File name of outputted csv data. If set to “none”, no file will be saved.mp_processses – Number of processes to spawn. For a single process,
runis used. For multiple processes,run_multiprocessis utilized.
Examples
A series of simulations using the
toricsurface code andmwpmdecoder can be easily setup. Benchmarking can be performed by supplying themethods_to_benchmarkargument of theBenchmarkDecoderclass. The function will initialize a benchmark object of each configuration and append all results as columns to the returned dataframe.>>> data = run_many( ... "toric", ... "mwpm", ... iterations = 1000, ... sizes = [8,12,16], ... enabled_errors = ["pauli"], ... error_rates = [{"p_bitflip: p} for p in [0.09, 0.1, 0.11]], ... ) >>> print(data) datetime decoded iterations no_error p_bitflip seed size 0 04/11/2020 14:45:36 1000.0 1000.0 820.0 0.09 13163.013981 8.0 1 04/11/2020 14:45:45 1000.0 1000.0 743.0 0.10 13172.277886 8.0 2 04/11/2020 14:45:54 1000.0 1000.0 673.0 0.11 13181.090130 8.0 3 04/11/2020 14:46:36 1000.0 1000.0 812.0 0.09 13190.191461 12.0 4 04/11/2020 14:47:18 1000.0 1000.0 768.0 0.10 13232.408302 12.0 5 04/11/2020 14:48:16 1000.0 1000.0 629.0 0.11 13274.044268 12.0 6 04/11/2020 14:51:47 1000.0 1000.0 855.0 0.09 13332.153639 16.0 7 04/11/2020 14:55:15 1000.0 1000.0 754.0 0.10 13542.533067 16.0 8 04/11/2020 14:59:14 1000.0 1000.0 621.0 0.11 13751.082511 16.0
- Return type
Optional[DataFrame]
-
qsurface.threshold.read_csv(file)¶ Reads a CSV file parses it as a Pandas DataFrame.
- Return type
DataFrame
-
class
qsurface.threshold.ThresholdFit(modified_ansatz=False, p=0.09, 0.1, 0.11, A=- inf, 0, inf, B=- inf, 0, inf, C=- inf, 0, inf, D=- 2, 1.6, 2, nu=0.8, 0.95, 1.2, mu=0, 0.7, 3)¶ Fitter for code threshold with data obtained by
~.threshold.run.Threshold fitting is performed using the equations described in [wang2003confinement]. The threshold is computing the ground state of the Hamiltonian that described the phase transition or the Nishimori line in the Random Bond Ising Model. The source provides two functions which are included in this fitting class, where the
modified_ansatzincludes a nonuniversion additive correction to correct for finite size effects.- wang2003confinement
Chenyang Wang, Jim Harrington and John Preskill, Confinement-Higgs transition in a disordered gauge theory and the accuracy threshold for quantum memory, Annals of Physics, 1:31-58, 2003.
-
fit_data(data, column, **kwargs)¶ Fits for the code threshold.
- Parameters
data (
DataFrame) – Data obtained viarun.column (
str) – The column of the DataFrame to fit for.kwargs – Keyword arguments are passed on the
scipy.curve_fit.
-
plot_data(data, column, figure=None, rescaled=False, scatter_kwargs={'s': 10}, line_kwargs={'alpha': 0.5, 'ls': 'dashed', 'lw': 1.5}, axis_attributes={'title': 'Threshold', 'xlabel': 'Physical error rate', 'ylabel': 'Logical error rate'}, num_x_fit=1000, **kwargs)¶ Plots the inputted data and the fit for the code threshold.
- Parameters
data (
DataFrame) – Data obtained viarun.column (
str) – The column of the DataFrame to fit for.figure (
Optional[Figure]) – If a figure is attached,showis not called. Instead, the figure is returned for futher manipulation.rescaled (
bool) – Plots the data on a rescaled x axis where the fit is a single line.scatter_kwargs (
dict) – Keyword arguments to pass on to thescatterfor the markers.line_kwargs (
dict) – Keyword arguments to pass on to the ~matplotlib.pyplot.plot for the line plot.axis_attributes (
dict) – Attributes to set of the axis viaaxis.set_{attribute}(value).num_x_fit (
int) – Numpy of points to plot for the fit.