CircuitRunner¶
- class CircuitRunner(shots, track_depth=False)[source]¶
Bases:
ABCA generic interface for anything that can “run” quantum circuits.
Attributes Summary
Circuit depth per batch when
track_depthis True.Whether the backend executes circuits asynchronously.
Get the number of measurement shots for circuit execution.
Whether the backend supports expectation value measurements.
Methods Summary
Average circuit depth across all tracked submissions.
Clear the depth history.
set_seed(seed)Seed the backend's random number generator, if supported.
Standard deviation of circuit depth across all tracked submissions.
submit_circuits(circuits, *[, ...])Submit quantum circuits for execution.
Attributes Documentation
- depth_history¶
Circuit depth per batch when
track_depthis True.Each element is a list of depths (one per circuit) for that submission. Empty when
track_depthis False or before any circuits have been run.
- is_async¶
Whether the backend executes circuits asynchronously.
- Returns:
- True if the backend returns a job ID and requires polling
for results (e.g., QoroService). False if the backend returns results immediately (e.g., QiskitSimulator).
- Return type:
- shots¶
Get the number of measurement shots for circuit execution.
- Returns:
Number of shots configured for this runner.
- Return type:
- supports_expval¶
Whether the backend supports expectation value measurements.
Methods Documentation
- average_depth()[source]¶
Average circuit depth across all tracked submissions.
Returns 0.0 when depth history is empty.
- Return type:
- clear_depth_history()[source]¶
Clear the depth history. Use when reusing the backend for a new run.
- Return type:
- set_seed(seed)[source]¶
Seed the backend’s random number generator, if supported.
The default implementation is a no-op. Backends that can seed their simulation RNG should override this method.
- std_depth()[source]¶
Standard deviation of circuit depth across all tracked submissions.
Returns 0.0 when depth history is empty or has a single value.
- Return type:
- abstractmethod submit_circuits(circuits, *, cancellation_event=None, **kwargs)[source]¶
Submit quantum circuits for execution.
This abstract method must be implemented by subclasses to define how circuits are executed on their respective backends (simulator, hardware, etc.).
- Parameters:
circuits (
Mapping[str,str]) – Dictionary mapping circuit labels to their OpenQASM string representations.cancellation_event (
Event|None) – When set, the backend aborts the batch and raisesExecutionCancelledError. Sync backends honour it between items; async backends thread it into their poll loop.**kwargs – Additional backend-specific parameters for circuit execution.
- Returns:
- For synchronous backends, contains results directly.
For asynchronous backends, contains a job_id that can be used to fetch results later.
- Return type: