FAILURE MAP
← Case archive

FA-90876 / Quantum circuit simulation / Open access

Marginal keys put the first listed qubit on the left · case 01

Measuring qubits [0, 1] of |01> (qubit 0 excited) is reported as outcome "10" instead of "01".

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

ROOT CAUSE

The key builder iterates the qubit list in given order, making the first listed qubit the leftmost character.

VERIFIED REPAIR

Iterate the qubit list in reverse so the first listed qubit is the rightmost character.

Unsuccessful approach: The attempted repair iterates the qubits sorted in descending order, which only matches the contract when the caller lists qubits in ascending order.

Case contract

Input [n, amps, qubits]; amps are 2**n [re, im] pairs (qubit 0 = LSB), possibly unnormalized. Return the marginal outcome distribution over the listed qubits as {bitstring: probability} where the first listed qubit is the rightmost character, probabilities are normalized by the total squared norm, rounded to 6 decimals after summation, and zero entries are omitted. Errors: "bad-length", "duplicate-qubit", "bad-qubit", "zero-state" (total squared norm <= 1e-12).

Why this case matters

Marginal readout distributions are what users compare against hardware counts; ordering or normalization slips mislabel every histogram.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    n, amps, qubits = x
    if len(amps) != 1 << n:
        return 'bad-length'
    if len(set(qubits)) != len(qubits):
        return 'duplicate-qubit'
    if any(q < 0 or q >= n for q in qubits):
        return 'bad-qubit'
    total = sum(re * re + im * im for re, im in amps)
    if total <= 1e-12:
        return 'zero-state'
    acc = {}
    for idx, (a, b) in enumerate(amps):
        p = a * a + b * b
        if p == 0:
            continue
        key = ''.join('1' if idx >> q & 1 else '0' for q in qubits)
        acc[key] = acc.get(key, 0.0) + p
    out = {}
    for key in sorted(acc):
        v = round(acc[key] / total, 6)
        if v > 0:
            out[key] = v
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: reversed qubit list', [2, [[0, 0], [1, 0], [0, 0], [0, 0]], [1, 0]], {'10': 1.0}], ['regression: random state 0', [2, [[0.0, 0.0], [0.282, -0.043], [-0.278, 0.017], [0.0, 0.0]], [0, 1]], {'01': 0.511954, '10': 0.488046}], ['regression: random state 14', [3, [[-0.144, 0.15], [-0.052, 0.123], [0.0, 0.0], [0.145, -0.129], [0.077, 0.218], [0.248, 0.026], [0.0, 0.0], [0.256, 0.015]], [2, 0, 1]], {'000': 0.154343, '001': 0.190816, '010': 0.06366, '011': 0.221969, '110': 0.134459, '111': 0.234753}], ['control: bell state on both qubits', [2, [[0.707107, 0], [0, 0], [0, 0], [0.707107, 0]], [0, 1]], {'00': 0.5, '11': 0.5}], ['control: single qubit marginal of |01>', [2, [[0, 0], [1, 0], [0, 0], [0, 0]], [1]], {'0': 1.0}], ['control: out of range qubit equals n', [2, [[1, 0], [0, 0], [0, 0], [0, 0]], [2]], 'bad-qubit'], ['control: negative qubit index', [2, [[1, 0], [0, 0], [0, 0], [0, 0]], [-1]], 'bad-qubit']], [['regression: random state 10', [3, [[-0.064, 0.212], [0.264, -0.114], [-0.15, -0.24], [0.031, 0.141], [0.037, -0.002], [0.023, -0.229], [0.193, -0.153], [0.251, 0.097]], [0, 1, 2]], {'000': 0.116738, '001': 0.196846, '010': 0.190676, '011': 0.049614, '100': 0.003268, '101': 0.126094, '110': 0.144395, '111': 0.17237}], ['regression: random state 13', [3, [[0.624, -0.422], [-0.596, 0.926], [-0.719, 1.0], [-0.208, -0.957], [-0.398, 0.533], [-0.189, -0.721], [-0.845, -0.901], [0.144, -0.267]], [0, 1, 2]], {'000': 0.082574, '001': 0.176465, '010': 0.220741, '011': 0.139566, '100': 0.064389, '101': 0.080843, '110': 0.222031, '111': 0.013391}], ['regression: random state 16', [3, [[0.907, 0.663], [0.0, 0.0], [0.331, -0.649], [0.0, 0.0], [0.0, 0.0], [-0.03, -0.991], [-0.867, 0.677], [0.598, 0.62]], [1, 2, 0]], {'000': 0.266968, '001': 0.11226, '011': 0.255927, '110': 0.207907, '111': 0.156939}], ['control: duplicate qubits', [2, [[0.6, 0], [0, 0.8], [0, 0], [0, 0]], [0, 0]], 'duplicate-qubit'], ['control: wrong amplitude count', [2, [[1, 0], [0, 0]], [0]], 'bad-length'], ['control: all-zero state', [1, [[0, 0], [0, 0]], [0]], 'zero-state'], ['control: tiny but valid state', [1, [[0.0001, 0], [0, 0.0002]], [0]], {'0': 0.2, '1': 0.8}]], [['regression: random state 16', [3, [[0.907, 0.663], [0.0, 0.0], [0.331, -0.649], [0.0, 0.0], [0.0, 0.0], [-0.03, -0.991], [-0.867, 0.677], [0.598, 0.62]], [1, 2, 0]], {'000': 0.266968, '001': 0.11226, '011': 0.255927, '110': 0.207907, '111': 0.156939}], ['regression: random state 18', [3, [[0.677, 0.096], [0.239, 0.327], [-0.403, -0.031], [-0.73, -0.336], [-0.268, 0.914], [-0.581, -0.023], [-0.881, -0.878], [0.033, 0.181]], [1, 2, 0]], {'000': 0.109573, '001': 0.038287, '010': 0.212615, '011': 0.362563, '100': 0.038447, '101': 0.151348, '110': 0.079234, '111': 0.007933}], ['regression: random state 21', [3, [[0.0, 0.0], [-0.212, 0.006], [-0.199, -0.102], [0.079, -0.15], [0.297, -0.206], [-0.22, -0.145], [0.0, 0.0], [0.093, 0.127]], [2, 1, 0]], {'001': 0.374798, '010': 0.143456, '100': 0.12904, '101': 0.199169, '110': 0.082453, '111': 0.071084}], ['control: unnormalized pair', [1, [[3, 0], [0, 4]], [0]], {'0': 0.36, '1': 0.64}], ['control: random state 1', [2, [[0.129, 0.125], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]], [1, 0]], {'00': 1.0}], ['control: random state 2', [1, [[0.541, -0.923], [-0.479, -0.646]], [0]], {'0': 0.638959, '1': 0.361041}], ['control: random state 4', [1, [[-0.217, 0.525], [-0.308, -0.181]], [0]], {'0': 0.716602, '1': 0.283398}]], [['regression: random state 21', [3, [[0.0, 0.0], [-0.212, 0.006], [-0.199, -0.102], [0.079, -0.15], [0.297, -0.206], [-0.22, -0.145], [0.0, 0.0], [0.093, 0.127]], [2, 1, 0]], {'001': 0.374798, '010': 0.143456, '100': 0.12904, '101': 0.199169, '110': 0.082453, '111': 0.071084}], ['regression: random state 23', [2, [[1.098, -1.804], [0.705, -1.883], [0.433, -0.442], [-1.414, -0.105]], [1, 0]], {'00': 0.409326, '01': 0.035137, '10': 0.371027, '11': 0.18451}], ['regression: random state 28', [2, [[-0.032, 0.121], [0.094, -0.239], [0.281, -0.051], [0.276, 0.224]], [1, 0]], {'00': 0.054104, '01': 0.281699, '10': 0.227802, '11': 0.436395}], ['control: random state 5', [2, [[0.175, -0.97], [0.914, 0.939], [-0.22, 0.959], [-0.79, 0.837]], [1]], {'0': 0.539737, '1': 0.460263}], ['control: random state 6', [3, [[-0.119, 0.092], [0.264, -0.223], [-0.189, 0.034], [-0.22, -0.267], [-0.291, -0.092], [0.09, -0.02], [0.062, -0.284], [-0.239, 0.039]], [2]], {'0': 0.54953, '1': 0.45047}], ['control: random state 7', [1, [[0.725, -0.825], [-0.233, -0.266]], [0]], {'0': 0.906073, '1': 0.093927}], ['control: random state 8', [2, [[0.258, -0.148], [-0.044, -0.154], [0.09, 0.21], [0.28, 0.265]], [0]], {'0': 0.446643, '1': 0.553357}]], [['regression: random state 25', [3, [[-0.902, 0.562], [0.758, -0.57], [0.975, 0.291], [-0.19, -0.662], [-0.541, 0.842], [0.0, 0.0], [-0.052, 0.984], [0.0, 0.0]], [1, 2]], {'00': 0.368146, '01': 0.273926, '10': 0.181748, '11': 0.17618}], ['regression: random state 28', [2, [[-0.032, 0.121], [0.094, -0.239], [0.281, -0.051], [0.276, 0.224]], [1, 0]], {'00': 0.054104, '01': 0.281699, '10': 0.227802, '11': 0.436395}], ['regression: random state 36', [2, [[-0.843, -0.261], [0.109, -0.794], [-0.202, 0.584], [-0.247, 0.059]], [1, 0]], {'00': 0.417026, '01': 0.204483, '10': 0.343956, '11': 0.034534}], ['control: random state 9', [1, [[-0.25, -0.175], [0.0, 0.0]], [0]], {'0': 1.0}], ['control: random state 11', [2, [[-0.211, 0.28], [0.154, -0.18], [-0.016, -0.095], [-0.157, 0.075]], [0]], {'0': 0.604789, '1': 0.395211}], ['control: random state 12', [1, [[0.536, -1.225], [-1.207, -1.215]], [0]], {'0': 0.378717, '1': 0.621283}], ['control: random state 15', [2, [[0.0, 0.0], [0.186, 0.555], [0.0, 0.0], [-0.236, -0.456]], [0]], {'1': 1.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 qubit list{'01': 1.0}{'10': 1.0}Failed
regression: random state 0{'01': 0.488046, '10': 0.511954}{'01': 0.511954, '10': 0.488046}Failed
regression: random state 14{'000': 0.154343, '010': 0.06366, '011': 0.134459, '100': 0.190816, '110': 0.221969, '111': 0.234753}{'000': 0.154343, '001': 0.190816, '010': 0.06366, '011': 0.221969, '110': 0.134459, '111': 0.234753}Failed
control: bell state on both qubits{'00': 0.5, '11': 0.5}{'00': 0.5, '11': 0.5}Passed
control: single qubit marginal of |01>{'0': 1.0}{'0': 1.0}Passed
control: out of range qubit equals nbad-qubitbad-qubitPassed
control: negative qubit indexbad-qubitbad-qubitPassed

SHA-256 / 9d2554c4fb37abb0270235644d2be40c82ba910cca4cee1cc54f626a05d00adc

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    n, amps, qubits = x
    if len(amps) != 1 << n:
        return 'bad-length'
    if len(set(qubits)) != len(qubits):
        return 'duplicate-qubit'
    if any(q < 0 or q >= n for q in qubits):
        return 'bad-qubit'
    total = sum(re * re + im * im for re, im in amps)
    if total <= 1e-12:
        return 'zero-state'
    acc = {}
    for idx, (a, b) in enumerate(amps):
        p = a * a + b * b
        if p == 0:
            continue
        key = ''.join('1' if idx >> q & 1 else '0' for q in sorted(qubits, reverse=True))
        acc[key] = acc.get(key, 0.0) + p
    out = {}
    for key in sorted(acc):
        v = round(acc[key] / total, 6)
        if v > 0:
            out[key] = v
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: reversed qubit list', [2, [[0, 0], [1, 0], [0, 0], [0, 0]], [1, 0]], {'10': 1.0}], ['regression: random state 0', [2, [[0.0, 0.0], [0.282, -0.043], [-0.278, 0.017], [0.0, 0.0]], [0, 1]], {'01': 0.511954, '10': 0.488046}], ['regression: random state 14', [3, [[-0.144, 0.15], [-0.052, 0.123], [0.0, 0.0], [0.145, -0.129], [0.077, 0.218], [0.248, 0.026], [0.0, 0.0], [0.256, 0.015]], [2, 0, 1]], {'000': 0.154343, '001': 0.190816, '010': 0.06366, '011': 0.221969, '110': 0.134459, '111': 0.234753}], ['control: bell state on both qubits', [2, [[0.707107, 0], [0, 0], [0, 0], [0.707107, 0]], [0, 1]], {'00': 0.5, '11': 0.5}], ['control: single qubit marginal of |01>', [2, [[0, 0], [1, 0], [0, 0], [0, 0]], [1]], {'0': 1.0}], ['control: out of range qubit equals n', [2, [[1, 0], [0, 0], [0, 0], [0, 0]], [2]], 'bad-qubit'], ['control: negative qubit index', [2, [[1, 0], [0, 0], [0, 0], [0, 0]], [-1]], 'bad-qubit']], [['regression: random state 10', [3, [[-0.064, 0.212], [0.264, -0.114], [-0.15, -0.24], [0.031, 0.141], [0.037, -0.002], [0.023, -0.229], [0.193, -0.153], [0.251, 0.097]], [0, 1, 2]], {'000': 0.116738, '001': 0.196846, '010': 0.190676, '011': 0.049614, '100': 0.003268, '101': 0.126094, '110': 0.144395, '111': 0.17237}], ['regression: random state 13', [3, [[0.624, -0.422], [-0.596, 0.926], [-0.719, 1.0], [-0.208, -0.957], [-0.398, 0.533], [-0.189, -0.721], [-0.845, -0.901], [0.144, -0.267]], [0, 1, 2]], {'000': 0.082574, '001': 0.176465, '010': 0.220741, '011': 0.139566, '100': 0.064389, '101': 0.080843, '110': 0.222031, '111': 0.013391}], ['regression: random state 16', [3, [[0.907, 0.663], [0.0, 0.0], [0.331, -0.649], [0.0, 0.0], [0.0, 0.0], [-0.03, -0.991], [-0.867, 0.677], [0.598, 0.62]], [1, 2, 0]], {'000': 0.266968, '001': 0.11226, '011': 0.255927, '110': 0.207907, '111': 0.156939}], ['control: duplicate qubits', [2, [[0.6, 0], [0, 0.8], [0, 0], [0, 0]], [0, 0]], 'duplicate-qubit'], ['control: wrong amplitude count', [2, [[1, 0], [0, 0]], [0]], 'bad-length'], ['control: all-zero state', [1, [[0, 0], [0, 0]], [0]], 'zero-state'], ['control: tiny but valid state', [1, [[0.0001, 0], [0, 0.0002]], [0]], {'0': 0.2, '1': 0.8}]], [['regression: random state 16', [3, [[0.907, 0.663], [0.0, 0.0], [0.331, -0.649], [0.0, 0.0], [0.0, 0.0], [-0.03, -0.991], [-0.867, 0.677], [0.598, 0.62]], [1, 2, 0]], {'000': 0.266968, '001': 0.11226, '011': 0.255927, '110': 0.207907, '111': 0.156939}], ['regression: random state 18', [3, [[0.677, 0.096], [0.239, 0.327], [-0.403, -0.031], [-0.73, -0.336], [-0.268, 0.914], [-0.581, -0.023], [-0.881, -0.878], [0.033, 0.181]], [1, 2, 0]], {'000': 0.109573, '001': 0.038287, '010': 0.212615, '011': 0.362563, '100': 0.038447, '101': 0.151348, '110': 0.079234, '111': 0.007933}], ['regression: random state 21', [3, [[0.0, 0.0], [-0.212, 0.006], [-0.199, -0.102], [0.079, -0.15], [0.297, -0.206], [-0.22, -0.145], [0.0, 0.0], [0.093, 0.127]], [2, 1, 0]], {'001': 0.374798, '010': 0.143456, '100': 0.12904, '101': 0.199169, '110': 0.082453, '111': 0.071084}], ['control: unnormalized pair', [1, [[3, 0], [0, 4]], [0]], {'0': 0.36, '1': 0.64}], ['control: random state 1', [2, [[0.129, 0.125], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]], [1, 0]], {'00': 1.0}], ['control: random state 2', [1, [[0.541, -0.923], [-0.479, -0.646]], [0]], {'0': 0.638959, '1': 0.361041}], ['control: random state 4', [1, [[-0.217, 0.525], [-0.308, -0.181]], [0]], {'0': 0.716602, '1': 0.283398}]], [['regression: random state 21', [3, [[0.0, 0.0], [-0.212, 0.006], [-0.199, -0.102], [0.079, -0.15], [0.297, -0.206], [-0.22, -0.145], [0.0, 0.0], [0.093, 0.127]], [2, 1, 0]], {'001': 0.374798, '010': 0.143456, '100': 0.12904, '101': 0.199169, '110': 0.082453, '111': 0.071084}], ['regression: random state 23', [2, [[1.098, -1.804], [0.705, -1.883], [0.433, -0.442], [-1.414, -0.105]], [1, 0]], {'00': 0.409326, '01': 0.035137, '10': 0.371027, '11': 0.18451}], ['regression: random state 28', [2, [[-0.032, 0.121], [0.094, -0.239], [0.281, -0.051], [0.276, 0.224]], [1, 0]], {'00': 0.054104, '01': 0.281699, '10': 0.227802, '11': 0.436395}], ['control: random state 5', [2, [[0.175, -0.97], [0.914, 0.939], [-0.22, 0.959], [-0.79, 0.837]], [1]], {'0': 0.539737, '1': 0.460263}], ['control: random state 6', [3, [[-0.119, 0.092], [0.264, -0.223], [-0.189, 0.034], [-0.22, -0.267], [-0.291, -0.092], [0.09, -0.02], [0.062, -0.284], [-0.239, 0.039]], [2]], {'0': 0.54953, '1': 0.45047}], ['control: random state 7', [1, [[0.725, -0.825], [-0.233, -0.266]], [0]], {'0': 0.906073, '1': 0.093927}], ['control: random state 8', [2, [[0.258, -0.148], [-0.044, -0.154], [0.09, 0.21], [0.28, 0.265]], [0]], {'0': 0.446643, '1': 0.553357}]], [['regression: random state 25', [3, [[-0.902, 0.562], [0.758, -0.57], [0.975, 0.291], [-0.19, -0.662], [-0.541, 0.842], [0.0, 0.0], [-0.052, 0.984], [0.0, 0.0]], [1, 2]], {'00': 0.368146, '01': 0.273926, '10': 0.181748, '11': 0.17618}], ['regression: random state 28', [2, [[-0.032, 0.121], [0.094, -0.239], [0.281, -0.051], [0.276, 0.224]], [1, 0]], {'00': 0.054104, '01': 0.281699, '10': 0.227802, '11': 0.436395}], ['regression: random state 36', [2, [[-0.843, -0.261], [0.109, -0.794], [-0.202, 0.584], [-0.247, 0.059]], [1, 0]], {'00': 0.417026, '01': 0.204483, '10': 0.343956, '11': 0.034534}], ['control: random state 9', [1, [[-0.25, -0.175], [0.0, 0.0]], [0]], {'0': 1.0}], ['control: random state 11', [2, [[-0.211, 0.28], [0.154, -0.18], [-0.016, -0.095], [-0.157, 0.075]], [0]], {'0': 0.604789, '1': 0.395211}], ['control: random state 12', [1, [[0.536, -1.225], [-1.207, -1.215]], [0]], {'0': 0.378717, '1': 0.621283}], ['control: random state 15', [2, [[0.0, 0.0], [0.186, 0.555], [0.0, 0.0], [-0.236, -0.456]], [0]], {'1': 1.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 qubit list{'01': 1.0}{'10': 1.0}Failed
regression: random state 0{'01': 0.511954, '10': 0.488046}{'01': 0.511954, '10': 0.488046}Passed
regression: random state 14{'000': 0.154343, '001': 0.06366, '011': 0.134459, '100': 0.190816, '101': 0.221969, '111': 0.234753}{'000': 0.154343, '001': 0.190816, '010': 0.06366, '011': 0.221969, '110': 0.134459, '111': 0.234753}Failed
control: bell state on both qubits{'00': 0.5, '11': 0.5}{'00': 0.5, '11': 0.5}Passed
control: single qubit marginal of |01>{'0': 1.0}{'0': 1.0}Passed
control: out of range qubit equals nbad-qubitbad-qubitPassed
control: negative qubit indexbad-qubitbad-qubitPassed

SHA-256 / 73b92369962050db515ced0b0910e541df19e5d8d96a1a47181fb2795f325f8a

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    n, amps, qubits = x
    if len(amps) != 1 << n:
        return 'bad-length'
    if len(set(qubits)) != len(qubits):
        return 'duplicate-qubit'
    if any(q < 0 or q >= n for q in qubits):
        return 'bad-qubit'
    total = sum(re * re + im * im for re, im in amps)
    if total <= 1e-12:
        return 'zero-state'
    acc = {}
    for idx, (a, b) in enumerate(amps):
        p = a * a + b * b
        if p == 0:
            continue
        key = ''.join('1' if idx >> q & 1 else '0' for q in reversed(qubits))
        acc[key] = acc.get(key, 0.0) + p
    out = {}
    for key in sorted(acc):
        v = round(acc[key] / total, 6)
        if v > 0:
            out[key] = v
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: reversed qubit list', [2, [[0, 0], [1, 0], [0, 0], [0, 0]], [1, 0]], {'10': 1.0}], ['regression: random state 0', [2, [[0.0, 0.0], [0.282, -0.043], [-0.278, 0.017], [0.0, 0.0]], [0, 1]], {'01': 0.511954, '10': 0.488046}], ['regression: random state 14', [3, [[-0.144, 0.15], [-0.052, 0.123], [0.0, 0.0], [0.145, -0.129], [0.077, 0.218], [0.248, 0.026], [0.0, 0.0], [0.256, 0.015]], [2, 0, 1]], {'000': 0.154343, '001': 0.190816, '010': 0.06366, '011': 0.221969, '110': 0.134459, '111': 0.234753}], ['control: bell state on both qubits', [2, [[0.707107, 0], [0, 0], [0, 0], [0.707107, 0]], [0, 1]], {'00': 0.5, '11': 0.5}], ['control: single qubit marginal of |01>', [2, [[0, 0], [1, 0], [0, 0], [0, 0]], [1]], {'0': 1.0}], ['control: out of range qubit equals n', [2, [[1, 0], [0, 0], [0, 0], [0, 0]], [2]], 'bad-qubit'], ['control: negative qubit index', [2, [[1, 0], [0, 0], [0, 0], [0, 0]], [-1]], 'bad-qubit']], [['regression: random state 10', [3, [[-0.064, 0.212], [0.264, -0.114], [-0.15, -0.24], [0.031, 0.141], [0.037, -0.002], [0.023, -0.229], [0.193, -0.153], [0.251, 0.097]], [0, 1, 2]], {'000': 0.116738, '001': 0.196846, '010': 0.190676, '011': 0.049614, '100': 0.003268, '101': 0.126094, '110': 0.144395, '111': 0.17237}], ['regression: random state 13', [3, [[0.624, -0.422], [-0.596, 0.926], [-0.719, 1.0], [-0.208, -0.957], [-0.398, 0.533], [-0.189, -0.721], [-0.845, -0.901], [0.144, -0.267]], [0, 1, 2]], {'000': 0.082574, '001': 0.176465, '010': 0.220741, '011': 0.139566, '100': 0.064389, '101': 0.080843, '110': 0.222031, '111': 0.013391}], ['regression: random state 16', [3, [[0.907, 0.663], [0.0, 0.0], [0.331, -0.649], [0.0, 0.0], [0.0, 0.0], [-0.03, -0.991], [-0.867, 0.677], [0.598, 0.62]], [1, 2, 0]], {'000': 0.266968, '001': 0.11226, '011': 0.255927, '110': 0.207907, '111': 0.156939}], ['control: duplicate qubits', [2, [[0.6, 0], [0, 0.8], [0, 0], [0, 0]], [0, 0]], 'duplicate-qubit'], ['control: wrong amplitude count', [2, [[1, 0], [0, 0]], [0]], 'bad-length'], ['control: all-zero state', [1, [[0, 0], [0, 0]], [0]], 'zero-state'], ['control: tiny but valid state', [1, [[0.0001, 0], [0, 0.0002]], [0]], {'0': 0.2, '1': 0.8}]], [['regression: random state 16', [3, [[0.907, 0.663], [0.0, 0.0], [0.331, -0.649], [0.0, 0.0], [0.0, 0.0], [-0.03, -0.991], [-0.867, 0.677], [0.598, 0.62]], [1, 2, 0]], {'000': 0.266968, '001': 0.11226, '011': 0.255927, '110': 0.207907, '111': 0.156939}], ['regression: random state 18', [3, [[0.677, 0.096], [0.239, 0.327], [-0.403, -0.031], [-0.73, -0.336], [-0.268, 0.914], [-0.581, -0.023], [-0.881, -0.878], [0.033, 0.181]], [1, 2, 0]], {'000': 0.109573, '001': 0.038287, '010': 0.212615, '011': 0.362563, '100': 0.038447, '101': 0.151348, '110': 0.079234, '111': 0.007933}], ['regression: random state 21', [3, [[0.0, 0.0], [-0.212, 0.006], [-0.199, -0.102], [0.079, -0.15], [0.297, -0.206], [-0.22, -0.145], [0.0, 0.0], [0.093, 0.127]], [2, 1, 0]], {'001': 0.374798, '010': 0.143456, '100': 0.12904, '101': 0.199169, '110': 0.082453, '111': 0.071084}], ['control: unnormalized pair', [1, [[3, 0], [0, 4]], [0]], {'0': 0.36, '1': 0.64}], ['control: random state 1', [2, [[0.129, 0.125], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]], [1, 0]], {'00': 1.0}], ['control: random state 2', [1, [[0.541, -0.923], [-0.479, -0.646]], [0]], {'0': 0.638959, '1': 0.361041}], ['control: random state 4', [1, [[-0.217, 0.525], [-0.308, -0.181]], [0]], {'0': 0.716602, '1': 0.283398}]], [['regression: random state 21', [3, [[0.0, 0.0], [-0.212, 0.006], [-0.199, -0.102], [0.079, -0.15], [0.297, -0.206], [-0.22, -0.145], [0.0, 0.0], [0.093, 0.127]], [2, 1, 0]], {'001': 0.374798, '010': 0.143456, '100': 0.12904, '101': 0.199169, '110': 0.082453, '111': 0.071084}], ['regression: random state 23', [2, [[1.098, -1.804], [0.705, -1.883], [0.433, -0.442], [-1.414, -0.105]], [1, 0]], {'00': 0.409326, '01': 0.035137, '10': 0.371027, '11': 0.18451}], ['regression: random state 28', [2, [[-0.032, 0.121], [0.094, -0.239], [0.281, -0.051], [0.276, 0.224]], [1, 0]], {'00': 0.054104, '01': 0.281699, '10': 0.227802, '11': 0.436395}], ['control: random state 5', [2, [[0.175, -0.97], [0.914, 0.939], [-0.22, 0.959], [-0.79, 0.837]], [1]], {'0': 0.539737, '1': 0.460263}], ['control: random state 6', [3, [[-0.119, 0.092], [0.264, -0.223], [-0.189, 0.034], [-0.22, -0.267], [-0.291, -0.092], [0.09, -0.02], [0.062, -0.284], [-0.239, 0.039]], [2]], {'0': 0.54953, '1': 0.45047}], ['control: random state 7', [1, [[0.725, -0.825], [-0.233, -0.266]], [0]], {'0': 0.906073, '1': 0.093927}], ['control: random state 8', [2, [[0.258, -0.148], [-0.044, -0.154], [0.09, 0.21], [0.28, 0.265]], [0]], {'0': 0.446643, '1': 0.553357}]], [['regression: random state 25', [3, [[-0.902, 0.562], [0.758, -0.57], [0.975, 0.291], [-0.19, -0.662], [-0.541, 0.842], [0.0, 0.0], [-0.052, 0.984], [0.0, 0.0]], [1, 2]], {'00': 0.368146, '01': 0.273926, '10': 0.181748, '11': 0.17618}], ['regression: random state 28', [2, [[-0.032, 0.121], [0.094, -0.239], [0.281, -0.051], [0.276, 0.224]], [1, 0]], {'00': 0.054104, '01': 0.281699, '10': 0.227802, '11': 0.436395}], ['regression: random state 36', [2, [[-0.843, -0.261], [0.109, -0.794], [-0.202, 0.584], [-0.247, 0.059]], [1, 0]], {'00': 0.417026, '01': 0.204483, '10': 0.343956, '11': 0.034534}], ['control: random state 9', [1, [[-0.25, -0.175], [0.0, 0.0]], [0]], {'0': 1.0}], ['control: random state 11', [2, [[-0.211, 0.28], [0.154, -0.18], [-0.016, -0.095], [-0.157, 0.075]], [0]], {'0': 0.604789, '1': 0.395211}], ['control: random state 12', [1, [[0.536, -1.225], [-1.207, -1.215]], [0]], {'0': 0.378717, '1': 0.621283}], ['control: random state 15', [2, [[0.0, 0.0], [0.186, 0.555], [0.0, 0.0], [-0.236, -0.456]], [0]], {'1': 1.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 qubit list{'10': 1.0}{'10': 1.0}Passed
regression: random state 0{'01': 0.511954, '10': 0.488046}{'01': 0.511954, '10': 0.488046}Passed
regression: random state 14{'000': 0.154343, '001': 0.190816, '010': 0.06366, '011': 0.221969, '110': 0.134459, '111': 0.234753}{'000': 0.154343, '001': 0.190816, '010': 0.06366, '011': 0.221969, '110': 0.134459, '111': 0.234753}Passed
control: bell state on both qubits{'00': 0.5, '11': 0.5}{'00': 0.5, '11': 0.5}Passed
control: single qubit marginal of |01>{'0': 1.0}{'0': 1.0}Passed
control: out of range qubit equals nbad-qubitbad-qubitPassed
control: negative qubit indexbad-qubitbad-qubitPassed

SHA-256 / e1db53e308351dab2e7a81aca9a2863aafd27dd6740022722305af6b4b53b965

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

Case digest / b1c8799b9acb220a97883def773d9bc668681b2e5fca556fd3289f52d16e2b92