start_simulation_using_sinter#
- tqec.simulation.start_simulation_using_sinter(block_graph, ks, ps, noise_model_factory, manhattan_radius, convention=Convention(name='fixed_bulk', triplet=ConventionTriplet(cube_builder=<tqec.compile.specs.library.fixed_bulk.FixedBulkCubeBuilder object>, pipe_builder=<tqec.compile.specs.library.fixed_bulk.FixedBulkPipeBuilder object>, observable_builder=ObservableBuilder(cube_top_readouts_builder=<function _get_top_readout_cube_qubits>, spatial_cube_top_readouts_builder=<function _get_top_readout_spatial_cube_qubits>, pipe_top_readouts_builder=<function _get_top_readout_pipe_qubits>, cube_bottom_stabilizers_builder=<function _get_bottom_stabilizer_cube_qubits>, spatial_cube_bottom_stabilizers_builder=<function _get_bottom_stabilizer_spatial_cube_qubits>, temporal_hadamard_includes_builder=<function _get_temporal_hadamard_includes_qubits>))), observables=None, detector_database=None, num_workers=4, progress_callback=None, max_shots=None, max_errors=None, decoders=('pymatching', ), print_progress=False, custom_decoders=None, save_resume_filepath=None, existing_data_filepaths=(), split_observable_stats=True)[source]#
Helper to run stim simulations using sinter.
This function is the preferred entry-point to run sinter computations using stim from circuits generated by tqec.
It removes the need to generate the stim.Circuit instances in parallel (due to the relative inefficiency of detector annotation at the moment) by importing and calling
generate_sinter_tasks()
. It also forwards several parameters tosinter.collect()
, but without showing in its signature arguments that we do not envision using.- Parameters:
block_graph (BlockGraph) – a representation of the QEC computation to simulate.
ks (Sequence[int]) – values of the scaling parameter k to use in order to generate the circuits.
ps (Sequence[float]) – values of the noise parameter p to use to instantiate a noise model using the provided noise_model_factory.
noise_model_factory (Callable[[float], NoiseModel]) – a callable that is used to instantiate a noise model from each of the noise parameters in ps.
manhattan_radius (int) – radius used to automatically compute detectors. The best value to set this argument to is the minimum integer such that flows generated from any given reset/measurement, from any plaquette at any spatial/temporal place in the QEC computation, do not propagate outside of the qubits used by plaquettes spatially located at maximum manhattan_radius plaquettes from the plaquette the reset/measurement belongs to (w.r.t. the Manhattan distance). Default to 2, which is sufficient for regular surface code. If negative, detectors are not computed automatically and are not added to the generated circuits.
convention (Convention) – convention used to generate the quantum circuits.
observables (list[CorrelationSurface] | None) – a list of correlation surfaces to compile to logical observables and generate statistics for. If None, all the correlation surfaces of the provided computation are used.
detector_database (DetectorDatabase | None) – an instance to retrieve from / store in detectors that are computed as part of the circuit generation.
num_workers (int) – The number of worker processes to use.
progress_callback (Callable[[Progress], None] | None) – Defaults to None (unused). If specified, then each time new sample statistics are acquired from a worker this method will be invoked with the new sinter.TaskStats.
max_shots (int | None) – Defaults to None (unused). Stops the sampling process after this many samples have been taken from the circuit.
max_errors (int | None) – Defaults to None (unused). Stops the sampling process after this many errors have been seen in samples taken from the circuit. The actual number sampled errors may be larger due to batching.
decoders (Iterable[str]) – Defaults to None (specified by each Task). The names of the decoders to use on each Task. It must either be the case that each Task specifies a decoder and this is set to None, or this is an iterable and each Task has its decoder set to None.
print_progress (bool) – When True, progress is printed to stderr while collection runs.
custom_decoders (dict[str, Decoder | Sampler] | None) – Named child classes of sinter.decoder, that can be used if requested by name by a task or by the decoders list. If not specified, only decoders with support built into sinter, such as ‘pymatching’ and ‘fusion_blossom’, can be used.
save_resume_filepath (str | Path | None) – Defaults to None (unused). If set to a filepath, results will be saved to that file while they are collected. If the python interpreter is stopped or killed, calling this method again with the same save_resume_filepath will load the previous results from the file so it can resume where it left off. The stats in this file will be counted in addition to each task’s previous_stats field (as opposed to overriding the field). Notes that the stats for each individual observable are not split but saved in the custom_counts field of the stats.
existing_data_filepaths (Iterable[str | Path]) – CSV data saved to these files will be loaded, included in the returned results, and count towards things like max_shots and max_errors.
split_observable_stats (bool) – Defaults to True. If True, the results are post-processed to get individual statistics for each observable in observables. If False, the results are returned as they are collected.
- Returns:
A list of lists of sinter.TaskStats. If split_observable_stats is True, the outer list has one element per provided observable in observables. If split_observable_stats is False, the outer list has only one element, containing the raw statistics collected.
- Return type:
list[list[TaskStats]]