uniqc.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.

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.

class uniqc.task.adapters.base.QuantumAdapter[source]#

Bases: ABC

Abstract 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.

is_available()[source]#

Return True if the required packages / credentials are configured.

Defaults to False so that subclasses must explicitly opt-in, avoiding the risk of an unconfigured adapter incorrectly reporting availability.

Return type:

bool

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 into BackendInfo objects.

Raises:

Exception – If the platform API call fails (auth error, network error, etc.). Subclasses should propagate the original exception type so callers can distinguish auth failures from network failures.

Return type:

list[dict[str, Any]]

name: str = 'base'#
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'.

Parameters:

taskids (list[str]) – List of task identifiers.

Returns:

status, result (list of results).

Return type:

dict with keys

abstractmethod submit(circuit, *, shots=1000, **kwargs)[source]#

Submit a circuit to the backend and return a task ID.

Parameters:
  • circuit (Any) – Provider-native circuit object (result of translate_circuit).

  • shots (int) – Number of measurement shots.

  • **kwargs (Any) – Additional provider-specific parameters (e.g. chip_id, auto_mapping, circuit_optimize).

Returns:

Task ID assigned by the backend.

Return type:

str

abstractmethod submit_batch(circuits, *, shots=1000, **kwargs)[source]#

Submit multiple circuits as a single batch.

Parameters:
  • circuits (list[Any]) – List of provider-native circuit objects.

  • shots (int) – Number of measurement shots.

  • **kwargs (Any) – Additional provider-specific parameters.

Returns:

Task IDs (one per circuit), or a single task ID if the backend returns a group ID.

Return type:

list[str]

abstractmethod translate_circuit(originir)[source]#

Translate an OriginIR circuit string to the provider’s native circuit type.

Parameters:

originir (str) – Circuit in OriginIR format.

Returns:

Provider-specific circuit object.

Return type:

Any