feat: size-realistic test-mode bypass samples (PYAUTO_TEST_MODE_SAMPLES)#1381
Merged
Merged
Conversation
_build_fake_samples now reads test_mode_samples(): unset/4 keeps today's literal 4-sample branch byte-identical; N > 4 synthesizes vectorized numpy samples (seed 0, prior-median best first, monotone logL, normalized exp-decay weights) through the same Sample.from_lists path a production sampler run uses, so samples.csv row count and byte size are representative. Design D1-D4 locked on #1378; task #1379. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jul 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PYAUTO_TEST_MODE=2/3bypass runs can now write asamples.csvwhose row count and byte size match a production sampler stage: setPYAUTO_TEST_MODE_SAMPLES=N(N ~ 10k–100k). Cold pipeline runs stay seconds-fast while resume/load timings measured against the completed outputs are honest — born from the SLaM resume-profiling task (PyAutoLabs/autolens_profiling#70). Implements the D1–D4 design locked on #1378, verbatim (#1379).Merge order: requires the paired PyAutoConf PR (new
test_mode_samples()accessor) — merge that first.API Changes
Added-only and default-off: new env var
PYAUTO_TEST_MODE_SAMPLES(default 4 — behaviour is byte-identical when unset) with the autoconf accessor re-exported asautofit.non_linear.test_mode.test_mode_samples. The private_build_fake_samplesgains a vectorized N > 4 branch; the N == 4 literal branch is untouched. No existing public symbol changed.See full details below.
Test Plan
pytest test_autofit/— 1493 passed, 1 skipped (full suite, worktree)ValueErrorat N=3; structure + fixed-seed determinism at N=50; zero-valued-parameter perturbation;summary()/median_pdfon the synthetic set (weighted-quantile path,pdf_converged is True);write_tableround-trip at N=100 with every weight above the 1e-10samples_weight_threshold; functional N=50,000PYAUTO_TEST_MODE=2 PYAUTO_TEST_MODE_SAMPLES=10000DynestyStaticfit ofaf.ex.Gaussian→ 1.7 s wall,samples.csv= 10,000 rows / 1.31 MB, min weight 4.5e-8, weights sum to 1.0,result.instance/result.modelintact, normal.completed+ zip cycleFull API Changes (for automation & release notes)
Added
PYAUTO_TEST_MODE_SAMPLES=N— number of fake samples the test-mode bypass writes (default 4 = historical behaviour; N < 4 raisesValueError).autofit.non_linear.test_mode.test_mode_samples— re-export of the new autoconf accessor (shim__all__updated).Changed Behaviour
AbstractSearch._build_fake_samples(private): at N > 4 synthesizes samples vectorized (numpy,default_rng(0); prior-median best sample first; monotonelogL_i = best − i; normalizedexp(−i/(N/10))weights) and materialises them through the sameSample.from_listspath a production sampler run uses. At N > ~11 the max weight is ~10/N < 0.99, soSamplesPDF.pdf_convergedisTrueand the real weighted-quantilemedian_pdfpath runs (the 4-sample branch keeps its max-likelihood fallback). The bypass write path applies no weight-threshold pruning (samples_above_weight_threshold_fromis updater-only); the weight floor ~(10/N)e⁻¹⁰stays above the 1e-10 threshold for N ≤ 1e5 so threshold-applying loads keep the full set.Migration
Generated by the PyAutoLabs agent workflow.