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, quafu, quark) we use("CZ", "SX", "RZ"). For IBM we defer to the backend’s advertisedbasis_gates(read fromBackendInfo.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.OriginIRfor OriginQ (pyqpanda3 path) andQASM2for qiskit / quafu / 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: dict[str, tuple[str, ...]] = {'dummy': (), 'ibm': (), 'originq': ('CZ', 'SX', 'RZ'), 'quafu': ('CZ', 'SX', 'RZ'), 'quark': ('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: dict[str, str] = {'dummy': 'OriginIR', 'ibm': 'QASM2', 'originq': 'OriginIR', 'quafu': 'QASM2', 'quark': 'QASM2'}¶
The wire language each adapter submits with.
- uniqc.compile.policy.compile_for_backend(circuit, backend_info, *, level=2, output_format='circuit')[source]¶
Compile
circuitso that it satisfiesbackend_info.For
originq,quafuandquarkthis lowers the circuit tocz + sx + rz(the supported superconducting basis) using the existinguniqc.compile.compile()pipeline. Foribm, the basis set is read from the backend’s advertisedbasis_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 aqiskit.QuantumCircuit. Normalization is delegated touniqc.compile.compile().backend_info (BackendInfo) – Target backend descriptor. Topology and
num_qubitsare used by the routing pass.level (int) – Optimization level (0–3) for the underlying transpiler. Default: 2.
output_format (str) –
"circuit"(default) returns aCircuit;"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:
- uniqc.compile.policy.resolve_basis_gates(backend, backend_info=None)[source]¶
Return the basis gate set we will compile to before submission.
- Resolution order:
Platform default from
PLATFORM_BASIS_GATESif non-empty.backend_info.extra["basis_gates"]if non-empty.Empty tuple — caller should treat this as “skip compile”.
- Parameters:
backend (str | BackendInfo)
backend_info (BackendInfo | None)
- Return type:
- uniqc.compile.policy.resolve_submit_language(backend)[source]¶
Return the wire language for
backendorNoneif unknown.- Parameters:
backend (str | BackendInfo)
- Return type:
str | None