Skip to content

AMICA_NumPy long fit drifts/degrades past ~150 iters (LL decreases, component match drops) #41

Closed

Description

@neuromechanist

Surfaced while resolving #39. With a fixed stable seed (seed=0) the NumPy backend no longer NaNs on the full 2000-iter sample config (the #39 restart mechanism + pinned seed), but the solution degrades over the long run:

iters normalized LL Hungarian W-match vs Fortran (min / mean, n>0.8)
150 -3.4043 0.921 / 0.970, 32/32
2000 -3.4093 some < 0.8 (test fails)

The LL decreases between iter ~150 and 2000 (worse solution with more iterations) and several component correlations drop below the 0.8 gate. At ~150 iters the match is excellent (32/32), so the backend finds the right solution and then drifts away from it.

The natural-gradient A-update is a gradient step (with lrate), not strict EM, so it can overshoot/oscillate. Fortran runs the same 2000-iter config and stays converged (the reference amicaout), so this is a convergence-schedule / stability parity gap (lrate ratchet / numdecs / Newton ramp), distinct from:

Scope

  • Reproduce and localize the drift (does max_decs/min_dll/lrate-reduction fire? does the LL oscillate?).
  • Align the long-run lrate/Newton schedule with Fortran so a converged solution is not degraded by over-iterating.
  • Then un-xfail test_sample_data_cli (the full 2000-iter CLI-vs-Fortran integration test).

Repro: fit AMICA_NumPy with the sample sample_params.json config at seed=0, compare loadmodout-W Hungarian match at 150 vs 2000 iters.

Activity

  1. added
    bug
    on Jul 5, 2026
  2. added a commit that references this issue on Jul 5, 2026
  3. neuromechanist commented on Jul 5, 2026

    @neuromechanist
    MemberAuthor

    Partially resolved by PR #43.

    Fixed: the LL-degradation drift. Two convergence bugs were corrected: numdecs/numincs never accumulated (they were incremented inside _check_convergence but never returned), and pyAMICA stopped at numdecs >= max_decs where Fortran (amica17.f90:1062-1108) instead ratchets the learning-rate ceiling (lrate0/newtrate/rholrate0) down and continues. With the Fortran-faithful ratchet, the seed=0 fit now improves over the long run (LL -3.399 at 2000 iters, vs the pre-fix -3.409 and the ~150-iter -3.404, and better than Fortran's -3.402). The 150-iter mean-corr parity test is unaffected.

    Residual (why test_sample_data_cli stays xfail): the strict all-32-components > 0.8 gate still fails (~27/32). At full convergence pyAMICA reaches a comparable/slightly-better-LL but different-partition solution than the Fortran reference on a few ill-determined components -- a solution-basin difference, not a drift. This is really the single-model tail of #27 (partition ambiguity); the project's other parity test uses the more appropriate mean > 0.9 bar and passes. Suggest tracking the residual under #27 (or relaxing the CLI gate to a mean-based metric) and closing this issue as the drift itself is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions