EmulatorInstance

class guppylang.emulator.EmulatorInstance(_instance: SeleneInstance, _n_qubits: int, _options: _Options = <factory>)[source]

An emulator instance for running a compiled program.

Returned by GuppyFunctionDefinition.emulator. Contains configuration options for the emulator instance, such as the number of qubits, the number of shots, the simulator backend, and more.

__delattr__(name)

Implement delattr(self, name).

__eq__(other)

Return self==value.

__hash__()

Return hash(self).

__init__(_instance: SeleneInstance, _n_qubits: int, _options: _Options = <factory>) None
__repr__()

Return repr(self).

__setattr__(name, value)

Implement setattr(self, name, value).

coinflip_sim() Self[source]

Set the simulation backend to the coinflip simulator. This performs no quantum simulation, and flips a coin for each measurement.

property error_model: ErrorModel

Device error model used for the emulator instance.

property n_processes: int

Number of processes to parallelise the emulator execution across. Defaults to 1, meaning no parallelisation.

property n_qubits: int

Number of qubits available in the emulator instance.

run() EmulatorResult[source]

Run the emulator instance and return the results. By default runs one shot, this can be configured with with_shots().

property runtime: Runtime

Runtime used for executing the emulator instance.

property seed: int | None

Random seed for the emulator instance, if any.

property shot_increment: int

Value to increment shot numbers by for each repeated run. Defaults to 1.

property shot_offset: int

Offset for the shot numbers, shot counts will begin at this offset. Defaults to 0.

This is useful for running multiple emulator instances in parallel

property shots: int

Number of shots to run for each execution.

property simulator: Simulator

Simulation backend used for running the emulator instance.

stabilizer_sim() Self[source]

Set the simulation backend to the stabilizer simulator. This only works for clifford circuits but is very fast.

statevector_sim() Self[source]

Set the simulation backend to the default statevector simulator.

property timeout: datetime.timedelta | None

Timeout for the emulator execution, if any.

property verbose: bool

Whether to print verbose output during the emulator execution.

with_error_model(value: ErrorModel) Self[source]

Set the device error model used for the emulator instance. Defaults to IdealErrorModel (no errors).

with_event_hook(value: EventHook) Self[source]

Set the event hook used for the emulator instance. Defaults to NoEventHook.

with_n_processes(value: int) Self[source]

Set the number of processes to parallelise the emulator execution across. Defaults to 1, meaning no parallelisation.

with_n_qubits(value: int) Self[source]

Set the number of qubits available in the emulator instance.

with_runtime(value: Runtime) Self[source]

Set the runtime used for executing the emulator instance. Defaults to SimpleRuntime.

with_seed(value: int | None) Self[source]

Set the random seed for the emulator instance. Defaults to None.

with_shot_increment(value: int) Self[source]

Set the value to increment shot numbers by for each repeated run. Defaults to 1.

with_shot_offset(value: int) Self[source]

Set the offset for the shot numbers, shot counts will begin at this offset. Defaults to 0.

This is useful for running multiple emulator instances in parallel.

with_shots(value: int) Self[source]

Set the number of shots to run for each execution. Defaults to 1.

with_simulator(value: Simulator) Self[source]

Set the simulation backend used for running the emulator instance. Defaults to statevector simulation.

with_timeout(value: datetime.timedelta | None) Self[source]

Set the timeout for the emulator execution. Defaults to None (no timeout).

with_verbose(value: bool) Self[source]

Set whether to print verbose output during the emulator execution. Defaults to False.