QuantumAtlas

Gates & Circuits

Transpilation

The compiler step that rewrites a quantum circuit into the gates and qubit layout a specific device can run.

Definition

Transpilation is what happens between writing a quantum program and running it on real hardware. The circuit you write uses convenient abstract gates and assumes any two qubits can interact. A real chip has a limited set of native gates and connects only certain pairs of qubits, so a compiler must rewrite the program to match: swapping gates to the native set, choosing which physical qubits to use, and inserting moves where needed. The quality of this step can decide whether a result is useful or noise.

In depth

Mapping and routing are the expensive parts. The initial layout decides which logical qubits sit on which physical qubits, and a good choice puts qubits that interact often next to each other and avoids qubits with high error rates. Routing then inserts SWAP gates for the interactions that remain between distant qubits. Finding the optimal mapping is NP-hard, so compilers use heuristics such as SABRE and look-ahead search, and results can differ by factors of two or more in two-qubit gate count.

Optimization passes then clean up the result. They cancel adjacent inverse gates, merge consecutive single-qubit rotations into one, commute gates to expose cancellations, and resynthesize blocks of gates into shorter equivalent sequences. On noisy devices these savings matter greatly: since two-qubit gates have error rates around one in a thousand or worse, removing a few hundred gates can improve the fidelity of the final answer by a large factor.

Modern toolchains add noise-aware features. They read calibration data about which qubits and couplings are best today and bias layout toward them, and they add error suppression such as dynamical decoupling and gate twirling. In error-corrected machines, transpilation also includes steps like converting arbitrary rotations to Clifford plus T and scheduling lattice surgery operations.

Technical Definition

Transpilation is a sequence of compiler passes: decomposing gates into the device's native basis, mapping logical qubits to physical qubits, routing two-qubit gates by inserting SWAPs for connectivity, and optimizing the circuit by cancelling gates and merging rotations. The objective is usually to minimize two-qubit gate count and depth, adjusted for per-qubit error rates.

Visual Explanation: An Analogy

Think of translating a recipe for a kitchen with a full set of tools into one for a camp stove with a single pan. The meal is the same, but the steps change, and a good translator saves time and avoids burning the food.

Key facts

ItemDetail
Main stepsGate decomposition, layout, routing, optimization, scheduling
Typical heuristicSABRE routing is widely used in open-source toolchains
ObjectiveMinimize two-qubit gates and depth, weighted by error rates
ComplexityOptimal layout and routing are NP-hard, so heuristics are standard
ToolsQiskit, Cirq, tket, and vendor compilers all include transpilers

Where the idea comes from

Compilation for quantum circuits began as hand optimization in the 1990s and became a field of its own in the 2010s, when the first cloud devices with fixed connectivity appeared. Qubit mapping algorithms, the SABRE heuristic of Li, Ding, and Xie in 2019, and tools such as Qiskit's transpiler and Quantinuum's tket made automatic compilation standard.

Real-World Use Cases

  • Preparing any algorithm to run on a specific superconducting, ion, or atom device.
  • Reducing two-qubit gate counts to improve fidelity on noisy hardware.
  • Choosing the best qubits on a chip based on daily calibration data.
  • Benchmarking compilers and hardware together, since performance depends on both.

How it differs from related ideas

  • Transpilation targets a particular device, while high-level compilation turns algorithm descriptions into circuits.
  • Classical compilers optimize for speed and memory, and quantum transpilers optimize for fidelity and gate counts.
  • Pulse-level control goes one step further and tunes the analog pulses that realize each gate.

Common Misconceptions

  • Transpilation does not change the answer the circuit computes. It changes how the circuit is executed.
  • A bigger chip does not always make circuits easier to run. Routing quality and error rates matter as much as qubit count.
  • The transpiler cannot fix a circuit that is too deep for the hardware's coherence.

Frequently asked questions

What does a quantum transpiler do?

It rewrites a circuit into the native gates and connectivity of a particular quantum device, and optimizes it to reduce gate count and error.

Why does the same circuit give different results on different devices?

Because the transpiled circuit has different gate counts and uses different qubits with different error rates.

What is routing?

The step that inserts SWAP gates so that qubits that need to interact are adjacent on the chip.

Related Terms

Keep exploring

← Back to the dictionary