FA-90916 / Quantum circuit simulation / Open access
Collapse reports unnormalized branch mass as probability · case 01
An input 2|00> + 2|11> reports probability 4 for outcome 0 of qubit 1.
ROOT CAUSE
The returned probability is the raw kept squared mass p rather than p divided by the total squared norm.
THE FAILURE
The returned probability is the raw kept squared mass p rather than p divided by the total squared norm.
Unsuccessful approach: The attempted repair divides by sqrt(norm), mixing amplitude and probability scales.
Case contract
Input [n, amps, q, outcome]; measure qubit q (0 = LSB) of the possibly unnormalized state. Return {"probability": p, "state": post} with p normalized by the total squared norm and the post-measurement state renormalized to unit norm with the other branch zeroed; values rounded to 6 decimals. Return "impossible" when p < 1e-12.
Why this case matters
Mid-circuit measurement and collapse drive dynamic circuits; wrong renormalization breaks every later probability.
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, q, outcome = x
psi = [complex(a, b) for a, b in amps]
keep = [((i >> q) & 1) == outcome for i in range(len(psi))]
p = sum(abs(v) ** 2 for i, v in enumerate(psi) if keep[i])
norm = sum(abs(v) ** 2 for v in psi)
prob = p
if prob < 1e-12:
return 'impossible'
scale = 1 / math.sqrt(p)
post = [v * scale if keep[i] else 0j for i, v in enumerate(psi)]
return {'probability': round(prob, 6) + 0.0, 'state': [[round(v.real, 6) + 0.0, round(v.imag, 6) + 0.0] for v in post]}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: unnormalized bell measure qubit 1', [2, [[2, 0], [0, 0], [0, 0], [2, 0]], 1, 0], {'probability': 0.5, 'state': [[1.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]]}], ['regression: tiny norm state', [1, [[3e-07, 0], [0, 4e-07]], 0, 1], {'probability': 0.64, 'state': [[0.0, 0.0], [0.0, 1.0]]}], ['regression: random collapse 0', [1, [[-0.305, 0.494], [0.447, -0.241]], 0, 0], {'probability': 0.566536, 'state': [[-0.525346, 0.850889], [0.0, 0.0]]}], ['control: measure 0 on |+>', [1, [[0.707107, 0], [0.707107, 0]], 0, 0], {'probability': 0.5, 'state': [[1.0, 0.0], [0.0, 0.0]]}], ['control: measure 1 on |+>', [1, [[0.707107, 0], [0.707107, 0]], 0, 1], {'probability': 0.5, 'state': [[0.0, 0.0], [1.0, 0.0]]}], ['control: impossible outcome', [1, [[1, 0], [0, 0]], 0, 1], 'impossible'], ['control: near impossible branch', [1, [[1, 0], [1e-08, 0]], 0, 1], 'impossible']], [['regression: random collapse 3', [3, [[0.755, 0.514], [0.624, 0.382], [-0.745, 0.675], [-0.295, 0.287], [0.799, -0.013], [-0.459, 0.107], [0.751, 0.682], [0.988, 0.816]], 0, 1], {'probability': 0.422407, 'state': [[0.0, 0.0], [0.38933, 0.23834], [0.0, 0.0], [-0.184058, 0.179067], [0.0, 0.0], [-0.286382, 0.06676], [0.0, 0.0], [0.616439, 0.509123]]}], ['regression: random collapse 4', [1, [[-0.125, -0.177], [0.075, 0.432]], 0, 0], {'probability': 0.196294, 'state': [[-0.576864, -0.81684], [0.0, 0.0]]}], ['regression: random collapse 0', [1, [[-0.305, 0.494], [0.447, -0.241]], 0, 0], {'probability': 0.566536, 'state': [[-0.525346, 0.850889], [0.0, 0.0]]}], ['control: random collapse 1', [2, [[0.5, 0.0], [0.0, 0.0], [0.0, -0.0], [-0.0, -0.0]], 0, 1], 'impossible'], ['control: random collapse 2', [2, [[0.0, 0.0], [0.0, 0.0], [0.591, 0.404], [0.405, 0.306]], 1, 0], 'impossible'], ['control: random collapse 7', [2, [[0.5, 0.0], [-0.0, 0.0], [0.0, 0.0], [0.0, 0.0]], 0, 1], 'impossible'], ['control: random collapse 12', [1, [[0.5, 0.0], [0.0, 0.0]], 0, 1], 'impossible']], [['regression: random collapse 6', [3, [[-0.436, -0.015], [-0.35, 0.017], [0.17, 0.002], [0.369, -0.461], [0.411, -0.033], [-0.475, 0.29], [0.379, -0.067], [-0.298, 0.408]], 2, 0], {'probability': 0.438863, 'state': [[-0.524618, -0.018049], [-0.421138, 0.020455], [0.204553, 0.002407], [0.444, -0.554699], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]]}], ['regression: random collapse 8', [2, [[-1.464, -0.995], [0.052, 0.311], [0.0, 0.0], [0.0, 0.0]], 0, 0], {'probability': 0.969244, 'state': [[-0.827063, -0.562109], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]]}], ['regression: random collapse 4', [1, [[-0.125, -0.177], [0.075, 0.432]], 0, 0], {'probability': 0.196294, 'state': [[-0.576864, -0.81684], [0.0, 0.0]]}], ['control: random collapse 16', [2, [[0.5, 0.0], [-0.0, 0.0], [0.0, -0.0], [-0.0, 0.0]], 0, 1], 'impossible'], ['control: random collapse 22', [2, [[0.5, 0.0], [-0.0, -0.0], [0.0, 0.0], [-0.0, -0.0]], 0, 1], 'impossible'], ['control: random collapse 23', [2, [[0.5, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, -0.0]], 0, 1], 'impossible'], ['control: random collapse 34', [2, [[0.5, 0.0], [0.0, 0.0], [0.0, 0.0], [-0.0, 0.0]], 1, 1], 'impossible']], [['regression: random collapse 10', [2, [[0.359, -0.323], [-0.182, -0.34], [0.238, 0.218], [-0.224, 0.46]], 0, 1], {'probability': 0.548886, 'state': [[0.0, 0.0], [-0.284063, -0.530667], [0.0, 0.0], [-0.349616, 0.717962]]}], ['regression: random collapse 11', [2, [[0.414, -0.429], [-0.452, -0.264], [0.422, -0.171], [-0.123, 0.056]], 0, 1], {'probability': 0.34182, 'state': [[0.0, 0.0], [-0.836084, -0.488332], [0.0, 0.0], [-0.227518, 0.103586]]}], ['regression: random collapse 6', [3, [[-0.436, -0.015], [-0.35, 0.017], [0.17, 0.002], [0.369, -0.461], [0.411, -0.033], [-0.475, 0.29], [0.379, -0.067], [-0.298, 0.408]], 2, 0], {'probability': 0.438863, 'state': [[-0.524618, -0.018049], [-0.421138, 0.020455], [0.204553, 0.002407], [0.444, -0.554699], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]]}], ['control: random collapse 37', [3, [[0.5, 0.0], [-0.0, -0.0], [0.0, -0.0], [0.0, 0.0], [0.0, -0.0], [-0.0, 0.0], [-0.0, -0.0], [-0.0, 0.0]], 0, 1], 'impossible'], ['control: measure 0 on |+>', [1, [[0.707107, 0], [0.707107, 0]], 0, 0], {'probability': 0.5, 'state': [[1.0, 0.0], [0.0, 0.0]]}], ['control: measure 1 on |+>', [1, [[0.707107, 0], [0.707107, 0]], 0, 1], {'probability': 0.5, 'state': [[0.0, 0.0], [1.0, 0.0]]}], ['control: impossible outcome', [1, [[1, 0], [0, 0]], 0, 1], 'impossible']], [['regression: random collapse 14', [2, [[-1.5, 0.759], [0.0, 0.0], [0.0, 0.0], [-2.588, 1.898]], 1, 0], {'probability': 0.2153, 'state': [[-0.892275, 0.451491], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]]}], ['regression: random collapse 15', [1, [[0.489, -0.285], [-0.403, 0.425]], 0, 1], {'probability': 0.5171, 'state': [[0.0, 0.0], [-0.688076, 0.725639]]}], ['regression: random collapse 9', [1, [[0.307, 0.202], [-0.161, 0.592]], 0, 0], {'probability': 0.264065, 'state': [[0.835384, 0.549666], [0.0, 0.0]]}], ['control: near impossible branch', [1, [[1, 0], [1e-08, 0]], 0, 1], 'impossible'], ['control: random collapse 1', [2, [[0.5, 0.0], [0.0, 0.0], [0.0, -0.0], [-0.0, -0.0]], 0, 1], 'impossible'], ['control: random collapse 2', [2, [[0.0, 0.0], [0.0, 0.0], [0.591, 0.404], [0.405, 0.306]], 1, 0], 'impossible'], ['control: random collapse 7', [2, [[0.5, 0.0], [-0.0, 0.0], [0.0, 0.0], [0.0, 0.0]], 0, 1], 'impossible']]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: unnormalized bell measure qubit 1 | {'probability': 4.0, 'state': [[1.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]]} | {'probability': 0.5, 'state': [[1.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]]} | Failed |
| regression: tiny norm state | impossible | {'probability': 0.64, 'state': [[0.0, 0.0], [0.0, 1.0]]} | Failed |
| regression: random collapse 0 | {'probability': 0.337061, 'state': [[-0.525346, 0.850889], [0.0, 0.0]]} | {'probability': 0.566536, 'state': [[-0.525346, 0.850889], [0.0, 0.0]]} | Failed |
| control: measure 0 on |+> | {'probability': 0.5, 'state': [[1.0, 0.0], [0.0, 0.0]]} | {'probability': 0.5, 'state': [[1.0, 0.0], [0.0, 0.0]]} | Passed |
| control: measure 1 on |+> | {'probability': 0.5, 'state': [[0.0, 0.0], [1.0, 0.0]]} | {'probability': 0.5, 'state': [[0.0, 0.0], [1.0, 0.0]]} | Passed |
| control: impossible outcome | impossible | impossible | Passed |
| control: near impossible branch | impossible | impossible | Passed |
SHA-256 / f4409bfec74c9c54f3c3c63fa9e59859fc25b41c3fcf4c471c9c456e8b7fc348
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, q, outcome = x
psi = [complex(a, b) for a, b in amps]
keep = [((i >> q) & 1) == outcome for i in range(len(psi))]
p = sum(abs(v) ** 2 for i, v in enumerate(psi) if keep[i])
norm = sum(abs(v) ** 2 for v in psi)
prob = p / math.sqrt(norm)
if prob < 1e-12:
return 'impossible'
scale = 1 / math.sqrt(p)
post = [v * scale if keep[i] else 0j for i, v in enumerate(psi)]
return {'probability': round(prob, 6) + 0.0, 'state': [[round(v.real, 6) + 0.0, round(v.imag, 6) + 0.0] for v in post]}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: unnormalized bell measure qubit 1', [2, [[2, 0], [0, 0], [0, 0], [2, 0]], 1, 0], {'probability': 0.5, 'state': [[1.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]]}], ['regression: tiny norm state', [1, [[3e-07, 0], [0, 4e-07]], 0, 1], {'probability': 0.64, 'state': [[0.0, 0.0], [0.0, 1.0]]}], ['regression: random collapse 0', [1, [[-0.305, 0.494], [0.447, -0.241]], 0, 0], {'probability': 0.566536, 'state': [[-0.525346, 0.850889], [0.0, 0.0]]}], ['control: measure 0 on |+>', [1, [[0.707107, 0], [0.707107, 0]], 0, 0], {'probability': 0.5, 'state': [[1.0, 0.0], [0.0, 0.0]]}], ['control: measure 1 on |+>', [1, [[0.707107, 0], [0.707107, 0]], 0, 1], {'probability': 0.5, 'state': [[0.0, 0.0], [1.0, 0.0]]}], ['control: impossible outcome', [1, [[1, 0], [0, 0]], 0, 1], 'impossible'], ['control: near impossible branch', [1, [[1, 0], [1e-08, 0]], 0, 1], 'impossible']], [['regression: random collapse 3', [3, [[0.755, 0.514], [0.624, 0.382], [-0.745, 0.675], [-0.295, 0.287], [0.799, -0.013], [-0.459, 0.107], [0.751, 0.682], [0.988, 0.816]], 0, 1], {'probability': 0.422407, 'state': [[0.0, 0.0], [0.38933, 0.23834], [0.0, 0.0], [-0.184058, 0.179067], [0.0, 0.0], [-0.286382, 0.06676], [0.0, 0.0], [0.616439, 0.509123]]}], ['regression: random collapse 4', [1, [[-0.125, -0.177], [0.075, 0.432]], 0, 0], {'probability': 0.196294, 'state': [[-0.576864, -0.81684], [0.0, 0.0]]}], ['regression: random collapse 0', [1, [[-0.305, 0.494], [0.447, -0.241]], 0, 0], {'probability': 0.566536, 'state': [[-0.525346, 0.850889], [0.0, 0.0]]}], ['control: random collapse 1', [2, [[0.5, 0.0], [0.0, 0.0], [0.0, -0.0], [-0.0, -0.0]], 0, 1], 'impossible'], ['control: random collapse 2', [2, [[0.0, 0.0], [0.0, 0.0], [0.591, 0.404], [0.405, 0.306]], 1, 0], 'impossible'], ['control: random collapse 7', [2, [[0.5, 0.0], [-0.0, 0.0], [0.0, 0.0], [0.0, 0.0]], 0, 1], 'impossible'], ['control: random collapse 12', [1, [[0.5, 0.0], [0.0, 0.0]], 0, 1], 'impossible']], [['regression: random collapse 6', [3, [[-0.436, -0.015], [-0.35, 0.017], [0.17, 0.002], [0.369, -0.461], [0.411, -0.033], [-0.475, 0.29], [0.379, -0.067], [-0.298, 0.408]], 2, 0], {'probability': 0.438863, 'state': [[-0.524618, -0.018049], [-0.421138, 0.020455], [0.204553, 0.002407], [0.444, -0.554699], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]]}], ['regression: random collapse 8', [2, [[-1.464, -0.995], [0.052, 0.311], [0.0, 0.0], [0.0, 0.0]], 0, 0], {'probability': 0.969244, 'state': [[-0.827063, -0.562109], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]]}], ['regression: random collapse 4', [1, [[-0.125, -0.177], [0.075, 0.432]], 0, 0], {'probability': 0.196294, 'state': [[-0.576864, -0.81684], [0.0, 0.0]]}], ['control: random collapse 16', [2, [[0.5, 0.0], [-0.0, 0.0], [0.0, -0.0], [-0.0, 0.0]], 0, 1], 'impossible'], ['control: random collapse 22', [2, [[0.5, 0.0], [-0.0, -0.0], [0.0, 0.0], [-0.0, -0.0]], 0, 1], 'impossible'], ['control: random collapse 23', [2, [[0.5, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, -0.0]], 0, 1], 'impossible'], ['control: random collapse 34', [2, [[0.5, 0.0], [0.0, 0.0], [0.0, 0.0], [-0.0, 0.0]], 1, 1], 'impossible']], [['regression: random collapse 10', [2, [[0.359, -0.323], [-0.182, -0.34], [0.238, 0.218], [-0.224, 0.46]], 0, 1], {'probability': 0.548886, 'state': [[0.0, 0.0], [-0.284063, -0.530667], [0.0, 0.0], [-0.349616, 0.717962]]}], ['regression: random collapse 11', [2, [[0.414, -0.429], [-0.452, -0.264], [0.422, -0.171], [-0.123, 0.056]], 0, 1], {'probability': 0.34182, 'state': [[0.0, 0.0], [-0.836084, -0.488332], [0.0, 0.0], [-0.227518, 0.103586]]}], ['regression: random collapse 6', [3, [[-0.436, -0.015], [-0.35, 0.017], [0.17, 0.002], [0.369, -0.461], [0.411, -0.033], [-0.475, 0.29], [0.379, -0.067], [-0.298, 0.408]], 2, 0], {'probability': 0.438863, 'state': [[-0.524618, -0.018049], [-0.421138, 0.020455], [0.204553, 0.002407], [0.444, -0.554699], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]]}], ['control: random collapse 37', [3, [[0.5, 0.0], [-0.0, -0.0], [0.0, -0.0], [0.0, 0.0], [0.0, -0.0], [-0.0, 0.0], [-0.0, -0.0], [-0.0, 0.0]], 0, 1], 'impossible'], ['control: measure 0 on |+>', [1, [[0.707107, 0], [0.707107, 0]], 0, 0], {'probability': 0.5, 'state': [[1.0, 0.0], [0.0, 0.0]]}], ['control: measure 1 on |+>', [1, [[0.707107, 0], [0.707107, 0]], 0, 1], {'probability': 0.5, 'state': [[0.0, 0.0], [1.0, 0.0]]}], ['control: impossible outcome', [1, [[1, 0], [0, 0]], 0, 1], 'impossible']], [['regression: random collapse 14', [2, [[-1.5, 0.759], [0.0, 0.0], [0.0, 0.0], [-2.588, 1.898]], 1, 0], {'probability': 0.2153, 'state': [[-0.892275, 0.451491], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]]}], ['regression: random collapse 15', [1, [[0.489, -0.285], [-0.403, 0.425]], 0, 1], {'probability': 0.5171, 'state': [[0.0, 0.0], [-0.688076, 0.725639]]}], ['regression: random collapse 9', [1, [[0.307, 0.202], [-0.161, 0.592]], 0, 0], {'probability': 0.264065, 'state': [[0.835384, 0.549666], [0.0, 0.0]]}], ['control: near impossible branch', [1, [[1, 0], [1e-08, 0]], 0, 1], 'impossible'], ['control: random collapse 1', [2, [[0.5, 0.0], [0.0, 0.0], [0.0, -0.0], [-0.0, -0.0]], 0, 1], 'impossible'], ['control: random collapse 2', [2, [[0.0, 0.0], [0.0, 0.0], [0.591, 0.404], [0.405, 0.306]], 1, 0], 'impossible'], ['control: random collapse 7', [2, [[0.5, 0.0], [-0.0, 0.0], [0.0, 0.0], [0.0, 0.0]], 0, 1], 'impossible']]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: unnormalized bell measure qubit 1 | {'probability': 1.414214, 'state': [[1.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]]} | {'probability': 0.5, 'state': [[1.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]]} | Failed |
| regression: tiny norm state | {'probability': 0.0, 'state': [[0.0, 0.0], [0.0, 1.0]]} | {'probability': 0.64, 'state': [[0.0, 0.0], [0.0, 1.0]]} | Failed |
| regression: random collapse 0 | {'probability': 0.436986, 'state': [[-0.525346, 0.850889], [0.0, 0.0]]} | {'probability': 0.566536, 'state': [[-0.525346, 0.850889], [0.0, 0.0]]} | Failed |
| control: measure 0 on |+> | {'probability': 0.5, 'state': [[1.0, 0.0], [0.0, 0.0]]} | {'probability': 0.5, 'state': [[1.0, 0.0], [0.0, 0.0]]} | Passed |
| control: measure 1 on |+> | {'probability': 0.5, 'state': [[0.0, 0.0], [1.0, 0.0]]} | {'probability': 0.5, 'state': [[0.0, 0.0], [1.0, 0.0]]} | Passed |
| control: impossible outcome | impossible | impossible | Passed |
| control: near impossible branch | impossible | impossible | Passed |
SHA-256 / cd323056ad42dd22a4f757e7f4db4a84c9816f23781fa7f2c4efd076c53517f7
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 7 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗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:31.048307+00:00.
Case digest / 1628f37510fed2c17cf1649f7c9a08ebc6fcd74a4f8ec37216e375dce8f9a39b