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:
QuantumAdapterAdapter 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:
- 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.
- 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 anyorigin:ororiginq:prefix becauseQCloudBackend.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:
- 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. Default200. uniqc slices any user batch larger than this into multiple platform jobs (one shard per slice) and aggregates the results transparently behind a singleuqt_*task id.
- 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_sync(taskid, interval=2.0, timeout=60.0, retry=5)[source]¶
Poll task status until completion or timeout.
- Parameters:
- Returns:
List of result dicts.
- Raises:
TimeoutError – If timeout is reached.
RuntimeError – If task fails or retry exhausted.
- Return type:
- 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:
- 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_idviaQCloudBackend.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 singlejob_idpacked in a one-element list). WhenFalse, submit each circuit individually (returns onejob_idper circuit, preserving the legacy 0.0.11 behaviour).
- 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 whennative_batch=Falseor for simulator backends that do not support native batching.
- Return type: