Repository navigation
Pin mir_history_ against rollback and load - #285
Merged
Merged
Conversation
Issue #161: the offset was already documented on AMICA.mir_history_ and in AMICATorchNG.__init__'s inline comment, but not on fit()'s mir_step parameter, the first place a reader would look.
Both mir_history_ pin tests (keep_best rollback, save/load emptiness) already existed from #245; this documents and closes the issue.
Merged
4 tasks done
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
Issue #161 asked for three things: a test that a
keep_bestrollback does not rewritemir_history_, a test that a loaded model'smir_history_comes back empty, and a docstring line on the one-update offset betweenmir_history_andll_history.Investigation found the first two were already fully implemented and passing on
dev(commitcec10fc), added by PR #213, whose commit message already noted "Folds in issue #161" (the issue stayed open because no closing keyword was used); #245 later fixed a waypoint assertion in the first test and added the offset notes while fixing a related waypoint-assertion bug, but issue #161 was never closed.test_mir_history_survives_keep_best_restore(pamica/tests/torch_tests/test_ng_convergence.py) already uses the established rollback recipe (n_models=2, do_newton=True, newt_start=1, lrate=0.5, seed=0, use_min_dll=True, min_dll=1e-4, maxincs=2, shared withtest_keep_best_restores_genuine_overshoot_under_min_dll_stop) withmir_step=1added, forces a genuine restore, and assertsmir_history_runs to the pre-restore final iteration with one entry per iteration (len(mir_history_) == final_it + 1), i.e. it is neither truncated nor rewritten.test_mir_history_empty_after_save_loadalready fits withmir_step=3, round-trips throughAMICA.save/AMICA.load, and assertsloaded.mir_history_ == []. I verified this against the code:AMICATorchNG.from_state_dictreconstructs viacls(device=device, **config)(i.e.__init__, which setsself.mir_history_ = []), and_load_paramsnever touchesmir_history_, so the empty-on-load contract is real, not incidental.The docstring line existed on
AMICA.mir_history_(pamica/amica.py) and as an inline comment inAMICATorchNG.__init__(pamica/torch_impl/core.py), both added by PR #213 (#245 later fixed a waypoint assertion and added the offset notes). It was missing fromAMICATorchNG.fit'smir_stepparameter docstring, the first place a reader passingmir_stepwould look, so I added it there.What this PR actually changes
pamica/torch_impl/core.py: one docstring sentence added tofit()'smir_stepparameter, mirroring the existing offset note in__init__/amica.py. No logic change.docs/changelog.md: a bullet documenting what already existed vs. what was added, and closing out Test mir_history_ against the keep_best rollback and save/load #161.No test file changes — the two pin tests requested by #161 were already present and already pass.
Test plan
uv run pytest pamica/tests/torch_tests/test_ng_convergence.py -q --no-cov— 22 passeduv run pytest -m "not slow" -n auto -q --no-cov— 412 passed, 25 skipped, 1 xfailed, 0 faileduv run ruff check ./uv run ruff format --check ./uv run ty check— all clean, zero new diagnosticsCloses #161