open-standards/wai/wai-quantum-landscape-fpga/scripts/power_tables.py
Transaction Science c1137390e2 wai-quantum-landscape-fpga: named for what it is, with its README, provenance, workflow and first measurements
The crate is wai-quantum-landscape-fpga, beside the fabric's simulated FPGA member, which has its own
workflow. The README gives the board and part as data, what the design does and refuses, what it
takes to build, the build and load steps, the checks and the power protocol. No bitstream is
distributed: the vendor tool's licence limits a bitstream holding its components to that vendor's
devices, which Apache-2.0 does not carry, so the README gives the build and the sha256 of the
bitstream measured.

measurements/2026-11-05 holds the first version's raw power logs and the predictions committed
before them, unchanged. The workflow runs the unit tests and every check against the model of the
logic on each change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-06 03:05:19 -05:00

33 lines
1.6 KiB
Python

#!/usr/bin/env python3
# SPDX-License-Identifier: Apache-2.0
"""Per-class table from meter logs, by the pre-registered statistic (mean of per-pass differences
of medians, SE across passes), plus a sensitivity column that was NOT pre-registered: the same
with a 10%-trimmed mean inside each point, which keeps sub-quantum information a median of
10 mW-quantised samples throws away. Passes flagged in the log are dropped.
python3 -I power_tables.py a.dat b.dat ...
"""
import statistics as st, sys, re
def trimmed(xs, f=0.1):
s = sorted(xs); k = int(len(s) * f)
s = s[k:len(s) - k] if k else s
return sum(s) / len(s)
for path in sys.argv[1:]:
pts, flagged = {}, set()
for line in open(path):
m = re.search(r'pass=(\d+)', line)
if line.startswith('#'):
if m and ('FLAGGED' in line or 'FOREIGN-LOAD' in line or 'NOT-OURS' in line):
flagged.add(int(m.group(1)))
continue
f = line.split()
if len(f) >= 4 and f[0].isdigit() and f[3].isdigit():
pts.setdefault((int(f[0]), f[1]), []).append(int(f[3]) / 1000.0)
passes = sorted({p for p, _ in pts} - flagged)
dm = [st.median(pts[(p, 'run')]) - st.median(pts[(p, 'halt')]) for p in passes]
dt = [trimmed(pts[(p, 'run')]) - trimmed(pts[(p, 'halt')]) for p in passes]
n = len(passes)
fmt = lambda d: f"{st.mean(d):7.1f} +/- {st.stdev(d) / n ** 0.5:4.1f}"
pr = st.mean(st.median(pts[(p, 'run')]) for p in passes)
print(f"{path.split('/')[-1]:24s} passes {n:2d} medians {fmt(dm)} mW trimmed {fmt(dt)} mW P_run {pr:6.0f} mW flagged {sorted(flagged)}")