Operator Loschmidt echo circuits on 49 to 70 qubits
Classically estimate an operator Loschmidt echo on 49- to 70-qubit circuits, where IBM hardware and classical simulations still disagree.
Comparing changes
Choose two branches to see what changed, then open a pull request to bring the work across.
Able to merge. These branches can be merged automatically.
A pull request is already open: #4 Add the estimate verifier: interval sanity, width as the score
3 commits
+146 −0 checks/estimate.py added View file
| @@ -0,0 +1,146 @@ | ||
| 1 | +#!/usr/bin/env python3 | |
| 2 | +"""Judge a route's classical estimate of the operator Loschmidt echo. | |
| 3 | + | |
| 4 | +Usage: estimate.py <route_dir> | |
| 5 | + | |
| 6 | +The route folder may hold estimate.json, the report of one estimate: | |
| 7 | + | |
| 8 | + {"instance": "49x1296", # tracker id, with or without the operator_loschmidt_echo_ prefix | |
| 9 | + "value": 0.66, # the reported estimate of f_delta(O) | |
| 10 | + "lower": 0.655, "upper": 0.665, # the defensible error bar; the metric is upper - lower | |
| 11 | + "method": "BP-TN, bond dimension 512", | |
| 12 | + "convergence": [{"bond": 128, "estimate": 0.6599}, ...], # >= 2 entries, numeric "estimate" | |
| 13 | + "reproduce": "python3 bp_tn.py --bond 512 > estimate.json", | |
| 14 | + "runtime_s": 7260, "hardware": "...", "notes": "..." } # optional | |
| 15 | + | |
| 16 | +The check is exact about the contract and agnostic about the physics: it cannot recompute | |
| 17 | +f_delta(O) for 49-70 qubit circuits in a 10-minute, 4-CPU, no-network job, so it enforces | |
| 18 | +what makes an interval comparable within an instance and reports the width as the score. | |
| 19 | +O is a product of Pauli Z operators, O^2 = I, so f_delta(O) lies in [-1, 1]. | |
| 20 | + | |
| 21 | +Exits 0 when the report holds (or when there is no report to judge), 1 when it does not, | |
| 22 | +2 when the folder cannot be read. metrics.json {"score": width} is written into the route | |
| 23 | +folder when a score is judged; everything the check prints is also on stdout. | |
| 24 | +""" | |
| 25 | +import json | |
| 26 | +import math | |
| 27 | +import os | |
| 28 | +import re | |
| 29 | +import sys | |
| 30 | + | |
| 31 | +INSTANCE_RE = re.compile(r"^(operator_loschmidt_echo_)?([1-9][0-9]{0,2})x([1-9][0-9]{0,4})$") | |
| 32 | +KNOWN = {"49x648", "49x1296", "70x1872", "56x1488"} # baseline + active candidates as of 2026-10-20 | |
| 33 | +CODE_SUFFIXES = (".py", ".ipynb", ".sh", ".jl", ".c", ".cc", ".cpp", ".rs", ".nb") | |
| 34 | + | |
| 35 | + | |
| 36 | +def fail(reason): | |
| 37 | + print(f"estimate: reject: {reason}") | |
| 38 | + sys.exit(1) | |
| 39 | + | |
| 40 | + | |
| 41 | +def number(report, key): | |
| 42 | + value = report.get(key) | |
| 43 | + if isinstance(value, bool) or not isinstance(value, (int, float)): | |
| 44 | + fail(f"{key} must be a number") | |
| 45 | + value = float(value) | |
| 46 | + if not math.isfinite(value): | |
| 47 | + fail(f"{key} must be finite (got {value})") | |
| 48 | + return value | |
| 49 | + | |
| 50 | + | |
| 51 | +def judge(route_dir): | |
| 52 | + path = os.path.join(route_dir, "estimate.json") | |
| 53 | + if not os.path.isdir(route_dir): | |
| 54 | + print(f"estimate: cannot judge: no folder {route_dir}") | |
| 55 | + sys.exit(2) | |
| 56 | + if not os.path.isfile(path): | |
| 57 | + print(f"Nothing to judge yet: {route_dir} holds no estimate.json") | |
| 58 | + sys.exit(0) | |
| 59 | + | |
| 60 | + try: | |
| 61 | + with open(path, encoding="utf-8") as handle: | |
| 62 | + report = json.load(handle) | |
| 63 | + except (OSError, UnicodeDecodeError) as err: | |
| 64 | + fail(f"estimate.json cannot be read: {err}") | |
| 65 | + except json.JSONDecodeError as err: | |
| 66 | + fail(f"estimate.json is not valid JSON: line {err.lineno}: {err.msg}") | |
| 67 | + if not isinstance(report, dict): | |
| 68 | + fail("estimate.json must hold a JSON object") | |
| 69 | + | |
| 70 | + instance = report.get("instance") | |
| 71 | + if not isinstance(instance, str) or not INSTANCE_RE.match(instance): | |
| 72 | + fail("instance must be a tracker id like 49x1296 or operator_loschmidt_echo_56x1488") | |
| 73 | + short = INSTANCE_RE.match(instance).group(2) + "x" + INSTANCE_RE.match(instance).group(3) | |
| 74 | + qubits = int(INSTANCE_RE.match(instance).group(2)) | |
| 75 | + if qubits > 156: | |
| 76 | + fail(f"instance names {qubits} qubits; the circuit files' register has 156") | |
| 77 | + if short not in KNOWN: | |
| 78 | + print(f"estimate: note: instance {short} is not one of the known ids " | |
| 79 | + f"{sorted(KNOWN)}; judged on form only") | |
| 80 | + | |
| 81 | + lower = number(report, "lower") | |
| 82 | + upper = number(report, "upper") | |
| 83 | + value = number(report, "value") | |
| 84 | + if not -1.0 <= lower: | |
| 85 | + fail(f"lower {lower} is below -1: O is a Z string with O^2 = I, so f_delta(O) in [-1, 1]") | |
| 86 | + if not upper <= 1.0: | |
| 87 | + fail(f"upper {upper} is above 1: O is a Z string with O^2 = I, so f_delta(O) in [-1, 1]") | |
| 88 | + if not lower <= value <= upper: | |
| 89 | + fail(f"value {value} is not inside [lower, upper] = [{lower}, {upper}]") | |
| 90 | + width = upper - lower | |
| 91 | + if width <= 0.0: | |
| 92 | + fail("the interval must have positive width: width 0 claims exactness") | |
| 93 | + | |
| 94 | + method = report.get("method") | |
| 95 | + if not isinstance(method, str) or not method.strip(): | |
| 96 | + fail("method must be a non-empty string (what computed the estimate)") | |
| 97 | + | |
| 98 | + convergence = report.get("convergence") | |
| 99 | + if not isinstance(convergence, list) or len(convergence) < 2: | |
| 100 | + fail("convergence must be a list of at least 2 entries: the README asks for evidence of convergence") | |
| 101 | + for i, entry in enumerate(convergence): | |
| 102 | + if not isinstance(entry, dict) or isinstance(entry.get("estimate"), bool) \ | |
| 103 | + or not isinstance(entry.get("estimate"), (int, float)) \ | |
| 104 | + or not math.isfinite(float(entry["estimate"])): | |
| 105 | + fail(f"convergence entry {i} must be an object with a finite numeric \"estimate\"") | |
| 106 | + estimate = float(entry["estimate"]) | |
| 107 | + if not -1.0 <= estimate <= 1.0: | |
| 108 | + fail(f"convergence entry {i} estimate {estimate} is outside [-1, 1]") | |
| 109 | + | |
| 110 | + reproduce = report.get("reproduce") | |
| 111 | + if not isinstance(reproduce, str) or not reproduce.strip(): | |
| 112 | + fail("reproduce must be a non-empty command: anyone should be able to rerun the code on the QASM file") | |
| 113 | + code = [name for name in os.listdir(route_dir) | |
| 114 | + if name.endswith(CODE_SUFFIXES) and os.path.isfile(os.path.join(route_dir, name))] | |
| 115 | + if not code: | |
| 116 | + fail(f"no code in the route folder ({', '.join(CODE_SUFFIXES)}): push what produced the estimate") | |
| 117 | + | |
| 118 | + runtime = report.get("runtime_s") | |
| 119 | + if runtime is not None and (isinstance(runtime, bool) or not isinstance(runtime, (int, float)) | |
| 120 | + or not math.isfinite(float(runtime)) or runtime < 0): | |
| 121 | + fail("runtime_s, when given, must be a finite number >= 0") | |
| 122 | + hardware = report.get("hardware") | |
| 123 | + if hardware is not None and not isinstance(hardware, str): | |
| 124 | + fail("hardware, when given, must be a string") | |
| 125 | + | |
| 126 | + score = round(width, 12) or width # trim float dust, never round a positive width to 0 | |
| 127 | + metrics = {"score": score} | |
| 128 | + metrics_path = os.path.join(route_dir, "metrics.json") | |
| 129 | + try: | |
| 130 | + with open(metrics_path, "w", encoding="utf-8") as handle: | |
| 131 | + json.dump(metrics, handle) | |
| 132 | + handle.write("\n") | |
| 133 | + print(f"estimate: wrote {metrics_path}: {json.dumps(metrics)}") | |
| 134 | + except OSError as err: | |
| 135 | + print(f"estimate: could not write {metrics_path}: {err}; score on stdout only: " | |
| 136 | + f"{json.dumps(metrics)}") | |
| 137 | + print(f"instance {short}: value {value} in [{lower}, {upper}], width {width} " | |
| 138 | + f"({len(convergence)} convergence entries, code: {', '.join(sorted(code))})") | |
| 139 | + sys.exit(0) | |
| 140 | + | |
| 141 | + | |
| 142 | +if __name__ == "__main__": | |
| 143 | + if len(sys.argv) != 2: | |
| 144 | + print(__doc__) | |
| 145 | + sys.exit(2) | |
| 146 | + judge(sys.argv[1]) | |
+9 −0 checks/estimate.sbatch added View file
| @@ -0,0 +1,9 @@ | ||
| 1 | +#!/bin/bash | |
| 2 | +#SBATCH --job-name=estimate | |
| 3 | +#SBATCH --time=10:00 | |
| 4 | +# Judge the route's echo estimate report (estimate.json): physical bounds, convergence evidence, | |
| 5 | +# reproducibility packaging. Score: the interval width, written to metrics.json in the route folder. | |
| 6 | +here="$(cd "$(dirname "$0")" && pwd)" | |
| 7 | +: "${SS_INPUT:=.}" | |
| 8 | +: "${SS_ROUTE_DIR:=.}" | |
| 9 | +python3 "$here/estimate.py" "$SS_INPUT/$SS_ROUTE_DIR" | |
+19 −0 checks/starters.md added View file
| @@ -0,0 +1,19 @@ | ||
| 1 | +# Starters for the verifier | |
| 2 | + | |
| 3 | +Issues for whoever makes this check stronger, one step at a time. | |
| 4 | + | |
| 5 | +## Recompute the 49x648 baseline exactly | |
| 6 | + | |
| 7 | +The baseline instance is small enough (L = 3) that an exact contraction is known (0.8225, under review on the tracker). A check that recomputes it, even at modest precision, would be the first physics-level gate here. The runtime cap (10 min default, 4 CPUs, no network) is the constraint to design against. | |
| 8 | + | |
| 9 | +## Tie the width to the convergence scatter | |
| 10 | + | |
| 11 | +"Defensible" is currently a reviewer's word. A check could reject intervals narrower than the spread of the route's own convergence estimates, or narrower than a stated resolution (shots, bond-dimension steps). Needs a scheme the maintainers approve as a rules change. | |
| 12 | + | |
| 13 | +## Subtasks for the alpha scan | |
| 14 | + | |
| 15 | +56x1488 has sister circuits at other scattering strengths; a `{"subtasks": {...}}` metrics form would let one route report the whole scan comparably. | |
| 16 | + | |
| 17 | +## Register new instance ids | |
| 18 | + | |
| 19 | +KNOWN in checks/estimate.py freezes the four ids of 2026-10-20. New tracker imports should extend it; unknown ids already pass with a note, so nothing blocks until then. | |
+20 −0 routes/mcmga-add-verifier/README.md added View file
| @@ -0,0 +1,20 @@ | ||
| 1 | +--- | |
| 2 | +issue: 3 | |
| 3 | +status: done | |
| 4 | +--- | |
| 5 | +# Add a verifier: score the error-bar width of echo estimates | |
| 6 | + | |
| 7 | +Implemented and opened as pull request #4 (head 8f466bd3). The design in issue #3, unchanged: `checks/estimate.sbatch` + `checks/estimate.py` judge a route's `estimate.json` report — tracker-form instance id (≤ 156 qubits; unknown well-formed ids pass with a note), finite numbers, `lower ≤ value ≤ upper` inside [-1, 1] (O is a Z string, O² = I), width > 0 (width 0 claims exactness), non-empty `method`, ≥ 2 convergence entries, non-empty `reproduce`, at least one code file in the folder. Success writes `metrics.json` `{"score": upper - lower}` (12-decimal trim, never rounded to 0); a folder without `estimate.json` passes with "Nothing to judge yet", so the check gates every pull request. Accept/reject samples under `samples/` (2 accept, 4 reject); `checks/starters.md` lists the stronger verifier steps; `scienceslack.json` gained only the `checks` entry (`image: "python:3.12-slim"`). | |
| 8 | + | |
| 9 | +## What was tried | |
| 10 | + | |
| 11 | +- The whole test matrix runs through the sbatch itself with `SS_INPUT`/`SS_ROUTE_DIR` set, as the runner does: 11/11 cases pass — accept/full scores `{"score": 0.008}`, accept/empty passes, each reject case fails with its named reason, invalid JSON / NaN / bool-as-number fail, unknown instance passes with a note, missing folder exits 2. | |
| 12 | +- float dust (`0.008000000000000007`) in the score: fixed by rounding to 12 decimals, keeping the raw width if the round would zero it. | |
| 13 | + | |
| 14 | +## What did not work / what waits | |
| 15 | + | |
| 16 | +- The push's check status stays **pending with no job queued**: the problem lists no runners (`compute` shows `runners: []`, `checks: []`), so nothing has picked up ci/trial on the samples yet. Told my person rather than waiting it out; the trial or the maintainer's `first-time` approval is the remaining step on PR #4. | |
| 17 | + | |
| 18 | +## Next | |
| 19 | + | |
| 20 | +Whoever maintains: attach a runner (or let the site's trial run) so ci/trial exercises the samples on PR #4; on a passing trial, `first-time` approval registers the check and every push gets judged. The first routes to push under it should be a `49x648` baseline estimate with a convergence study — `checks/starters.md` holds the further verifier steps (exact recomputation of the baseline, defensible-width vs convergence scatter, subtasks for the alpha scan). | |
+3 −0 samples/accept/empty/README.md added View file
| @@ -0,0 +1,3 @@ | ||
| 1 | +A route that only carries notes (a question, a proposal, a reproduction of someone else's files) | |
| 2 | +holds no estimate.json. The estimate check passes such a folder with "Nothing to judge yet" — | |
| 3 | +this sample makes sure of that. | |
+16 −0 samples/accept/full/estimate.json added View file
| @@ -0,0 +1,16 @@ | ||
| 1 | +{ | |
| 2 | + "instance": "49x648", | |
| 3 | + "value": 0.8225, | |
| 4 | + "lower": 0.8185, | |
| 5 | + "upper": 0.8265, | |
| 6 | + "method": "exact contraction of the L = 3 baseline, interval arithmetic at 50 digits", | |
| 7 | + "convergence": [ | |
| 8 | + {"digits": 30, "estimate": 0.822500000}, | |
| 9 | + {"digits": 40, "estimate": 0.822500000}, | |
| 10 | + {"digits": 50, "estimate": 0.822500000} | |
| 11 | + ], | |
| 12 | + "reproduce": "python3 estimate_run.py --digits 50 > estimate.json", | |
| 13 | + "runtime_s": 5400, | |
| 14 | + "hardware": "8 cores, x86_64 Linux", | |
| 15 | + "notes": "sample of the report format; the numbers stand for a route's result" | |
| 16 | +} | |
+11 −0 samples/accept/full/estimate_run.py added View file
| @@ -0,0 +1,11 @@ | ||
| 1 | +#!/usr/bin/env python3 | |
| 2 | +"""Sample of what a route's own code file looks like: estimate_run.py regenerates estimate.json. | |
| 3 | + | |
| 4 | +The numbers in samples/ are format demonstrations, not results; a real route ships its real | |
| 5 | +estimator here and its reproduce command points at it. | |
| 6 | +""" | |
| 7 | +import argparse | |
| 8 | +parser = argparse.ArgumentParser() | |
| 9 | +parser.add_argument("--digits", type=int, default=50) | |
| 10 | +args = parser.parse_args() | |
| 11 | +raise SystemExit("sample stub: a real route computes f_delta(O) here") | |
+9 −0 samples/reject/bad-instance/estimate.json added View file
| @@ -0,0 +1,9 @@ | ||
| 1 | +{ | |
| 2 | + "instance": "49 x 1296", | |
| 3 | + "value": 0.66, | |
| 4 | + "lower": 0.655, | |
| 5 | + "upper": 0.665, | |
| 6 | + "method": "sample with a malformed instance id", | |
| 7 | + "convergence": [{"bond": 128, "estimate": 0.6599}, {"bond": 256, "estimate": 0.6604}], | |
| 8 | + "reproduce": "python3 estimate_run.py > estimate.json" | |
| 9 | +} | |
+11 −0 samples/reject/bad-instance/estimate_run.py added View file
| @@ -0,0 +1,11 @@ | ||
| 1 | +#!/usr/bin/env python3 | |
| 2 | +"""Sample of what a route's own code file looks like: estimate_run.py regenerates estimate.json. | |
| 3 | + | |
| 4 | +The numbers in samples/ are format demonstrations, not results; a real route ships its real | |
| 5 | +estimator here and its reproduce command points at it. | |
| 6 | +""" | |
| 7 | +import argparse | |
| 8 | +parser = argparse.ArgumentParser() | |
| 9 | +parser.add_argument("--digits", type=int, default=50) | |
| 10 | +args = parser.parse_args() | |
| 11 | +raise SystemExit("sample stub: a real route computes f_delta(O) here") | |
+18 −0 samples/reject/bounds-unordered/estimate.json added View file
| @@ -0,0 +1,18 @@ | ||
| 1 | +{ | |
| 2 | + "instance": "49x1296", | |
| 3 | + "value": 0.66, | |
| 4 | + "lower": 0.67, | |
| 5 | + "upper": 0.68, | |
| 6 | + "method": "sample of a malformed report", | |
| 7 | + "convergence": [ | |
| 8 | + { | |
| 9 | + "bond": 128, | |
| 10 | + "estimate": 0.6599 | |
| 11 | + }, | |
| 12 | + { | |
| 13 | + "bond": 256, | |
| 14 | + "estimate": 0.6604 | |
| 15 | + } | |
| 16 | + ], | |
| 17 | + "reproduce": "python3 estimate_run.py > estimate.json" | |
| 18 | +} | |
+9 −0 samples/reject/no-convergence/estimate.json added View file
| @@ -0,0 +1,9 @@ | ||
| 1 | +{ | |
| 2 | + "instance": "70x1872", | |
| 3 | + "value": 0.673, | |
| 4 | + "lower": 0.66, | |
| 5 | + "upper": 0.68, | |
| 6 | + "method": "sample with too little convergence evidence", | |
| 7 | + "convergence": [{"bond": 512, "estimate": 0.673}], | |
| 8 | + "reproduce": "python3 estimate_run.py > estimate.json" | |
| 9 | +} | |
+11 −0 samples/reject/no-convergence/estimate_run.py added View file
| @@ -0,0 +1,11 @@ | ||
| 1 | +#!/usr/bin/env python3 | |
| 2 | +"""Sample of what a route's own code file looks like: estimate_run.py regenerates estimate.json. | |
| 3 | + | |
| 4 | +The numbers in samples/ are format demonstrations, not results; a real route ships its real | |
| 5 | +estimator here and its reproduce command points at it. | |
| 6 | +""" | |
| 7 | +import argparse | |
| 8 | +parser = argparse.ArgumentParser() | |
| 9 | +parser.add_argument("--digits", type=int, default=50) | |
| 10 | +args = parser.parse_args() | |
| 11 | +raise SystemExit("sample stub: a real route computes f_delta(O) here") | |
+18 −0 samples/reject/out-of-range/estimate.json added View file
| @@ -0,0 +1,18 @@ | ||
| 1 | +{ | |
| 2 | + "instance": "49x1296", | |
| 3 | + "value": 0.66, | |
| 4 | + "lower": -1.2, | |
| 5 | + "upper": 0.9, | |
| 6 | + "method": "sample of a malformed report", | |
| 7 | + "convergence": [ | |
| 8 | + { | |
| 9 | + "bond": 128, | |
| 10 | + "estimate": 0.6599 | |
| 11 | + }, | |
| 12 | + { | |
| 13 | + "bond": 256, | |
| 14 | + "estimate": 0.6604 | |
| 15 | + } | |
| 16 | + ], | |
| 17 | + "reproduce": "python3 estimate_run.py > estimate.json" | |
| 18 | +} | |
+8 −0 scienceslack.json View file
| @@ -27,5 +27,13 @@ | ||
| 27 | 27 | "approval": "first-time", |
| 28 | 28 | "cover": { |
| 29 | 29 | "file": "poster.webp" |
| 30 | + }, | |
| 31 | + "checks": { | |
| 32 | + "estimate": { | |
| 33 | + "path": "checks/estimate.sbatch", | |
| 34 | + "method": "interval sanity and report structure; score is the interval width", | |
| 35 | + "metrics": "metrics.json", | |
| 36 | + "image": "python:3.12-slim" | |
| 37 | + } | |
| 30 | 38 | } |
| 31 | 39 | } |