Manuscript En02-B@1 · En02-B-v1.tex · section · ca28dee4
Exact finite checks and a schedule explorer
Exact finite checks and a schedule explorer · lines 2141–2231
def apply_circuit(v, gates): out = list(v) h_count = 0 for gate in gates: out = apply_gate(out, gate) h_count += gate[0] == "H" return out, h_count
BATCH = ( ("CZ", 0, 1), ("CZ", 1, 2), ("SD", 0), ("SD", 2), ("H", 0), ("H", 2), ("CX", 0, 1), ("CX", 2, 1), ("Y", 1), )
EARLY = ( ("H", 1), ("CX", 0, 1), ("SD", 0), ("H", 0), )
def select_coordinates(v, fixed, survivors): """Unnormalized bra projection and factor deletion.""" n = nqubits(v) need(set(fixed).isdisjoint(survivors), "fixed and surviving positions overlap") need(set(fixed) | set(survivors) == set(range(n)), "coordinates are not completely accounted for") out = [ZERO] * (1 << len(survivors)) for k, amp in enumerate(v): bs = bits(k, n) if all(bs[j] == b for j, b in fixed.items()): out[index_of(tuple(bs[j] for j in survivors))] = amp return out
def check_low_weight_privacy(code): v0, v1 = code for weight in (1, 2): for sites in combinations(range(5), weight): for letters in product("XYZ", repeat=weight): word = ["I"] * 5 for q, letter in zip(sites, letters): word[q] = letter images = [pauli_action(v, "".join(word)) for v in code] for i in (0, 1): for j in (0, 1): need(inner(code[i], images[j]) == ZERO, "low-weight logical compression is nonzero")
def check_batch_certificate(code): decoded = [] for v in code: out, h_count = apply_circuit(v, BATCH) need(h_count == 2, "batch Hadamard count changed") decoded.append(out)
chi0 = select_coordinates(decoded[0], 1: 0, (0, 2, 3, 4)) chi1 = select_coordinates(decoded[1], 1: 1, (0, 2, 3, 4)) wrong0 = select_coordinates(decoded[0], 1: 1, (0, 2, 3, 4)) wrong1 = select_coordinates(decoded[1], 1: 0, (0, 2, 3, 4))
need(all(x == ZERO for x in wrong0 + wrong1), "batch decoder mixes logical basis values") need(chi0 == chi1, "batch decoder loses logical coherence") # True chi is chi0 / (4 * sqrt(2)**2) = chi0 / 8. need(inner(chi0, chi0) == (64, 0), "wrong decoded norm")
# Syndrome positions are the first two coordinates of chi. for f in range(4): for g in range(4): value = ZERO for e in range(4): value = add(value, mul(chi0[4 * f + e], conj(chi0[4 * g + e]))) expected = (16, 0) if f == g else ZERO need(value == expected, "syndrome is not I_4/4")
# A single syndrome branch has probability 16/64 = 1/4. need(sum(norm_sq(x) for x in chi0[:4]) == 16, "postselection probability certificate failed")
def check_stream_certificate(code): early = [apply_circuit(v, EARLY) for v in code] need(all(h == 2 for _, h in early), "early H count changed")