Document mir_history offset; fix waypoint assertion - #245
Conversation
The bucket assertion passed under a restore that truncated mir_history_ to the best iterate: min_dll/maxincs halts one or two iterations past the peak, so at mir_step=5 the last waypoint landed before the best iterate and the damaged window was never sampled. Record every iteration instead, assert the last waypoint is the final iteration and the trajectory holds one entry per iteration, and drop the tautological bound (it followed from the floor division above it). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Review findings addressed; merging. Finding 1 (Critical) — the assertion could not witness a truncating restore. Confirmed and fixed. The reviewer's sabotage (filter Finding 2 (Important) — Finding 3 (Important) — magic Finding 4 — noted; the new form is robust to stopping-iteration drift, since it no longer depends on where the stop lands relative to a waypoint boundary. The docstring accuracy confirmation was useful independently: the off-by-one being documented is real ( 22/22 in the file pass, |
Closes #161, and repairs a test my own #241 broke.
#161 was mostly already done
Both of its testable claims already have tests in
test_ng_convergence.py—test_mir_history_survives_keep_best_restoreandtest_mir_history_empty_after_save_load. Only the third, informational item was outstanding.Verified before documenting it:
llcomes from the E-step accumulator at the top of the loop,_update_parametersruns, and the MIR waypoint is computed after. Somir_history_[i]reflects the parameters after iterationi's update whilell_history[i]is the likelihood of the parameters before it. Zipping them by index compares different parameter states. Now stated on both the backend attribute and theAMICA.mir_history_docstring.A regression from #241
Running the whole file rather than a subset surfaced
test_mir_history_survives_keep_best_restorefailing ondev:I bisected it: the test passes at
257d20e(the commit before #241 merged) and fails atc80fb33(the merge). #241 caused it. That PR's gm-ordering change shifts multi-model trajectories by ~1e-6, which moved themin_dllstop to iteration 55; MIR waypoints land on multiples ofmir_step=5, so the last one is at 50, not 54.The assertion
last_it == len(ll_history) - 1was fragile from the start — it only held while the stop happened to coincide with a waypoint, and any trajectory perturbation could break it. It now asserts what the test is actually about: the last waypoint is the highest multiple ofmir_stepat or below the final iteration, and is within one interval of the end, so a restore that truncated the trajectory would still fail it.Why CI did not catch it
The test is not
slow-marked, so CI runs it, and CI was green on #241's branch. I have not established why the branch and the squashed merge behave differently here; the practical lesson is that I ran a subset locally on #241 and would not have seen this either way. Flagging rather than leaving it implicit.