Skip to content

numpy Newton crashes when sharing collapses a whole model #267

Closed

Description

@neuromechanist

Found while writing Phase 1 (#258) tests in PR #266. When a share_comps pass merges ALL of one model's components into another model's (total model collapse), the NumPy Newton path crashes with a shape mismatch: ValueError: operands could not be broadcast together with shapes (16,2) (2,1) (rank-reduced 16-channel, 2-model fit, do_newton=True, max_iter=25). Pre-existing, unrelated to the #258 metric change; #266's rank-reduced sharing test runs with do_newton=False to stay in scope.

Repro sketch: AMICA_NumPy(num_models=2, pcakeep=16, share_comps=True, low comp_thresh, do_newton=True) on the bundled sample EEG; crash fires on the first Newton update after the merge that empties one model.

Worth checking whether AMICATorchNG handles the same total-collapse case (its comp_used masking may protect it) and whether Fortran's comp_used path defines the intended behavior. Part of #231's parity-quality track.

Related: #258, #266, #257, #60.

Activity

  1. added
    bug
    on Aug 23, 2026
  2. neuromechanist commented on Aug 23, 2026

    @neuromechanist
    MemberAuthor

    Fixed in PR #271 (squash-merged into the epic branch for #260): the dgm broadcast in the numpy Newton finalize used [:, None] instead of [None, :], crashing ANY multi-model Newton fit (not only the share_comps collapse reported here) whenever data_dim != num_models. Regression-tested for 1/2/3 models in pamica/tests/test_numpy_newton_multimodel.py. Reaches dev with the epic #260 final merge — happy to ping when it lands if you want to re-run your MEG configuration.

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