Quantum optimization experiments often use cost Hamiltonians containing pairwise interactions between binary decisions. A complete interaction graph gives a particularly clear example of the routing challenge: every logical qubit must interact with every other logical qubit in a cost layer.
A quantum processor with sparse connections cannot realize all of those logical interactions directly. Before evaluating a compiler on this workload, it is useful to understand a structured reference construction whose routing schedule follows from the graph itself.
A cost layer is a collection of commuting operations
For a weighted Ising model, write the pairwise part of the cost Hamiltonian as
HC = ∑i<j wijZi Zj.
The corresponding pairwise rotations in a QAOA cost layer commute. Their order can therefore change without changing the logical operation. This property permits a routing schedule that introduces each interaction whenever the relevant pair of logical qubits becomes adjacent.
Consider a physical path. Place the logical qubits in order along the path. In alternating rounds, swap neighboring qubits at even and odd positions. Over a complete sequence of n rounds on a path of n qubits, every pair of logical qubits becomes a swapping pair exactly once. Immediately before each swap, the pair is adjacent and can undergo its required interaction.
The following example constructs the pair schedule and verifies that every pair occurs once. It records the final logical order, which is reversed. It also checks that the edges of a smaller graph, here the path itself, appear among the scheduled pairs.
Illustration: standalone Python calculation.
from itertools import combinations
n = 6
layout = list(range(n))
encounters = []
for r in range(n):
pairs = []
for p in range(r % 2, n-1, 2):
a,b = layout[p:p+2]
pairs.append(tuple(sorted((a,b))))
layout[p],layout[p+1] = b,a
encounters.extend(pairs)
print('Round', r+1, pairs)
expected = set(combinations(range(n),2))
assert len(encounters) == len(set(encounters)) == len(expected)
assert set(encounters) == expected
assert layout == list(reversed(range(n)))
path_edges = {(i,i+1) for i in range(n-1)}
assert set(e for e in encounters if e in path_edges) == path_edges
print('Final logical order:',layout) What the reference tells us
The pair schedule establishes a constructive way to route the complete interaction graph on a path. It does not fix the final native gate count: an interaction and a SWAP may admit a joint synthesis, and the native cost depends on the gate set and rotation angle. The final permutation must be tracked in the rest of the circuit or restored if required.
On a sparse graph, some scheduled pairs need no cost rotation. A compiler can use the missing interactions and the processor's additional connections to seek a different schedule. An interaction pattern that already fits the physical graph may need little routing. Those are different computational cases, and grouping them together into a single benchmark average can hide the properties that matter to the experimenter.
Make the benchmark answer the right question
A useful comparison includes a structured reference as well as a general compilation method. Construct the same logical cost layers, mixer and angles, use the same available target operations, and record the mapping conventions. Compare native counts and depth for equivalent circuits. Record the compilation resources separately from execution resources.
If the experiment also assesses solution quality, retain the original optimization instance. Use a classical reference on that model, with a defined objective, feasibility check and computation budget. When a compiled circuit produces samples, evaluate the decoded samples against the original objective and report the appropriate sampling statistic. A graph used to route the circuit is not a substitute for the graph that defines the optimization problem.
The two questions then become complementary: how efficiently can we implement the quantum computation, and how useful are its answers for the optimization problem?
Use the 4colors Optimizer for QUBO to investigate the classical optimization model and the 4colors Quantum Compiler to investigate the circuit implementation. For a wider experimental question, explore our Quantum Proof of Concept projects.