Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions experiments/nautilus_30d_evidence_check/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@
from scipy.special import logsumexp, ndtri


def verify(directory):
def verify(directory, streams=("saved", "seed1", "seed2")):
receipt = json.loads((directory / "result.json").read_text())
if receipt["status"] != "complete" or [r["stream"] for r in receipt["runs"]] != [
"saved",
"seed1",
"seed2",
]:
raise ValueError("All three conditional streams are required")
if receipt["status"] != "complete" or [r["stream"] for r in receipt["runs"]] != list(streams):
raise ValueError("All expected streams are required")
dimension = 30
axis = np.arange(dimension)
covariance = 0.6 ** abs(axis[:, None] - axis)
Expand Down
30 changes: 30 additions & 0 deletions experiments/nautilus_30d_independent/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# 30D evidence with independently learned bounds

At the three terminal checkpoints, seed 1 was above the analytic evidence and seeds 2 and 3 were below it. **None reached the registered fresh-only ESS of 10,000** within 2,400 seconds per seed. Rows marked partial describe the last verified sample set for that seed. They remain outside the endpoint comparison. [Phase protocol](https://github.com/PyAutoLabs/autofit_profiling/issues/32).

| Exploration seed | Exploration logZ error | Fresh samples | Fresh ESS | Fresh logZ | Fresh logZ error | Evidence error | Outcome |
|---:|---:|---:|---:|---:|---:|---:|---|
| 1 | -0.892372 | 1,074,100 | 8,147.4 | -36.763453 | +0.004235 | +0.42% | Partial, terminal |
| 2 | -0.955682 | 1,090,100 | 9,904.2 | -36.785425 | -0.017737 | -1.76% | Partial, terminal |
| 3 | -0.888639 | 936,500 | 6,920.3 | -36.771196 | -0.003508 | -0.35% | Partial, terminal |

Analytic log evidence is -36.767688153. Signed log error is estimate minus truth. Relative evidence error is exp(log error) − 1. Each partial run stopped at its wall limit; no fit was retried. Its effective sample size and estimate can change with further sampling. The checkpoints belong to different stages of convergence. They supply no calibrated bias estimate.

## What repeated across explorations

Each seed began empty with a fresh RNG and no input checkpoint. All three learned distinct outer ellipsoid centres and shape matrices, also distinct from those in the historical seed-0 checkpoint. Their exploration-only errors all lay between −0.956 and −0.888 in log evidence. The original seed-0 exploration had error −0.908. Fresh sampling substantially narrowed that discrepancy in all three new runs. The earlier three fully sampled continuations gave errors between −0.0481 and −0.0278 on a single shared set of bounds. The comparison above uses the independently learned bounds once each. [Earlier conditional results](../nautilus_30d_evidence_check/README.md).

## Verification and reproduction

Each native checkpoint was read without advancing the RNG. The audit verified the exploration-exclusion flag, learned geometry, position/likelihood row counts, per-shell ESS and mean likelihood, total calls and fresh counts. It recomputed log evidence and ESS directly from fresh likelihood rows and stored shell volumes, compared both with a native reopening, and verified the inspected file hash stayed unchanged. The audit receipt identifies whether each estimate used the terminal file or an earlier checked copy. [Checkpoint hashes and estimates](checkpoints.json) · [Supervisor outcomes and runtime pins](result.json).

The target, prior, Nautilus 1.0.5, 400 live points, four networks, native update interval 400, batch 100 and f_live 0.01 match the earlier fixture. The first native run stops at the exploration transition. The second continues the same RNG with fresh-only samples, requiring ESS ≥10,000 and at least 100 fresh samples per shell. All three children used one numerical thread each and a 4 GiB RSS cap on the shared laptop.

Use the library pins in the receipt and the input checkpoint from the original direct 30D case, case-719639ab504cacbebb25-attempt-001. The only use of seed 0 is a read-only geometry comparison. The supervisor writes separate checkpoints and exit diagnostics for each seed. A nonzero exit with an incomplete receipt indicates that the endpoint or verification was missed. The following commands reproduce the run and audit a closed checkpoint.

```sh
python experiments/nautilus_30d_independent/run.py FRESH_OUTPUT_DIRECTORY --reference SEED0.hdf5
python experiments/nautilus_30d_independent/read_saved.py FRESH_OUTPUT_DIRECTORY/seed1/checkpoint.hdf5 FRESH_OUTPUT_DIRECTORY/seed1/exploration.json -36.76768815337412
```

This local phase 0b evidence remains outside the Pulse dashboard. [Canonical profiling task](https://github.com/PyAutoLabs/PyAutoPulse/blob/main/tasks/autofit_profiling_bootstrap.md).
254 changes: 254 additions & 0 deletions experiments/nautilus_30d_independent/checkpoints.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
{
"analytic_logZ": -36.76768815337412,
"seeds": [
{
"stream": "seed1",
"exploration": {
"estimate": {
"logZ": -37.66005977621391,
"logZ_error": -0.8923716228397964,
"n_eff": 9404.067074797325,
"posterior_sha256": "b1fc0250d84a27f27f3ed829cc88391229361efd57011c0c16ffb8c51878af88",
"n_like": 33700,
"selected_samples": 33604,
"fresh_samples_per_shell": [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
"max_standardized_mean_error": 0.07522447858566512,
"covariance_relative_error": 0.11324048324169811,
"shell_log_v": [
-0.6611641347068946,
-1.1918213339373716,
-1.8723893448819184,
-2.6845631510275214,
-3.3699083135107455,
-4.184129031369544,
-5.144183562769725,
-5.8852240735247,
-6.751225111222878,
-7.581958803339073,
-8.246729519778587,
-9.133985383828069,
-10.108029970016997,
-10.642726374438181,
-11.674553178829672,
-12.519699167564522,
-13.193992058392128,
-13.9516116164908,
-14.891077335630303,
-15.434981396334377
]
},
"geometry": {
"ellipsoids": 14,
"sha256": "317b31244c0dee2d2623068473b7746c28db5214ccb5880dd5aa94568a4d15c8"
}
},
"checkpoint_source": "terminal",
"checkpoint_sha256": "dc8d367eab1fee88a2d468b3791531c29a4292bb1d436d85518de8d492c3b8a9",
"native_and_raw_agree": true,
"completed": false,
"supervision": {
"returncode": 124,
"termination_reason": "timeout",
"sampled_group_peak_rss_bytes": 661897216,
"memory_limit_bytes": 4294967296,
"rss_sample_interval_s": 0.5,
"rss_note": "process group sum; shared pages may repeat; sub-interval spikes may be missed",
"elapsed_s": 2400.390853568002
},
"estimate": {
"total_calls": 1107800,
"fresh_samples": 1074100,
"ess": 8147.378896306706,
"logZ": -36.76345342679733,
"logZ_error": 0.004234726576790138
}
},
{
"stream": "seed2",
"exploration": {
"estimate": {
"logZ": -37.723370143614204,
"logZ_error": -0.9556819902400875,
"n_eff": 9743.152828952005,
"posterior_sha256": "e560b1267a3a283881d9679d40261fbe97cfdad05af8431deaccd822fa238341",
"n_like": 34600,
"selected_samples": 34382,
"fresh_samples_per_shell": [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
"max_standardized_mean_error": 0.03684884931157322,
"covariance_relative_error": 0.10990721870666056,
"shell_log_v": [
-0.6981597223834896,
-1.2138943376341211,
-1.95341635346034,
-2.5413888701218523,
-3.3398364677866827,
-4.186246886303789,
-5.0875563368555685,
-5.964122815350779,
-6.759819660017344,
-7.771435806199773,
-8.603351144898824,
-9.313841859610797,
-10.039028502073734,
-10.855301444109099,
-11.542848656513433,
-12.36967389261914,
-13.231133932023768,
-14.03794446892126,
-14.906172323953447,
-15.613704352617031
]
},
"geometry": {
"ellipsoids": 14,
"sha256": "e46ee4dd4133511541d3a5a56fb16a5c5cd9aea6dfaa141359ce83a7f12c0ad5"
}
},
"checkpoint_source": "terminal",
"checkpoint_sha256": "cd5c24b2ffe1cbc16b335efb2e41e28b2d8d2f8b29f460bba7a3e8cc8c40dfdf",
"native_and_raw_agree": true,
"completed": false,
"supervision": {
"returncode": 124,
"termination_reason": "timeout",
"sampled_group_peak_rss_bytes": 639578112,
"memory_limit_bytes": 4294967296,
"rss_sample_interval_s": 0.5,
"rss_note": "process group sum; shared pages may repeat; sub-interval spikes may be missed",
"elapsed_s": 2400.194811236004
},
"estimate": {
"total_calls": 1124700,
"fresh_samples": 1090100,
"ess": 9904.195098069627,
"logZ": -36.78542499890535,
"logZ_error": -0.017736845531231893
}
},
{
"stream": "seed3",
"exploration": {
"estimate": {
"logZ": -37.65632698394958,
"logZ_error": -0.8886388305754664,
"n_eff": 9239.34196874813,
"posterior_sha256": "7dcdd8785faf783bbc57e1d09c46a4b27439ae767e3ee4eeacb00549f7820453",
"n_like": 34200,
"selected_samples": 34200,
"fresh_samples_per_shell": [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
"max_standardized_mean_error": 0.06729117273824446,
"covariance_relative_error": 0.1026256527816213,
"shell_log_v": [
-0.6443570163905132,
-1.3037831172331948,
-1.884526297077409,
-2.686483449392004,
-3.358739813266205,
-4.058950957511103,
-4.934299456910265,
-5.649410031881214,
-6.542036325016354,
-7.282784974475383,
-8.160522177103672,
-9.05017833555404,
-9.853431358131333,
-10.593786915007133,
-11.454100370817352,
-12.224977020710023,
-13.109710528005134,
-13.72418532917296,
-13.871769768261938,
-15.22099985137453
]
},
"geometry": {
"ellipsoids": 14,
"sha256": "1e2546b454d5f00401130d4f3a68ae6be579c242e71d4a8467cf0b831eb00a82"
}
},
"checkpoint_source": "terminal",
"checkpoint_sha256": "ba75eacd2703186ccbed1ad4e8fffffba6b61227f15e91053a7caa3a8beb202a",
"native_and_raw_agree": true,
"completed": false,
"supervision": {
"returncode": 124,
"termination_reason": "timeout",
"sampled_group_peak_rss_bytes": 576385024,
"memory_limit_bytes": 4294967296,
"rss_sample_interval_s": 0.5,
"rss_note": "process group sum; shared pages may repeat; sub-interval spikes may be missed",
"elapsed_s": 2400.3947408360036
},
"estimate": {
"total_calls": 970700,
"fresh_samples": 936500,
"ess": 6920.338728359906,
"logZ": -36.771195776280365,
"logZ_error": -0.0035076229062482867
}
}
]
}
86 changes: 86 additions & 0 deletions experiments/nautilus_30d_independent/read_saved.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
"""Recover a fresh-only evidence estimate from a closed native checkpoint after a cap."""

import argparse
import json
from pathlib import Path

import h5py
import numpy as np
from run import geometry
from scipy.special import logsumexp


def inspect_checkpoint(path, exploration, truth):
boundary = json.loads(exploration.read_text())
if geometry(path) != boundary["geometry"]:
raise ValueError("Learned geometry differs from this seed's boundary")
weights = []
with h5py.File(path, "r") as file:
g = file["sampler"]
a = dict(g.attrs)
if not a["explored"] or not a["_discard_exploration"]:
raise ValueError("Expected a fresh-only checkpoint")
for i, cut in enumerate(a["shell_end_exp"]):
likelihoods = g[f"log_l_{i}"]
if len(likelihoods) != len(g[f"points_{i}"]):
raise ValueError("Mismatched position and likelihood counts")
ll = likelihoods[cut:]
if len(ll) != a["shell_n"][i] or len(ll) < 100:
raise ValueError("Incomplete shell")
z = logsumexp(ll)
ess = np.exp(2 * z - logsumexp(2 * ll))
if not np.isclose(
z - np.log(len(ll)), a["shell_log_l"][i], rtol=0, atol=1e-10
) or not np.isclose(ess, a["shell_n_eff"][i], rtol=1e-9):
raise ValueError("Native shell summary differs from stored likelihoods")
weights.append(ll + a["shell_log_v"][i] - np.log(len(ll)))
calls = int(a["n_like"])
weights = np.concatenate(weights)
if len(weights) != calls - boundary["estimate"]["n_like"]:
raise ValueError("Fresh counts do not reconcile")
z = float(logsumexp(weights))
ess = float(np.exp(2 * z - logsumexp(2 * weights)))
if not np.isfinite(z) or not np.isfinite(ess):
raise ValueError("Nonfinite estimate")
# Native construction reopens the existing file. No sampling or writes are requested.
from nautilus import Sampler
from profiling.nautilus_manifest import RunConfig
from profiling.nautilus_target import CorrelatedGaussianTarget

target = CorrelatedGaussianTarget(30)
native = Sampler(
target.prior,
target,
filepath=str(path),
**RunConfig(dimension=30, n_live=400).constructor(),
)
if (
not native.discard_exploration
or native.n_like != calls
or abs(z - native.log_z) > 1e-10
or abs(ess - native.n_eff) > 1e-5
or abs(truth - target.log_evidence) > 1e-12
):
raise ValueError("Native and stored-row diagnostics disagree")
return {
"total_calls": calls,
"fresh_samples": len(weights),
"ess": ess,
"logZ": z,
"logZ_error": z - truth,
}


if __name__ == "__main__":
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("checkpoint", type=Path)
parser.add_argument("exploration", type=Path)
parser.add_argument("truth", type=float)
args = parser.parse_args()
print(
json.dumps(
inspect_checkpoint(args.checkpoint, args.exploration, args.truth),
indent=2,
allow_nan=False,
)
)
Loading
Loading