Transpilation Passes
A transpiler turns an abstract circuit into one a specific device can run. It does this not in a single sweep but as a pipeline of passes — small, composable transformations, each solving one sub-problem, run in a deliberate order by a pass manager. Understanding the pipeline explains why the earlier lessons (decomposition, routing, simplification) are the pieces, not the whole.
Two kinds of pass
- Transformation passes rewrite the circuit: decompose a gate, insert a swap, cancel an inverse pair, merge rotations.
- Analysis passes compute properties without changing the circuit: depth, gate counts, the current logical-to-physical mapping, commutation structure. Their results are written to a shared property set that later transformation passes consult.
The pass manager threads the property set through the sequence and can loop a group of passes until a fixed point (no further change) is reached.
A representative pipeline
A typical pipeline runs roughly in this order:
- Unrolling / decomposition — expand high-level gates into a working set of one- and two-qubit gates.
- Initial layout — choose which physical qubit each logical qubit starts on, given the coupling map.
- Routing — insert SWAPs so every two-qubit gate lands on a coupled edge.
- Basis translation — rewrite all gates into the device's native basis.
- Optimization — cancellation, rotation merging, and commutation-based peephole rewrites to shrink gate count and depth.
- Scheduling — assign start times, insert delays/dynamical-decoupling, and account for gate durations.
Optimization levels
Production transpilers expose optimization levels that trade compile time for output quality: a low level does a single quick pass over each stage, while a high level enables aggressive resynthesis, repeated optimization loops, and stochastic layout search with the best result kept. Because routing and layout are heuristic, higher levels often run the whole pipeline several times from different random seeds and select the lowest-cost circuit.
Equivalence is the invariant
Every transformation pass must preserve the circuit's unitary (up to global phase) and its measurement semantics. The pipeline may change how the computation is expressed — different gates, different qubits, different depth — but never what it computes. That invariant is what lets passes be reordered, looped, and swapped out while still producing a circuit that is faithful to the programmer's intent.
The takeaway
Transpilation is not one algorithm but an orchestrated sequence of focused passes — decompose, lay out, route, translate to the native basis, optimize, schedule — coordinated by a pass manager that shares analysis results and iterates to a fixed point, all while preserving the unitary the programmer wrote.
Sign in on the full site to ask questions and join the discussion.