uniqc.backend_adapter.task.adapters.originq_adapter module

OriginQ Cloud backend adapter.

Submits OriginIR circuits to the OriginQ Cloud service using pyqpanda3.

Installation:

pip install unified-quantum[originq]

class uniqc.backend_adapter.task.adapters.originq_adapter.OriginQAdapter(backend_name=None)[source]

Bases: QuantumAdapter

Adapter for OriginQ Cloud (本源量子云) using pyqpanda3.

This adapter uses pyqpanda3’s QCloudService API for cloud task submission, which simplifies configuration by only requiring an API key.

Note

The pyqpanda3 package is required for this adapter. Install with: pip install unified-quantum[originq]

Parameters:

backend_name (str | None)

dry_run(originir, *, shots=1000, **kwargs)[source]

Dry-run validation for OriginQ Cloud backends.

Validates offline by calling translate_circuit() which internally calls convert_originir_string_to_qprog() — a purely local pyqpanda3 call. The pyqpanda3 compiler will reject unknown gates.

This method makes NO network calls.

Note

Any dry-run success followed by actual submission failure is a critical bug. Please report it at the UnifiedQuantum issue tracker.

Parameters:
Return type:

DryRunResult

get_available_backends()[source]

Return only backends that are currently available.

Hardware backends may become unavailable due to maintenance or queue congestion. Use this method to get a curated list of backends that can accept jobs right now.

Simulator backends (full_amplitude, partial_amplitude, single_amplitude) are always considered available.

Returns:

List of backend dicts (same format as list_backends()) filtered to available == True.

Return type:

list[dict[str, Any]]

get_chip_characterization(backend_name)[source]

Return per-qubit and per-pair calibration data for a hardware backend.

Parameters:

backend_name (str) – Backend name, e.g. "origin:wuyuan:wk180", "originq:WK_C180", or the bare chip name "WK_C180". The chip name is extracted by stripping any origin: or originq: prefix because QCloudBackend.chip_info() only accepts bare chip names.

Returns:

None if the backend is not found or chip info is unavailable.

Return type:

ChipCharacterization or None

is_available()[source]

Check if the OriginQ adapter is available (credentials configured).

Returns:

True if api_key is configured.

Return type:

bool

list_backends()[source]

Return raw OriginQ Cloud backend metadata.

For each hardware backend (non-simulator), fetches chip_info() to populate qubit count, topology, fidelity, and coherence data.

Returns:

name, available, num_qubits, topology (list of [u, v] edge pairs), available_qubits, avg_1q_fidelity, avg_2q_fidelity, avg_readout_fidelity, coherence_t1, coherence_t2.

Return type:

List of dicts with keys

property max_native_batch_size: int

OriginQ native batch limit, taken from originq.task_group_size.

Configurable via ~/.uniqc/uniqc.yml. Default 200. uniqc slices any user batch larger than this into multiple platform jobs (one shard per slice) and aggregates the results transparently behind a single uqt_* task id.

name: str = 'originq'
query(taskid)[source]

Query a single task’s status.

Parameters:

taskid (str) – Task ID to query.

Returns:

taskid, status, result (if completed)

Return type:

dict with keys

query_batch(taskids)[source]

Query multiple tasks and merge results.

Parameters:

taskids (str | list[str]) – List of task IDs to query.

Returns:

Combined result dict with status and merged results.

Return type:

dict[str, Any]

query_sync(taskid, interval=2.0, timeout=60.0, retry=5)[source]

Poll task status until completion or timeout.

Parameters:
  • taskid (str | list[str]) – Task ID or list of task IDs.

  • interval (float) – Polling interval in seconds.

  • timeout (float) – Maximum wait time in seconds.

  • retry (int) – Number of retries on query failure.

Returns:

List of result dicts.

Raises:
Return type:

list[dict[str, Any]]

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

Submit a single circuit to OriginQ Cloud.

Parameters:
  • circuit (str) – OriginIR format circuit string.

  • shots (int) – Number of measurement shots.

  • **kwargs (Any) – Additional options: - backend_name: Backend name (e.g., ‘origin:wuyuan:d5’) - circuit_optimize: Enable circuit optimization (default: True) - measurement_amend: Enable measurement amendment (default: False) - auto_mapping: Enable automatic qubit mapping (default: False)

Returns:

Task ID string.

Return type:

str

submit_batch(circuits, *, shots=1000, native_batch=True, **kwargs)[source]

Submit a batch of circuits.

OriginQ Cloud (pyqpanda3) supports a native batch mode where many circuits are scheduled under a single job_id via QCloudBackend.run_instruction([instr1, instr2, ...], shots, options). That single job spends only one position in the queue, so a 100-circuit batch can be tens of times faster end-to-end than submitting 100 jobs.

Parameters:
  • circuits (list[str]) – List of OriginIR format circuit strings.

  • shots (int) – Number of measurement shots applied to every circuit.

  • native_batch (bool) – When True (default) on a hardware chip backend, use pyqpanda3’s native batch (returns a single job_id packed in a one-element list). When False, submit each circuit individually (returns one job_id per circuit, preserving the legacy 0.0.11 behaviour).

  • **kwargs (Any) – Additional options (see submit()).

Returns:

  • [batch_job_id] — single-element list when native batch is used (one queue position, one task ID for the whole batch).

  • [id_0, id_1, ...] — N-element list when native_batch=False or for simulator backends that do not support native batching.

Return type:

list[str]

translate_circuit(originir)[source]

Convert OriginIR string to QProg using pyqpanda3.

Parameters:

originir (str) – OriginIR format circuit string.

Returns:

QProg object for pyqpanda3.

Return type:

Any