SeleneInstance¶
- class selene_sim.SeleneInstance(root: Path, artifacts: Path, runs: Path, executable: Path, library_search_dirs: list[Path])¶
Represents a selene instance, which is a wrapper around the selene executable generated from a user program by build.py’s build function.
- __eq__(other)¶
Return self==value.
- __hash__ = None¶
- __init__(root: Path, artifacts: Path, runs: Path, executable: Path, library_search_dirs: list[Path]) None ¶
- __post_init__()¶
Setup the run directory ready for invocation.
- __repr__()¶
Return repr(self).
- artifacts: Path¶
- delete_files()¶
Deletes the files associated with this instance, including the executable, artifacts, and run directories.
- delete_run_directories()¶
Deletes the run directories associated with this instance. This does not delete the artifacts directory or the executable.
- executable: Path¶
- library_search_dirs: list[Path]¶
- root: Path¶
- run(simulator: ~selene_core.simulator.Simulator, n_qubits: int, runtime: ~selene_core.runtime.Runtime = SimpleRuntimePlugin(random_seed=None), error_model: ~selene_core.error_model.ErrorModel = IdealPlugin(random_seed=None), event_hook: ~selene_sim.event_hooks.event_hook.EventHook = <selene_sim.event_hooks.event_hook.NoEventHook object>, verbose: bool = False, timeout: ~selene_sim.timeout.Timeout | ~datetime.timedelta | float | None = None, results_logfile=None, random_seed: int | None = None, shot_offset: int = 0, parse_results: bool = True) Iterator[tuple[str, int | float | bool | list[int | float | bool]]] ¶
Run the compiled program through a single selene shot.
- Parameters:
simulator – The simulator plugin to use
n_qubits – The maximum number of qubits to simulate
runtime – The runtime plugin to use
error_model – The error model plugin to use (if any)
event_hook – Event hook that configures Selene to output additional information to the results stream, and handles the output.
verbose – Whether to print verbose output for diagnostics
timeout – The maximum time to wait for the program to complete
results_logfile – The file to write the results to (if any)
random_seed – The random seed to use for the simulator, error model, and runtime if they have not been set explicitly
- run_shots(simulator: ~selene_core.simulator.Simulator, n_qubits: int, n_shots: int = 1, error_model: ~selene_core.error_model.ErrorModel = IdealPlugin(random_seed=None), runtime: ~selene_core.runtime.Runtime = SimpleRuntimePlugin(random_seed=None), event_hook: ~selene_sim.event_hooks.event_hook.EventHook = <selene_sim.event_hooks.event_hook.NoEventHook object>, verbose: bool = False, timeout: ~selene_sim.timeout.Timeout | ~datetime.timedelta | float | None = None, results_logfile: ~pathlib.Path | None = None, random_seed: int | None = None, shot_offset: int = 0, shot_increment: int = 1, n_processes: int = 1, parse_results: bool = True) Iterator[Iterator[tuple[str, int | float | bool | list[int | float | bool]]]] ¶
Run the compiled program through multiple selene shots. :param simulator: The simulator plugin to use :param n_qubits: The maximum number of qubits to simulate :param n_shots: The number of shots to run :param error_model: The error model plugin to use (if any) :param runtime: The runtime plugin to use :param event_hook: Event hook that configures Selene to output
additional information to the results stream, and handles the output.
- Parameters:
verbose – Whether to print verbose output for diagnostics
timeout – Timeout configuration for various aspects of the emulation run. If a timedelta is provided directly, it is assumed to be the time limit of the overall run. If None is provided, no timeout is set. If a float is provided, it is assumed to be the time limit in seconds of the overall run.
results_logfile – The file to write the results to (if any)
random_seed – The random seed to use for the simulator, error model, and runtime if they have not been set explicitly. On each shot, the random seed will be incremented by 1.
parse_results –
Whether to interpret tags in the result stream. If True (default), tags will be stripped, interpreted, and routed according to their type, e.g: - (“USER:INT:example”, 42) will be interpreted as
an output variable “example”
- (“METRICS:INT:user_program:qalloc_count”, 5) will
be interpreted as a metric with the name “qalloc_count” in the “user_program” namespace, and given to a MetricStore event hook WITHOUT yielding it as a result.
If False, no stripping or routing will be done: everything in the result stream is passed directly to the result iterator, e.g: - (“USER:INT:example”, 42) will be yielded as-is,
without interpretation.
(“METRICS:INT:user_program:qalloc_count”, 5) will also be yielded as-is, without interpretation.
Setting to True provides the high level Selene interface, and using False allows for Selene to be used as an intermediate component for use with an external result stream handler.
- runs: Path¶
- write_manifest(data: dict)¶
Writes the build manifest corresponding to this instance for future reference.