Skip to content

share_comps similarity space differs: torch sensor-space, numpy sphered-space #258

Closed

Description

@neuromechanist

Found during #253 (PR #256). The two backends compute the component-sharing similarity in different spaces, so they can select different merge pairs on the same data.

torch_impl's _identify_shared_comps de-spheres the mixing columns before the |cos| comparison (now pinv(sphere) @ A, the Fortran Spinv mapping, amica15.f90:1898 + :550-560). numpy_impl/utils.py:identify_shared_components (line 103) correlates the columns of A directly in the sphered space -- it never touches the sphere at all (verified line 45: np.dot(A[:, k1], A[:, k2]) on raw A).

Fortran compares de-sphered sensor-space maps, so torch matches the reference and numpy is the divergent one. Because ZCA sphering is not orthogonal, |cos| in the two spaces genuinely differs and merge decisions near comp_thresh can flip.

Work

  • Port the sensor-space (pseudo-inverse de-sphered) comparison to numpy_impl's identify_shared_components, matching torch/Fortran
  • Cross-backend test: same data/config produce the same merge pairs (.rules/backend_parity.md)

Should land after the in-flight #240/#242 numpy sharing rework to avoid conflicts. The divergence is recorded in docs/guides/amica-differences.md by PR #256 until fixed.

Related: #253, #240, #242, #60. Part of #231.

Activity

  1. neuromechanist commented on Aug 23, 2026

    @neuromechanist
    MemberAuthor

    Completed in PR #266, squash-merged into the epic branch feature/issue-260-epic-mlx-parity (commit 7c50e83). Both numpy and torch backends now measure sharing similarity on de-sphered sensor-space maps (pinv(sphere) @ A); reaches dev with the epic #260 final merge.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions