TopoLS: Lattice Surgery Compilation via Topological Program Transformations
Lattice surgery is a leading approach for implementing fault-tolerant logical operations in surface code quantum computing. Current compilers largely treat lattice surgery as a layout problem downstream of a gate-level circuit; this circuit-centric view hinders a substantial optimization opportunity: lattice surgery computations are topological programs whose semantics are determined by connectivity, so different concrete space–time realizations may implement the same computation while offering different space–time volumes. Circuit-centric compilers, however, commit to fixed realizations throughout the program. We tackle this problem by presenting TopoLS, a topology-centric compiler that uses ZX diagrams as the intermediate representation (IR) for automated lattice surgery compilation. Compiler transformations on this graph preserve its semantics, and the backend must produce a valid pipe diagram, i.e., a 3D space–time layout of the lattice surgery program, with the same semantics. TopoLS first simplifies the graph and slices it into layers, and then uses Monte Carlo Tree Search to place the graph’s nodes as cubes in a 3D grid and to route its edges as pipes. To scale to large circuits, TopoLS partitions the graph so that each search step routes a bounded number of connections. Across evaluated benchmarks, TopoLS reduces space–time volume by $46%$ on average over prior circuit-centric compilers, with improvements ranging from $25%$ to $90%$, while exhibiting strong empirical scalability on large benchmark families.