This reference documents the public API: the Executor factory, the
shared executor interface, the backend-agnostic building blocks, and each
backend plugin.
Factory class for creating executor instances based on backend name.
This class provides a plugin-based architecture for executor backends.
Backends can be registered using the @Executor.register() decorator or
discovered automatically via entry points.
Create an executor instance for the specified backend.
Parameters:
target (str | Any) – Name of the backend (e.g., “qiskit”, “pennylane”, “qulacs”).
May also be a Qiskit Backend / BackendV2 instance, in
which case the "qiskit" executor is used automatically and
the object is forwarded as backend=<instance>. An already
constructed ExecutorBase instance is returned
unchanged (no **kwargs allowed in that case).
**kwargs – Configuration parameters passed to the backend constructor
Switch an executor to a different backend while preserving its configuration.
Creates a new executor instance with the specified backend, copying
the current configuration and applying any overrides.
Parameters:
executor (ExecutorBase) – The existing executor whose configuration
should be copied.
backend (str | Any) – Name of the backend to switch to (e.g., "qiskit",
"pennylane", "qulacs"). May also be a Qiskit
Backend / BackendV2 instance, in which case the
"qiskit" executor is used automatically.
**overrides – Configuration parameters to override (e.g., shots=2048)
>>> executor=Executor.create("qiskit",shots=1024,seed=42)>>> pennylane_executor=Executor.switch_backend(executor,"pennylane")>>> # pennylane_executor has shots=1024, seed=42>>>>>> # Override specific parameters>>> qulacs_executor=Executor.switch_backend(executor,"qulacs",shots=2048)>>> # qulacs_executor has shots=2048, seed=42>>>>>> # Switch to a real IBM Quantum backend>>> fromqiskit_ibm_runtimeimportQiskitRuntimeService>>> service=QiskitRuntimeService()>>> ibm_backend=service.least_busy(operational=True,simulator=False)>>> ibm_executor=Executor.switch_backend(executor,ibm_backend)
All backend executors inherit from
ExecutorBase, which defines the common
configuration options (passed through Executor.create) and the evaluation interface shared by
every backend.
Calculate the expectation value of the observable with respect to the circuit.
Parameters:
circuit (QuantumCircuitBase | List[QuantumCircuitBase]) – The quantum circuit
or a list of circuits.
observable (QuantumOperatorBase | List[QuantumOperatorBase]) – The quantum
observable or a list of observables.
parameters – Additional values for the free parameters of the circuit(s) and
the observable(s) given as keyword arguments.
Both vector-style keys (e.g., x=[0.1,0.2]) and indexed keys
(e.g., x[0]=0.1,x[1]=0.2) are accepted and normalized.
Returns:
The expectation value either as a single float or as a
numpy array if multiple circuits/observables are provided.
Calculate the derivatives of the expectation value with respect to the
parameters of the circuit.
The return format and the ordering below are part of the public API;
downstream consumers rely on both. The full gradient of a circuit is
obtained by supplying all of its parameter-vector names (see
QuantumCircuitBase.parameter_vector_names) as derivative
arguments.
Parameters:
circuit (QuantumCircuitBase | List[QuantumCircuitBase]) – The quantum circuit
or a list of circuits.
observable (QuantumOperatorBase | List[QuantumOperatorBase]) – The quantum
observable or a list of observables. Lists of circuits and
observables are evaluated combinatorially: every circuit is
paired with every observable. Observable lists are handled
natively by each backend; a circuit list is expanded here.
derivative – The parameter(s) with respect to which the derivative is calculated.
parameters – Additional values for the free parameters of the circuit(s) and
the observable(s) given as keyword arguments.
Both vector-style keys (e.g., x=[0.1,0.2]) and indexed keys
(e.g., x[0]=0.1,x[1]=0.2) are accepted and normalized.
Returns:
The derivative of the expectation value:
single float/array if one derivative parameter is requested
dictionary mapping parameter names to gradient arrays if multiple
parameters are requested
A list input adds a leading axis per list: (n_circuits,...)
for a circuit list, (n_observables,...) for an observable
list, and (n_circuits,n_observables,...) for both.
Entries within each parameter vector are ordered by numeric
element index, i.e. theta[2] precedes theta[10].
Computes samples of the quantumstate of the given circuit.
Bitstring keys use the big-endian convention q[0]q[1]...q[n-1]
(qubit 0 is the leftmost character).
Parameters:
circuit (QuantumCircuitBase | List[QuantumCircuitBase]) – The quantum circuit
or a list of circuits.
parameters – Additional values for the free parameters of the circuit(s)
given as keyword arguments.
Both vector-style keys (e.g., x=[0.1,0.2]) and indexed keys
(e.g., x[0]=0.1,x[1]=0.2) are accepted and normalized.
Returns:
The sampled results either as a single dictionary or a
list of dictionaries if multiple circuits are provided.
Amplitudes use the big-endian basis ordering: index i encodes
qubit 0 as the most significant bit.
Parameters:
circuit (QuantumCircuitBase | List[QuantumCircuitBase]) – The quantum circuit
or a list of circuits.
parameters – Additional values for the free parameters of the circuit(s)
given as keyword arguments.
Both vector-style keys (e.g., x=[0.1,0.2]) and indexed keys
(e.g., x[0]=0.1,x[1]=0.2) are accepted and normalized.
Compute the measurement probabilities of a circuit.
With shots=None the probabilities are exact (derived from the
statevector); otherwise they are estimated from sampled counts.
Parameters:
circuit (QuantumCircuitBase) – A single quantum circuit.
cutoff (float, optional) – Only probabilities strictly greater
than this threshold are returned. The default of 0.0
omits exact zeros only, matching what the backends report
natively; pass a larger value to keep the result sparse for
many qubits.
parameters – Values for the free parameters of the circuit given as
keyword arguments. Passing more than one parameter set (the
same batching convention as expectation_value()) is
supported on backends whose statevector()/sample()
support it.
Returns:
Mapping of basis-state
index (big-endian ordering, qubit 0 = most significant bit) to
probability - one mapping for a single parameter set, or a list
of mappings, one per set, for a batch of parameter sets.
Transpile the circuit for execution on this executor’s backend.
Subclasses may override _transpile_circuit() to apply
backend-specific optimisations (e.g. gate decomposition, qubit
routing). When a list of circuits is provided, each circuit is
transpiled and cached individually.
Parameters:
circuit (QuantumCircuitBase | List[QuantumCircuitBase]) – The
quantum circuit or a list of circuits to transpile.
Transpile the operator for execution on this executor’s backend.
Subclasses may override _transpile_operator() to apply
backend-specific conversions (e.g., to wrapper types). When a list
of operators is provided, each operator is transpiled and cached individually.
Parameters:
operator (QuantumOperatorBase | List[QuantumOperatorBase]) – The
quantum operator or a list of operators to transpile.
**options – Backend-specific transpilation options, forwarded to
_transpile_operator(). The Pauli-propagation backend uses
this for symmetry_strategy.
Return a list of backend object types accepted by this executor.
This is used for auto-detection when a non-string backend is passed to
Executor.create(). If the backend object is an instance of any
of the returned types, this executor will be selected automatically.
This optional list is used by Executor.create() when a string
target is not a registered backend name. The factory resolves aliases
to the owning plugin and forwards the original string via
backend=<target>.
Import a Qiskit circuit into the framework-independent IR.
The circuit’s instructions are translated into the instruction store,
so the result runs on every backend – unlike
QiskitCircuit.from_qiskit,
which only carries a pre-built circuit for the Qiskit backend and is the
right tool for ISA-transpiled circuits. Requires the qiskit extra.
Parameters:
qiskit_circuit (Any) – The qiskit.QuantumCircuit to import.
Each plugin provides an executor plus native circuit/operator wrappers. You
normally obtain an executor through Executor.create("<name>") rather than
instantiating these classes directly, but their public classes are documented
on the per-plugin pages below.