deltakit.decode.analysis.StimDecoderManager.run_batch_shots_parallel#
- StimDecoderManager.run_batch_shots_parallel(batch_limit: int | None, processes: int, pool, min_tasks_per_process: int = 50) tuple[int, int]#
Run batch of shots in parallel using processes number of runners from pool. Cap the number of processes created such that a minimum of min_tasks_per_process should be running per process. By default the ABC implementation is a naive serial execution of run_batch_shots which should be overridden for better parallel resource utilisation. This method will block until it is finished.
Each process in the pool should be initialised with this decoder manager stored in the process global variables by calling configure_pool. The Manager authenticates that a worker processes has a consistent decoder manager with the main process by comparing the managers _mp_token. The pool should have its state cleared once a sequence of calls to this method exclusive to this decoder manager is finished by calling clear_pool_manager.
- Parameters:
batch_limit (Optional[int]) – How many samples to take. If None, will attempt to exhaust the noise source
processes (int) – How many runners to distribute shot execution across.
pool (pathos.multiprocessing.ProcessPool) – Pathos pool to use to run shots in parallel. Assumed given pool is already configured with decoder manager data.
min_shots_per_process (int, optional) – Minimum of shots that should be running per process, will reduce processes if umber of shots taken and number of those shots that failed.
Example
num_parallel_processes = 4 decoder_manager.configure_pool(pool, num_parallel_processes) for i in range(10): decoder_manager.run_batch_shots_parallel( batch_limit=self.batch_size, processes=num_parallel_processes, pool=pool, ) decoder_manager.clear_pool_manager(pool, num_parallel_processes)