As of 2026-07-10Level 3

Transpilation and Routing

Transpilation rewrites a quantum circuit into the native gate set a chip actually supports; routing maps logical qubits onto physical qubits under limited connectivity, inserting SWAP gates where direct connections are missing.

What it means

A circuit written with familiar gates like H and CX usually cannot run directly on hardware.Each chip supports only a native gate set — and this set is not fixed chip physics but is defined by calibration, so the same chip may support different gates on different days, and even different gates per qubit.Transpilation translates between languages at the same abstraction level (like TypeScript to JavaScript), in contrast to compilation, which lowers to a deeper level (like Java to bytecode).Because real chips have limited connectivity, a two-qubit gate between unconnected qubits is physically impossible: the router inserts SWAP gates to walk states across the chip, and each SWAP adds extra two-qubit gates, time, and error, so routers minimize detours.Optimizers also cancel redundant gates — two adjacent H gates vanish — while a barrier, a scheduler directive rather than a mathematical operation, forbids reordering across it.Good transpilers are calibration-aware: they read today's per-qubit coherence times and per-connection error rates when choosing the mapping, and they must remember that mapping to translate measurement results back to the original logical qubits.

Everyday analogy

I wrote a letter using the words H and CX, but this chip only understands the words PRX and CZ — so the letter must be rewritten in words the chip knows. That same-level translation is transpiling (like TypeScript → JavaScript), unlike compiling, which goes DOWN a level (like Java → bytecode). And when qubits Q0 and Q1 are not directly wired, their states must be walked over via SWAP stepping-stones — each SWAP costs time and errors, so the router minimizes the detour. A barrier is a fence telling the clever cleaner (the optimizer, who deletes two adjacent H gates because they cancel): do not clean past this line.
Etymology hook: transpile = trans- (Latin, 'across') + compile, from Latin compilare, 'to heap together' — a sideways translation, not a downward one. Routing comes from French route, from Latin rupta via, 'a broken-through road' — the router literally breaks a path across the chip. SWAP comes from Middle English swappen, 'to strike, to exchange' — two qubit states struck into each other's places.

Common misconceptions

  • All qubits are NOT equal — coherence times and error rates differ per qubit and per connection (two-qubit gate fidelity varies by pair), and these values drift daily, so transpilers must read today's calibration data rather than assume a uniform chip.
  • 'Logical qubit' has two meanings — a circuit-level qubit in your program versus an error-corrected qubit built from many physical qubits. In the transpilation context it means the former: one qubit in your circuit, before mapping to hardware.
  • A barrier is not a mathematical operation — it is a scheduler directive, like a mutex guarding against reordering in multithreaded code. It changes what the optimizer may do, not the quantum state.

Key takeaways

  • Native gate sets are defined by calibration, not fixed chip physics — the same chip can support different gates on different days and per qubit.
  • Every SWAP inserts extra two-qubit gates, meaning more time and more error — routers exist to minimize SWAP count.
  • Qiskit offers optimization levels 0–3; gate cancellation (two adjacent H gates removed) is a typical optimization, and barriers control where it may act.
  • As of 2026, Qiskit is used by roughly 70% of quantum developers and more than 4 trillion circuits have been run — transpiler quality is an active research battleground.

Check your understanding

On a chip where physical qubits Q0 and Q1 have no direct connection, why can't cx(0,1) run directly, and what does the transpiler do about it?

  1. A.The CX gate is not universal, so it must be replaced by single-qubit gates
  2. B.Two-qubit gates act on the coupler joining a connected pair, so the router inserts SWAP gates to move the states onto connected qubits
  3. C.Q0 and Q1 always have different frequencies, making any interaction physically impossible forever
  4. D.The transpiler measures both qubits and reconstructs the state on connected qubits
Show the answer

Answer: B. Two-qubit gates act on the coupler joining a connected pair, so the router inserts SWAP gates to move the states onto connected qubits

Why: Two-qubit gates operate on the coupler between physically connected qubits. Without a direct connection, the router inserts SWAP gates to walk the states to a connected pair — each SWAP costing extra two-qubit gates, time, and error, which is why routers minimize them.

What is a barrier in a quantum circuit?

  1. A.A unitary gate that blocks the evolution of the quantum state
  2. B.A measurement that separates two stages of the circuit
  3. C.A scheduler directive that forbids the optimizer from reordering or canceling gates across it
  4. D.A hardware component that isolates qubits from cross-talk
Show the answer

Answer: C. A scheduler directive that forbids the optimizer from reordering or canceling gates across it

Why: A barrier is not a mathematical operation. Like a mutex in multithreaded code, it tells the transpiler's optimizer not to reorder or cancel operations across the line — for example, to preserve two adjacent H gates that would otherwise be deleted.

Builds on

Core concept is standard practice, but native gate sets, vendor tooling and ecosystem stats (Qiskit adoption, optimization levels) evolve; graded timebound as of source date. Qiskit ~70% / 4T-circuit stats re-verified 2026-07-10 against IBM Newsroom (2026-06-02); the 70% figure originates from the Unitary Fund 2023 OSS survey (self-selected sample).

Learn it hands-on

This concept is part of a 46-level curriculum with an interactive simulator and Lumen, a tutor whose answers are verified before you see them. Levels 1–5 are free.