Skip to content

loqs.core.executors

Structural executor protocols shared by shot-level and program-level parallelism.

Two distinct executor shapes exist in this codebase, matching two different dispatch mechanisms:

  • SubmitExecutor: anything exposing a concurrent.futures-style .submit() method returning a Future. Satisfied by loky.get_reusable_executor() and mpi4py.futures.MPIPoolExecutor (both real concurrent.futures.Executor subclasses) without a hard dependency on either package. Used for shot-level parallelism (run()'s shot_executor parameter) and, via loqs.tools.paralleltools.ParallelStrategy, for program-level parallelism dispatched one .submit() call per chunk.
  • MapArrayExecutor: anything exposing a submitit-style .map_array() bulk-submission method. Satisfied by submitit.Executor, which submits a single sbatch call covering an entire batch of chunks rather than one job per chunk. Used exclusively for program-level parallelism via loqs.tools.paralleltools.ParallelStrategy; never for shot-level parallelism. Note that a submitit.Executor actually satisfies both protocols (it has a .submit() method too), so code that cares about map_array's bulk-submission efficiency must check for MapArrayExecutor first.

Both are runtime_checkable, so isinstance(x, SubmitExecutor)/ isinstance(x, MapArrayExecutor) work directly for dispatch-mechanism detection, without hardcoding which concrete package produced x.

Classes