compilation_error
- GateCompiler.compilation_error(circuit, compiled)
Return a compiled gate-level circuit’s error against its source circuit.
Note
This builds the dense \(2^n \times 2^n\) unitary of both circuits (via
qiskit.quantum_info.Operator), so its cost grows exponentially in the qubit count. It is practical up to about 10 qubits.The two circuits may be passed in either order: both are turned into unitaries via
from_circuit()(which applies a circuit’s.layoutif it has one and is otherwise equivalent toOperator), and average gate fidelity is symmetric, socompilation_error(circuit, compiled)andcompilation_error(compiled, circuit)return the same value.- Parameters:
circuit (
QuantumCircuit) – One of the circuits to compare (typically the original circuit before gate-level compilation).compiled (
QuantumCircuit) – The other circuit (typically the compiled circuit returned bycompile()). Its.layout(a QiskitTranspileLayout) is consumed byfrom_circuit(), so any input/output qubit relabeling is undone transparently – a non-trivial layout is handled the same way as a transpiled circuit’s.
- Return type:
- Returns:
Compilation error between the two circuits (1 minus their average gate fidelity), with either circuit’s layout accounted for. 0 is a perfect match; larger is worse.
- Raises:
ValidationError – If a circuit holds a Pauli readout, a reset or a measurement.