FA-91091 / Quantum circuit simulation / Open access
Bloch vector only rejects an exactly zero state · case 01
Amplitudes of order 1e-7 (numerical noise) are blown up into a unit Bloch vector instead of "zero-state".
ROOT CAUSE
The degenerate-state guard compares the squared norm with == 0 instead of the 1e-12 tolerance.
VERIFIED REPAIR
Return "zero-state" whenever |a|^2 + |b|^2 < 1e-12.
Unsuccessful approach: The attempted repair tests each amplitude magnitude against 1e-12, which is the square root of the intended scale.
Case contract
Input [[ar, ai], [br, bi]] for a|0> + b|1> (possibly unnormalized). Return the Bloch vector [2Re(conj(a) b), 2Im(conj(a) b), |a|^2 - |b|^2] divided by |a|^2 + |b|^2, rounded to 6 decimals, or "zero-state" when the squared norm is below 1e-12.
Why this case matters
Bloch coordinates feed visualizers and single-qubit tomography checks; sign or scale slips put states on the wrong axis.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
(ar, ai), (br, bi) = x
a, b = complex(ar, ai), complex(br, bi)
nrm = abs(a) ** 2 + abs(b) ** 2
if nrm == 0:
return 'zero-state'
cross = a.conjugate() * b
bx = 2 * cross.real / nrm
by = 2 * cross.imag / nrm
bz = (abs(a) ** 2 - abs(b) ** 2) / nrm
return [round(v, 6) + 0.0 for v in (bx, by, bz)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: numerical noise state', [[1e-07, 0], [0, 1e-07]], 'zero-state'], ['regression: noise on one amplitude', [[3e-08, 0], [0, 0]], 'zero-state'], ['control: ket zero', [[1, 0], [0, 0]], [0.0, 0.0, 1.0]], ['control: ket one', [[0, 0], [1, 0]], [0.0, 0.0, -1.0]], ['control: plus', [[0.707107, 0], [0.707107, 0]], [1.0, 0.0, 0.0]], ['control: plus i', [[0.707107, 0], [0, 0.707107]], [0.0, 1.0, 0.0]]], [['regression: noise on one amplitude', [[3e-08, 0], [0, 0]], 'zero-state'], ['regression: numerical noise state', [[1e-07, 0], [0, 1e-07]], 'zero-state'], ['control: minus i', [[0.707107, 0], [0, -0.707107]], [0.0, -1.0, 0.0]], ['control: zero vector', [[0, 0], [0, 0]], 'zero-state'], ['control: unnormalized', [[3, 0], [0, 4]], [0.0, 0.96, -0.28]], ['control: global phase i', [[0, 1], [0, 0]], [0.0, 0.0, 1.0]]], [['regression: numerical noise state', [[1e-07, 0], [0, 1e-07]], 'zero-state'], ['regression: noise on one amplitude', [[3e-08, 0], [0, 0]], 'zero-state'], ['control: random qubit 0', [[-1.176, -0.41], [1.26, -1.053]], [-0.494424, 0.826337, -0.26965]], ['control: random qubit 1', [[1.052, -0.843], [-0.499, 1.97]], [-0.735014, 0.555478, -0.388843]], ['control: random qubit 2', [[0.057, -1.052], [0.48, 1.205]], [-0.888347, 0.410865, -0.205012]], ['control: random qubit 3', [[1.769, -1.743], [0.441, -0.443]], [0.47339, -0.004576, 0.880841]]], [['regression: noise on one amplitude', [[3e-08, 0], [0, 0]], 'zero-state'], ['regression: numerical noise state', [[1e-07, 0], [0, 1e-07]], 'zero-state'], ['control: random qubit 4', [[-1.063, 1.137], [0.11, -1.819]], [-0.760893, 0.629754, -0.156369]], ['control: random qubit 5', [[1.781, 0.313], [-0.534, -1.473]], [-0.493327, -0.858114, 0.142371]], ['control: random qubit 6', [[1.624, -0.932], [-1.233, 0.708]], [-0.963265, 0.00023, 0.268554]], ['control: random qubit 7', [[-1.454, -0.834], [1.157, -0.946]], [-0.354262, 0.928143, 0.114234]]], [['regression: numerical noise state', [[1e-07, 0], [0, 1e-07]], 'zero-state'], ['regression: noise on one amplitude', [[3e-08, 0], [0, 0]], 'zero-state'], ['control: random qubit 8', [[-1.932, 0.067], [0.651, -1.416]], [-0.438732, 0.873211, 0.212174]], ['control: random qubit 9', [[0.467, -1.484], [-1.959, -0.631]], [0.006475, -0.962062, -0.272753]], ['control: random qubit 10', [[-1.198, -0.992], [1.144, -1.926]], [0.145232, 0.925635, -0.349439]], ['control: random qubit 11', [[0.295, -0.421], [-0.884, -0.915]], [0.13217, -0.682004, -0.719306]]]]
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: numerical noise state | [0.0, 1.0, 0.0] | zero-state | Failed |
| regression: noise on one amplitude | [0.0, 0.0, 1.0] | zero-state | Failed |
| control: ket zero | [0.0, 0.0, 1.0] | [0.0, 0.0, 1.0] | Passed |
| control: ket one | [0.0, 0.0, -1.0] | [0.0, 0.0, -1.0] | Passed |
| control: plus | [1.0, 0.0, 0.0] | [1.0, 0.0, 0.0] | Passed |
| control: plus i | [0.0, 1.0, 0.0] | [0.0, 1.0, 0.0] | Passed |
SHA-256 / 9ba9b5b5d7816fcf6191f174406900e910357cbdebd2f9c28c1fe2fd22b51788
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
(ar, ai), (br, bi) = x
a, b = complex(ar, ai), complex(br, bi)
nrm = abs(a) ** 2 + abs(b) ** 2
if abs(a) < 1e-12 and abs(b) < 1e-12:
return 'zero-state'
cross = a.conjugate() * b
bx = 2 * cross.real / nrm
by = 2 * cross.imag / nrm
bz = (abs(a) ** 2 - abs(b) ** 2) / nrm
return [round(v, 6) + 0.0 for v in (bx, by, bz)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: numerical noise state', [[1e-07, 0], [0, 1e-07]], 'zero-state'], ['regression: noise on one amplitude', [[3e-08, 0], [0, 0]], 'zero-state'], ['control: ket zero', [[1, 0], [0, 0]], [0.0, 0.0, 1.0]], ['control: ket one', [[0, 0], [1, 0]], [0.0, 0.0, -1.0]], ['control: plus', [[0.707107, 0], [0.707107, 0]], [1.0, 0.0, 0.0]], ['control: plus i', [[0.707107, 0], [0, 0.707107]], [0.0, 1.0, 0.0]]], [['regression: noise on one amplitude', [[3e-08, 0], [0, 0]], 'zero-state'], ['regression: numerical noise state', [[1e-07, 0], [0, 1e-07]], 'zero-state'], ['control: minus i', [[0.707107, 0], [0, -0.707107]], [0.0, -1.0, 0.0]], ['control: zero vector', [[0, 0], [0, 0]], 'zero-state'], ['control: unnormalized', [[3, 0], [0, 4]], [0.0, 0.96, -0.28]], ['control: global phase i', [[0, 1], [0, 0]], [0.0, 0.0, 1.0]]], [['regression: numerical noise state', [[1e-07, 0], [0, 1e-07]], 'zero-state'], ['regression: noise on one amplitude', [[3e-08, 0], [0, 0]], 'zero-state'], ['control: random qubit 0', [[-1.176, -0.41], [1.26, -1.053]], [-0.494424, 0.826337, -0.26965]], ['control: random qubit 1', [[1.052, -0.843], [-0.499, 1.97]], [-0.735014, 0.555478, -0.388843]], ['control: random qubit 2', [[0.057, -1.052], [0.48, 1.205]], [-0.888347, 0.410865, -0.205012]], ['control: random qubit 3', [[1.769, -1.743], [0.441, -0.443]], [0.47339, -0.004576, 0.880841]]], [['regression: noise on one amplitude', [[3e-08, 0], [0, 0]], 'zero-state'], ['regression: numerical noise state', [[1e-07, 0], [0, 1e-07]], 'zero-state'], ['control: random qubit 4', [[-1.063, 1.137], [0.11, -1.819]], [-0.760893, 0.629754, -0.156369]], ['control: random qubit 5', [[1.781, 0.313], [-0.534, -1.473]], [-0.493327, -0.858114, 0.142371]], ['control: random qubit 6', [[1.624, -0.932], [-1.233, 0.708]], [-0.963265, 0.00023, 0.268554]], ['control: random qubit 7', [[-1.454, -0.834], [1.157, -0.946]], [-0.354262, 0.928143, 0.114234]]], [['regression: numerical noise state', [[1e-07, 0], [0, 1e-07]], 'zero-state'], ['regression: noise on one amplitude', [[3e-08, 0], [0, 0]], 'zero-state'], ['control: random qubit 8', [[-1.932, 0.067], [0.651, -1.416]], [-0.438732, 0.873211, 0.212174]], ['control: random qubit 9', [[0.467, -1.484], [-1.959, -0.631]], [0.006475, -0.962062, -0.272753]], ['control: random qubit 10', [[-1.198, -0.992], [1.144, -1.926]], [0.145232, 0.925635, -0.349439]], ['control: random qubit 11', [[0.295, -0.421], [-0.884, -0.915]], [0.13217, -0.682004, -0.719306]]]]
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: numerical noise state | [0.0, 1.0, 0.0] | zero-state | Failed |
| regression: noise on one amplitude | [0.0, 0.0, 1.0] | zero-state | Failed |
| control: ket zero | [0.0, 0.0, 1.0] | [0.0, 0.0, 1.0] | Passed |
| control: ket one | [0.0, 0.0, -1.0] | [0.0, 0.0, -1.0] | Passed |
| control: plus | [1.0, 0.0, 0.0] | [1.0, 0.0, 0.0] | Passed |
| control: plus i | [0.0, 1.0, 0.0] | [0.0, 1.0, 0.0] | Passed |
SHA-256 / 0aa3bbef493b11f2ceb1a40470e11b595e66bd579dcf0141182452ada572825e
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
(ar, ai), (br, bi) = x
a, b = complex(ar, ai), complex(br, bi)
nrm = abs(a) ** 2 + abs(b) ** 2
if nrm < 1e-12:
return 'zero-state'
cross = a.conjugate() * b
bx = 2 * cross.real / nrm
by = 2 * cross.imag / nrm
bz = (abs(a) ** 2 - abs(b) ** 2) / nrm
return [round(v, 6) + 0.0 for v in (bx, by, bz)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: numerical noise state', [[1e-07, 0], [0, 1e-07]], 'zero-state'], ['regression: noise on one amplitude', [[3e-08, 0], [0, 0]], 'zero-state'], ['control: ket zero', [[1, 0], [0, 0]], [0.0, 0.0, 1.0]], ['control: ket one', [[0, 0], [1, 0]], [0.0, 0.0, -1.0]], ['control: plus', [[0.707107, 0], [0.707107, 0]], [1.0, 0.0, 0.0]], ['control: plus i', [[0.707107, 0], [0, 0.707107]], [0.0, 1.0, 0.0]]], [['regression: noise on one amplitude', [[3e-08, 0], [0, 0]], 'zero-state'], ['regression: numerical noise state', [[1e-07, 0], [0, 1e-07]], 'zero-state'], ['control: minus i', [[0.707107, 0], [0, -0.707107]], [0.0, -1.0, 0.0]], ['control: zero vector', [[0, 0], [0, 0]], 'zero-state'], ['control: unnormalized', [[3, 0], [0, 4]], [0.0, 0.96, -0.28]], ['control: global phase i', [[0, 1], [0, 0]], [0.0, 0.0, 1.0]]], [['regression: numerical noise state', [[1e-07, 0], [0, 1e-07]], 'zero-state'], ['regression: noise on one amplitude', [[3e-08, 0], [0, 0]], 'zero-state'], ['control: random qubit 0', [[-1.176, -0.41], [1.26, -1.053]], [-0.494424, 0.826337, -0.26965]], ['control: random qubit 1', [[1.052, -0.843], [-0.499, 1.97]], [-0.735014, 0.555478, -0.388843]], ['control: random qubit 2', [[0.057, -1.052], [0.48, 1.205]], [-0.888347, 0.410865, -0.205012]], ['control: random qubit 3', [[1.769, -1.743], [0.441, -0.443]], [0.47339, -0.004576, 0.880841]]], [['regression: noise on one amplitude', [[3e-08, 0], [0, 0]], 'zero-state'], ['regression: numerical noise state', [[1e-07, 0], [0, 1e-07]], 'zero-state'], ['control: random qubit 4', [[-1.063, 1.137], [0.11, -1.819]], [-0.760893, 0.629754, -0.156369]], ['control: random qubit 5', [[1.781, 0.313], [-0.534, -1.473]], [-0.493327, -0.858114, 0.142371]], ['control: random qubit 6', [[1.624, -0.932], [-1.233, 0.708]], [-0.963265, 0.00023, 0.268554]], ['control: random qubit 7', [[-1.454, -0.834], [1.157, -0.946]], [-0.354262, 0.928143, 0.114234]]], [['regression: numerical noise state', [[1e-07, 0], [0, 1e-07]], 'zero-state'], ['regression: noise on one amplitude', [[3e-08, 0], [0, 0]], 'zero-state'], ['control: random qubit 8', [[-1.932, 0.067], [0.651, -1.416]], [-0.438732, 0.873211, 0.212174]], ['control: random qubit 9', [[0.467, -1.484], [-1.959, -0.631]], [0.006475, -0.962062, -0.272753]], ['control: random qubit 10', [[-1.198, -0.992], [1.144, -1.926]], [0.145232, 0.925635, -0.349439]], ['control: random qubit 11', [[0.295, -0.421], [-0.884, -0.915]], [0.13217, -0.682004, -0.719306]]]]
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: numerical noise state | zero-state | zero-state | Passed |
| regression: noise on one amplitude | zero-state | zero-state | Passed |
| control: ket zero | [0.0, 0.0, 1.0] | [0.0, 0.0, 1.0] | Passed |
| control: ket one | [0.0, 0.0, -1.0] | [0.0, 0.0, -1.0] | Passed |
| control: plus | [1.0, 0.0, 0.0] | [1.0, 0.0, 0.0] | Passed |
| control: plus i | [0.0, 1.0, 0.0] | [0.0, 1.0, 0.0] | Passed |
SHA-256 / 02d5fdbca16566b3925a1be4d8d1bbbe164c30f1bebf3cb6f22a6688d1dc19a5
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.848214+00:00.
Case digest / 0ed18e7c0e086739b8aae57721ecd2744d77d24ae242dc3ed6ce6452e83985a7