Computing Library › Quantum Logic Gates
Quantum Logic Gates

Quantum Transpilation

The full compiler pass that rewrites an abstract circuit into one a specific device can run efficiently.

What transpilation does

Transpilation converts a device-independent circuit into an equivalent circuit that respects a target machine's constraints: its native gate set, its qubit connectivity graph, and its timing and error characteristics. It is the quantum analogue of compiling source code down to a specific instruction set.

The main passes

Kronos motion — quantum verdict

Routing under connectivity limits

Most hardware connects only neighboring qubits. When a two-qubit gate is needed between distant qubits, the transpiler inserts SWAP gates to bring them adjacent — each SWAP costing three CNOTs. Minimizing inserted SWAPs is an NP-hard problem, so transpilers use heuristics like SABRE that balance quality against compile time.

Optimization levels

Compilers expose optimization levels that trade compile effort for circuit quality. Low levels do minimal rewriting; high levels run repeated commutation, gate fusion into single U3 blocks, and KAK-based two-qubit resynthesis. The best level depends on whether compile time or circuit fidelity dominates the workload.

python
# conceptual Qiskit-style call
# from qiskit import transpile
# tqc = transpile(qc, backend, optimization_level=3)
def swap_cost(distance):
    return 3*max(0, distance-1)  # CNOTs to route across a line

Noise-aware choices

Because error rates vary across a chip, a transpiler can map critical two-qubit gates onto the highest-fidelity physical links and steer around dead qubits. This noise-aware layout often matters more than raw gate count for near-term devices. See native gate sets and gate synthesis.