Skip to content

Lock full-fit numerical parity between AMICA_NumPy and AMICATorchNG #37

Closed

Description

@neuromechanist

We are keeping both the NumPy reference (AMICA_NumPy) and the PyTorch AMICATorchNG backend. AMICATorchNG was ported line-by-line from the NumPy _get_block_updates/_update_parameters, and the suite already proves per-block numerical parity to ~1e-8 (test_sufficient_stats_match_numpy_reference, test_newton_stats_match_numpy_reference, test_newton_mstep_matches_numpy_reference, test_multimodel_sufficient_stats_match_numpy_reference).

What is missing is an explicit full-fit head-to-head test: today each backend is validated only against the Fortran binary, not against each other end-to-end.

Scope

  • Add a @pytest.mark.slow real-data test that fits AMICA_NumPy and AMICATorchNG independently with the same single-model config and asserts they converge to the same solution: final LL within tolerance, and Hungarian-matched total-spatial-filter (unmixing @ sphere) correlation near 1.0.
  • Thresholds set empirically from a measured run (not guessed) to avoid flakiness.

Note on "identical"

Per-step update math is identical to ~1e-8 (already tested). A full multi-iteration fit is NOT bit-identical across NumPy and PyTorch (float reduction order / BLAS vs ATen), which is expected; the bar is "same converged solution", not bit-identical trajectories.

Activity

  1. added
    enhancement
    on Jul 4, 2026
  2. added a commit that references this issue on Jul 4, 2026
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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions