A quantum processor is often described by its number of qubits. For a compiler, an equally important part of the description is the set of pairs of qubits on which it can perform an entangling operation. Two processors with the same number of qubits can require quite different circuits to implement the same computation.

A useful way to understand the difference is to draw two graphs. One describes the physical connections between qubits. The other describes the interactions required by the algorithm. Compilation has to reconcile the two, while retaining the computation expressed by the original circuit.

Two graphs, one computation

Consider a circuit in which a central qubit interacts with every other qubit. A physical node with enough available neighbors may host the central logical qubit, provided the required operations are supported on those connections. On a line, every internal qubit has only two neighbors. The compiler may need to move logical states, or use a different synthesis of the intended operation, to bring all the required interactions within reach.

A different circuit may contain interactions mainly between nearest neighbors in a chain. A line of physical qubits is then a natural match. A processor with more couplers offers greater placement flexibility, but those extra couplers need not reduce the cost of this particular circuit. The graph of an algorithm matters as much as the number of qubits it uses.

The interaction graph is itself an incomplete description. The order of gates matters, as does the possibility of executing disjoint operations concurrently. A single placement that looks good for the first layer may be less useful for the next. Some syntheses also change the apparent interaction graph without changing the computation.

Counting the cost of one interaction

Take a deliberately simple example: implement a controlled-NOT between the endpoints of a path of physical qubits and restore the original placement. For this example, assume each edge supports a controlled-NOT in either direction, and a SWAP costs three controlled-NOTs. Move one endpoint's logical state along the path until it is adjacent to the other, execute the gate, then reverse the moves.

If the endpoints are separated by d edges, this construction requires 2(d − 1) SWAPs and one controlled-NOT. A direct connection requires no SWAPs. The calculation below compares that specific construction on several small graphs.

Illustration: standalone Python calculation.

from collections import deque

def distance(edges, start, end):
    adj = {}
    for u, v in edges:
        adj.setdefault(u, []).append(v)
        adj.setdefault(v, []).append(u)
    q, seen = deque([(start, 0)]), {start}
    while q:
        u, d = q.popleft()
        if u == end:
            return d
        for v in adj.get(u, []):
            if v not in seen:
                seen.add(v)
                q.append((v, d + 1))
    raise ValueError('disconnected target')

line = [(0, 1), (1, 2), (2, 3)]
for name, edges in [('line', line), ('ring', line + [(3, 0)]),
                    ('shortcut', line + [(0, 2)])]:
    d = distance(edges, 0, 3)
    print(name, d, 6 * (d - 1) + 1)
assert distance(line, 0, 3) == 3

The example prints:

line 3 13
ring 1 1
shortcut 2 7

This is one valid implementation, not a lower bound on every possible synthesis. A compiler can sometimes retain a changed logical placement, combine a move with a neighboring operation, or synthesize the interaction in a different way. The example explains why the target graph changes the search problem.

Comparing processors on the same workload

To compare hardware designs, start with a collection of circuits representative of the intended work. Include sparse interaction patterns, star-shaped interactions and circuits with more widely distributed entanglement. Use the same circuit semantics, approximation policy and native-gate accounting for each target. Record the qubit count, two-qubit count and two-qubit depth separately.

If the available native gates differ, a count alone is only one part of the comparison. Gate duration, calibration and measurement conditions may change the experimental cost. A useful study first isolates connectivity by holding the gate convention fixed, then examines the implications of actual device characteristics.

For hardware designers, this gives a way to investigate whether adding a particular coupler helps a target workload. For researchers choosing a device, it offers a way to compare the compiled circuits before reserving hardware time. In both cases, the interesting result is the relationship between the algorithm and the physical design.

The 4colors Quantum Compiler accepts hardware-specific target descriptions. Bring the circuits you intend to execute and compare their compiled implementations on the target graphs you are considering.