Repository navigation
Description
Overview
Design phase (1 of 4) for extending PYAUTO_TEST_MODE bypass runs to produce size-representative outputs: a sample-count knob so samples.csv matches a production Nautilus SLaM stage (N ~ 10k–100k rows) instead of today's 4 fake samples. This makes cold SLaM runs instant while keeping resume-overhead profiling honest (born from the slam-resume-profiling task, autolens_profiling#70). This phase edits no source — the deliverable is four locked design decisions (D1–D4) posted on this issue, which phase 2 implements verbatim.
Plan
- Ground the design against the live bypass path:
PYAUTO_TEST_MODElevels in autoconf,_fit_bypass_test_mode→_build_fake_samplesin PyAutoFit. - Fix the parity target: measure a production Nautilus SLaM stage's
samples.csv(rows, columns, byte size) against today's 4-sample bypass output. - Lock and post the four decisions: D1 knob name + accessor placement, D2 vectorized synthesis recipe, D3 downstream contract + the concrete phase-2 test list, D4 representativeness limits (recorded, not solved).
- Exit: D1–D4 on this issue; phase 2 unblocked with zero open design questions.
Detailed implementation plan
Affected Repositories
- PyAutoFit (primary — design target; no edits this phase)
- PyAutoConf (only if D1 places the accessor next to
test_mode_level())
Branch Survey
| Repository | Current Branch | Dirty? |
|---|---|---|
| ./PyAutoFit | main | clean (claimed by aggregator-sqlite, PR#1376 awaiting merge) |
| ./PyAutoConf | main | clean |
Suggested branch: feature/test-mode-representative-samples (family branch, created in phase 2; phase 1 needs none). Phase 2 is blocked until the aggregator-sqlite PyAutoFit claim frees.
Implementation Steps
- Read
autoconf/test_mode.py(test_mode_level()accessor pattern) — decide D1: env varPYAUTO_TEST_MODE_SAMPLES(default 4 = today's behaviour, byte-identical when unset); accessor in PyAutoConf next totest_mode_level()vs a local read in PyAutoFit (the latter drops PyAutoConf from phase 2 entirely). - Read
autofit/non_linear/search/abstract_search.py—_fit_bypass_test_mode,_build_fake_samples(prior-median best + 3 perturbed),save_samples/save_samples_summary— and the samples CSV writer +Samples.summary()quantile/weight machinery. Design D2: vectorized numpy synthesis at N (deterministic seed and where it lives; parameter scatter around the prior median; monotone plausible log-likelihoods; valid normalized weights; exactsamples.csvcolumn layout/dtypes so row count and byte size match production). - Measure a production reference from the slam-resume-profiling outputs (autolens_profiling#70): rows, columns, bytes of a real Nautilus SLaM stage
samples.csv; same for a bypass-completed stage. Sets the N target range. - Enumerate D3 — everything that must keep working on the synthetic set, with the concrete phase-2 test for each (numpy-only unit tests; no JAX):
samples.summary()quantiles, search chaining (result.model/result.instance), aggregator scrape, database load, existing 4-sample multi-batch structural guarantees at large N, default-unset back-compat, and a generation-speed check (N=50k in seconds, vectorized). - Record D4 — known representativeness limits, recorded not solved: single bypass likelihood call leaves no realistically-sized search-internal state; adapt-image FITS values come from the prior-median model (size right, values wrong); test mode auto-skips latents.
- Post D1–D4 as issue comments; mark phase 2 unblocked (design-wise).
Key Files
PyAutoConf/autoconf/test_mode.py—test_mode_level(); candidate home for the new accessor (D1)PyAutoFit/autofit/non_linear/search/abstract_search.py—_fit_bypass_test_mode,_build_fake_samples(D2)PyAutoFit/autofit/non_linear/samples/— CSV writer,Samples.summary(), weight handling (D2/D3)PyAutoFit/autofit/aggregator/— scrape path exercised by the D3 contract
Original Prompt
Click to expand starting prompt
Test-mode representative outputs — Phase 1: design
Type: feature
Target: autofit
Repos:
- PyAutoFit
- PyAutoConf
Difficulty: small
Autonomy: supervised
Priority: normal
Status: formalised
Phase 1 of 4 of draft/feature/autofit/test_mode_representative_outputs_size_realistic.md
(the parent umbrella — read it first; its scoping notes were verified against source
2026-07-16). Design only — no source edits; the deliverable is a set of locked
decisions recorded on this phase's GitHub issue, which phase 2 implements verbatim.
Decisions to lock
- D1 — knob. Confirm
PYAUTO_TEST_MODE_SAMPLES=N(env var, default 4 = today's
behaviour, so nothing changes for existing users/tests) and where it is read:
accessor next totest_mode_level()in @PyAutoConfautoconf/test_mode.pyvs
reading it locally in @PyAutoFit. Decide whether PyAutoConf is touched at all. - D2 — synthesis scheme. Exact vectorized recipe
_build_fake_samplesuses at
large N: parameter scatter around the prior median (deterministic seed — where does
the seed live?), monotone plausible log-likelihoods, valid normalized weights, and
the samples.csv column layout/dtypes so row count and byte size match a production
Nautilus SLaM stage (N ~ 10k–100k). - D3 — downstream contract. Enumerate what must keep working on the synthetic set
and how phase 2 tests each:samples.summary()quantiles, search chaining
(result.model/result.instance), aggregator scrape, database load, and the
existing 4-sample multi-batch structural guarantees at large N. - D4 — representativeness limits. Record (not solve) the known deltas from a
production resume: single bypass likelihood call leaves no realistically-sized
search-internal state; adapt-image FITS values come from the prior-median model
(size right, values wrong); test mode auto-skips latents.
Exit criteria
D1–D4 posted on the issue as locked decisions; phase 2 unblocked with no open design
questions.
Activity
Jammy2211 commentedon Jul 16, 2026
Locked design decisions (phase 1 deliverable — phase 2 implements these verbatim)
Grounded against source on
main2026-07-16 and a production reference:slam-resume-profilinghst_fast/source_lp[1]samples.csv= 10,187 rows × 21 cols, 9.07 MB (~890 B/row, fixed-width fields fromwrite_table).D1 — knob:
PYAUTO_TEST_MODE_SAMPLES, accessor in autoconfPYAUTO_TEST_MODE_SAMPLES=N, default 4 — unset behaviour is byte-identical to today.test_mode_samples()lives inautoconf/test_mode.pynext totest_mode_level(), re-exported through the existing shimautofit/non_linear/test_mode.py(added to its__all__). This follows the repo rule "shared utilities (e.g.test_mode) belong in autoconf" — PyAutoConf IS touched; phase 2 ships the PyAutoConf PR first (dependency direction: autofit → autoconf only).N < 4raisesValueErrorloudly (no silent clamp): 4 is the floor that preserves the existing multi-batch structural guarantee.D2 — synthesis: vectorized numpy → the production
Sample.from_listspathN == 4(default): the existing literal branch runs unchanged (scales 1.001/0.999/1.002, weights 1/.5/.25/.125) — exact back-compat, no behavioural risk to every existing test-mode user.N > 4: vectorized synthesis, then materialization through the identical machinery a real Nautilus run uses (nautilus/search.py:549-562: numpy arrays →.tolist()→Sample.from_lists→SamplesPDF→write_table). Structure, CSV layout (headers =model.joined_paths+log_likelihood, log_prior, log_posterior, weight) and byte-size are then representative by construction; only the parameter/logL/weight generation is new, and it is pure numpy:rng = np.random.default_rng(0)— fixed constant seed; identical outputs across runs/machines, no coupling to the search identifier.(N, D)arrayp * (1 + 1e-3 * G)withG ~ N(0,1), prior-median vectorpas row 0 unperturbed (today's zero-handling kept:p == 0→ the scatter term itself).logL_i = logL_best − i(best-first, monotone), somax_log_likelihood_samplestays the prior-median sample in both branches (mode 3'slogL_best = -1e99works unchanged).w_i ∝ exp(−i / (N/10)), normalized to sum 1 — strictly positive, healthy effective sample size (~N/10), andw_min ≈ (10/N)·e⁻¹⁰ ≥ 4.5e-10for the supported profiling range N ≤ 1e5, safely above the defaultsamples_weight_threshold: 1.0e-10. (Note: the bypass write path applies no pruning anyway —samples_above_weight_threshold_fromis only called fromupdater.py; the bound matters for later loads that re-apply the threshold, cf. PyAutoFit#1375's 2-sample pruning incident.)log_prior = 0for all samples, as today.save_covariance_matrixgets a non-degenerate covariance (today's 4 near-collinear samples are borderline singular).from_listsmaterialization cost is exactly what production pays at the same N — cost parity, not overhead).D3 — downstream contract + phase-2 test list (numpy-only unit tests)
_build_fake_samplesoutput equals today's 4 samples exactly (literal expected values).samples.summary()finite;median_pdf≈ prior median within scatter tolerance; errors at σ=1 and σ=3 finite and positive.result.model/result.instancefrom the bypass result reconstruct the prior-median instance (search-chaining contract).save_samples→ reloadsamples.csv: row count N, header layoutjoined_paths + 4 tail cols, weights normalized/positive/above the D2 floor.PYAUTO_TEST_MODE_SAMPLES=3→ValueError.D4 — representativeness limits (recorded, NOT solved — timing-honest, not science-honest)
search_internal/checkpoint — resume timings measured this way exclude search-internal restore cost.autoconf.test_mode.skip_latents) — a production resume includes latent load; the phase-3 recipe must state this delta.log_evidenceis stubbed to the single logL; evidence arithmetic is size-only, not value-representative.Phase-2 consequences
_build_fake_samples+ tests). Family branchfeature/test-mode-representative-samples.aggregator-sqlitePyAutoFit claim frees (perf: aggregator result-loading speedups (single-scan listing, cached summaries, faster samples parse) #1376 awaiting merge).Exit criteria met: no open design questions. Amendments to these decisions before phase 2 starts are welcome on this thread.
Jammy2211 commentedon Jul 16, 2026
Phase 1 complete — D1–D4 locked in the comment above (design validated; no source edits in this phase). Phase 2 (core API: PyAutoConf accessor → PyAutoFit vectorized builder, branch
feature/test-mode-representative-samples) will be issued next; it starts once the aggregator-sqlite PyAutoFit claim (#1377) frees. Completion record: PyAutoMindcomplete/2026/07/test-mode-representative-samples-phase-1-design.md.