Skip to main content
On error-corrected hardware you don’t run gates directly on physical qubits. Each logical qubit is a patch of many physical qubits protected by a surface code, and every logical operation is carried out as a lattice-surgery procedure — patches merge, interact, and split across repeated error-correction (syndrome) cycles to realize the gate. Routing is the step that turns your logical circuit into this concrete, fault-tolerant execution plan: route_circuit works out where and when each operation happens on the surface-code lattice.

What routing produces

The plan lives on a 3-D lattice:
  • the two spatial axes are the grid of surface-code patches — your logical qubits and the free space they use to interact;
  • the third axis is time, measured in error-correction cycles.
Each operation becomes a space-time volume in this lattice. The visualization draws these as cubes connected by pipes — the pipes are the channels along which patches merge and split to carry out gates. T gates get special treatment: they consume a magic state produced by a cultivation (distillation) routine, which routing schedules alongside the Clifford operations. The output is a TopologicalProgram — a complete, cycle-by-cycle layout of the circuit on the lattice, together with summary statistics. Its size (how many patches, over how many cycles) is the real cost of running the circuit fault-tolerantly, and it’s what the later stages visualize and turn into an error estimate. Finding a good layout is a hard combinatorial problem; the engine solves it pragmatically to scale to circuits well beyond what hand-routing allows.
For an interactive, visual walkthrough of the routed lattice, see the Fault Tolerance Engine overview.

Routing a circuit

Routing expects a transpiled Clifford+T circuit — the gate set surface codes implement natively. Build and synthesize a model as usual, then export it to OpenQASM with a FaultTolerantTranspilationConfig so the circuit is decomposed into Clifford+T, and pass the resulting QASM to route_circuit:
The resulting program is a TopologicalProgram. Next, you can visualize it or estimate its total error.