uniqc.backend_adapter.task.adapters.base module¶
Base adapter interface for quantum cloud backends.
Every backend adapter must implement this interface, providing: 1. Translation from OriginIR string to the provider’s native circuit type. 2. Task submission via the provider’s Python SDK (not raw REST). 3. Task status query and result retrieval. 4. Dry-run validation without making any network calls.
The adapter layer replaces all direct requests REST calls within the
task modules. Each adapter is a stateful object that holds the provider
session / client and configuration.
Dry-run Validation¶
Every adapter implements dry_run(originir, shots, **kwargs) to validate
a circuit offline before submission. This checks:
OriginIR parses without error.
All gates are supported by the target backend.
Qubit count fits within the backend’s limits.
The native circuit object is structurally valid.
No cloud API calls are made. A dry-run success followed by actual submission failure is a critical bug — please report it at the issue tracker.
- class uniqc.backend_adapter.task.adapters.base.QuantumAdapter[source]¶
Bases:
ABCAbstract base class for quantum cloud backend adapters.
Subclass this for each backend (originq_cloud, quafu, ibm, …). Each adapter is instantiated once per task module and reused.
- Class attributes:
name: Adapter identifier. max_native_batch_size: Maximum number of circuits the adapter
can pack into a single platform-side job. uniqc relies on this to auto-shard oversized batches; see
uniqc.backend_adapter.task_manager.submit_batch(). The base default is1(no native batching, one platform job per circuit). Adapters that natively support grouped submission override this — seeOriginQAdapter(200, configurable viaoriginq.task_group_size) andQiskitAdapter(100).
- dry_run(originir, *, shots=1000, **kwargs)[source]¶
Validate a circuit without making network calls.
Subclasses must implement this method. The default implementation raises NotImplementedError.
Validation checklist (where determinable offline): 1. OriginIR parses without error. 2. All gates are supported by the target backend. 3. Qubit count fits within the backend’s limits. 4. The native circuit object is structurally valid.
This method must NOT make any cloud API calls. All checks must be local-only.
- Parameters:
- Returns:
DryRunResult with success=True/False, details, warnings, and metadata.
- Raises:
NotImplementedError – Subclasses must implement this method.
- Return type:
Note
Any dry-run success followed by actual submission failure is a critical bug. Please report it at the UnifiedQuantum issue tracker.
- is_available()[source]¶
Return True if the required packages / credentials are configured.
Defaults to
Falseso that subclasses must explicitly opt-in, avoiding the risk of an unconfigured adapter incorrectly reporting availability.- Return type:
- list_backends()[source]¶
Return raw backend metadata from the platform API.
Returns a list of dicts with at least a
"name"key. The dict shape is platform-specific; the caller is responsible for normalising the data intoBackendInfoobjects.
- abstractmethod query(taskid)[source]¶
Query a single task’s status and result.
- Parameters:
taskid (str) – Task identifier.
- Returns:
status:'success'|'failed'|'running'result: execution result (present when status is'success'or'failed')
- Return type:
dict with keys
- abstractmethod query_batch(taskids)[source]¶
Query multiple tasks’ status and merge results.
Overall status is the worst case:
'failed'>'running'>'success'.
- abstractmethod submit(circuit, *, shots=1000, **kwargs)[source]¶
Submit a circuit to the backend and return a task ID.