uniqc.compile.policy module

Per-platform submission policy: basis gates, language, compile dispatch.

This module is the single source of truth for “what does each cloud platform expect from a circuit before we hand it over”. Two pieces of policy live here:

  • PLATFORM_BASIS_GATES — the gate set we compile to before submission on each platform. For superconducting CN-style platforms (originq, quark, tianyan, logicalqubit) we use ("CZ", "SX", "RZ"). For IBM we defer to the backend’s advertised basis_gates (read from BackendInfo.extra ["basis_gates"]) and fall back to qiskit’s defaults if missing.

  • PLATFORM_SUBMIT_LANGUAGE — the IR string each adapter actually sends on the wire. OriginIR for OriginQ (pyqpanda3 path), TianYan (translated to QCIS by the adapter) and LogicalQubit (translated to an lqcloud circuit by the adapter); QASM2 for qiskit / quark.

The high-level helper compile_for_backend() glues the policy and the existing uniqc.compile.compile() function together, returning a circuit that is ready to submit (gate set + language) for the given backend.

uniqc.compile.policy.PLATFORM_BASIS_GATES = {'dummy': (), 'ibm': (), 'logicalqubit': ('CZ', 'SX', 'RZ'), 'originq': ('CZ', 'SX', 'RZ'), 'quark': ('CZ', 'SX', 'RZ'), 'tianyan': ('CZ', 'SX', 'RZ')}

Default basis gate set per platform (uppercase, OriginIR/qiskit names). Empty tuple means “no opinion — defer to the backend’s own advertisement”.

uniqc.compile.policy.PLATFORM_SUBMIT_LANGUAGE = {'dummy': 'OriginIR', 'ibm': 'QASM2', 'logicalqubit': 'OriginIR', 'originq': 'OriginIR', 'quark': 'QASM2', 'tianyan': 'OriginIR'}

The wire language each adapter submits with.

uniqc.compile.policy.compile_for_backend(circuit, backend_info, *, level=2, output_format='circuit')[source]

Compile circuit so that it satisfies backend_info.

For originq, quark, tianyan and logicalqubit this lowers the circuit to cz + sx + rz (the supported superconducting basis) using the existing uniqc.compile.compile() pipeline. For ibm, the basis set is read from the backend’s advertised basis_gates (typically ("CZ", "SX", "RZ", "X") plus IBM-specific extras). When the backend does not advertise a basis set, qiskit’s default is used.

Parameters:
  • circuit – The input circuit. Accepts a uniqc.Circuit, an OriginIR string, an OpenQASM 2.0 string, or a qiskit.QuantumCircuit. Normalization is delegated to uniqc.compile.compile().

  • backend_info – Target backend descriptor. Topology and num_qubits are used by the routing pass.

  • level – Optimization level (0–3) for the underlying transpiler. Default: 2.

  • output_format"circuit" (default) returns a Circuit; "originir" returns an OriginIR string; "qasm" returns an OpenQASM 2.0 string; "auto" matches the detected input format.

Returns:

The compiled circuit in the requested format.

Return type:

Circuit | str

uniqc.compile.policy.resolve_basis_gates(backend, backend_info=None)[source]

Return the basis gate set we will compile to before submission.

Resolution order:
  1. Platform default from PLATFORM_BASIS_GATES if non-empty.

  2. backend_info.extra["basis_gates"] if non-empty.

  3. Empty tuple — caller should treat this as “skip compile”.

uniqc.compile.policy.resolve_submit_language(backend)[source]

Return the wire language for backend or None if unknown.