A quantum error-correcting code defines a mathematical relationship between physical qubits and logical information. Its distance describes the weight of the smallest nontrivial logical operator. Its syndrome-extraction circuit determines how the checks are measured on a device. Both properties matter when evaluating a candidate code, and both raise optimization questions.
Find low-weight logical operators
For a CSS stabilizer code, let HX and HZ be binary check matrices satisfying HXHZT = 0 over the binary field GF(2). A candidate Z operator e commutes with all X checks when HXe = 0 over GF(2). To represent a nontrivial logical operator it must also lie outside the row space of HZ. Equivalently, it anticommutes with at least one member of a complete set of independent X logical operators.
For a chosen X logical vector ℓ, anticommutation requires ℓTe = 1 modulo two. Each parity constraint can be expressed as an integer equality with a bounded integer slack: ∑j∈ Sej − 2z = b, where b is zero or one. With support size |S| and parity b, the slack ranges from zero to ⌊(|S| − b)/2⌋. Binary variables can encode that bounded integer. Minimize ∑j ej subject to those rows. A feasible assignment supplies an upper bound on the relevant logical weight. Proving the minimum over a complete collection of logical tests is necessary to certify the corresponding Z distance.
Illustration: standalone Python calculation.
from itertools import product
hx=[(1,1,0),(0,1,1)]
logical_x=(1,0,0)
xs=list(product((0,1),repeat=3))
feasible=[e for e in xs if all(sum(a*b for a,b in zip(r,e))%2==0 for r in hx)
and sum(a*b for a,b in zip(logical_x,e))%2==1]
assert feasible==[(1,1,1)] For the CSS code with the two displayed X checks and no Z checks, the example tests its single independent X logical vector. The minimum Z logical weight is three; the X logical weight is one, so the full distance is one. The X-type problem must be considered separately when determining a CSS code's distance.
Compile the syndrome-extraction circuit
A check matrix also specifies a bipartite interaction pattern between data qubits and check ancillas. A hardware layout that supports these connections directly can simplify the required circuit. Other layouts require placement and routing. The extraction schedule must respect operation order and the requirements of the particular fault-tolerant protocol. Preserving the ideal syndrome map is an important check, but it is not sufficient to establish fault tolerance.
For a candidate code, retain the matrices, logical operators and the circuit construction. Independently check the parity and logical conditions on returned error vectors. For the circuit, compare native gate counts and depth on each specified target, verify the ideal syndrome behavior and evaluate fault propagation using a model appropriate to the protocol. The combination of mathematical bounds and hardware-specific circuit evaluation offers a way to assess code designs from more than one perspective.
Explore binary parity models with the 4colors Optimizer for QUBO and syndrome circuits with the 4colors Quantum Compiler.