In a variational quantum eigensolver (VQE), an expectation value is often a weighted sum of many Pauli observables. Measuring each term separately can require many different circuit settings. Grouping compatible terms reduces the number of settings, creating an optimization problem before the quantum experiment has even begun.
But there is a second decision. Some groups can be measured using only local basis changes, while others require an entangling measurement circuit. A grouping with fewer settings may therefore lead to more expensive individual circuits.
Two kinds of compatibility
A Pauli string is a product of single-qubit operators chosen from I, X, Y and Z. Two strings are qubit-wise commuting when their operators on every qubit either agree or one is the identity. Such a group has a common local measurement basis.
General commutation is a weaker condition. Count the positions at which two strings have different non-identity Pauli operators. If the count is even, the strings commute; if it is odd, they anticommute. General commuting groups admit a common eigenbasis, but the circuit that changes to that basis may contain entangling gates.
The strings XX and ZZ illustrate the difference. They differ at both positions, so they commute globally. They are not qubit-wise commuting. Their joint eigenbasis is the Bell basis, which can be mapped to computational-basis measurement by a controlled-NOT followed by a Hadamard on its control. The first (control) measurement bit gives the XX eigenvalue (−1)b0, and the second gives the ZZ eigenvalue (−1)b1. Local X and Z basis measurements alone cannot implement that joint basis in a single setting.
Turning measurement settings into a coloring problem
Construct a graph with one node for each Pauli term. Join two nodes when the selected compatibility rule says they cannot share a group. A valid graph coloring is then a valid grouping. The colors correspond to measurement settings.
With a fixed number K of candidate colors, use a binary variable xic for assigning term i to color c. Require each term to have exactly one color, and minimize
∑(i,j)∈ E ∑c=1K xicxjc.
The objective counts conflicting pairs assigned the same color. A feasible assignment with zero objective gives a proper coloring with at most K groups. Finding such an assignment proves that K groups suffice. Failing to find one within a search budget is not a proof that K groups are impossible.
Here is a small example that builds both conflict graphs and finds their minimum color counts by enumeration. It verifies compatibility directly, without relying on a quantum software package.
Illustration: standalone Python calculation.
from itertools import combinations, product
labels=['XX','ZZ','YY','ZI','IZ']
def conflict(a,b,qwc):
d=sum(x!=y and x!='I' and y!='I' for x,y in zip(a,b))
return d>0 if qwc else d%2==1
def color_count(qwc):
edges=[(i,j) for i,j in combinations(range(len(labels)),2) if conflict(labels[i],labels[j],qwc)]
for k in range(1,len(labels)+1):
for c in product(range(k),repeat=len(labels)):
if all(c[i]!=c[j] for i,j in edges):
return k,c
qwc=color_count(True); gc=color_count(False)
print('local groups',qwc,'general groups',gc)
assert qwc[0]==3 and gc[0]==2
assert not conflict('XX','ZZ',False) and conflict('XX','ZZ',True)
# A separate pair shows a strict difference in group count.
labels=['XX','ZZ']
assert color_count(True)[0]==2 and color_count(False)[0]==1 The example prints:
local groups (3, (0, 1, 2, 1, 1)) general groups (2, (0, 0, 0, 1, 1)) The cost of measuring a group
A minimum-color grouping is a useful candidate, rather than the final answer to the experimental cost question. For every general commuting group, construct a joint diagonalization circuit and verify how measured bit strings map to the individual eigenvalues. Append that measurement circuit to the state-preparation circuit and compile the complete circuit for the intended hardware. This accounts for possible cancellation between state preparation and measurement operations.
Compare the compiled two-qubit counts and depths, then consider the number of shots allocated to each group. Terms measured together can have correlated outcomes. For a weighted sum of measured terms, Var(∑i aiPi) = ∑i,jai ajCov(Pi,Pj). The covariance terms affect the shots required to reach a desired precision, independently of the number of settings. The relevant comparison is the computational cost of obtaining an estimate with a specified uncertainty.
Combining optimization and compilation
The 4colors Optimizer for QUBO provides a way to express the coloring model with explicit assignment constraints. The 4colors Quantum Compiler can then be used to evaluate the hardware-specific circuit implementations. The coloring objective measures compatibility; compilation determines the operations needed to implement the chosen measurement basis. Compare their joint effect at a fixed target precision.
Further reading
V. Verteletskyi, T.-C. Yen and A. F. Izmaylov, Measurement optimization in the variational quantum eigensolver using a minimum clique cover.