A classical optimization problem does not specify a unique quantum circuit. Even the choice of how to represent a decision can change the number of qubits, the structure of the interactions and the probability of observing a usable answer.

Consider the problem of assigning a color to each node of a graph so that as many edges as possible connect nodes of different colors. With three colors, the underlying combinatorial problem is simple to state. There are several quite different ways to express it in a variational quantum algorithm.

Three representations of a color

A one-hot representation uses a separate bit for each color. The assignment is valid when exactly one bit is set. In a penalty-based quantum approximate optimization algorithm (QAOA) construction, a term proportional to (∑c xic − 1)2 discourages invalid assignments. A conventional X mixer, however, can move between valid and invalid assignments. The final sample distribution may contain both.

A second representation uses the same one-hot bits but changes the initial state and mixer. Prepare a state with exactly one excitation in each node's register. A mixer built from XY interactions preserves that excitation number in the ideal circuit; hardware noise can still take the state outside the feasible subspace. The feasibility condition is then preserved by the algorithm's dynamics rather than encouraged by a penalty alone. State preparation and mixer implementation become part of the circuit cost.

A third representation uses two bits per node. There are four bit patterns, so one color can be assigned two patterns. For example, decode the integer b0 + 2b_1 by taking its minimum with the integer representing the last color. Every pattern now represents a valid color. This saves logical qubits compared with one-hot, but an edge's cut indicator becomes a function of the four bits of its endpoints. Its diagonal phase representation can include interactions involving more than two qubits.

Compare the initial distributions too

The two-bit representation has an interesting consequence. A uniform distribution over its bit patterns is not uniform over colors. One color has twice the probability of either of the others. For independently drawn colors with probabilities pc, the probability that an edge is cut is

1 − ∑c pc2.

The expected cut of a uniform random coloring and the expected cut of the uniform binary encoding are therefore different. A comparison that begins after the variational optimization may attribute some of the difference to the algorithm when it actually originates in the initial state.

For the one-hot penalty representation with a uniform bit-string start, only a subset of patterns is valid at each node. If an invalid complete assignment is scored as zero, its expected score depends strongly on the number of nodes. A conditional score over feasible samples answers a different question from the unconditional score across all samples.

The example below enumerates the possible two-node patterns and calculates the starting feasibility and expected cut under the three representations.

Illustration: standalone Python calculation.

from itertools import product
from fractions import Fraction

def onehot(bits):
    return bits.index(1) if sum(bits)==1 else None
penalty=[onehot(list(b)) for b in product((0,1),repeat=3)]
xy=[0,1,2]  # ideal uniform single-excitation state
binary=[min(k,2) for k in range(4)]
def measure(colors):
    pairs=list(product(colors,repeat=2))
    valid=[(a,b) for a,b in pairs if a is not None and b is not None]
    return Fraction(len(valid),len(pairs)),Fraction(sum(a!=b for a,b in valid),len(pairs))
for name,colors in [('penalty',penalty),('XY',xy),('binary',binary)]:
    print(name,measure(colors))
assert measure(penalty)==(Fraction(9,64),Fraction(6,64))
assert measure(xy)==(1,Fraction(2,3))
assert measure(binary)==(1,Fraction(5,8))

The example prints:

penalty (Fraction(9, 64), Fraction(3, 32))
XY (Fraction(1, 1), Fraction(2, 3))
binary (Fraction(1, 1), Fraction(5, 8))

Evaluating the encoded circuits

Use a common graph and a classical reference cut value. Specify the initial state, penalty and mixer, depth, parameter-tuning procedure and how samples are decoded. Report the fraction of feasible samples and the score over all samples; conditional quality can be a useful additional measurement. Compare the tuned distributions against their own initial distributions as well as against the common classical reference.

Compile each complete circuit for the same hardware description. State preparation, mixers, cost layers and any multi-qubit phase synthesis should all be included. The encoding with fewer qubits may use more entangling operations after compilation. The choice depends on the workload, the device and the desired output quality.

The 4colors Optimizer for QUBO can express the classical one-hot formulation with explicit assignment constraints. The 4colors Quantum Compiler can be used to investigate the circuits arising from different quantum representations. Comparing these choices is also a natural subject for a Quantum Proof of Concept experiment.

Further reading

S. Hadfield and colleagues, From the Quantum Approximate Optimization Algorithm to a Quantum Alternating Operator Ansatz.