FAILURE MAP
← Case archive

FA-91306 / Quantum circuit simulation / Open access

Register expansion truncates mismatched measure broadcasts · case 01

measure q -> c with three qubits and two clbits silently drops the last qubit.

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

ROOT CAUSE

The size check for register-to-register measurement is missing; zip truncates.

VERIFIED REPAIR

Return "size-mismatch" when the qubit and clbit operand widths differ.

Unsuccessful approach: The attempted repair only rejects more qubits than clbits, not the reverse.

Case contract

Input a list of OpenQASM-2-like statements: "qreg n[k];", "creg n[k];", gate statements "g a,b;" and "measure a -> b;" where operands are whole registers or "n[i]". Registers are flattened in declaration order per kind (qubits and clbits have separate counters). Whole-register operands broadcast; a single qubit operand is reused across the broadcast. Return [[g, [flat qubits]] or ["measure", q, c]...] or [error, statement index] with errors "unknown-register", "index-out-of-range", "size-mismatch".

Why this case matters

Front-end register flattening decides which physical qubits every later pass touches; offset or broadcast slips silently rewire circuits.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import re
N = 1
observations = []
def solve(x):
    qregs, cregs = {}, {}
    nq = nc = 0
    out = []
    def ref(tok, regs):
        m = re.fullmatch(r'([a-z]\w*)(?:\[(\d+)\])?', tok.strip())
        name, idx = m.group(1), m.group(2)
        if name not in regs:
            raise KeyError('unknown-register')
        off, size = regs[name]
        if idx is None:
            return [off + i for i in range(size)]
        if int(idx) >= size:
            raise KeyError('index-out-of-range')
        return [off + int(idx)]
    for no, stmt in enumerate(x):
        s = stmt.strip().rstrip(';').strip()
        head, _, rest = s.partition(' ')
        try:
            if head in ('qreg', 'creg'):
                m = re.fullmatch(r'([a-z]\w*)\[(\d+)\]', rest.strip())
                size = int(m.group(2))
                if head == 'qreg':
                    qregs[m.group(1)] = (nq, size)
                    nq += size
                else:
                    cregs[m.group(1)] = (nc, size)
                    nc += size
            elif head == 'measure':
                src, dst = rest.split('->')
                qs, cs = ref(src, qregs), ref(dst, cregs)
                out += [['measure', a, b] for a, b in zip(qs, cs)]
            else:
                args = [ref(t, qregs) for t in rest.split(',')]
                width = max(len(a) for a in args)
                if any(len(a) not in (1, width) for a in args):
                    raise KeyError('size-mismatch')
                for i in range(width):
                    out.append([head, [a[0] if len(a) == 1 else a[i] for a in args]])
        except KeyError as e:
            return [e.args[0], no]
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: measure size mismatch', ['qreg q[3];', 'creg c[2];', 'measure q -> c;'], ['size-mismatch', 2]], ['regression: random program 1', ['qreg q[3];', 'creg c[2];', 'h q;', 'measure q[0] -> c;'], ['size-mismatch', 3]], ['regression: random program 4', ['qreg q[3];', 'creg c[3];', 'qreg r[1];', 'creg d[3];', 'qreg s[1];', 'creg e[2];', 'x s;', 'measure s[0] -> e;', 'cx q,r[0];'], ['size-mismatch', 7]], ['control: two registers broadcast', ['qreg q[2];', 'qreg r[2];', 'creg c[2];', 'cx q,r;', 'measure r -> c;'], [['cx', [0, 2]], ['cx', [1, 3]], ['measure', 2, 0], ['measure', 3, 1]]], ['control: creg declared between qregs', ['qreg a[1];', 'creg c[2];', 'qreg b[2];', 'h b[1];'], [['h', [2]]]], ['control: index equals size', ['qreg q[2];', 'h q[2];'], ['index-out-of-range', 1]], ['control: second register overflow', ['qreg q[2];', 'qreg r[2];', 'x r[3];'], ['index-out-of-range', 2]]], [['regression: random program 10', ['qreg q[2];', 'qreg r[2];', 'creg c[2];', 'h q[0];', 'x q;', 'measure r[0] -> c;'], ['size-mismatch', 5]], ['regression: random program 11', ['qreg q[2];', 'creg c[1];', 'qreg r[1];', 'creg d[3];', 'measure q -> d[2];', 'x r[0];', 'x q;', 'measure q[0] -> d[0];'], ['size-mismatch', 4]], ['regression: random program 13', ['qreg q[2];', 'qreg r[2];', 'qreg s[1];', 'creg c[2];', 'cx r[0],q;', 'measure q[0] -> c[1];', 'cx r[1],r;', 'measure r[0] -> c;'], ['size-mismatch', 7]], ['control: single control broadcast target', ['qreg q[1];', 'qreg r[3];', 'cx q[0],r;'], [['cx', [0, 1]], ['cx', [0, 2]], ['cx', [0, 3]]]], ['control: register control single target', ['qreg q[3];', 'qreg r[1];', 'cx q,r[0];'], [['cx', [0, 3]], ['cx', [1, 3]], ['cx', [2, 3]]]], ['control: measure into qreg name', ['qreg q[1];', 'qreg r[1];', 'measure q[0] -> r[0];'], ['unknown-register', 2]], ['control: unknown register', ['qreg q[1];', 'h z[0];'], ['unknown-register', 1]]], [['regression: random program 19', ['qreg q[1];', 'qreg r[1];', 'qreg s[2];', 'creg c[3];', 'measure s[0] -> c;', 'h q[0];'], ['size-mismatch', 4]], ['regression: random program 24', ['qreg q[3];', 'creg c[2];', 'h q[0];', 'measure q[2] -> c;'], ['size-mismatch', 3]], ['regression: random program 28', ['qreg q[3];', 'creg c[2];', 'h q[0];', 'cx q[1],q[0];', 'measure q[1] -> c;'], ['size-mismatch', 4]], ['control: random program 0', ['qreg q[2];', 'creg c[2];', 'h q[0];', 'measure q[1] -> c[0];'], [['h', [0]], ['measure', 1, 0]]], ['control: random program 2', ['qreg q[3];', 'creg c[3];', 'qreg r[1];', 'creg d[1];', 'h q[1];'], [['h', [1]]]], ['control: random program 3', ['qreg q[2];', 'creg c[2];', 'h q[1];'], [['h', [1]]]], ['control: random program 5', ['qreg q[1];', 'creg c[3];', 'qreg r[1];', 'creg d[3];', 'cx r[0],q[0];', 'measure r -> d[0];', 'cx q[0],q[0];', 'cx r[0],r;'], [['cx', [1, 0]], ['measure', 1, 3], ['cx', [0, 0]], ['cx', [1, 1]]]]], [['regression: random program 38', ['qreg q[3];', 'creg c[1];', 'measure q -> c[0];', 'h q[0];', 'measure q[3] -> c[0];', 'cx q[2],q[0];'], ['size-mismatch', 2]], ['regression: random program 40', ['qreg q[1];', 'qreg r[1];', 'creg c[3];', 'measure r -> c;'], ['size-mismatch', 3]], ['regression: random program 28', ['qreg q[3];', 'creg c[2];', 'h q[0];', 'cx q[1],q[0];', 'measure q[1] -> c;'], ['size-mismatch', 4]], ['control: random program 6', ['qreg q[3];', 'creg c[2];', 'cx q[2],q;'], [['cx', [2, 0]], ['cx', [2, 1]], ['cx', [2, 2]]]], ['control: random program 7', ['qreg q[1];', 'creg c[3];', 'x q;', 'cx q,q[1];', 'cx q[0],q[0];', 'cx q[0],q;'], ['index-out-of-range', 3]], ['control: random program 8', ['qreg q[2];', 'qreg r[1];', 'qreg s[2];', 'creg c[2];', 'cx r[0],s[1];', 'h s;', 'measure q[1] -> c[1];', 'h s;'], [['cx', [2, 4]], ['h', [3]], ['h', [4]], ['measure', 1, 1], ['h', [3]], ['h', [4]]]], ['control: random program 9', ['qreg q[1];', 'qreg r[1];', 'qreg s[1];', 'creg c[2];', 'h q[0];'], [['h', [0]]]]], [['regression: random program 43', ['qreg q[3];', 'creg c[2];', 'measure q[0] -> c;'], ['size-mismatch', 2]], ['regression: random program 48', ['qreg q[2];', 'creg c[3];', 'qreg r[2];', 'measure q[0] -> c[2];', 'measure q -> c;'], ['size-mismatch', 4]], ['regression: random program 53', ['qreg q[2];', 'creg c[3];', 'qreg r[2];', 'qreg s[3];', 'measure r -> c;', 'x q[1];', 'cx q[1],q[0];'], ['size-mismatch', 4]], ['control: random program 12', ['qreg q[3];', 'creg c[1];', 'qreg r[2];', 'creg d[3];', 'x q;', 'h r;', 'x r[1];'], [['x', [0]], ['x', [1]], ['x', [2]], ['h', [3]], ['h', [4]], ['x', [4]]]], ['control: random program 14', ['qreg q[3];', 'creg c[2];', 'qreg r[2];', 'creg d[3];', 'qreg s[2];', 'x r[1];', 'x q;', 'x r[0];', 'cx s[0],r;'], [['x', [4]], ['x', [0]], ['x', [1]], ['x', [2]], ['x', [3]], ['cx', [5, 3]], ['cx', [5, 4]]]], ['control: random program 15', ['qreg q[1];', 'qreg r[2];', 'qreg s[3];', 'creg c[2];', 'x q;', 'h r[1];', 'cx s[2],r[1];', 'cx r[1],q[0];'], [['x', [0]], ['h', [2]], ['cx', [5, 2]], ['cx', [2, 0]]]], ['control: random program 16', ['qreg q[2];', 'creg c[2];', 'qreg r[1];', 'qreg s[2];', 'creg d[1];', 'cx s,q;', 'x r[0];'], [['cx', [3, 0]], ['cx', [4, 1]], ['x', [2]]]]]]
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: measure size mismatch[['measure', 0, 0], ['measure', 1, 1]]['size-mismatch', 2]Failed
regression: random program 1[['h', [0]], ['h', [1]], ['h', [2]], ['measure', 0, 0]]['size-mismatch', 3]Failed
regression: random program 4[['x', [4]], ['measure', 4, 6], ['cx', [0, 3]], ['cx', [1, 3]], ['cx', [2, 3]]]['size-mismatch', 7]Failed
control: two registers broadcast[['cx', [0, 2]], ['cx', [1, 3]], ['measure', 2, 0], ['measure', 3, 1]][['cx', [0, 2]], ['cx', [1, 3]], ['measure', 2, 0], ['measure', 3, 1]]Passed
control: creg declared between qregs[['h', [2]]][['h', [2]]]Passed
control: index equals size['index-out-of-range', 1]['index-out-of-range', 1]Passed
control: second register overflow['index-out-of-range', 2]['index-out-of-range', 2]Passed

SHA-256 / 5552735ec5f8ba93ed21137896ade71e5226f694fcf3277fdf8f7e579d17a1ae

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import re
N = 1
observations = []
def solve(x):
    qregs, cregs = {}, {}
    nq = nc = 0
    out = []
    def ref(tok, regs):
        m = re.fullmatch(r'([a-z]\w*)(?:\[(\d+)\])?', tok.strip())
        name, idx = m.group(1), m.group(2)
        if name not in regs:
            raise KeyError('unknown-register')
        off, size = regs[name]
        if idx is None:
            return [off + i for i in range(size)]
        if int(idx) >= size:
            raise KeyError('index-out-of-range')
        return [off + int(idx)]
    for no, stmt in enumerate(x):
        s = stmt.strip().rstrip(';').strip()
        head, _, rest = s.partition(' ')
        try:
            if head in ('qreg', 'creg'):
                m = re.fullmatch(r'([a-z]\w*)\[(\d+)\]', rest.strip())
                size = int(m.group(2))
                if head == 'qreg':
                    qregs[m.group(1)] = (nq, size)
                    nq += size
                else:
                    cregs[m.group(1)] = (nc, size)
                    nc += size
            elif head == 'measure':
                src, dst = rest.split('->')
                qs, cs = ref(src, qregs), ref(dst, cregs)
                if len(qs) > len(cs):
                    raise KeyError('size-mismatch')
                out += [['measure', a, b] for a, b in zip(qs, cs)]
            else:
                args = [ref(t, qregs) for t in rest.split(',')]
                width = max(len(a) for a in args)
                if any(len(a) not in (1, width) for a in args):
                    raise KeyError('size-mismatch')
                for i in range(width):
                    out.append([head, [a[0] if len(a) == 1 else a[i] for a in args]])
        except KeyError as e:
            return [e.args[0], no]
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: measure size mismatch', ['qreg q[3];', 'creg c[2];', 'measure q -> c;'], ['size-mismatch', 2]], ['regression: random program 1', ['qreg q[3];', 'creg c[2];', 'h q;', 'measure q[0] -> c;'], ['size-mismatch', 3]], ['regression: random program 4', ['qreg q[3];', 'creg c[3];', 'qreg r[1];', 'creg d[3];', 'qreg s[1];', 'creg e[2];', 'x s;', 'measure s[0] -> e;', 'cx q,r[0];'], ['size-mismatch', 7]], ['control: two registers broadcast', ['qreg q[2];', 'qreg r[2];', 'creg c[2];', 'cx q,r;', 'measure r -> c;'], [['cx', [0, 2]], ['cx', [1, 3]], ['measure', 2, 0], ['measure', 3, 1]]], ['control: creg declared between qregs', ['qreg a[1];', 'creg c[2];', 'qreg b[2];', 'h b[1];'], [['h', [2]]]], ['control: index equals size', ['qreg q[2];', 'h q[2];'], ['index-out-of-range', 1]], ['control: second register overflow', ['qreg q[2];', 'qreg r[2];', 'x r[3];'], ['index-out-of-range', 2]]], [['regression: random program 10', ['qreg q[2];', 'qreg r[2];', 'creg c[2];', 'h q[0];', 'x q;', 'measure r[0] -> c;'], ['size-mismatch', 5]], ['regression: random program 11', ['qreg q[2];', 'creg c[1];', 'qreg r[1];', 'creg d[3];', 'measure q -> d[2];', 'x r[0];', 'x q;', 'measure q[0] -> d[0];'], ['size-mismatch', 4]], ['regression: random program 13', ['qreg q[2];', 'qreg r[2];', 'qreg s[1];', 'creg c[2];', 'cx r[0],q;', 'measure q[0] -> c[1];', 'cx r[1],r;', 'measure r[0] -> c;'], ['size-mismatch', 7]], ['control: single control broadcast target', ['qreg q[1];', 'qreg r[3];', 'cx q[0],r;'], [['cx', [0, 1]], ['cx', [0, 2]], ['cx', [0, 3]]]], ['control: register control single target', ['qreg q[3];', 'qreg r[1];', 'cx q,r[0];'], [['cx', [0, 3]], ['cx', [1, 3]], ['cx', [2, 3]]]], ['control: measure into qreg name', ['qreg q[1];', 'qreg r[1];', 'measure q[0] -> r[0];'], ['unknown-register', 2]], ['control: unknown register', ['qreg q[1];', 'h z[0];'], ['unknown-register', 1]]], [['regression: random program 19', ['qreg q[1];', 'qreg r[1];', 'qreg s[2];', 'creg c[3];', 'measure s[0] -> c;', 'h q[0];'], ['size-mismatch', 4]], ['regression: random program 24', ['qreg q[3];', 'creg c[2];', 'h q[0];', 'measure q[2] -> c;'], ['size-mismatch', 3]], ['regression: random program 28', ['qreg q[3];', 'creg c[2];', 'h q[0];', 'cx q[1],q[0];', 'measure q[1] -> c;'], ['size-mismatch', 4]], ['control: random program 0', ['qreg q[2];', 'creg c[2];', 'h q[0];', 'measure q[1] -> c[0];'], [['h', [0]], ['measure', 1, 0]]], ['control: random program 2', ['qreg q[3];', 'creg c[3];', 'qreg r[1];', 'creg d[1];', 'h q[1];'], [['h', [1]]]], ['control: random program 3', ['qreg q[2];', 'creg c[2];', 'h q[1];'], [['h', [1]]]], ['control: random program 5', ['qreg q[1];', 'creg c[3];', 'qreg r[1];', 'creg d[3];', 'cx r[0],q[0];', 'measure r -> d[0];', 'cx q[0],q[0];', 'cx r[0],r;'], [['cx', [1, 0]], ['measure', 1, 3], ['cx', [0, 0]], ['cx', [1, 1]]]]], [['regression: random program 38', ['qreg q[3];', 'creg c[1];', 'measure q -> c[0];', 'h q[0];', 'measure q[3] -> c[0];', 'cx q[2],q[0];'], ['size-mismatch', 2]], ['regression: random program 40', ['qreg q[1];', 'qreg r[1];', 'creg c[3];', 'measure r -> c;'], ['size-mismatch', 3]], ['regression: random program 28', ['qreg q[3];', 'creg c[2];', 'h q[0];', 'cx q[1],q[0];', 'measure q[1] -> c;'], ['size-mismatch', 4]], ['control: random program 6', ['qreg q[3];', 'creg c[2];', 'cx q[2],q;'], [['cx', [2, 0]], ['cx', [2, 1]], ['cx', [2, 2]]]], ['control: random program 7', ['qreg q[1];', 'creg c[3];', 'x q;', 'cx q,q[1];', 'cx q[0],q[0];', 'cx q[0],q;'], ['index-out-of-range', 3]], ['control: random program 8', ['qreg q[2];', 'qreg r[1];', 'qreg s[2];', 'creg c[2];', 'cx r[0],s[1];', 'h s;', 'measure q[1] -> c[1];', 'h s;'], [['cx', [2, 4]], ['h', [3]], ['h', [4]], ['measure', 1, 1], ['h', [3]], ['h', [4]]]], ['control: random program 9', ['qreg q[1];', 'qreg r[1];', 'qreg s[1];', 'creg c[2];', 'h q[0];'], [['h', [0]]]]], [['regression: random program 43', ['qreg q[3];', 'creg c[2];', 'measure q[0] -> c;'], ['size-mismatch', 2]], ['regression: random program 48', ['qreg q[2];', 'creg c[3];', 'qreg r[2];', 'measure q[0] -> c[2];', 'measure q -> c;'], ['size-mismatch', 4]], ['regression: random program 53', ['qreg q[2];', 'creg c[3];', 'qreg r[2];', 'qreg s[3];', 'measure r -> c;', 'x q[1];', 'cx q[1],q[0];'], ['size-mismatch', 4]], ['control: random program 12', ['qreg q[3];', 'creg c[1];', 'qreg r[2];', 'creg d[3];', 'x q;', 'h r;', 'x r[1];'], [['x', [0]], ['x', [1]], ['x', [2]], ['h', [3]], ['h', [4]], ['x', [4]]]], ['control: random program 14', ['qreg q[3];', 'creg c[2];', 'qreg r[2];', 'creg d[3];', 'qreg s[2];', 'x r[1];', 'x q;', 'x r[0];', 'cx s[0],r;'], [['x', [4]], ['x', [0]], ['x', [1]], ['x', [2]], ['x', [3]], ['cx', [5, 3]], ['cx', [5, 4]]]], ['control: random program 15', ['qreg q[1];', 'qreg r[2];', 'qreg s[3];', 'creg c[2];', 'x q;', 'h r[1];', 'cx s[2],r[1];', 'cx r[1],q[0];'], [['x', [0]], ['h', [2]], ['cx', [5, 2]], ['cx', [2, 0]]]], ['control: random program 16', ['qreg q[2];', 'creg c[2];', 'qreg r[1];', 'qreg s[2];', 'creg d[1];', 'cx s,q;', 'x r[0];'], [['cx', [3, 0]], ['cx', [4, 1]], ['x', [2]]]]]]
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: measure size mismatch['size-mismatch', 2]['size-mismatch', 2]Passed
regression: random program 1[['h', [0]], ['h', [1]], ['h', [2]], ['measure', 0, 0]]['size-mismatch', 3]Failed
regression: random program 4[['x', [4]], ['measure', 4, 6], ['cx', [0, 3]], ['cx', [1, 3]], ['cx', [2, 3]]]['size-mismatch', 7]Failed
control: two registers broadcast[['cx', [0, 2]], ['cx', [1, 3]], ['measure', 2, 0], ['measure', 3, 1]][['cx', [0, 2]], ['cx', [1, 3]], ['measure', 2, 0], ['measure', 3, 1]]Passed
control: creg declared between qregs[['h', [2]]][['h', [2]]]Passed
control: index equals size['index-out-of-range', 1]['index-out-of-range', 1]Passed
control: second register overflow['index-out-of-range', 2]['index-out-of-range', 2]Passed

SHA-256 / 9d9778c97c9598dcba931c824239cd4bfda66cca57854db51e867152492abb96

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import re
N = 1
observations = []
def solve(x):
    qregs, cregs = {}, {}
    nq = nc = 0
    out = []
    def ref(tok, regs):
        m = re.fullmatch(r'([a-z]\w*)(?:\[(\d+)\])?', tok.strip())
        name, idx = m.group(1), m.group(2)
        if name not in regs:
            raise KeyError('unknown-register')
        off, size = regs[name]
        if idx is None:
            return [off + i for i in range(size)]
        if int(idx) >= size:
            raise KeyError('index-out-of-range')
        return [off + int(idx)]
    for no, stmt in enumerate(x):
        s = stmt.strip().rstrip(';').strip()
        head, _, rest = s.partition(' ')
        try:
            if head in ('qreg', 'creg'):
                m = re.fullmatch(r'([a-z]\w*)\[(\d+)\]', rest.strip())
                size = int(m.group(2))
                if head == 'qreg':
                    qregs[m.group(1)] = (nq, size)
                    nq += size
                else:
                    cregs[m.group(1)] = (nc, size)
                    nc += size
            elif head == 'measure':
                src, dst = rest.split('->')
                qs, cs = ref(src, qregs), ref(dst, cregs)
                if len(qs) != len(cs):
                    raise KeyError('size-mismatch')
                out += [['measure', a, b] for a, b in zip(qs, cs)]
            else:
                args = [ref(t, qregs) for t in rest.split(',')]
                width = max(len(a) for a in args)
                if any(len(a) not in (1, width) for a in args):
                    raise KeyError('size-mismatch')
                for i in range(width):
                    out.append([head, [a[0] if len(a) == 1 else a[i] for a in args]])
        except KeyError as e:
            return [e.args[0], no]
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: measure size mismatch', ['qreg q[3];', 'creg c[2];', 'measure q -> c;'], ['size-mismatch', 2]], ['regression: random program 1', ['qreg q[3];', 'creg c[2];', 'h q;', 'measure q[0] -> c;'], ['size-mismatch', 3]], ['regression: random program 4', ['qreg q[3];', 'creg c[3];', 'qreg r[1];', 'creg d[3];', 'qreg s[1];', 'creg e[2];', 'x s;', 'measure s[0] -> e;', 'cx q,r[0];'], ['size-mismatch', 7]], ['control: two registers broadcast', ['qreg q[2];', 'qreg r[2];', 'creg c[2];', 'cx q,r;', 'measure r -> c;'], [['cx', [0, 2]], ['cx', [1, 3]], ['measure', 2, 0], ['measure', 3, 1]]], ['control: creg declared between qregs', ['qreg a[1];', 'creg c[2];', 'qreg b[2];', 'h b[1];'], [['h', [2]]]], ['control: index equals size', ['qreg q[2];', 'h q[2];'], ['index-out-of-range', 1]], ['control: second register overflow', ['qreg q[2];', 'qreg r[2];', 'x r[3];'], ['index-out-of-range', 2]]], [['regression: random program 10', ['qreg q[2];', 'qreg r[2];', 'creg c[2];', 'h q[0];', 'x q;', 'measure r[0] -> c;'], ['size-mismatch', 5]], ['regression: random program 11', ['qreg q[2];', 'creg c[1];', 'qreg r[1];', 'creg d[3];', 'measure q -> d[2];', 'x r[0];', 'x q;', 'measure q[0] -> d[0];'], ['size-mismatch', 4]], ['regression: random program 13', ['qreg q[2];', 'qreg r[2];', 'qreg s[1];', 'creg c[2];', 'cx r[0],q;', 'measure q[0] -> c[1];', 'cx r[1],r;', 'measure r[0] -> c;'], ['size-mismatch', 7]], ['control: single control broadcast target', ['qreg q[1];', 'qreg r[3];', 'cx q[0],r;'], [['cx', [0, 1]], ['cx', [0, 2]], ['cx', [0, 3]]]], ['control: register control single target', ['qreg q[3];', 'qreg r[1];', 'cx q,r[0];'], [['cx', [0, 3]], ['cx', [1, 3]], ['cx', [2, 3]]]], ['control: measure into qreg name', ['qreg q[1];', 'qreg r[1];', 'measure q[0] -> r[0];'], ['unknown-register', 2]], ['control: unknown register', ['qreg q[1];', 'h z[0];'], ['unknown-register', 1]]], [['regression: random program 19', ['qreg q[1];', 'qreg r[1];', 'qreg s[2];', 'creg c[3];', 'measure s[0] -> c;', 'h q[0];'], ['size-mismatch', 4]], ['regression: random program 24', ['qreg q[3];', 'creg c[2];', 'h q[0];', 'measure q[2] -> c;'], ['size-mismatch', 3]], ['regression: random program 28', ['qreg q[3];', 'creg c[2];', 'h q[0];', 'cx q[1],q[0];', 'measure q[1] -> c;'], ['size-mismatch', 4]], ['control: random program 0', ['qreg q[2];', 'creg c[2];', 'h q[0];', 'measure q[1] -> c[0];'], [['h', [0]], ['measure', 1, 0]]], ['control: random program 2', ['qreg q[3];', 'creg c[3];', 'qreg r[1];', 'creg d[1];', 'h q[1];'], [['h', [1]]]], ['control: random program 3', ['qreg q[2];', 'creg c[2];', 'h q[1];'], [['h', [1]]]], ['control: random program 5', ['qreg q[1];', 'creg c[3];', 'qreg r[1];', 'creg d[3];', 'cx r[0],q[0];', 'measure r -> d[0];', 'cx q[0],q[0];', 'cx r[0],r;'], [['cx', [1, 0]], ['measure', 1, 3], ['cx', [0, 0]], ['cx', [1, 1]]]]], [['regression: random program 38', ['qreg q[3];', 'creg c[1];', 'measure q -> c[0];', 'h q[0];', 'measure q[3] -> c[0];', 'cx q[2],q[0];'], ['size-mismatch', 2]], ['regression: random program 40', ['qreg q[1];', 'qreg r[1];', 'creg c[3];', 'measure r -> c;'], ['size-mismatch', 3]], ['regression: random program 28', ['qreg q[3];', 'creg c[2];', 'h q[0];', 'cx q[1],q[0];', 'measure q[1] -> c;'], ['size-mismatch', 4]], ['control: random program 6', ['qreg q[3];', 'creg c[2];', 'cx q[2],q;'], [['cx', [2, 0]], ['cx', [2, 1]], ['cx', [2, 2]]]], ['control: random program 7', ['qreg q[1];', 'creg c[3];', 'x q;', 'cx q,q[1];', 'cx q[0],q[0];', 'cx q[0],q;'], ['index-out-of-range', 3]], ['control: random program 8', ['qreg q[2];', 'qreg r[1];', 'qreg s[2];', 'creg c[2];', 'cx r[0],s[1];', 'h s;', 'measure q[1] -> c[1];', 'h s;'], [['cx', [2, 4]], ['h', [3]], ['h', [4]], ['measure', 1, 1], ['h', [3]], ['h', [4]]]], ['control: random program 9', ['qreg q[1];', 'qreg r[1];', 'qreg s[1];', 'creg c[2];', 'h q[0];'], [['h', [0]]]]], [['regression: random program 43', ['qreg q[3];', 'creg c[2];', 'measure q[0] -> c;'], ['size-mismatch', 2]], ['regression: random program 48', ['qreg q[2];', 'creg c[3];', 'qreg r[2];', 'measure q[0] -> c[2];', 'measure q -> c;'], ['size-mismatch', 4]], ['regression: random program 53', ['qreg q[2];', 'creg c[3];', 'qreg r[2];', 'qreg s[3];', 'measure r -> c;', 'x q[1];', 'cx q[1],q[0];'], ['size-mismatch', 4]], ['control: random program 12', ['qreg q[3];', 'creg c[1];', 'qreg r[2];', 'creg d[3];', 'x q;', 'h r;', 'x r[1];'], [['x', [0]], ['x', [1]], ['x', [2]], ['h', [3]], ['h', [4]], ['x', [4]]]], ['control: random program 14', ['qreg q[3];', 'creg c[2];', 'qreg r[2];', 'creg d[3];', 'qreg s[2];', 'x r[1];', 'x q;', 'x r[0];', 'cx s[0],r;'], [['x', [4]], ['x', [0]], ['x', [1]], ['x', [2]], ['x', [3]], ['cx', [5, 3]], ['cx', [5, 4]]]], ['control: random program 15', ['qreg q[1];', 'qreg r[2];', 'qreg s[3];', 'creg c[2];', 'x q;', 'h r[1];', 'cx s[2],r[1];', 'cx r[1],q[0];'], [['x', [0]], ['h', [2]], ['cx', [5, 2]], ['cx', [2, 0]]]], ['control: random program 16', ['qreg q[2];', 'creg c[2];', 'qreg r[1];', 'qreg s[2];', 'creg d[1];', 'cx s,q;', 'x r[0];'], [['cx', [3, 0]], ['cx', [4, 1]], ['x', [2]]]]]]
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: measure size mismatch['size-mismatch', 2]['size-mismatch', 2]Passed
regression: random program 1['size-mismatch', 3]['size-mismatch', 3]Passed
regression: random program 4['size-mismatch', 7]['size-mismatch', 7]Passed
control: two registers broadcast[['cx', [0, 2]], ['cx', [1, 3]], ['measure', 2, 0], ['measure', 3, 1]][['cx', [0, 2]], ['cx', [1, 3]], ['measure', 2, 0], ['measure', 3, 1]]Passed
control: creg declared between qregs[['h', [2]]][['h', [2]]]Passed
control: index equals size['index-out-of-range', 1]['index-out-of-range', 1]Passed
control: second register overflow['index-out-of-range', 2]['index-out-of-range', 2]Passed

SHA-256 / e2970fd2aca789cda9c175d61bc034051a003e56197c024ba725ded74df6435c

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:34.822920+00:00.

Case digest / f606e3ae7c506526701b502532aae1354d41d4c9efd5e3d696e43d7a49bd0359