Commit ·
7bd2bb1
1
Parent(s): 5ee1fb5
Answer the referee report and clarify the paper: notation, an example, a conclusion and the organism's records
Browse files- paper/README.md +9 -3
- paper/runs/paper_noise_masked.json +126 -0
- paper/universal_construction_ternary.pdf +2 -2
- paper/universal_construction_ternary.tex +0 -0
- src/noise.py +70 -2
paper/README.md
CHANGED
|
@@ -13,7 +13,13 @@ runs/ the record written by each command
|
|
| 13 |
|
| 14 |
Each command is `python src/<file>.py <command>` and writes its record to `runs/`;
|
| 15 |
`paper.py rocq` needs Rocq 9.1 with the opam packages `coq-coquelicot` and
|
| 16 |
-
`coq-interval`, and ocamlfind, on the PATH.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
| Command | Record | Establishes |
|
| 19 |
|---|---|---|
|
|
@@ -41,9 +47,9 @@ Each command is `python src/<file>.py <command>` and writes its record to `runs/
|
|
| 41 |
| `twohead.py organism` | `paper_twohead.json` | the organism on the ring machine M_{3,160,3200}, six generations with the copies and the period (`organism run --generations 6 --S 160 --L 3200`); `organism rocq` writes `rocq/Organism.v` |
|
| 42 |
| `twohead.py net` | `paper_twohead_net.json` | the netlist N_{K,S,L} against the machine on random states of three members (`net check`), one generation of the organism on it in C beside the machine (`net lockstep`), the netlists extracted from Rocq (`net extract`), and the rows of its levelization with the noise a generation of the stored host survives (`net lev`) |
|
| 43 |
| `twohead.py stored` | `paper_stored_host.json` | the host compiled into records of the ring machine: one pass against the host's step and its device on random states (`stored check`), the startup, step, device and hand-over records on decision diagrams (`stored symbolic`), and six generations in C in a ring of three banks (`stored run 6`); `--width A` checks H_A in place of H_8, and `stored widths` tabulates A = 8 to 12 |
|
| 44 |
-
| `noise.py host` | `paper_noise_*.json` | the margin, the profile bound in sum and product form, read noise, the deviation curve, the exact Poisson intervals of the measured rates (`host intervals`), weight error with leakage, the active-input counts of the orbit certificate |
|
| 45 |
| `noise.py amplified` | `paper_redundant_*.json` | the amplified host N_3: one step on replicated states, the margin 3/2, exact self-reproduction in C, the run under noise, the deviation curve and its bound by layer, the failure rate of the state read by majority and the restoration bound, computed by `src/restore_bound.c` |
|
| 46 |
-
| `independent.py` | `independent_*.json` | code written from the paper's definitions alone: H_A rebuilt from Construction 5.8 for A = 3 to 12, Lev(N_host) from sigma and the measurements of Section 8.1 and Appendix
|
| 47 |
|
| 48 |
Rebuild the typeset paper with any TeX installation:
|
| 49 |
|
|
|
|
| 13 |
|
| 14 |
Each command is `python src/<file>.py <command>` and writes its record to `runs/`;
|
| 15 |
`paper.py rocq` needs Rocq 9.1 with the opam packages `coq-coquelicot` and
|
| 16 |
+
`coq-interval`, and ocamlfind, on the PATH; the development was checked on OCaml 4.14.2 with
|
| 17 |
+
these versions:
|
| 18 |
+
|
| 19 |
+
```bash
|
| 20 |
+
opam install rocq-core.9.1.1 rocq-stdlib.9.2.0 coq-coquelicot.3.4.5 coq-interval.4.11.4 \
|
| 21 |
+
rocq-mathcomp-ssreflect.2.4.0 coq-flocq.4.2.2 rocq-bignums.9.0.0+rocq9.1 ocamlfind.1.9.8
|
| 22 |
+
```
|
| 23 |
|
| 24 |
| Command | Record | Establishes |
|
| 25 |
|---|---|---|
|
|
|
|
| 47 |
| `twohead.py organism` | `paper_twohead.json` | the organism on the ring machine M_{3,160,3200}, six generations with the copies and the period (`organism run --generations 6 --S 160 --L 3200`); `organism rocq` writes `rocq/Organism.v` |
|
| 48 |
| `twohead.py net` | `paper_twohead_net.json` | the netlist N_{K,S,L} against the machine on random states of three members (`net check`), one generation of the organism on it in C beside the machine (`net lockstep`), the netlists extracted from Rocq (`net extract`), and the rows of its levelization with the noise a generation of the stored host survives (`net lev`) |
|
| 49 |
| `twohead.py stored` | `paper_stored_host.json` | the host compiled into records of the ring machine: one pass against the host's step and its device on random states (`stored check`), the startup, step, device and hand-over records on decision diagrams (`stored symbolic`), and six generations in C in a ring of three banks (`stored run 6`); `--width A` checks H_A in place of H_8, and `stored widths` tabulates A = 8 to 12 |
|
| 50 |
+
| `noise.py host` | `paper_noise_*.json` | the margin, the profile bound in sum and product form, read noise, the deviation curve, the exact Poisson intervals of the measured rates (`host intervals`), weight error with leakage, the active-input counts of the orbit certificate, and the steps in which some row fails against the product form b' with the fraction the state masks (`host masked`) |
|
| 51 |
| `noise.py amplified` | `paper_redundant_*.json` | the amplified host N_3: one step on replicated states, the margin 3/2, exact self-reproduction in C, the run under noise, the deviation curve and its bound by layer, the failure rate of the state read by majority and the restoration bound, computed by `src/restore_bound.c` |
|
| 52 |
+
| `independent.py` | `independent_*.json` | code written from the paper's definitions alone: H_A rebuilt from Construction 5.8 for A = 3 to 12, Lev(N_host) from sigma and the measurements of Section 8.1 and Appendix E with the noise simulator `src/nsim.c` |
|
| 53 |
|
| 54 |
Rebuild the typeset paper with any TeX installation:
|
| 55 |
|
paper/runs/paper_noise_masked.json
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"M": 41967,
|
| 3 |
+
"grid": [
|
| 4 |
+
0.08,
|
| 5 |
+
0.09,
|
| 6 |
+
0.1,
|
| 7 |
+
0.11,
|
| 8 |
+
0.12,
|
| 9 |
+
0.15,
|
| 10 |
+
0.2
|
| 11 |
+
],
|
| 12 |
+
"rows": [
|
| 13 |
+
{
|
| 14 |
+
"sigma": 0.08,
|
| 15 |
+
"copies": 1024,
|
| 16 |
+
"steps": 4000,
|
| 17 |
+
"copy_steps": 4096000,
|
| 18 |
+
"row_failure_steps": 31,
|
| 19 |
+
"deviations": 30,
|
| 20 |
+
"masked": 1,
|
| 21 |
+
"masked_fraction": 0.03225806451612903,
|
| 22 |
+
"row_failure_rate": 7.568359375e-06,
|
| 23 |
+
"deviation_rate": 7.32421875e-06,
|
| 24 |
+
"product_form_mean": 6.339578158376758e-06,
|
| 25 |
+
"row_failures_expected": 25.9669121367112,
|
| 26 |
+
"row_failures_sd": 5.09575779301011,
|
| 27 |
+
"seconds": 208.27974448201712
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"sigma": 0.09,
|
| 31 |
+
"copies": 1024,
|
| 32 |
+
"steps": 4000,
|
| 33 |
+
"copy_steps": 4096000,
|
| 34 |
+
"row_failure_steps": 1739,
|
| 35 |
+
"deviations": 1639,
|
| 36 |
+
"masked": 100,
|
| 37 |
+
"masked_fraction": 0.05750431282346176,
|
| 38 |
+
"row_failure_rate": 0.000424560546875,
|
| 39 |
+
"deviation_rate": 0.000400146484375,
|
| 40 |
+
"product_form_mean": 0.00042732896942724436,
|
| 41 |
+
"row_failures_expected": 1750.3394587739929,
|
| 42 |
+
"row_failures_sd": 41.82811662962366,
|
| 43 |
+
"seconds": 212.16002563602524
|
| 44 |
+
},
|
| 45 |
+
{
|
| 46 |
+
"sigma": 0.1,
|
| 47 |
+
"copies": 1024,
|
| 48 |
+
"steps": 4000,
|
| 49 |
+
"copy_steps": 4096000,
|
| 50 |
+
"row_failure_steps": 35940,
|
| 51 |
+
"deviations": 33671,
|
| 52 |
+
"masked": 2269,
|
| 53 |
+
"masked_fraction": 0.06313299944351697,
|
| 54 |
+
"row_failure_rate": 0.0087744140625,
|
| 55 |
+
"deviation_rate": 0.008220458984375,
|
| 56 |
+
"product_form_mean": 0.008815790265558641,
|
| 57 |
+
"row_failures_expected": 36109.476927728196,
|
| 58 |
+
"row_failures_sd": 189.185309214523,
|
| 59 |
+
"seconds": 300.7043810179457
|
| 60 |
+
},
|
| 61 |
+
{
|
| 62 |
+
"sigma": 0.11,
|
| 63 |
+
"copies": 1024,
|
| 64 |
+
"steps": 4000,
|
| 65 |
+
"copy_steps": 4096000,
|
| 66 |
+
"row_failure_steps": 333003,
|
| 67 |
+
"deviations": 313064,
|
| 68 |
+
"masked": 19939,
|
| 69 |
+
"masked_fraction": 0.05987633745041336,
|
| 70 |
+
"row_failure_rate": 0.081299560546875,
|
| 71 |
+
"deviation_rate": 0.076431640625,
|
| 72 |
+
"product_form_mean": 0.08118096356967355,
|
| 73 |
+
"row_failures_expected": 332517.22678138287,
|
| 74 |
+
"row_failures_sd": 552.7370818611178,
|
| 75 |
+
"seconds": 312.9539852250018
|
| 76 |
+
},
|
| 77 |
+
{
|
| 78 |
+
"sigma": 0.12,
|
| 79 |
+
"copies": 1024,
|
| 80 |
+
"steps": 4000,
|
| 81 |
+
"copy_steps": 4096000,
|
| 82 |
+
"row_failure_steps": 1556080,
|
| 83 |
+
"deviations": 1479361,
|
| 84 |
+
"masked": 76719,
|
| 85 |
+
"masked_fraction": 0.04930273507788803,
|
| 86 |
+
"row_failure_rate": 0.37990234375,
|
| 87 |
+
"deviation_rate": 0.361172119140625,
|
| 88 |
+
"product_form_mean": 0.3795909822472992,
|
| 89 |
+
"row_failures_expected": 1554804.6632849376,
|
| 90 |
+
"row_failures_sd": 982.1122694402926,
|
| 91 |
+
"seconds": 279.61808501696214
|
| 92 |
+
},
|
| 93 |
+
{
|
| 94 |
+
"sigma": 0.15,
|
| 95 |
+
"copies": 1024,
|
| 96 |
+
"steps": 4000,
|
| 97 |
+
"copy_steps": 4096000,
|
| 98 |
+
"row_failure_steps": 4095990,
|
| 99 |
+
"deviations": 4095979,
|
| 100 |
+
"masked": 11,
|
| 101 |
+
"masked_fraction": 2.6855534315269323e-06,
|
| 102 |
+
"row_failure_rate": 0.99999755859375,
|
| 103 |
+
"deviation_rate": 0.999994873046875,
|
| 104 |
+
"product_form_mean": 0.9999982229194877,
|
| 105 |
+
"row_failures_expected": 4095992.7210782217,
|
| 106 |
+
"row_failures_sd": 2.6979452350816384,
|
| 107 |
+
"seconds": 226.470565449039
|
| 108 |
+
},
|
| 109 |
+
{
|
| 110 |
+
"sigma": 0.2,
|
| 111 |
+
"copies": 1024,
|
| 112 |
+
"steps": 4000,
|
| 113 |
+
"copy_steps": 4096000,
|
| 114 |
+
"row_failure_steps": 4096000,
|
| 115 |
+
"deviations": 4096000,
|
| 116 |
+
"masked": 0,
|
| 117 |
+
"masked_fraction": 0.0,
|
| 118 |
+
"row_failure_rate": 1.0,
|
| 119 |
+
"deviation_rate": 1.0,
|
| 120 |
+
"product_form_mean": 1.0,
|
| 121 |
+
"row_failures_expected": 4096000.0,
|
| 122 |
+
"row_failures_sd": 0.0,
|
| 123 |
+
"seconds": 209.7733603650122
|
| 124 |
+
}
|
| 125 |
+
]
|
| 126 |
+
}
|
paper/universal_construction_ternary.pdf
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0889b461dfbb6eef038b940bbaea4141a3cd589b30c095aeed305175cb481164
|
| 3 |
+
size 385800
|
paper/universal_construction_ternary.tex
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
src/noise.py
CHANGED
|
@@ -529,6 +529,73 @@ def run_certify(args) -> int:
|
|
| 529 |
return 0
|
| 530 |
|
| 531 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 532 |
def run_intervals(args) -> int:
|
| 533 |
"""Exact Poisson intervals for the measured rates of the host and of the threefold host."""
|
| 534 |
out = {"confidence": 0.95, "host": [], "amplified_r3": []}
|
|
@@ -549,7 +616,8 @@ def run_intervals(args) -> int:
|
|
| 549 |
|
| 550 |
def main_host() -> int:
|
| 551 |
ap = argparse.ArgumentParser()
|
| 552 |
-
ap.add_argument("mode", choices=["omega", "curve", "leak", "margin", "profile", "certify", "intervals"
|
|
|
|
| 553 |
ap.add_argument("--short", action="store_true", help="certify: the leak orbit only")
|
| 554 |
ap.add_argument("--states", type=int, default=800)
|
| 555 |
ap.add_argument("--device", default="cuda")
|
|
@@ -559,7 +627,7 @@ def main_host() -> int:
|
|
| 559 |
args = ap.parse_args()
|
| 560 |
return {"omega": run_omega, "curve": run_curve, "leak": run_leak,
|
| 561 |
"margin": run_margin, "profile": run_profile,
|
| 562 |
-
"certify": run_certify, "intervals": run_intervals}[args.mode](args)
|
| 563 |
|
| 564 |
SRC = os.path.join(REPO, "src")
|
| 565 |
|
|
|
|
| 529 |
return 0
|
| 530 |
|
| 531 |
|
| 532 |
+
def run_masked(args) -> int:
|
| 533 |
+
"""The steps in which some row fails, against the product form b'(t), and the fraction of them
|
| 534 |
+
that leave the state on the orbit; every noisy copy starts each step from the exact state."""
|
| 535 |
+
import torch
|
| 536 |
+
from host import M_P, LevEvaluator, describe, read_host
|
| 537 |
+
sigma = read_host()
|
| 538 |
+
L = LevEvaluator(sigma, device=args.device, dense=True)
|
| 539 |
+
M = sum(int(W.shape[0]) for W in L.W)
|
| 540 |
+
r_H = describe(sigma)
|
| 541 |
+
B, T = args.batch, args.steps
|
| 542 |
+
grid = [float(x) for x in args.grid.split(",")]
|
| 543 |
+
print(f"[masked] M = {M:,}; {B} noisy copies restarted from the exact state at each of "
|
| 544 |
+
f"{T:,} steps", flush=True)
|
| 545 |
+
rows = []
|
| 546 |
+
for s in grid:
|
| 547 |
+
gen = torch.Generator(device=args.device).manual_seed(11 + int(1000 * s))
|
| 548 |
+
v = L._vec(0, M_P).unsqueeze(0).to(args.device)
|
| 549 |
+
D = Devices(L, [r_H], args.device)
|
| 550 |
+
failed = deviated = 0
|
| 551 |
+
expected = variance = 0.0
|
| 552 |
+
t0 = time.perf_counter()
|
| 553 |
+
steps = T
|
| 554 |
+
for n in range(T):
|
| 555 |
+
y = v.repeat(B + 1, 1)
|
| 556 |
+
bad = torch.zeros(B, dtype=torch.bool, device=args.device)
|
| 557 |
+
keep = torch.zeros((), dtype=torch.float64, device=args.device)
|
| 558 |
+
for W, b in zip(L.W, L.B):
|
| 559 |
+
pre = y @ W.T + b
|
| 560 |
+
# copy 0 is noise free and reads the orbit's values, so its pre-activations are the
|
| 561 |
+
# orbit's, and a row fails with probability Q(|z + 1/2| / s)
|
| 562 |
+
q = 0.5 * torch.erfc((pre[0].double() + 0.5).abs() / (s * math.sqrt(2.0)))
|
| 563 |
+
keep += torch.log1p(-q).sum()
|
| 564 |
+
noise = torch.randn(pre.shape, generator=gen, device=pre.device) * s
|
| 565 |
+
noise[0] = 0.0
|
| 566 |
+
y = ((pre + noise) >= -0.5).float()
|
| 567 |
+
bad |= (y[1:] != y[0]).any(dim=1)
|
| 568 |
+
off = (y[1:] != y[0]).any(dim=1)
|
| 569 |
+
failed += int(bad.sum())
|
| 570 |
+
deviated += int(off.sum())
|
| 571 |
+
bp = float(-torch.expm1(keep)) # b'(t): some row of the step fails
|
| 572 |
+
expected += B * bp
|
| 573 |
+
variance += B * bp * (1.0 - bp)
|
| 574 |
+
v = y[0:1]
|
| 575 |
+
if D.step(v)[0]:
|
| 576 |
+
steps = n + 1
|
| 577 |
+
break
|
| 578 |
+
dt = time.perf_counter() - t0
|
| 579 |
+
n_cs = B * steps
|
| 580 |
+
rows.append({"sigma": s, "copies": B, "steps": steps, "copy_steps": n_cs,
|
| 581 |
+
"row_failure_steps": failed, "deviations": deviated,
|
| 582 |
+
"masked": failed - deviated,
|
| 583 |
+
"masked_fraction": (failed - deviated) / failed if failed else None,
|
| 584 |
+
"row_failure_rate": failed / n_cs, "deviation_rate": deviated / n_cs,
|
| 585 |
+
"product_form_mean": expected / n_cs,
|
| 586 |
+
"row_failures_expected": expected,
|
| 587 |
+
"row_failures_sd": math.sqrt(variance),
|
| 588 |
+
"seconds": dt})
|
| 589 |
+
print(f" s={s:.2f}: {failed:,} steps with a failing row against {expected:,.1f} "
|
| 590 |
+
f"(sd {math.sqrt(variance):.1f}) from b'; {deviated:,} left the orbit, "
|
| 591 |
+
f"{failed - deviated:,} masked"
|
| 592 |
+
+ (f" ({(failed - deviated) / failed:.2%})" if failed else "")
|
| 593 |
+
+ f" ({dt / 60:.1f} min)", flush=True)
|
| 594 |
+
json.dump({"M": M, "grid": grid, "rows": rows},
|
| 595 |
+
open(runs_path("paper_noise_masked.json"), "w"), indent=1)
|
| 596 |
+
return 0
|
| 597 |
+
|
| 598 |
+
|
| 599 |
def run_intervals(args) -> int:
|
| 600 |
"""Exact Poisson intervals for the measured rates of the host and of the threefold host."""
|
| 601 |
out = {"confidence": 0.95, "host": [], "amplified_r3": []}
|
|
|
|
| 616 |
|
| 617 |
def main_host() -> int:
|
| 618 |
ap = argparse.ArgumentParser()
|
| 619 |
+
ap.add_argument("mode", choices=["omega", "curve", "leak", "margin", "profile", "certify", "intervals",
|
| 620 |
+
"masked"])
|
| 621 |
ap.add_argument("--short", action="store_true", help="certify: the leak orbit only")
|
| 622 |
ap.add_argument("--states", type=int, default=800)
|
| 623 |
ap.add_argument("--device", default="cuda")
|
|
|
|
| 627 |
args = ap.parse_args()
|
| 628 |
return {"omega": run_omega, "curve": run_curve, "leak": run_leak,
|
| 629 |
"margin": run_margin, "profile": run_profile,
|
| 630 |
+
"certify": run_certify, "intervals": run_intervals, "masked": run_masked}[args.mode](args)
|
| 631 |
|
| 632 |
SRC = os.path.join(REPO, "src")
|
| 633 |
|