GateCompiler
- class GateCompiler(gateset, config=None)
Compile Qiskit circuits into a gate set’s native representation.
GateCompileris the main user-facing entry point for gate-level compilation. It binds a targetGateSetand aCompilerConfig, and compiles circuits withcompile(). The configuration selects the compilation path: aSynthesisConfigsubclass (AdaptiveConfig,TreeSearchConfig,ErrorAwareAdaptiveConfig,ErrorAwareTreeSearchConfig) synthesizes the circuit’s unitary with thequasarcppbackend, while aQiskitConfigcompiles it through the Qiskit transpiler.- Parameters:
gateset (
GateSet) – Target native gate set.config (
CompilerConfig|None) – Compilation configuration, given as aCompilerConfigsubclass, orNonefor the default adaptive configuration. Usefrom_dict()to build aGateCompilerfrom a plain configurationdictinstead.
- Raises:
ValidationError – If
gatesetis not aGateSet.ConfigError – If
configis neither aCompilerConfignorNone.
from qiskit import QuantumCircuit import quasar circuit = QuantumCircuit(2) circuit.h(0) circuit.cx(0, 1) compiler = quasar.GateCompiler(quasar.CROTGateSet(2)) native = compiler.compile(circuit) error = compiler.compilation_error(circuit, native) qiskit_compiler = quasar.GateCompiler(quasar.CROTGateSet(2), config=quasar.QiskitConfig()) native_via_qiskit = qiskit_compiler.compile(circuit)
Note
compile()andcompilation_error()are the two calls most users need (see the example above).from_dict(),generate_topology(),load_qasm_circuit(), andbuild_pauli_readout_circuit()are lower-level supporting utilities – construction from a plain config dict, topology introspection, and a readout helper used for characterization rather than the main compile workflow.
Attributes
Active compilation configuration. |
|
Target native gate set bound to this compiler. |
Methods
|
Return a compiled gate-level circuit's error against its source circuit. |
|
Compile a Qiskit circuit into the target gate set's native operations. |
|
Compile the circuit preparing a state on the device. |
|
Estimate how far a compiled circuit sits from its target on hardware. |
|
Return the error of a compiled preparation against the state it should produce. |
Low-level API methods
|
Construct a gate-set-native readout circuit for a requested Pauli string. |
|
Construct a |
Return the connectivity edges of the target gate set. |
|
|
Load an OpenQASM 2 circuit with QUASAR native-gate extensions. |