Repository navigation
docs: stored Chapter 2 fit results so HowToLens tutorials skip sampling - #134
Merged
Merged
Conversation
…orial notes Adds .github/scripts/stored_results.py (harvest + check), seeds the three Chapter 2 simulators so every reader simulates the data the stored fits describe, and explains in Tutorials 1-6 that later fits load stored results. Stored outputs follow from the RAL regeneration run. Refs #130 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
n_live=21 on the 20-parameter model crashes Nautilus while it builds its first bounds (numpy LinAlgError: Matrix is not positive definite): 4/4 runs (3 laptop + RAL 414812), and n_live=30 crashed 1/2. n_live=40 (4/4) and 50 (2/2) ran past the window where every crash occurred. The prose now explains that 21 is accepted but too few points for Nautilus to build its bounds. Refs #130 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nverge Real RAL runs showed these 20-parameter fits are seed-sensitive at the tutorial live-point counts: tutorial 2 (n_live=200) reached the right solution on the laptop but a poor one (log Z -42,262 vs +3,322) on RAL. With seed=1 and seed=2 every search lands where its lesson needs it: - tutorial 2 reference n_live=200: +3,322 (both seeds) - prior tuning 75 -> 150: 75 stalled (no new bound for 68k calls), 100 reached a poor fit (-4,831), 150 gives +3,336 (both seeds) - reduced complexity 75 -> 300: 75 and 150 reached poor fits, 200 stalled (both seeds), 300 gives +3,340 (both seeds) and now matches the thorough search, so that comparison isolates the effect of linking - more thorough n_live=300: +3,322 (both seeds) Every chapter 2 tutorial 2/3 search now uses seed=1, explained in the prose. stored_results.py check now removes the setup folders a refused search writes. Refs #130 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ten fits from RAL runs at the released 2026.11.9.1 libraries, harvested by .github/scripts/stored_results.py: tutorial 2's illustrated folder (3.9 MB, 1,000 samples) and minimal ~40-200 KB folders for every other search. stored_results.py check passes for tutorials 2-6 (no search samples). harvest now keeps only samples the model can rebuild (elliptical components inside the unit circle) and always the best of them: tutorial 3's failed less-thorough fit puts 99% of its weight on invalid source shapes, and with only invalid rows PyAutoFit cannot rebuild any result. search.summary is optional, since not every completed search writes one. Refs #130 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…esults in AGENTS.md Refs #130 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…seeded Same-seed reruns were shown to give the same outcome on one cluster, not the same path on every computer. Tutorial 2's 200-live-point fit failed in 1 of 4 real runs without a seed; say so and point to Why Modeling Is Hard. Refs #130 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Runs .github/scripts/stored_results.py check with test mode off after pip install -r requirements.txt, so a library release that moves a stored fit's identifier turns HowToLens red instead of silently sending readers back to sampling. Daily schedule because library releases never push here. check now prints the last 20 lines of a failing tutorial. Refs #130 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
HowToLens now ships the completed output of every Chapter 2 search from Tutorial 2 onwards. When a reader runs a tutorial, PyAutoFit finds the stored result, prints
Fit Already Completed: skipping non-linear searchand loads it in seconds, so the chapter can be worked through without waiting tens of minutes per search. The tutorials say this is deliberate and print the real run time of each stored fit. Tutorial 1 stays the reader's one live search.Closes #130 (phase 1: Chapter 2; Chapters 3-4, the optional chapter and the other HowTo series follow).
What is stored: ten fits from real runs (test mode off) on RAL at the released 2026.11.9.1 libraries, about 5.5 MB in total. Each keeps only what PyAutoFit needs to rebuild the result, with
samples.csvthinned to 10 equal-weight draws (~40-200 KB per fit). Two fits whose corner plots the text asks readers to interpret keep 1,000 draws: Tutorial 2 and Tutorial 6's second search. Tutorial 2 keeps a fuller, illustrated folder (3.9 MB, minus the corner-plot PNGs) because it walks the reader through the output tree.Tooling:
.github/scripts/stored_results.pyharvest <root>copies completed real runs intooutput/howtolens/chapter_2, keeping the minimal files and thinning samples (valid shapes only, always the best one).checkruns Tutorials 2-6 with test mode off and any real sampling refused. It currently passes for all five.CI: new
.github/workflows/stored_results.ymlrunscheckagainst the released libraries (pip install -r requirements.txt, test mode off) on PRs, onmainand daily. Library releases never push to this repo, so the daily run is what turns HowToLens red if a release moves a stored fit's identifier.AGENTS.mddocuments how to refresh the store.Decisions to review
Tutorial 3 live points. Real runs showed the settings in the current text don't work on this 20-parameter model. Nautilus's default
n_points_minis n_dim + 50 = 70.LinAlgErrorwhile building its first bounds).seed=1on every Tutorial 2/3 Nautilus search, explained in the text. Unseeded, Tutorial 2's 200-live-point fit reached the right solution on the laptop but a poor one on RAL (log Z −42,262 vs +3,322). With seed 1 and seed 2, every search ends where its lesson needs it:Simulators use
noise_seed=1, so every reader simulates the exact data the stored fits describe. Noise was random before.Tutorial 1 is not stored. Its search has no
name, so it writes no output; it takes about 4 minutes live.Known rough edges
WARNINGthat its best sample "cannot be reconstructed as a model instance", then falls back. That failed search put 99% of its weight on source elliptical components with magnitude ≥ 1, which the sampler scored but the model can't rebuild. This is a library bug, to be filed separately; the stored data is kept as the search produced it..zipand status files there. They're gitignored, so readers'git statusstays clean.Heart RED override (development only)
Heart was RED at ship time for reasons outside HowToLens:
autocti_workspace: Smoke Tests failure on mainmanifest drift: organism-map blocks (generated) — 7 mismatch(es) vs PyAutoMind/repos.yamlPyAutoArray: open PR 7d oldPyAutoMind: open PR 7d oldrelease validation incomplete: no rehearsal for current sourceThe live human authorized this PR in the session: "yes override, open the PR". Full record on #130: #130 (comment). This PR does not fix any of those reasons. Merge needs a separate human
/prmand every required check green.Scripts Changed
scripts/chapter_2_lens_modeling/tutorial_1_non_linear_search.py: notes that this is the one live search.scripts/chapter_2_lens_modeling/tutorial_2_practicalities.py:__Stored Results__section,seed=1with an explanation (including that this fit can fail unseeded), and a print of the recorded run time.scripts/chapter_2_lens_modeling/tutorial_3_why_modeling_is_hard.py:n_live21→50, 75→150 and 75→300;seed=1on all searches; matching text and live-points table.scripts/chapter_2_lens_modeling/tutorial_4_linear_profiles.py,tutorial_5_data_and_likelihoods.py,tutorial_6_search_chaining.py: one-line stored-result notes.scripts/simulator/lens_sersic.py,no_lens_light__mass_sis.py,lens_extra_galaxy.py:noise_seed=1..github/scripts/stored_results.py(new),.github/workflows/stored_results.yml(new),AGENTS.md,output/howtolens/chapter_2/(stored fits, force-added), and regenerated notebooks.Test Plan
python .github/scripts/stored_results.py check: OK for Tutorials 2-6.profile_smoke.yaml), local:scripts/simulatorall PASS; Chapter 2 Tutorials 2 and 4–7 PASS. Tutorials 1 and 3 hit the 300 s cap while the laptop was saturated (load average 8.5–9.3 on 8 cores). Rerun individually under the same environment, they PASS (24 s and 45 s). Exact-head CI smoke is authoritative.stored_resultsjob.Generated by the PyAutoLabs agent workflow.
🤖 Generated with Claude Code