Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

qamomile.qbraid

qBraid execution integration for Qamomile (executor-only, no transpiler).

Design intent: unlike the other engine packages, qBraid provides no emit pass or GateEmitter of its own. QBraidExecutor (executor.py) implements circuit’s QuantumExecutor[QuantumCircuit] protocol over circuits already emitted by the Qiskit engine, routing them to qBraid-accessible devices through the qBraid runtime. Compile with QiskitTranspiler, execute with QBraidExecutor.

Constraints:

Overview

ClassDescription
QBraidExecutorQuantum executor that runs Qiskit circuits on qBraid-supported devices.

Classes

QBraidExecutor [source]

class QBraidExecutor(QuantumExecutor['QuantumCircuit'])

Quantum executor that runs Qiskit circuits on qBraid-supported devices.

This executor implements the QuantumExecutor[QuantumCircuit] contract, allowing ExecutableProgram.sample(), measured run(), and expectation-value run() to work with any qBraid-accessible backend.

The estimate() method uses a counts-based measurement approach. It only supports circuits with num_clbits == 0 (no pre-existing classical bits). Circuits with existing classical bits are rejected with an ExecutionError to prevent silent wrong results caused by qBraid’s counts normalization removing register separators.

Endian convention:

execute() returns canonical Qiskit-style bitstring keys after normalization. Keys are big-endian classical-bit strings: the leftmost character is the highest classical-bit index and the rightmost character is classical bit 0. QBraidExecutor never reverses or permutes the bit order; normalization only removes spaces and zero-pads under-width keys.

estimate() uses the same bitstring convention when reconstructing expectation values from counts. Since it applies measure_all() to a circuit with no pre-existing classical bits, classical bit i measures qubit i. Therefore, in estimate() the rightmost count character corresponds to qubit 0 and the leftmost character to the highest qubit index.

Parameters:

NameTypeDescription
deviceAny | NoneA pre-configured qBraid QuantumDevice. Mutually exclusive with device_id, provider, and api_key.
device_idstr | NoneqBraid device identifier (e.g., "qbraid_qir_simulator").
providerAny | NoneA QbraidProvider instance for device lookup.
api_keystr | NoneqBraid API key, used to create a QbraidProvider when provider is not given.
expval_shotsintNumber of shots for each basis-rotation circuit in estimate(). Defaults to 4096.
timeoutint | NoneTimeout in seconds for wait_for_final_state(). None means wait indefinitely.
poll_intervalintPolling interval in seconds for wait_for_final_state(). Defaults to 5.
run_kwargsdict[str, Any] | NoneExtra keyword arguments forwarded to device.run(). Must not contain "shots" — use the shots parameter of execute() instead.

Raises:

Example (device_id + api_key)::

executor = QBraidExecutor(
    device_id="qbraid_qir_simulator",
    api_key="your-api-key",
)

Example (pre-configured device)::

from qbraid import QbraidProvider
provider = QbraidProvider(api_key="...")
device = provider.get_device("qbraid_qir_simulator")
executor = QBraidExecutor(device=device)

Constructor

def __init__(
    self,
    device: Any | None = None,
    *,
    device_id: str | None = None,
    provider: Any | None = None,
    api_key: str | None = None,
    expval_shots: int = 4096,
    timeout: int | None = None,
    poll_interval: int = 5,
    run_kwargs: dict[str, Any] | None = None,
) -> None

Initialize qBraid device access and execution policy.

Parameters:

NameTypeDescription
deviceAny | NonePre-configured qBraid device. Mutually exclusive with identifier and credential arguments.
device_idstr | NoneqBraid device identifier. Defaults to None.
providerAny | NoneProvider used to resolve device_id. Defaults to None.
api_keystr | NoneAPI key used when constructing a provider. Defaults to None.
expval_shotsintPositive shots per expectation basis group. Defaults to 4096.
timeoutint | NoneDefault result wait timeout in seconds. Defaults to no timeout.
poll_intervalintPositive provider polling interval in seconds. Defaults to five.
run_kwargsdict[str, Any] | NoneAdditional qBraid submission options. Defaults to None.

Raises:

Attributes

Methods

bind_parameters
def bind_parameters(
    self,
    circuit: 'QuantumCircuit',
    bindings: dict[str, Any],
    parameter_metadata: ParameterMetadata,
) -> 'QuantumCircuit'

Bind parameter values to the Qiskit circuit.

Uses the same indexed-binding semantics as QiskitExecutor.

Parameters:

NameTypeDescription
circuit'QuantumCircuit'The parameterized circuit.
bindingsdict[str, Any]Dict mapping parameter names to values.
parameter_metadataParameterMetadataMetadata about circuit parameters.

Returns:

'QuantumCircuit' — New circuit with parameters bound.

estimate
def estimate(
    self,
    circuit: 'QuantumCircuit',
    hamiltonian: 'qm_o.Hamiltonian',
    params: Sequence[float] | None = None,
) -> float

Estimate the expectation value of a Hamiltonian using counts.

This method decomposes the Hamiltonian into Pauli terms, groups them by measurement basis, applies basis-rotation gates, and reconstructs the expectation value from measurement counts.

Only circuits with num_clbits == 0 are supported. Circuits with pre-existing classical bits are rejected because qBraid’s counts normalization removes register separators, making it impossible to reliably identify which measured bits correspond to which qubits.

Count bitstrings are interpreted using the same big-endian convention as Qiskit counts: the leftmost character is the highest measured qubit index and the rightmost character is qubit 0. This follows directly from calling measure_all() on a circuit whose classical-bit indices match its qubit indices.

Parameters:

NameTypeDescription
circuit'QuantumCircuit'The state-preparation circuit (no measurements).
hamiltonian'qm_o.Hamiltonian'The Hamiltonian whose expectation value is computed.
paramsSequence[float] | NoneOptional parameter values for parametric circuits. Values are bound positionally in Qiskit circuit parameter order. If None, the circuit must already have all parameters bound.

Returns:

float — The estimated real-valued expectation value.

Raises:

execute
def execute(self, circuit: 'QuantumCircuit', shots: int) -> dict[str, int]

Execute circuit and return bitstring counts.

If the circuit has no classical bits, measure_all() is added automatically (on a copy).

Returned keys use canonical Qiskit-style big-endian classical-bit order: the leftmost character is the highest classical-bit index and the rightmost character is classical bit 0. execute() does not reinterpret those keys as qubit-ordered strings.

Parameters:

NameTypeDescription
circuit'QuantumCircuit'The quantum circuit to execute.
shotsintNumber of measurement shots.

Returns:

dict[str, int] — Dictionary mapping canonical big-endian classical-bit strings dict[str, int] — to counts.

submit_estimate
def submit_estimate(self, request: EstimateRequest['QuantumCircuit']) -> ExecutionHandle[float]

Submit counts-based expectation tasks without waiting.

Parameters:

NameTypeDescription
requestEstimateRequest[QuantumCircuit]Circuit invocation, Hamiltonian, and optional shot policy.

Returns:

ExecutionHandle[float] — ExecutionHandle[float]: Lazy aggregate expectation handle.

Raises:

submit_sample
def submit_sample(
    self,
    request: SampleRequest['QuantumCircuit'],
) -> ExecutionHandle[dict[str, int]]

Submit qBraid sampling without waiting for the remote result.

Parameters:

NameTypeDescription
requestSampleRequest[QuantumCircuit]Circuit invocation and requested shot count.

Returns:

ExecutionHandle[dict[str, int]] — ExecutionHandle[dict[str, int]]: Lazy qBraid sampling handle.

Raises:


qamomile.qbraid.execution

Adapt qBraid quantum jobs to Qamomile execution handles.

Overview

ClassDescription
ExecutionHandleExpose an engine execution without forcing immediate result retrieval.
ExecutionReferenceStore secret-free identifiers needed to restore remote execution.
JobStatusDescribe a provider-independent execution state.
QBraidExecutionHandleExpose one qBraid sampling job through the shared lifecycle API.

Classes

ExecutionHandle [source]

class ExecutionHandle(ABC, Generic[ResultT])

Expose an engine execution without forcing immediate result retrieval.

Attributes
Methods
cancel
def cancel(self) -> None

Request best-effort cancellation.

Cancellation is intentionally not reported as a boolean because providers may accept a request after execution has already started. Call :meth:status to observe the eventual state.

metadata
def metadata(self) -> Mapping[str, Any]

Return optional provider execution metadata.

Returns:

Mapping[str, Any] — Mapping[str, Any]: Provider metadata such as timestamps or usage.

raw_status
def raw_status(self) -> object

Return provider-specific status information.

Returns:

object — Provider status value, or the normalized status when no richer value exists.

references
def references(self) -> tuple[ExecutionReference, ...]

Return serializable remote execution references.

Returns:

tuple[ExecutionReference, ...] — tuple[ExecutionReference, ...]: Secret-free provider references.

result
def result(self, timeout: float | None = None) -> ResultT

Wait for and return the engine-neutral raw result.

Parameters:

NameTypeDescription
timeoutfloat | NoneMaximum local wait in seconds. None delegates the wait policy to the provider.

Returns:

ResultT — Raw result normalized by the engine executor.

Raises:

result_async
def result_async(self, timeout: float | None = None) -> ResultT

Wait asynchronously for the engine-neutral raw result.

Parameters:

NameTypeDescription
timeoutfloat | NoneMaximum local wait in seconds. Defaults to provider behavior when None.

Returns:

ResultT — Raw result normalized by the engine executor.

Raises:

snapshot
def snapshot(self) -> ExecutionSnapshot

Capture one remote execution without fetching its result.

Adapters exposing several logical references must override this method with an explicit reconstruction structure. A provider reference may itself contain multiple physical job IDs.

Returns:

ExecutionSnapshot — One opaque provider execution.

Raises:

status
def status(self) -> JobStatus

Return the current provider-independent execution status.

Returns:

JobStatus — Current normalized status.


ExecutionReference [source]

class ExecutionReference

Store secret-free identifiers needed to restore remote execution.

Parameters:

NameTypeDescription
providerstrStable provider or adapter name.
job_idstuple[str, ...]One or more provider job identifiers.
targetstr | NoneProvider target or device identifier. Defaults to None.
group_idstr | NoneSession, batch, program, or parent identifier. Defaults to None.
contextMapping[str, str]Additional non-secret identifiers needed to restore the job. Defaults to an empty mapping.

Raises:

Constructor
def __init__(
    self,
    provider: str,
    job_ids: tuple[str, ...],
    target: str | None = None,
    group_id: str | None = None,
    context: Mapping[str, str] = dict(),
) -> None
Attributes
Methods
from_dict
@classmethod
def from_dict(cls, data: Mapping[str, Any]) -> ExecutionReference

Reconstruct a provider reference from JSON-compatible data.

Parameters:

NameTypeDescription
dataMapping[str, Any]Mapping produced by :meth:to_dict.

Returns:

ExecutionReference — Validated provider execution reference.

Raises:

to_dict
def to_dict(self) -> dict[str, Any]

Convert the provider reference to JSON-compatible data.

Returns:

dict[str, Any] — dict[str, Any]: Provider identifiers and decoding context without credentials or SDK objects.


JobStatus [source]

class JobStatus(Enum)

Describe a provider-independent execution state.

The numeric values of the original four states remain stable for serialization compatibility.

Attributes

QBraidExecutionHandle [source]

class QBraidExecutionHandle(ExecutionHandle[dict[str, int]])

Expose one qBraid sampling job through the shared lifecycle API.

Parameters:

NameTypeDescription
jobAnyqBraid QuantumJob or compatible object.
decoderCallable[[Any], dict[str, int]]Function converting the native result to normalized bitstring counts.
targetstr | NoneqBraid device identifier. Defaults to None.
timeoutfloat | NoneDefault provider wait timeout in seconds. Defaults to None.
poll_intervalfloatProvider polling interval in seconds.

Raises:

Constructor
def __init__(
    self,
    job: Any,
    decoder: Callable[[Any], dict[str, int]],
    *,
    target: str | None,
    timeout: float | None,
    poll_interval: float,
) -> None

Initialize a lazy qBraid execution handle.

Parameters:

NameTypeDescription
jobAnyNative qBraid job.
decoderCallable[[Any], dict[str, int]]Native result decoder.
targetstr | NoneqBraid device identifier.
timeoutfloat | NoneDefault provider wait timeout in seconds.
poll_intervalfloatPositive provider polling interval.

Raises:

Attributes
Methods
cancel
def cancel(self) -> None

Request best-effort cancellation from qBraid.

metadata
def metadata(self) -> Mapping[str, Any]

Return native qBraid job metadata when available.

Returns:

Mapping[str, Any] — Mapping[str, Any]: Provider metadata, or an empty mapping.

raw_status
def raw_status(self) -> object

Return the native qBraid status value.

Returns:

object — Provider status enum or string.

references
def references(self) -> tuple[ExecutionReference, ...]

Return the qBraid job identifier when the SDK exposes one.

Returns:

tuple[ExecutionReference, ...] — tuple[ExecutionReference, ...]: One qBraid reference, or an empty tuple for jobs without a stable identifier.

result
def result(self, timeout: float | None = None) -> dict[str, int]

Wait for and decode the qBraid result once.

Parameters:

NameTypeDescription
timeoutfloat | NoneMaximum wait in seconds. None uses the executor-configured timeout.

Returns:

dict[str, int] — dict[str, int]: Normalized big-endian bitstring counts.

Raises:

status
def status(self) -> JobStatus

Return the normalized qBraid job status.

Returns:

JobStatus — Current provider-independent state.


qamomile.qbraid.executor

qBraid executor integration for Qamomile.

This module provides QBraidExecutor, which bridges Qamomile’s compiled Qiskit circuits to qBraid-supported quantum devices via the qBraid runtime.

Example:

from qamomile.qbraid import QBraidExecutor

executor = QBraidExecutor(device_id="qbraid_qir_simulator")
counts = executor.execute(circuit, shots=1000)

Overview

ClassDescription
CircuitInvocationKeep an emitted circuit and runtime parameter values together.
CompletedExecutionHandleWrap an already available result for synchronous executors.
CompositeExecutionHandleAggregate several independently submitted executions.
EstimateRequestDescribe one Hamiltonian expectation execution.
ExactRequest an analytic expectation value without shot noise.
ExecutionCapabilitiesDeclare the execution features implemented by one executor.
ExecutionErrorError during program execution.
ExecutionHandleExpose an engine execution without forcing immediate result retrieval.
MappedExecutionHandleLazily transform another execution handle’s result.
QBraidExecutionHandleExpose one qBraid sampling job through the shared lifecycle API.
QBraidExecutorQuantum executor that runs Qiskit circuits on qBraid-supported devices.
SampleRequestDescribe one sampling execution.
ShotBasedRequest a shot-based expectation value.
TargetPrecisionRequest an expectation value at a provider target precision.

Classes

CircuitInvocation [source]

class CircuitInvocation(Generic[CircuitT])

Keep an emitted circuit and runtime parameter values together.

Engines may bind the values into a new circuit or submit them through a native parameter-input API. Keeping both forms available preserves native parameter sweeps and provider-side compilation caches.

Parameters:

NameTypeDescription
circuitCircuitTEmitted engine circuit or kernel artifact.
bindingsMapping[str, Any]Flattened Qamomile runtime bindings.
parameter_metadataParameterMetadataMapping from public parameter names to engine parameter objects.
Constructor
def __init__(
    self,
    circuit: CircuitT,
    bindings: Mapping[str, Any],
    parameter_metadata: ParameterMetadata,
) -> None
Attributes

CompletedExecutionHandle [source]

class CompletedExecutionHandle(ExecutionHandle[ResultT])

Wrap an already available result for synchronous executors.

Parameters:

NameTypeDescription
valueResultTCompleted execution value.
Constructor
def __init__(self, value: ResultT) -> None

Initialize an immediately completed execution.

Parameters:

NameTypeDescription
valueResultTCompleted execution value.
Methods
result
def result(self, timeout: float | None = None) -> ResultT

Return the completed value without waiting.

Parameters:

NameTypeDescription
timeoutfloat | NoneIgnored compatibility timeout.

Returns:

ResultT — Stored execution value.

snapshot
def snapshot(self) -> ExecutionSnapshot

Capture the already available raw result without waiting.

Returns:

ExecutionSnapshot — Owned, type-preserving local value.

Raises:

status
def status(self) -> JobStatus

Return the completed status.

Returns:

JobStatus — Always :attr:JobStatus.COMPLETED.


CompositeExecutionHandle [source]

class CompositeExecutionHandle(ExecutionHandle[tuple[ResultT, ...]])

Aggregate several independently submitted executions.

Parameters:

NameTypeDescription
handlesSequence[ExecutionHandle[ResultT]]Child executions in stable result order.
Constructor
def __init__(self, handles: Sequence[ExecutionHandle[ResultT]]) -> None

Initialize an ordered execution aggregate.

Parameters:

NameTypeDescription
handlesSequence[ExecutionHandle[ResultT]]Child executions.
Attributes
Methods
cancel
def cancel(self) -> None

Attempt cancellation of every child not known to be terminal.

A status lookup failure leaves the child’s state unknown, so cancellation is still attempted. Failures are reported together after all children have been visited, retaining the original exceptions and tracebacks.

Raises:

metadata
def metadata(self) -> Mapping[str, Any]

Return metadata grouped by child index.

Returns:

Mapping[str, Any] — Mapping[str, Any]: Child metadata sequence.

raw_status
def raw_status(self) -> object

Return every child provider status.

Returns:

object — Tuple of child raw statuses.

references
def references(self) -> tuple[ExecutionReference, ...]

Return the legacy one-reference-per-child view.

This flat view cannot preserve child boundaries when a child exposes zero or multiple references. Use :meth:snapshot to retain local results and nested groups in their original positions.

Returns:

tuple[ExecutionReference, ...] — tuple[ExecutionReference, ...]: Ordered child references, or an empty tuple when any child does not expose exactly one.

result
def result(self, timeout: float | None = None) -> tuple[ResultT, ...]

Return all child results in submission order.

Parameters:

NameTypeDescription
timeoutfloat | NoneTotal local wait budget in seconds.

Returns:

tuple[ResultT, ...] — tuple[ResultT, ...]: Ordered child results.

Raises:

result_async
def result_async(self, timeout: float | None = None) -> tuple[ResultT, ...]

Return all child results asynchronously.

Parameters:

NameTypeDescription
timeoutfloat | NoneTotal local wait budget in seconds.

Returns:

tuple[ResultT, ...] — tuple[ResultT, ...]: Ordered child results.

Raises:

snapshot
def snapshot(self) -> ExecutionSnapshot

Capture all children with their original tuple boundaries.

Returns:

ExecutionSnapshot — Ordered nested execution structure.

Raises:

status
def status(self) -> JobStatus

Aggregate child statuses without hiding partial completion.

Returns:

JobStatus — Aggregate execution status.


EstimateRequest [source]

class EstimateRequest(Generic[CircuitT])

Describe one Hamiltonian expectation execution.

Parameters:

NameTypeDescription
invocationCircuitInvocation[CircuitT]Circuit and runtime inputs.
hamiltonianqm_o.HamiltonianObservable to evaluate.
accuracyEstimationAccuracy | NoneExplicit accuracy policy. None uses the executor’s configured default.
Constructor
def __init__(
    self,
    invocation: CircuitInvocation[CircuitT],
    hamiltonian: qm_o.Hamiltonian,
    accuracy: EstimationAccuracy | None = None,
) -> None
Attributes

Exact [source]

class Exact

Request an analytic expectation value without shot noise.

Constructor
def __init__(self) -> None

ExecutionCapabilities [source]

class ExecutionCapabilities

Declare the execution features implemented by one executor.

Parameters:

NameTypeDescription
supports_async_samplingboolWhether sampling submission returns before provider execution completes. Defaults to False.
supports_async_estimationboolWhether expectation submission returns before provider execution completes. Defaults to False.
supports_estimationboolWhether expectation-value execution is implemented. Defaults to False.
supports_cancellationboolWhether provider-backed handles can request cancellation. Defaults to False.
supports_restorationboolWhether execution references can recreate provider-backed handles. Defaults to False.
supports_native_batchboolWhether multiple logical requests can be submitted through one provider-native batch or job. Defaults to False.
supports_native_parameter_inputsboolWhether runtime values remain separate from emitted circuits during provider submission. Defaults to False.
estimation_accuracyfrozenset[EstimationPolicyType]Explicit per-request accuracy policies accepted by the executor. An empty set means only executor-configured estimation behavior is available.

Raises:

Constructor
def __init__(
    self,
    supports_async_sampling: bool = False,
    supports_async_estimation: bool = False,
    supports_estimation: bool = False,
    supports_cancellation: bool = False,
    supports_restoration: bool = False,
    supports_native_batch: bool = False,
    supports_native_parameter_inputs: bool = False,
    estimation_accuracy: frozenset[EstimationPolicyType] = frozenset(),
) -> None
Attributes

ExecutionError [source]

class ExecutionError(QamomileCompileError)

Error during program execution.


ExecutionHandle [source]

class ExecutionHandle(ABC, Generic[ResultT])

Expose an engine execution without forcing immediate result retrieval.

Attributes
Methods
cancel
def cancel(self) -> None

Request best-effort cancellation.

Cancellation is intentionally not reported as a boolean because providers may accept a request after execution has already started. Call :meth:status to observe the eventual state.

metadata
def metadata(self) -> Mapping[str, Any]

Return optional provider execution metadata.

Returns:

Mapping[str, Any] — Mapping[str, Any]: Provider metadata such as timestamps or usage.

raw_status
def raw_status(self) -> object

Return provider-specific status information.

Returns:

object — Provider status value, or the normalized status when no richer value exists.

references
def references(self) -> tuple[ExecutionReference, ...]

Return serializable remote execution references.

Returns:

tuple[ExecutionReference, ...] — tuple[ExecutionReference, ...]: Secret-free provider references.

result
def result(self, timeout: float | None = None) -> ResultT

Wait for and return the engine-neutral raw result.

Parameters:

NameTypeDescription
timeoutfloat | NoneMaximum local wait in seconds. None delegates the wait policy to the provider.

Returns:

ResultT — Raw result normalized by the engine executor.

Raises:

result_async
def result_async(self, timeout: float | None = None) -> ResultT

Wait asynchronously for the engine-neutral raw result.

Parameters:

NameTypeDescription
timeoutfloat | NoneMaximum local wait in seconds. Defaults to provider behavior when None.

Returns:

ResultT — Raw result normalized by the engine executor.

Raises:

snapshot
def snapshot(self) -> ExecutionSnapshot

Capture one remote execution without fetching its result.

Adapters exposing several logical references must override this method with an explicit reconstruction structure. A provider reference may itself contain multiple physical job IDs.

Returns:

ExecutionSnapshot — One opaque provider execution.

Raises:

status
def status(self) -> JobStatus

Return the current provider-independent execution status.

Returns:

JobStatus — Current normalized status.


MappedExecutionHandle [source]

class MappedExecutionHandle(ExecutionHandle[MappedT], Generic[ResultT, MappedT])

Lazily transform another execution handle’s result.

Parameters:

NameTypeDescription
sourceExecutionHandle[ResultT]Underlying execution handle.
transformCallable[[ResultT], MappedT]Result transformation.
snapshot_sourceboolWhether the owning executable reconstructs this transformation when restoring the source. Defaults to False.
Constructor
def __init__(
    self,
    source: ExecutionHandle[ResultT],
    transform: Callable[[ResultT], MappedT],
    *,
    snapshot_source: bool = False,
) -> None

Initialize a lazy mapped execution.

Parameters:

NameTypeDescription
sourceExecutionHandle[ResultT]Underlying execution handle.
transformCallable[[ResultT], MappedT]Result transformation.
snapshot_sourceboolAllow source snapshots only when the owner rebuilds the transformation on restore. Defaults to False.
Attributes
Methods
cancel
def cancel(self) -> None

Forward a cancellation request to the source execution.

metadata
def metadata(self) -> Mapping[str, Any]

Return source execution metadata.

Returns:

Mapping[str, Any] — Mapping[str, Any]: Source metadata.

raw_status
def raw_status(self) -> object

Return the source provider status.

Returns:

object — Provider-specific source status.

references
def references(self) -> tuple[ExecutionReference, ...]

Return source execution references.

Returns:

tuple[ExecutionReference, ...] — tuple[ExecutionReference, ...]: Source references.

result
def result(self, timeout: float | None = None) -> MappedT

Retrieve and transform the source result once.

Parameters:

NameTypeDescription
timeoutfloat | NoneMaximum local wait in seconds.

Returns:

MappedT — Cached transformed result.

Raises:

result_async
def result_async(self, timeout: float | None = None) -> MappedT

Retrieve and transform the source result asynchronously.

Parameters:

NameTypeDescription
timeoutfloat | NoneMaximum local wait in seconds.

Returns:

MappedT — Cached transformed result.

Raises:

snapshot
def snapshot(self) -> ExecutionSnapshot

Capture a source whose mapping is rebuilt by its owning executable.

Python callables are never serialized. Arbitrary mappings must supply an adapter-specific restoration recipe instead of losing conversion.

Returns:

ExecutionSnapshot — Source reconstruction structure.

Raises:

status
def status(self) -> JobStatus

Return the source execution status.

Returns:

JobStatus — Current mapped execution status.


QBraidExecutionHandle [source]

class QBraidExecutionHandle(ExecutionHandle[dict[str, int]])

Expose one qBraid sampling job through the shared lifecycle API.

Parameters:

NameTypeDescription
jobAnyqBraid QuantumJob or compatible object.
decoderCallable[[Any], dict[str, int]]Function converting the native result to normalized bitstring counts.
targetstr | NoneqBraid device identifier. Defaults to None.
timeoutfloat | NoneDefault provider wait timeout in seconds. Defaults to None.
poll_intervalfloatProvider polling interval in seconds.

Raises:

Constructor
def __init__(
    self,
    job: Any,
    decoder: Callable[[Any], dict[str, int]],
    *,
    target: str | None,
    timeout: float | None,
    poll_interval: float,
) -> None

Initialize a lazy qBraid execution handle.

Parameters:

NameTypeDescription
jobAnyNative qBraid job.
decoderCallable[[Any], dict[str, int]]Native result decoder.
targetstr | NoneqBraid device identifier.
timeoutfloat | NoneDefault provider wait timeout in seconds.
poll_intervalfloatPositive provider polling interval.

Raises:

Attributes
Methods
cancel
def cancel(self) -> None

Request best-effort cancellation from qBraid.

metadata
def metadata(self) -> Mapping[str, Any]

Return native qBraid job metadata when available.

Returns:

Mapping[str, Any] — Mapping[str, Any]: Provider metadata, or an empty mapping.

raw_status
def raw_status(self) -> object

Return the native qBraid status value.

Returns:

object — Provider status enum or string.

references
def references(self) -> tuple[ExecutionReference, ...]

Return the qBraid job identifier when the SDK exposes one.

Returns:

tuple[ExecutionReference, ...] — tuple[ExecutionReference, ...]: One qBraid reference, or an empty tuple for jobs without a stable identifier.

result
def result(self, timeout: float | None = None) -> dict[str, int]

Wait for and decode the qBraid result once.

Parameters:

NameTypeDescription
timeoutfloat | NoneMaximum wait in seconds. None uses the executor-configured timeout.

Returns:

dict[str, int] — dict[str, int]: Normalized big-endian bitstring counts.

Raises:

status
def status(self) -> JobStatus

Return the normalized qBraid job status.

Returns:

JobStatus — Current provider-independent state.


QBraidExecutor [source]

class QBraidExecutor(QuantumExecutor['QuantumCircuit'])

Quantum executor that runs Qiskit circuits on qBraid-supported devices.

This executor implements the QuantumExecutor[QuantumCircuit] contract, allowing ExecutableProgram.sample(), measured run(), and expectation-value run() to work with any qBraid-accessible backend.

The estimate() method uses a counts-based measurement approach. It only supports circuits with num_clbits == 0 (no pre-existing classical bits). Circuits with existing classical bits are rejected with an ExecutionError to prevent silent wrong results caused by qBraid’s counts normalization removing register separators.

Endian convention:

execute() returns canonical Qiskit-style bitstring keys after normalization. Keys are big-endian classical-bit strings: the leftmost character is the highest classical-bit index and the rightmost character is classical bit 0. QBraidExecutor never reverses or permutes the bit order; normalization only removes spaces and zero-pads under-width keys.

estimate() uses the same bitstring convention when reconstructing expectation values from counts. Since it applies measure_all() to a circuit with no pre-existing classical bits, classical bit i measures qubit i. Therefore, in estimate() the rightmost count character corresponds to qubit 0 and the leftmost character to the highest qubit index.

Parameters:

NameTypeDescription
deviceAny | NoneA pre-configured qBraid QuantumDevice. Mutually exclusive with device_id, provider, and api_key.
device_idstr | NoneqBraid device identifier (e.g., "qbraid_qir_simulator").
providerAny | NoneA QbraidProvider instance for device lookup.
api_keystr | NoneqBraid API key, used to create a QbraidProvider when provider is not given.
expval_shotsintNumber of shots for each basis-rotation circuit in estimate(). Defaults to 4096.
timeoutint | NoneTimeout in seconds for wait_for_final_state(). None means wait indefinitely.
poll_intervalintPolling interval in seconds for wait_for_final_state(). Defaults to 5.
run_kwargsdict[str, Any] | NoneExtra keyword arguments forwarded to device.run(). Must not contain "shots" — use the shots parameter of execute() instead.

Raises:

Example (device_id + api_key)::

executor = QBraidExecutor(
    device_id="qbraid_qir_simulator",
    api_key="your-api-key",
)

Example (pre-configured device)::

from qbraid import QbraidProvider
provider = QbraidProvider(api_key="...")
device = provider.get_device("qbraid_qir_simulator")
executor = QBraidExecutor(device=device)
Constructor
def __init__(
    self,
    device: Any | None = None,
    *,
    device_id: str | None = None,
    provider: Any | None = None,
    api_key: str | None = None,
    expval_shots: int = 4096,
    timeout: int | None = None,
    poll_interval: int = 5,
    run_kwargs: dict[str, Any] | None = None,
) -> None

Initialize qBraid device access and execution policy.

Parameters:

NameTypeDescription
deviceAny | NonePre-configured qBraid device. Mutually exclusive with identifier and credential arguments.
device_idstr | NoneqBraid device identifier. Defaults to None.
providerAny | NoneProvider used to resolve device_id. Defaults to None.
api_keystr | NoneAPI key used when constructing a provider. Defaults to None.
expval_shotsintPositive shots per expectation basis group. Defaults to 4096.
timeoutint | NoneDefault result wait timeout in seconds. Defaults to no timeout.
poll_intervalintPositive provider polling interval in seconds. Defaults to five.
run_kwargsdict[str, Any] | NoneAdditional qBraid submission options. Defaults to None.

Raises:

Attributes
Methods
bind_parameters
def bind_parameters(
    self,
    circuit: 'QuantumCircuit',
    bindings: dict[str, Any],
    parameter_metadata: ParameterMetadata,
) -> 'QuantumCircuit'

Bind parameter values to the Qiskit circuit.

Uses the same indexed-binding semantics as QiskitExecutor.

Parameters:

NameTypeDescription
circuit'QuantumCircuit'The parameterized circuit.
bindingsdict[str, Any]Dict mapping parameter names to values.
parameter_metadataParameterMetadataMetadata about circuit parameters.

Returns:

'QuantumCircuit' — New circuit with parameters bound.

estimate
def estimate(
    self,
    circuit: 'QuantumCircuit',
    hamiltonian: 'qm_o.Hamiltonian',
    params: Sequence[float] | None = None,
) -> float

Estimate the expectation value of a Hamiltonian using counts.

This method decomposes the Hamiltonian into Pauli terms, groups them by measurement basis, applies basis-rotation gates, and reconstructs the expectation value from measurement counts.

Only circuits with num_clbits == 0 are supported. Circuits with pre-existing classical bits are rejected because qBraid’s counts normalization removes register separators, making it impossible to reliably identify which measured bits correspond to which qubits.

Count bitstrings are interpreted using the same big-endian convention as Qiskit counts: the leftmost character is the highest measured qubit index and the rightmost character is qubit 0. This follows directly from calling measure_all() on a circuit whose classical-bit indices match its qubit indices.

Parameters:

NameTypeDescription
circuit'QuantumCircuit'The state-preparation circuit (no measurements).
hamiltonian'qm_o.Hamiltonian'The Hamiltonian whose expectation value is computed.
paramsSequence[float] | NoneOptional parameter values for parametric circuits. Values are bound positionally in Qiskit circuit parameter order. If None, the circuit must already have all parameters bound.

Returns:

float — The estimated real-valued expectation value.

Raises:

execute
def execute(self, circuit: 'QuantumCircuit', shots: int) -> dict[str, int]

Execute circuit and return bitstring counts.

If the circuit has no classical bits, measure_all() is added automatically (on a copy).

Returned keys use canonical Qiskit-style big-endian classical-bit order: the leftmost character is the highest classical-bit index and the rightmost character is classical bit 0. execute() does not reinterpret those keys as qubit-ordered strings.

Parameters:

NameTypeDescription
circuit'QuantumCircuit'The quantum circuit to execute.
shotsintNumber of measurement shots.

Returns:

dict[str, int] — Dictionary mapping canonical big-endian classical-bit strings dict[str, int] — to counts.

submit_estimate
def submit_estimate(self, request: EstimateRequest['QuantumCircuit']) -> ExecutionHandle[float]

Submit counts-based expectation tasks without waiting.

Parameters:

NameTypeDescription
requestEstimateRequest[QuantumCircuit]Circuit invocation, Hamiltonian, and optional shot policy.

Returns:

ExecutionHandle[float] — ExecutionHandle[float]: Lazy aggregate expectation handle.

Raises:

submit_sample
def submit_sample(
    self,
    request: SampleRequest['QuantumCircuit'],
) -> ExecutionHandle[dict[str, int]]

Submit qBraid sampling without waiting for the remote result.

Parameters:

NameTypeDescription
requestSampleRequest[QuantumCircuit]Circuit invocation and requested shot count.

Returns:

ExecutionHandle[dict[str, int]] — ExecutionHandle[dict[str, int]]: Lazy qBraid sampling handle.

Raises:


SampleRequest [source]

class SampleRequest(Generic[CircuitT])

Describe one sampling execution.

Parameters:

NameTypeDescription
invocationCircuitInvocation[CircuitT]Circuit and runtime inputs.
shotsintNumber of requested samples.

Raises:

Constructor
def __init__(self, invocation: CircuitInvocation[CircuitT], shots: int) -> None
Attributes

ShotBased [source]

class ShotBased

Request a shot-based expectation value.

Parameters:

NameTypeDescription
shotsintPositive number of measurement shots.

Raises:

Constructor
def __init__(self, shots: int) -> None
Attributes

TargetPrecision [source]

class TargetPrecision

Request an expectation value at a provider target precision.

Parameters:

NameTypeDescription
precisionfloatPositive absolute target precision.

Raises:

Constructor
def __init__(self, precision: float) -> None
Attributes