FAILURE MAP
← Case archive

FA-91051 / Quantum circuit simulation / Open access

Direction fixer wraps Hadamards around the unflipped CNOT · case 01

A reversed CNOT is emitted as h c, h t, cx c t, h c, h t, still in the non-native direction.

Verified by executionVariant 1 · 7 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The rewrite keeps the original operand order inside the Hadamard sandwich.

VERIFIED REPAIR

Emit cx t c between the Hadamards.

Unsuccessful approach: The attempted repair flips the operands but only conjugates the target with Hadamards, which is not an equivalent circuit.

Case contract

Input [edges, ops]; edges are directed native CNOT pairs [c, t]. Each ["cx", c, t] is kept if [c, t] is native, else rewritten as h c, h t, cx t c, h c, h t if [t, c] is native, else the result is ["unroutable", op index]; c == t gives ["invalid", op index]. Other ops pass through. A final stack pass cancels an ["h", q] against an identical immediately preceding ["h", q].

Why this case matters

Direction fixing is a mandatory transpiler pass for devices with directed couplers; errors either break hardware constraints or bloat circuits.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    edges, ops = x
    allowed = {(a, b) for a, b in edges}
    out = []
    for idx, op in enumerate(ops):
        if op[0] != 'cx':
            out.append(list(op))
            continue
        c, t = op[1], op[2]
        if c == t:
            return ['invalid', idx]
        if (c, t) in allowed:
            out.append(['cx', c, t])
        elif (t, c) in allowed:
            out += [['h', c], ['h', t], ['cx', c, t], ['h', c], ['h', t]]
        else:
            return ['unroutable', idx]
    res = []
    for op in out:
        if op[0] == 'h' and res and res[-1] == op:
            res.pop()
        else:
            res.append(op)
    return res
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: reversed direction', [[[0, 1], [1, 2], [2, 3]], [['cx', 1, 0]]], [['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1], ['h', 0]]], ['regression: flip then h cancels', [[[0, 1], [1, 2], [2, 3]], [['cx', 1, 0], ['h', 0]]], [['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1]]], ['regression: flip then h on target cancels', [[[0, 1], [1, 2], [2, 3]], [['cx', 1, 0], ['h', 1], ['cx', 0, 1]]], [['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1], ['h', 0], ['h', 1], ['cx', 0, 1]]], ['control: native direction', [[[0, 1], [1, 2], [2, 3]], [['cx', 0, 1]]], [['cx', 0, 1]]], ['control: bidirectional edge', [[[0, 1], [1, 0]], [['cx', 1, 0]]], [['cx', 1, 0]]], ['control: self loop', [[[0, 1], [1, 2], [2, 3]], [['h', 0], ['cx', 2, 2]]], ['invalid', 1]], ['control: unroutable pair', [[[0, 1], [1, 2], [2, 3]], [['h', 1], ['cx', 0, 2]]], ['unroutable', 1]]], [['regression: random coupling 25', [[[0, 2], [2, 1], [0, 1], [2, 3], [1, 2]], [['cx', 1, 0], ['cx', 0, 2], ['x', 1], ['x', 3], ['h', 3]]], [['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1], ['h', 0], ['cx', 0, 2], ['x', 1], ['x', 3], ['h', 3]]], ['regression: random coupling 33', [[[3, 2], [2, 1]], [['h', 0], ['cx', 2, 3]]], [['h', 0], ['h', 2], ['h', 3], ['cx', 3, 2], ['h', 2], ['h', 3]]], ['regression: flip then h on target cancels', [[[0, 1], [1, 2], [2, 3]], [['cx', 1, 0], ['h', 1], ['cx', 0, 1]]], [['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1], ['h', 0], ['h', 1], ['cx', 0, 1]]], ['control: hadamards cancel', [[[0, 1], [1, 2], [2, 3]], [['h', 0], ['h', 0], ['x', 1]]], [['x', 1]]], ['control: hadamards on different qubits', [[[0, 1], [1, 2], [2, 3]], [['h', 0], ['h', 1]]], [['h', 0], ['h', 1]]], ['control: random coupling 0', [[[2, 1], [3, 2], [1, 2], [1, 0]], [['h', 2], ['cx', 1, 0], ['cx', 2, 0], ['x', 1]]], ['unroutable', 2]], ['control: random coupling 1', [[[2, 3], [3, 2], [0, 1], [0, 2]], [['h', 1]]], [['h', 1]]]], [['regression: random coupling 47', [[[2, 1], [1, 2], [0, 2], [1, 0]], [['cx', 2, 0], ['cx', 0, 1], ['cx', 2, 1]]], [['h', 2], ['h', 0], ['cx', 0, 2], ['h', 2], ['h', 1], ['cx', 1, 0], ['h', 0], ['h', 1], ['cx', 2, 1]]], ['regression: random coupling 56', [[[0, 2], [1, 2], [2, 3], [1, 0], [2, 1]], [['cx', 1, 0], ['h', 3], ['cx', 2, 0], ['h', 0]]], [['cx', 1, 0], ['h', 3], ['h', 2], ['h', 0], ['cx', 0, 2], ['h', 2]]], ['regression: random coupling 33', [[[3, 2], [2, 1]], [['h', 0], ['cx', 2, 3]]], [['h', 0], ['h', 2], ['h', 3], ['cx', 3, 2], ['h', 2], ['h', 3]]], ['control: random coupling 2', [[[0, 2], [2, 3], [2, 1]], [['h', 3]]], [['h', 3]]], ['control: random coupling 3', [[[1, 0], [2, 3]], [['cx', 1, 2], ['h', 1], ['x', 2]]], ['unroutable', 0]], ['control: random coupling 4', [[[0, 2], [2, 3]], [['h', 0], ['cx', 0, 3], ['cx', 2, 0], ['x', 3]]], ['unroutable', 1]], ['control: random coupling 5', [[[3, 2], [0, 2], [2, 3], [1, 2]], [['cx', 1, 0], ['h', 3], ['h', 0], ['cx', 0, 3]]], ['unroutable', 0]]], [['regression: flip then h cancels', [[[0, 1], [1, 2], [2, 3]], [['cx', 1, 0], ['h', 0]]], [['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1]]], ['regression: flip then h on target cancels', [[[0, 1], [1, 2], [2, 3]], [['cx', 1, 0], ['h', 1], ['cx', 0, 1]]], [['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1], ['h', 0], ['h', 1], ['cx', 0, 1]]], ['regression: random coupling 47', [[[2, 1], [1, 2], [0, 2], [1, 0]], [['cx', 2, 0], ['cx', 0, 1], ['cx', 2, 1]]], [['h', 2], ['h', 0], ['cx', 0, 2], ['h', 2], ['h', 1], ['cx', 1, 0], ['h', 0], ['h', 1], ['cx', 2, 1]]], ['control: random coupling 6', [[[0, 1], [2, 1]], [['cx', 2, 0], ['x', 2], ['cx', 0, 2], ['cx', 3, 0], ['h', 3], ['h', 3]]], ['unroutable', 0]], ['control: random coupling 7', [[[0, 1], [2, 3], [2, 1], [1, 2]], [['cx', 1, 3]]], ['unroutable', 0]], ['control: random coupling 8', [[[2, 1], [1, 2], [3, 2]], [['x', 0], ['h', 3]]], [['x', 0], ['h', 3]]], ['control: random coupling 9', [[[0, 2], [0, 1], [1, 2], [3, 2]], [['h', 1], ['cx', 0, 2]]], [['h', 1], ['cx', 0, 2]]]], [['regression: random coupling 33', [[[3, 2], [2, 1]], [['h', 0], ['cx', 2, 3]]], [['h', 0], ['h', 2], ['h', 3], ['cx', 3, 2], ['h', 2], ['h', 3]]], ['regression: random coupling 37', [[[0, 2], [0, 1], [1, 0]], [['h', 2], ['cx', 2, 0], ['cx', 0, 2]]], [['h', 0], ['cx', 0, 2], ['h', 2], ['h', 0], ['cx', 0, 2]]], ['regression: reversed direction', [[[0, 1], [1, 2], [2, 3]], [['cx', 1, 0]]], [['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1], ['h', 0]]], ['control: random coupling 10', [[[0, 2], [2, 1], [3, 2]], [['h', 2], ['cx', 1, 0]]], ['unroutable', 1]], ['control: random coupling 11', [[[2, 3], [1, 2], [3, 2], [0, 2]], [['cx', 2, 3], ['cx', 0, 2], ['h', 2], ['cx', 1, 1], ['h', 0]]], ['invalid', 3]], ['control: random coupling 12', [[[0, 2], [3, 2]], [['x', 2], ['cx', 3, 1], ['h', 2], ['h', 3]]], ['unroutable', 1]], ['control: random coupling 13', [[[1, 0], [0, 2], [3, 2], [2, 3], [0, 1]], [['cx', 2, 1], ['cx', 3, 1], ['x', 1]]], ['unroutable', 0]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: reversed direction[['h', 1], ['h', 0], ['cx', 1, 0], ['h', 1], ['h', 0]][['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1], ['h', 0]]Failed
regression: flip then h cancels[['h', 1], ['h', 0], ['cx', 1, 0], ['h', 1]][['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1]]Failed
regression: flip then h on target cancels[['h', 1], ['h', 0], ['cx', 1, 0], ['h', 1], ['h', 0], ['h', 1], ['cx', 0, 1]][['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1], ['h', 0], ['h', 1], ['cx', 0, 1]]Failed
control: native direction[['cx', 0, 1]][['cx', 0, 1]]Passed
control: bidirectional edge[['cx', 1, 0]][['cx', 1, 0]]Passed
control: self loop['invalid', 1]['invalid', 1]Passed
control: unroutable pair['unroutable', 1]['unroutable', 1]Passed

SHA-256 / cf210f2a06944c6423fed32f2edb75211f8103f96c23796dabe4c1f41bb16d5d

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    edges, ops = x
    allowed = {(a, b) for a, b in edges}
    out = []
    for idx, op in enumerate(ops):
        if op[0] != 'cx':
            out.append(list(op))
            continue
        c, t = op[1], op[2]
        if c == t:
            return ['invalid', idx]
        if (c, t) in allowed:
            out.append(['cx', c, t])
        elif (t, c) in allowed:
            out += [['h', t], ['cx', t, c], ['h', t]]
        else:
            return ['unroutable', idx]
    res = []
    for op in out:
        if op[0] == 'h' and res and res[-1] == op:
            res.pop()
        else:
            res.append(op)
    return res
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: reversed direction', [[[0, 1], [1, 2], [2, 3]], [['cx', 1, 0]]], [['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1], ['h', 0]]], ['regression: flip then h cancels', [[[0, 1], [1, 2], [2, 3]], [['cx', 1, 0], ['h', 0]]], [['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1]]], ['regression: flip then h on target cancels', [[[0, 1], [1, 2], [2, 3]], [['cx', 1, 0], ['h', 1], ['cx', 0, 1]]], [['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1], ['h', 0], ['h', 1], ['cx', 0, 1]]], ['control: native direction', [[[0, 1], [1, 2], [2, 3]], [['cx', 0, 1]]], [['cx', 0, 1]]], ['control: bidirectional edge', [[[0, 1], [1, 0]], [['cx', 1, 0]]], [['cx', 1, 0]]], ['control: self loop', [[[0, 1], [1, 2], [2, 3]], [['h', 0], ['cx', 2, 2]]], ['invalid', 1]], ['control: unroutable pair', [[[0, 1], [1, 2], [2, 3]], [['h', 1], ['cx', 0, 2]]], ['unroutable', 1]]], [['regression: random coupling 25', [[[0, 2], [2, 1], [0, 1], [2, 3], [1, 2]], [['cx', 1, 0], ['cx', 0, 2], ['x', 1], ['x', 3], ['h', 3]]], [['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1], ['h', 0], ['cx', 0, 2], ['x', 1], ['x', 3], ['h', 3]]], ['regression: random coupling 33', [[[3, 2], [2, 1]], [['h', 0], ['cx', 2, 3]]], [['h', 0], ['h', 2], ['h', 3], ['cx', 3, 2], ['h', 2], ['h', 3]]], ['regression: flip then h on target cancels', [[[0, 1], [1, 2], [2, 3]], [['cx', 1, 0], ['h', 1], ['cx', 0, 1]]], [['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1], ['h', 0], ['h', 1], ['cx', 0, 1]]], ['control: hadamards cancel', [[[0, 1], [1, 2], [2, 3]], [['h', 0], ['h', 0], ['x', 1]]], [['x', 1]]], ['control: hadamards on different qubits', [[[0, 1], [1, 2], [2, 3]], [['h', 0], ['h', 1]]], [['h', 0], ['h', 1]]], ['control: random coupling 0', [[[2, 1], [3, 2], [1, 2], [1, 0]], [['h', 2], ['cx', 1, 0], ['cx', 2, 0], ['x', 1]]], ['unroutable', 2]], ['control: random coupling 1', [[[2, 3], [3, 2], [0, 1], [0, 2]], [['h', 1]]], [['h', 1]]]], [['regression: random coupling 47', [[[2, 1], [1, 2], [0, 2], [1, 0]], [['cx', 2, 0], ['cx', 0, 1], ['cx', 2, 1]]], [['h', 2], ['h', 0], ['cx', 0, 2], ['h', 2], ['h', 1], ['cx', 1, 0], ['h', 0], ['h', 1], ['cx', 2, 1]]], ['regression: random coupling 56', [[[0, 2], [1, 2], [2, 3], [1, 0], [2, 1]], [['cx', 1, 0], ['h', 3], ['cx', 2, 0], ['h', 0]]], [['cx', 1, 0], ['h', 3], ['h', 2], ['h', 0], ['cx', 0, 2], ['h', 2]]], ['regression: random coupling 33', [[[3, 2], [2, 1]], [['h', 0], ['cx', 2, 3]]], [['h', 0], ['h', 2], ['h', 3], ['cx', 3, 2], ['h', 2], ['h', 3]]], ['control: random coupling 2', [[[0, 2], [2, 3], [2, 1]], [['h', 3]]], [['h', 3]]], ['control: random coupling 3', [[[1, 0], [2, 3]], [['cx', 1, 2], ['h', 1], ['x', 2]]], ['unroutable', 0]], ['control: random coupling 4', [[[0, 2], [2, 3]], [['h', 0], ['cx', 0, 3], ['cx', 2, 0], ['x', 3]]], ['unroutable', 1]], ['control: random coupling 5', [[[3, 2], [0, 2], [2, 3], [1, 2]], [['cx', 1, 0], ['h', 3], ['h', 0], ['cx', 0, 3]]], ['unroutable', 0]]], [['regression: flip then h cancels', [[[0, 1], [1, 2], [2, 3]], [['cx', 1, 0], ['h', 0]]], [['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1]]], ['regression: flip then h on target cancels', [[[0, 1], [1, 2], [2, 3]], [['cx', 1, 0], ['h', 1], ['cx', 0, 1]]], [['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1], ['h', 0], ['h', 1], ['cx', 0, 1]]], ['regression: random coupling 47', [[[2, 1], [1, 2], [0, 2], [1, 0]], [['cx', 2, 0], ['cx', 0, 1], ['cx', 2, 1]]], [['h', 2], ['h', 0], ['cx', 0, 2], ['h', 2], ['h', 1], ['cx', 1, 0], ['h', 0], ['h', 1], ['cx', 2, 1]]], ['control: random coupling 6', [[[0, 1], [2, 1]], [['cx', 2, 0], ['x', 2], ['cx', 0, 2], ['cx', 3, 0], ['h', 3], ['h', 3]]], ['unroutable', 0]], ['control: random coupling 7', [[[0, 1], [2, 3], [2, 1], [1, 2]], [['cx', 1, 3]]], ['unroutable', 0]], ['control: random coupling 8', [[[2, 1], [1, 2], [3, 2]], [['x', 0], ['h', 3]]], [['x', 0], ['h', 3]]], ['control: random coupling 9', [[[0, 2], [0, 1], [1, 2], [3, 2]], [['h', 1], ['cx', 0, 2]]], [['h', 1], ['cx', 0, 2]]]], [['regression: random coupling 33', [[[3, 2], [2, 1]], [['h', 0], ['cx', 2, 3]]], [['h', 0], ['h', 2], ['h', 3], ['cx', 3, 2], ['h', 2], ['h', 3]]], ['regression: random coupling 37', [[[0, 2], [0, 1], [1, 0]], [['h', 2], ['cx', 2, 0], ['cx', 0, 2]]], [['h', 0], ['cx', 0, 2], ['h', 2], ['h', 0], ['cx', 0, 2]]], ['regression: reversed direction', [[[0, 1], [1, 2], [2, 3]], [['cx', 1, 0]]], [['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1], ['h', 0]]], ['control: random coupling 10', [[[0, 2], [2, 1], [3, 2]], [['h', 2], ['cx', 1, 0]]], ['unroutable', 1]], ['control: random coupling 11', [[[2, 3], [1, 2], [3, 2], [0, 2]], [['cx', 2, 3], ['cx', 0, 2], ['h', 2], ['cx', 1, 1], ['h', 0]]], ['invalid', 3]], ['control: random coupling 12', [[[0, 2], [3, 2]], [['x', 2], ['cx', 3, 1], ['h', 2], ['h', 3]]], ['unroutable', 1]], ['control: random coupling 13', [[[1, 0], [0, 2], [3, 2], [2, 3], [0, 1]], [['cx', 2, 1], ['cx', 3, 1], ['x', 1]]], ['unroutable', 0]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: reversed direction[['h', 0], ['cx', 0, 1], ['h', 0]][['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1], ['h', 0]]Failed
regression: flip then h cancels[['h', 0], ['cx', 0, 1]][['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1]]Failed
regression: flip then h on target cancels[['h', 0], ['cx', 0, 1], ['h', 0], ['h', 1], ['cx', 0, 1]][['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1], ['h', 0], ['h', 1], ['cx', 0, 1]]Failed
control: native direction[['cx', 0, 1]][['cx', 0, 1]]Passed
control: bidirectional edge[['cx', 1, 0]][['cx', 1, 0]]Passed
control: self loop['invalid', 1]['invalid', 1]Passed
control: unroutable pair['unroutable', 1]['unroutable', 1]Passed

SHA-256 / e62d96d22336c7b2e2b5442a0e0e87de3a7b4de631985bb4d5adefacbf79eeea

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    edges, ops = x
    allowed = {(a, b) for a, b in edges}
    out = []
    for idx, op in enumerate(ops):
        if op[0] != 'cx':
            out.append(list(op))
            continue
        c, t = op[1], op[2]
        if c == t:
            return ['invalid', idx]
        if (c, t) in allowed:
            out.append(['cx', c, t])
        elif (t, c) in allowed:
            out += [['h', c], ['h', t], ['cx', t, c], ['h', c], ['h', t]]
        else:
            return ['unroutable', idx]
    res = []
    for op in out:
        if op[0] == 'h' and res and res[-1] == op:
            res.pop()
        else:
            res.append(op)
    return res
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: reversed direction', [[[0, 1], [1, 2], [2, 3]], [['cx', 1, 0]]], [['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1], ['h', 0]]], ['regression: flip then h cancels', [[[0, 1], [1, 2], [2, 3]], [['cx', 1, 0], ['h', 0]]], [['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1]]], ['regression: flip then h on target cancels', [[[0, 1], [1, 2], [2, 3]], [['cx', 1, 0], ['h', 1], ['cx', 0, 1]]], [['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1], ['h', 0], ['h', 1], ['cx', 0, 1]]], ['control: native direction', [[[0, 1], [1, 2], [2, 3]], [['cx', 0, 1]]], [['cx', 0, 1]]], ['control: bidirectional edge', [[[0, 1], [1, 0]], [['cx', 1, 0]]], [['cx', 1, 0]]], ['control: self loop', [[[0, 1], [1, 2], [2, 3]], [['h', 0], ['cx', 2, 2]]], ['invalid', 1]], ['control: unroutable pair', [[[0, 1], [1, 2], [2, 3]], [['h', 1], ['cx', 0, 2]]], ['unroutable', 1]]], [['regression: random coupling 25', [[[0, 2], [2, 1], [0, 1], [2, 3], [1, 2]], [['cx', 1, 0], ['cx', 0, 2], ['x', 1], ['x', 3], ['h', 3]]], [['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1], ['h', 0], ['cx', 0, 2], ['x', 1], ['x', 3], ['h', 3]]], ['regression: random coupling 33', [[[3, 2], [2, 1]], [['h', 0], ['cx', 2, 3]]], [['h', 0], ['h', 2], ['h', 3], ['cx', 3, 2], ['h', 2], ['h', 3]]], ['regression: flip then h on target cancels', [[[0, 1], [1, 2], [2, 3]], [['cx', 1, 0], ['h', 1], ['cx', 0, 1]]], [['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1], ['h', 0], ['h', 1], ['cx', 0, 1]]], ['control: hadamards cancel', [[[0, 1], [1, 2], [2, 3]], [['h', 0], ['h', 0], ['x', 1]]], [['x', 1]]], ['control: hadamards on different qubits', [[[0, 1], [1, 2], [2, 3]], [['h', 0], ['h', 1]]], [['h', 0], ['h', 1]]], ['control: random coupling 0', [[[2, 1], [3, 2], [1, 2], [1, 0]], [['h', 2], ['cx', 1, 0], ['cx', 2, 0], ['x', 1]]], ['unroutable', 2]], ['control: random coupling 1', [[[2, 3], [3, 2], [0, 1], [0, 2]], [['h', 1]]], [['h', 1]]]], [['regression: random coupling 47', [[[2, 1], [1, 2], [0, 2], [1, 0]], [['cx', 2, 0], ['cx', 0, 1], ['cx', 2, 1]]], [['h', 2], ['h', 0], ['cx', 0, 2], ['h', 2], ['h', 1], ['cx', 1, 0], ['h', 0], ['h', 1], ['cx', 2, 1]]], ['regression: random coupling 56', [[[0, 2], [1, 2], [2, 3], [1, 0], [2, 1]], [['cx', 1, 0], ['h', 3], ['cx', 2, 0], ['h', 0]]], [['cx', 1, 0], ['h', 3], ['h', 2], ['h', 0], ['cx', 0, 2], ['h', 2]]], ['regression: random coupling 33', [[[3, 2], [2, 1]], [['h', 0], ['cx', 2, 3]]], [['h', 0], ['h', 2], ['h', 3], ['cx', 3, 2], ['h', 2], ['h', 3]]], ['control: random coupling 2', [[[0, 2], [2, 3], [2, 1]], [['h', 3]]], [['h', 3]]], ['control: random coupling 3', [[[1, 0], [2, 3]], [['cx', 1, 2], ['h', 1], ['x', 2]]], ['unroutable', 0]], ['control: random coupling 4', [[[0, 2], [2, 3]], [['h', 0], ['cx', 0, 3], ['cx', 2, 0], ['x', 3]]], ['unroutable', 1]], ['control: random coupling 5', [[[3, 2], [0, 2], [2, 3], [1, 2]], [['cx', 1, 0], ['h', 3], ['h', 0], ['cx', 0, 3]]], ['unroutable', 0]]], [['regression: flip then h cancels', [[[0, 1], [1, 2], [2, 3]], [['cx', 1, 0], ['h', 0]]], [['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1]]], ['regression: flip then h on target cancels', [[[0, 1], [1, 2], [2, 3]], [['cx', 1, 0], ['h', 1], ['cx', 0, 1]]], [['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1], ['h', 0], ['h', 1], ['cx', 0, 1]]], ['regression: random coupling 47', [[[2, 1], [1, 2], [0, 2], [1, 0]], [['cx', 2, 0], ['cx', 0, 1], ['cx', 2, 1]]], [['h', 2], ['h', 0], ['cx', 0, 2], ['h', 2], ['h', 1], ['cx', 1, 0], ['h', 0], ['h', 1], ['cx', 2, 1]]], ['control: random coupling 6', [[[0, 1], [2, 1]], [['cx', 2, 0], ['x', 2], ['cx', 0, 2], ['cx', 3, 0], ['h', 3], ['h', 3]]], ['unroutable', 0]], ['control: random coupling 7', [[[0, 1], [2, 3], [2, 1], [1, 2]], [['cx', 1, 3]]], ['unroutable', 0]], ['control: random coupling 8', [[[2, 1], [1, 2], [3, 2]], [['x', 0], ['h', 3]]], [['x', 0], ['h', 3]]], ['control: random coupling 9', [[[0, 2], [0, 1], [1, 2], [3, 2]], [['h', 1], ['cx', 0, 2]]], [['h', 1], ['cx', 0, 2]]]], [['regression: random coupling 33', [[[3, 2], [2, 1]], [['h', 0], ['cx', 2, 3]]], [['h', 0], ['h', 2], ['h', 3], ['cx', 3, 2], ['h', 2], ['h', 3]]], ['regression: random coupling 37', [[[0, 2], [0, 1], [1, 0]], [['h', 2], ['cx', 2, 0], ['cx', 0, 2]]], [['h', 0], ['cx', 0, 2], ['h', 2], ['h', 0], ['cx', 0, 2]]], ['regression: reversed direction', [[[0, 1], [1, 2], [2, 3]], [['cx', 1, 0]]], [['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1], ['h', 0]]], ['control: random coupling 10', [[[0, 2], [2, 1], [3, 2]], [['h', 2], ['cx', 1, 0]]], ['unroutable', 1]], ['control: random coupling 11', [[[2, 3], [1, 2], [3, 2], [0, 2]], [['cx', 2, 3], ['cx', 0, 2], ['h', 2], ['cx', 1, 1], ['h', 0]]], ['invalid', 3]], ['control: random coupling 12', [[[0, 2], [3, 2]], [['x', 2], ['cx', 3, 1], ['h', 2], ['h', 3]]], ['unroutable', 1]], ['control: random coupling 13', [[[1, 0], [0, 2], [3, 2], [2, 3], [0, 1]], [['cx', 2, 1], ['cx', 3, 1], ['x', 1]]], ['unroutable', 0]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: reversed direction[['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1], ['h', 0]][['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1], ['h', 0]]Passed
regression: flip then h cancels[['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1]][['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1]]Passed
regression: flip then h on target cancels[['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1], ['h', 0], ['h', 1], ['cx', 0, 1]][['h', 1], ['h', 0], ['cx', 0, 1], ['h', 1], ['h', 0], ['h', 1], ['cx', 0, 1]]Passed
control: native direction[['cx', 0, 1]][['cx', 0, 1]]Passed
control: bidirectional edge[['cx', 1, 0]][['cx', 1, 0]]Passed
control: self loop['invalid', 1]['invalid', 1]Passed
control: unroutable pair['unroutable', 1]['unroutable', 1]Passed

SHA-256 / 33c5fe37badcf4a463e660c48b8f48e54e59397156a46a34e689c053700961cf

Verification & scope

A deterministic bounded teaching model with a stipulated toy contract; amplitudes are rounded to fixed decimals for strict JSON output. It is not a production quantum SDK and claims no standards conformance. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:51:32.332011+00:00.

Case digest / cb1aec379e01f099b9377cd564de430d7b5e0acc9a1f344a2bcb3c793538be9e