Skip to content

fix: MultiStartProdigy "stopped at 49 steps" is a summary misread, not a quick-update stop #1553

Closed

Description

@Jammy2211

Overview

An imaging/start_here.py run using MultiStartProdigy with iterations_per_quick_update=50 was reported to "stop at 49 steps", suggesting the quick-update cycle terminates the search at the first cadence boundary and returns a barely-started result.

Investigation shows the search cannot stop at a quick-update boundary: nothing in AbstractMultiStartGradient._fit reads iterations_per_quick_update (the cadence is currently inert for this family — see the EXEMPT entry in test_quick_update_wiring.py and #1433), and the only stop paths are the auto-convergence plateau check (gated behind min_steps=100) and the n_steps ceiling. An end-to-end run with iterations_per_quick_update=50 and n_steps=120 takes all 120 steps.

The "49" is search.summary's first line: Total Samples = 49 — 1 best sample + n_starts=48 per-start final points, a sample count fixed by construction that carries no step information. The summary never reports the actual step count, so its one prominent number reads as "the search ran 49 iterations", and 49 = 50 − 1 invites blaming the quick-update cadence.

Plan

  • Make search.summary for the MultiStartGradient family report the real run length: a Total Steps = N line and a Stop Reason = converged|max_steps line, and disambiguate the Total Samples line so it can no longer read as a step count.
  • Pin the non-interaction with an end-to-end regression test: a MultiStartProdigy fit with a finite iterations_per_quick_update mid-search runs past the cadence boundary to the n_steps ceiling (the prompt's Witness), written so it stays valid once real quick updates are wired in (by the sibling MultiStart quick-update wiring task).
  • No behaviour change to the search itself — this task deliberately does not wire quick updates into the step loop (that is the sibling task covering iterations_per_quick_update / live_visual_update being ignored).
Detailed implementation plan

Affected Repositories

  • PyAutoFit (primary)

Branch Survey

Repository Current Branch Dirty?
./PyAutoFit main (remote session clone) clean

Suggested branch: feature/multistart-quick-update-49-steps

Implementation Steps

  1. autofit/text/text_util.py — in search_summary_from_samples, inside the gradient-search block (guarded on "n_value_nan_lane_steps" in samples_info):
    • rewrite the Total Samples line to state its composition (1 best + {n_starts} per-start final points), so the count cannot read as a step count;
    • append Total Steps = {samples_info["total_steps"]} and, when present, Stop Reason = {samples_info["stop_reason"]} (read defensively — a legacy search_internal may predate stop_reason).
  2. test_autofit/text/test_text_util.py — new tests asserting the step-count and stop-reason lines for a gradient samples_info, their absence for other searches, and the legacy-file (no stop_reason) path.
  3. New test_autofit/non_linear/search/mle/test_multi_start_quick_update_termination.py — end-to-end regression (skipped when jax/optax absent, same pattern as test_blackjax_smc.py): a JAX-traceable Gaussian analysis fit with MultiStartProdigy(n_starts=4, n_steps=60, iterations_per_quick_update=25) asserts total_steps == 60 (well past the first cadence boundary at 25) and stop_reason == "max_steps". The analysis implements perform_quick_update as a recording no-op so the assertion stays valid if/when the sibling task wires quick updates into the step loop.

Key Files

  • autofit/text/text_util.py — search_summary_from_samples (the misread Total Samples line; where the step count belongs)
  • autofit/non_linear/search/mle/multi_start_gradient/search.py — _fit step loop (evidence: cadence never read), samples_via_internal_from (samples_info already carries total_steps / stop_reason; sample list is 1 + n_starts by construction)
  • autofit/non_linear/search/mle/multi_start_gradient/convergence.py — min_steps=100 gate (evidence a 49-step stop is impossible)
  • test_autofit/text/test_text_util.py, test_autofit/non_linear/search/test_quick_update_wiring.py — existing tests around both seams

Original Prompt

Click to expand starting prompt

MultiStartProdigy stops at 49 steps when iterations_per_quick_update=50 in @PyAutoFit

Type: bug
Target: PyAutoFit
Repos:

  • PyAutoFit
    Difficulty: small
    Autonomy: safe
    Priority: normal
    Status: formalised
    Consequence: glance
    Witness: an imaging/start_here.py run using MultiStartProdigy with iterations_per_quick_update=50 runs past the first quick update (total steps well above 50) instead of terminating at 49 steps, and the interaction is covered by a PyAutoFit unit test in which a quick update mid-search does not end the search.
    Review-minutes: 3
    Unattended: ready

MultiStartProdigy stops at 49 steps when iterations_per_quick_update=50 in @PyAutoFit

Type: bug

Original report (verbatim): the imaging/start_here.py run I did which uses MultiStartProdigy stopped at 49 steps, which is probbably due to iterations_per_quick_update=50, meaning the result is rubbish. Is there an issue with this combination of quick updates and prodigy?

Investigate the interaction between the quick-update cycle and MultiStartProdigy: the search appears to terminate at the first quick-update boundary (49 steps with iterations_per_quick_update=50) instead of resuming sampling afterwards, so the returned result is from a barely-started search.

Witness: an imaging/start_here.py run using MultiStartProdigy with iterations_per_quick_update=50 runs past the first quick update (total steps well above 50) instead of terminating at 49 steps, and the interaction is covered by a PyAutoFit unit test in which a quick update mid-search does not end the search.

Activity

  1. Jammy2211 commented on Aug 31, 2026

    @Jammy2211
    CollaboratorAuthor

    Library PR created: #1555 (pending-release; --auto run, five-leg gate passed — details in the PR's validation checklist).

    Workspace-impact analysis → option (iii), no workspace work needed. ## API Changes is "None — internal": the diff changes only the text search.summary writes for the MultiStartGradient family. Grep evidence: no library code, test, or workspace script parses search.summary or its Total Samples line (workspace mentions are prose in output-directory docstrings only), so no script migration and no new demos. The three start_here.py scripts' misleading iterations_per_quick_update prose is already scoped to the sibling wiring task (autofit-multistart-iterations), not this one.

    Batch note: merge #1555 before the sibling quick-update wiring PR (serial order per the 2026-08-31-pm batch record). The sibling's wiring change must flip the new e2e test's quick_update_count == 0 tripwire into a "fired" assertion — the test's comment says exactly this at the assertion site.

    Run ends at PR-open per the autonomy contract; merge stays human.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions