Skip to content

Document final_ll_ semantics when a merge lands on the last iteration #269

Closed

Description

@neuromechanist

PR #268's review found that when a share_comps merge fires on the final fit iteration, final_ll_ (== ll_history[-1]) reports the log-likelihood computed under the PRE-merge comp_list while A/W/comp_list are already post-merge: the merge's LL effect only appears in the NEXT iteration's E-step, which never runs. Reproduced on the MLX backend (share_start=10, share_iter=100, max_iter=10: comp_used drops 64 to 34, final_ll_ is the pre-merge value). The torch fit loop has the same ordering, and it matches Fortran (identify_shared_comps runs after the iteration's LL accumulation, amica15.f90:1856 vs the LL accumulation earlier in the loop), so this is Fortran-faithful behavior, not a defect.

Scope: decide and document, across backends, that final_ll_ under share_comps trails the last merge by design (docstrings for final_ll_/fit, plus a note in docs/guides/amica-differences.md), or alternatively recompute the LL after a final-iteration merge (a deliberate divergence that would need recording per .rules/backend_parity.md). PR #268 adds an MLX test pinning that a merge on the last iteration still completes with a reduced comp_used and finite final_ll_; the cross-backend documentation/decision is this issue.

Found by the PR #268 review (pr-test-analyzer). Related: #263, epic #260.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions