Repository navigation
Document final_ll_ semantics under final-iteration merges - #281
Merged
Merged
Conversation
Merged
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
final_ll_(torch/MLX) andself.ll[-1](NumPy) report the log-likelihood computed under the PRE-mergecomp_listwhen ashare_compsmerge fires on the final fit iteration, while the returnedA/W/comp_listare already post-merge.This ordering matches Fortran:
identify_shared_compsruns after the iteration's LL accumulation (amica15.f90:1856), not before, so the merge's effect on the likelihood only shows up in the next iteration's E-step, which never runs.Lead decision: this is Fortran-faithful behavior and stays as-is. This PR documents it and pins it with tests, per issue #269; it makes no behavior change (production-code edits are docstring/comment text only).
Changes
pamica/torch_impl/core.py,pamica/numpy_impl/core.py,pamica/mlx_impl/core.pyexplain the ordering atfinal_ll_/self.lland atfit(), and note that PyTorch'skeep_bestsafeguard is already disabled undershare_comps(so this is not akeep_bestartifact).docs/guides/amica-differences.mdgets a new subsection recording the semantics across backends.tests/mlx_tests/test_mlx_sharing.py::test_merge_on_the_final_iteration_completes, landed in Phase 2: port share_comps to the MLX backend #268):tests/torch_tests/test_ng_sharing.py::test_merge_on_the_final_iteration_completesandtests/test_numpy_share_comps.py::test_merge_on_the_final_iteration_completes, both using the same loose-threshold, last-iteration-merge schedule (share_start=10,share_iter/share_int=100,max_iter=10,comp_thresh=0.9) on real sample EEG.docs/changelog.mdgets one Unreleased bullet.Test plan
uv run pytest pamica/tests/test_numpy_share_comps.py pamica/tests/torch_tests/test_ng_sharing.py pamica/tests/mlx_tests/test_mlx_sharing.py -q --no-cov— 69 passeduv run pytest -m "not slow" -n auto— 521 passed, 15 skipped, 1 xfaileduv run ruff check ./uv run ruff format --check ./uv run ty check— all cleanCloses #269