Repository navigation
perf: back off the fnnls warm-start memo on scattered evaluation streams - #615
Merged
Merged
Conversation
The passive-set memo's fallback guard judges a seed only after the seeded solve has run, so on a scattered (iid) stream every other solve paid for a bad seed (autolens_profiling#332: alma Delaunay solve 2.17x slower memo-on). Add a per-key back-off in nnls_memo: after 2 consecutive seeded-solve fallbacks the next 1, 2, 4, ... (cap 32) would-be-seeded solves start dense (still refreshing the entry). Each backed-off dense solve also checks, for free, whether the seed it skipped would have passed the guard against it (symmetric difference with the final passive set == warm_start_errors); if so the remaining skips are cancelled, so a stream that turns local regains the memo after one solve. An accepted real seed resets the streak. A local walk never falls back twice in a row, so its path and every reconstruction are unchanged. New stats key warm_start_backoff; memo_clear() clears entries and back-off state together. No config keys or tolerances change. Local witness (n=576, solver-only, min of 3, 3 seeds, 64 solves): iid on/off 1.49x -> 1.17x; walk 0.18x -> 0.18x; iid->walk phase recovery 0.69x. Refs #613 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S11WE9oj7Mvkfhc4EPBnyN
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
The fnnls passive-set warm-start memo judges a seed only after the seeded solve has run, so on a scattered (iid) evaluation stream every other solve paid for a bad seed (autolens_profiling#332: ALMA Delaunay solve 2.17x slower with the memo on).
This adds a per-key exponential back-off in
nnls_memo: after 2 consecutive seeded-solve fallbacks, the next 1, 2, 4, ... (cap 32) would-be-seeded solves start dense (still refreshing the entry). Each backed-off dense solve also checks, for free, whether the seed it skipped would have passed the guard; if so the remaining skips are cancelled, so a stream that turns local regains the memo after one solve. An accepted real seed resets the streak. A local walk never falls back twice in a row, so its path and every reconstruction are unchanged. No config keys or tolerances change.Local witness (n=576, solver-only, min of 3, 3 seeds, 64 solves): iid on/off 1.49x -> 1.17x; walk 0.18x -> 0.18x; iid->walk phase recovery 0.69x.
Closes #613
API Changes
None to the public modelling API — internal solver behaviour only. Adds a new
warm_start_backoffkey to the positive-only solver stats dict and annls_memo.memo_clear()helper that clears memo entries and back-off state together (harnesses that clear_nnls_passive_set_memodirectly now leave back-off state behind; see Downstream notes).See full details below.
Test Plan
pytest test_autoarray/— 1975 passed, 4 xfailedtest_autoarray/inversion/inversion/test_nnls_memo.py(back-off schedule, streak reset, shadow-check recovery, local walk unchanged)Readiness (Heart)
Heart verdict YELLOW, acknowledged by the human for this ship. Reasons verbatim from
pyauto-heart readiness --json:Downstream notes
fixed_light_numba.py,delaunay_numba_nnls_iterations.py,fixed_light_numpy_solvers.py,fixed_light_s4b_checks.py) clearnnls_memo._nnls_passive_set_memodirectly; they should switch tonnls_memo.memo_clear()so back-off state does not leak between rows._production_config.pyprose citesnnls_memo.py:63, which shifts with this PR (cosmetic). Follow-up noted on perf: back off the fnnls warm-start memo on scattered evaluation streams #613.Full API Changes (for automation & release notes)
Added
autoarray.inversion.inversion.nnls_memo.memo_clear()— clears passive-set entries and back-off state togethernnls_memo.BackoffState,nnls_memo.backoff_should_skip(key),backoff_record_fallback(key),backoff_end_skip(key),backoff_record_accept(key),seed_error_fraction(seed_passive_set, passive_set, n)— internal back-off helpersstats["warm_start_backoff"]— new key in the stats dict filled byreconstruction_positive_only_from(Truewhen the memo seed was skipped by back-off)Changed Behaviour
reconstruction_positive_only_from(memo on): after 2 consecutive seed fallbacks for a key, the next 1, 2, 4, ... (cap 32) would-be-seeded solves start dense; reconstructions are unchanged (dense and seeded starts converge to the same NNLS solution), only the start/iteration path differs.Generated by the PyAutoLabs agent workflow.
🤖 Generated with Claude Code