MultiProgramRunner¶
Bases: Serializable, Generic[T]
Base class for crash-recoverable program runners bundling config fields
and a template-method run() for checkpoint/resume/progress.
Subclasses implement hook methods to define their specific work logic.
Checkpoint/resume behavior is controlled by explicit checkpoint and
resume flags, applied against item_checkpoint_dir's own on-disk state
according to a 4-case state machine (see run()). Once run() completes,
item_wall_clock_times/shot_wall_clock_times are populated as instance
attributes recording each item's/shot's own wall-clock duration (see their
own attribute docstrings for the exact mapping).
MultiProgramRunner ¶
MultiProgramRunner(parallel_strategy: ParallelStrategy | None = None, config: CheckpointConfig | None = None, run_kwargs: dict[str, Any] | None = None)
Attributes¶
| Name | Type | Value | Doc |
|---|---|---|---|
CHKPT_SUBDIR_PREFIX |
str |
'item' |
|
checkpoint |
bool |
read-only property | |
checkpoint_config |
CheckpointConfig |
read-only property | Rebundles this runner's own unpacked checkpoint/execution-control |
items |
Sequence[T] |
unset | |
shot_checkpoint |
bool |
read-only property |
build_output ¶
build_output(ordered_results: list[tuple[Any, Any]]) -> Any
Build final output from ordered (item, result) pairs.
Warns if any result is None (incomplete run), then delegates to _build_output for subclass-specific final assembly.
build_program ¶
build_program(index: int) -> QuantumProgram
Build a QuantumProgram for the item at the given index.
decode¶
Inherited static method from Serializable.decode().
dump¶
Inherited method from Serializable.dump().
encode¶
Inherited static method from Serializable.encode().
load¶
Inherited class method from Serializable.load().
read¶
Inherited class method from Serializable.read().
reduce_program_outcomes ¶
reduce_program_outcomes(program_results: Any) -> Any
Reduce program_results to a single outcome value.
run ¶
run() -> Any
Run the program with checkpoint/resume support.
Implements a 4-case state machine based on checkpoint and resume
flags and on-disk state (runner.h5 presence in item_checkpoint_dir):
(a) checkpoint=True, resume=False, no on-disk state: free to create
and start; write runner.h5.
(b) checkpoint=True, resume=False, on-disk state exists: raise
ValueError (never silently overwrite/resume).
(c) checkpoint=True, resume=True, on-disk state exists: resume,
subject to the existing mismatch check (force_resume bypasses).
(d) checkpoint=True, resume=True, no on-disk state: raise
ValueError (nothing to resume from).
For both cases (a) and (c), runner.h5 is written once, atomically,
before dispatch. A resume reads only the stored config for the
mismatch check (and the stored index_map), and the rewrite carries
the committed entries over without decoding them. Done-detection
reads the item store strictly. Once dispatch completes,
_run_dispatch consolidates the store and fills the result
attributes from it; without checkpointing, the same assembly runs
over an in-memory store holding each item's dispatch result.
serialize_function¶
Inherited static method from Serializable.serialize_function().
write¶
Inherited method from Serializable.write().