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
31 changes: 17 additions & 14 deletions agents/faculties/samplers/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@ samplers.sh [--json]
-> the findings maturation lane (below):
experiment probes (autolens_workspace_developer/searches_minimal)
experiment findings (the same tier's *_findings.md, name + verdict)
mature (autolens_profiling — one row per
sampler/dataset_class/model_type cell)
mature (autolens_inference — one row per
sampler/dataset_class/model_type cell;
empty until autolens-inference phase 3)
-> the latest minimal-tier benchmark table (output/comparison.txt)
-> tier gaps: prototyped-never-promoted, promoted-never-integration-tested
```

Surfaces are resolved as sibling checkouts (`PYAUTO_FIT`,
`PYAUTO_FIT_DEVELOPER`, `PYAUTO_FIT_TEST`, `PYAUTO_LENS_DEVELOPER`,
`PYAUTO_PROFILING` override); absent ones are
`PYAUTO_INFERENCE` override); absent ones are
reported, never fatal. Exit codes: `0` digest · `4` no surface · `5` usage.

A mature-tier cell is read from its leaf's `run_search(sampler=,
Expand Down Expand Up @@ -93,7 +94,7 @@ Promote a prototyped sampler only when **all** hold:
see nss_simple's 15-nat error in the benchmark record).
3. It wins somewhere concrete: a use case (likelihood class × hardware)
where it beats the incumbents on time-to-ML or time/eval at equal
quality — ideally confirmed on a real likelihood (autolens_profiling),
quality — ideally confirmed on a real likelihood (autolens_inference),
not just the 1D Gaussian.
4. The implementation cost is justified: a full `NonLinearSearch` subclass
must support the Analysis wrap, results/samples API, visualization and
Expand All @@ -111,12 +112,15 @@ and promote what matures:
hand-rolled harnesses, env-knob objectives, findings docs
(`*_findings.md`). This tier may bypass the `af` search wrapper to probe
mechanisms; its artifacts are the campaign record, not the product.
2. **Mature** — `autolens_profiling/scripts/<dataset>/searches/<sampler>/`:
2. **Mature** — `autolens_inference/scripts/<dataset>/searches/<sampler>/`:
when a configuration *works*, it becomes a first-class cell on the
**library** `af` search via the searches framework (`misc/searches/`
model registry + per-cell knobs), with the *why it works and what was
learned* in the cell docstring + `misc/searches/README.md`. Never promote
`searches_minimal`-style hand-rolled loops.
**library** `af` search, with the *why it works and what was learned* in
the cell docstring and the section README. Never promote
`searches_minimal`-style hand-rolled loops. **Empty until
autolens-inference phase 3**: `autolens_profiling` held these cells until
its retired inference programme was scrapped (autolens_profiling#245), and
the successor repo has not built them yet — an empty mature tier is the
expected reading today, not a missing surface.
3. **User-facing** — `autolens_workspace/scripts/guides/modeling/searches.py`
(and siblings): the lessons at user altitude — which settings matter and
when, no campaign internals.
Expand Down Expand Up @@ -147,11 +151,10 @@ not inventoried.
PyAutoMemory is personal — its citations flow into Mind prompts, issues
and Brain plans, but never into public user-facing output (the memory
faculty's AGENTS.md is the rule's home).
- **Profiling campaigns** — `autolens_profiling` (A100/HPC runs on real
lensing likelihoods); its `scripts/<dataset>/searches/<sampler>/` cells are
the mature tier of the findings lane above, driven by
`scripts/misc/searches/` (model registry, per-cell knobs, README with the
campaign knowledge).
- **Inference campaigns** — `autolens_inference` (A100/HPC search runs on
real lensing likelihoods); its `scripts/<dataset>/searches/<sampler>/` cells
are the mature tier of the findings lane above. `autolens_profiling` is
likelihood timing only and holds no search cells.
- **Real-likelihood search experiments** —
`autolens_workspace_developer/searches_minimal/` (findings docs:
`pix_prodigy_findings.md`, `lr_free_findings.md`,
Expand Down
40 changes: 24 additions & 16 deletions agents/faculties/samplers/_samplers.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ def tier_promoted(autofit: Path) -> list[str]:
# as module constants so callers and tests can refer to a tier without
# re-spelling an instance fact.
SURFACE_LENS_DEVELOPER = "autolens_workspace_developer"
SURFACE_PROFILING = "autolens_profiling"
SURFACE_INFERENCE = "autolens_inference"
TIER_LENS_PROBES = "experiment probes (autolens searches_minimal)"
TIER_LENS_FINDINGS = "experiment findings (autolens searches_minimal)"
TIER_LENS_MATURE = "mature (autolens_profiling searches cells)"
TIER_LENS_MATURE = "mature (autolens_inference searches cells)"


def tier_lens_probes(lens_developer: Path) -> list[str]:
Expand Down Expand Up @@ -156,14 +156,22 @@ def _declared_cell(leaf: Path) -> tuple[str, str, str] | None:
return None


def tier_lens_mature(profiling: Path) -> list[str]:
def tier_lens_mature(inference: Path) -> list[str]:
"""Mature tier: the (sampler x dataset_class x model_type) cell matrix.

Walks `scripts/<dataset>/searches/<sampler>/<model_type>.py`, skipping the
`misc/` framework directory and `_`-prefixed helpers. A leaf with no
parsable declaration falls back to its path shape rather than vanishing.
Walks `scripts/<dataset>/searches/<sampler>/<model_type>.py` under the
`autolens_inference` checkout, skipping the `misc/` framework directory and
`_`-prefixed helpers. A leaf with no parsable declaration falls back to its
path shape rather than vanishing.

The tier is EMPTY until autolens-inference phase 3 builds these cells
(autolens_profiling#245 removed the retired inference programme's copies,
and this walk was repointed here rather than left pointing at a tree that
no longer exists). An absent or empty `scripts/` returns `[]` — never
raises — so an un-cloned or still-empty successor repo is reported as a
surface with no cells rather than a crash.
"""
scripts = profiling / "scripts"
scripts = inference / "scripts"
if not scripts.is_dir():
return []
cells = set()
Expand Down Expand Up @@ -208,7 +216,7 @@ def gaps(minimal, integration, promoted) -> list[str]:
return out


def digest(autofit, developer, test, lens_developer=None, profiling=None) -> dict:
def digest(autofit, developer, test, lens_developer=None, inference=None) -> dict:
d = {
"surfaces_present": [],
"tiers": {},
Expand Down Expand Up @@ -240,9 +248,9 @@ def digest(autofit, developer, test, lens_developer=None, profiling=None) -> dic
d["surfaces_present"].append(SURFACE_LENS_DEVELOPER)
d["tiers"][TIER_LENS_PROBES] = tier_lens_probes(lens_developer)
d["tiers"][TIER_LENS_FINDINGS] = tier_lens_findings(lens_developer)
if profiling and profiling.is_dir():
d["surfaces_present"].append(SURFACE_PROFILING)
d["tiers"][TIER_LENS_MATURE] = tier_lens_mature(profiling)
if inference and inference.is_dir():
d["surfaces_present"].append(SURFACE_INFERENCE)
d["tiers"][TIER_LENS_MATURE] = tier_lens_mature(inference)
# The lane tiers are inventory only: `gaps` stays keyed on the autofit
# promotion tiers, so adding them introduces no new judgment.
if minimal or promoted:
Expand Down Expand Up @@ -282,20 +290,20 @@ def main(argv=None) -> int:
ap.add_argument("--lens-developer", default="", dest="lens_developer",
help="autolens_workspace_developer checkout "
"(lane experiment tier)")
ap.add_argument("--profiling", default="",
help="autolens_profiling checkout (lane mature tier)")
ap.add_argument("--inference", default="",
help="autolens_inference checkout (lane mature tier)")
ap.add_argument("--json", action="store_true", dest="as_json")
a = ap.parse_args(argv)
autofit = Path(a.autofit) if a.autofit else None
developer = Path(a.developer) if a.developer else None
test = Path(a.test) if a.test else None
lens_developer = Path(a.lens_developer) if a.lens_developer else None
profiling = Path(a.profiling) if a.profiling else None
d = digest(autofit, developer, test, lens_developer, profiling)
inference = Path(a.inference) if a.inference else None
d = digest(autofit, developer, test, lens_developer, inference)
if not d["surfaces_present"]:
print("samplers: no sampler surface found (PyAutoFit / "
"autofit_workspace_developer / autofit_workspace_test / "
"autolens_workspace_developer / autolens_profiling absent)",
"autolens_workspace_developer / autolens_inference absent)",
file=sys.stderr)
return 4
print(json.dumps(d, indent=2)) if a.as_json else emit_human(d)
Expand Down
4 changes: 2 additions & 2 deletions agents/faculties/samplers/samplers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ test_ws="$(_resolve_dir PYAUTO_FIT_TEST autofit_workspace_test 2>/dev/null || tr
# The findings maturation lane's two tiers (AGENTS.md "Judgment: the maturation
# lane") — present-if-checked-out, exactly like the autofit-side surfaces.
lens_developer="$(_resolve_dir PYAUTO_LENS_DEVELOPER autolens_workspace_developer 2>/dev/null || true)"
profiling="$(_resolve_dir PYAUTO_PROFILING autolens_profiling 2>/dev/null || true)"
inference="$(_resolve_dir PYAUTO_INFERENCE autolens_inference 2>/dev/null || true)"

exec python3 "$HERE/_samplers.py" \
${autofit:+--autofit "$autofit"} \
${developer:+--developer "$developer"} \
${test_ws:+--test "$test_ws"} \
${lens_developer:+--lens-developer "$lens_developer"} \
${profiling:+--profiling "$profiling"} \
${inference:+--inference "$inference"} \
"$@"
27 changes: 21 additions & 6 deletions tests/test_samplers_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ def test_experiment_tier_lists_probes_and_findings_verdicts(tmp_path):


def test_mature_tier_reads_the_declaration_not_the_path(tmp_path):
d = _digest("--profiling", str(_make_mature(tmp_path)))
assert _samplers.SURFACE_PROFILING in d["surfaces_present"]
d = _digest("--inference", str(_make_mature(tmp_path)))
assert _samplers.SURFACE_INFERENCE in d["surfaces_present"]
cells = d["tiers"][_samplers.TIER_LENS_MATURE]
# the cluster/ leaf declares `group`, and the declaration wins — parsing the
# path instead would mislabel it and silently collide with a real cell
Expand All @@ -101,22 +101,22 @@ def test_mature_tier_falls_back_to_path_when_undeclared(tmp_path):
undeclared = root / "scripts" / "interferometer" / "searches" / "emcee"
undeclared.mkdir(parents=True)
(undeclared / "delaunay.py").write_text("# no run_search call at all\n")
cells = _digest("--profiling", str(root))["tiers"][_samplers.TIER_LENS_MATURE]
cells = _digest("--inference", str(root))["tiers"][_samplers.TIER_LENS_MATURE]
assert "emcee/interferometer/delaunay" in cells


def test_lane_tiers_add_no_gaps(tmp_path):
"""Inventory only — `gaps` stays keyed on the autofit promotion tiers."""
root = _make_mature(_make_experiment(tmp_path))
d = _digest("--lens-developer", str(root), "--profiling", str(root))
d = _digest("--lens-developer", str(root), "--inference", str(root))
assert d["gaps"] == []


def test_absent_lane_checkouts_are_not_fatal(tmp_path):
result = subprocess.run(
[sys.executable, str(FACULTY / "_samplers.py"), "--json",
"--lens-developer", str(tmp_path / "nope"),
"--profiling", str(tmp_path / "also-nope")],
"--inference", str(tmp_path / "also-nope")],
capture_output=True, text=True,
)
assert result.returncode == 4 # no surface, reported cleanly
Expand All @@ -126,5 +126,20 @@ def test_absent_lane_checkouts_are_not_fatal(tmp_path):
def test_never_writes(tmp_path):
root = _make_mature(_make_experiment(tmp_path))
before = sorted(str(p) for p in root.rglob("*"))
_digest("--lens-developer", str(root), "--profiling", str(root))
_digest("--lens-developer", str(root), "--inference", str(root))
assert sorted(str(p) for p in root.rglob("*")) == before


def test_empty_mature_surface_yields_no_cells(tmp_path):
"""The mature tier is empty until its cells are built — a surface with zero
rows, not a crash and not a missing surface."""
empty = tmp_path / "successor"
empty.mkdir()
d = _digest("--inference", str(empty))
assert _samplers.SURFACE_INFERENCE in d["surfaces_present"]
assert d["tiers"][_samplers.TIER_LENS_MATURE] == []
# and again with a scripts/ tree that holds no searches cells at all
(empty / "scripts" / "imaging" / "likelihood_runtime").mkdir(parents=True)
(empty / "scripts" / "imaging" / "likelihood_runtime" / "mge.py").write_text("x = 1\n")
d = _digest("--inference", str(empty))
assert d["tiers"][_samplers.TIER_LENS_MATURE] == []
Loading