Skip to content

NG backend converges to a different fixed point than Fortran (~0.68 corr, blocks >0.95 gate) #21

Closed

Description

@neuromechanist

Summary

The AMICATorchNG backend plateaus at ~0.68 Hungarian-matched component correlation vs the
Fortran binary (LL ~ -3.47 vs Fortran -3.41) on the sample EEG data, and this is independent of
Newton
. Phase 4 (#13) ported Newton, adaptive-PDF, and outlier rejection into the NG backend and
verified them to float64 precision against the (Fortran-corrected) NumPy reference, but they only
accelerate convergence to the NG backend's own fixed point. This blocks the epic (#9) definition of
done (>0.95 correlation), so test_end_to_end_correlation_vs_fortran remains xfail.

Evidence (all 100 iters vs amica15mac, seed 42; correlation ~0.65-0.69 in every case)

  • data-space natural gradient vs Fortran source-space g^T b (b=Wx): both ~0.68.
  • gradient-style mu/beta updates vs Fortran's exact EM fixed-point updates
    (mu += dmu_numer/dmu_denom, no lrate, rho-dependent denominators; sbeta *= sqrt(...)): both ~0.68.
  • Newton on vs off: both ~0.68 (Newton is positive-definite and active every iteration when on).
  • Whitening: NG PCA-whitening vs a symmetric-ZCA rotation made it worse (0.44), so it is a real
    fixed-point plateau, not a basis mismatch.

Because no update-rule change moves the plateau, the remaining suspects are outside the update
equations:

  1. Initialization mismatch. NG seeds A/mu/beta via numpy RandomState (matched to the
    NumPy port), but the Fortran binary uses its own RNG/init, so the two start from different
    points of a non-convex objective.
  2. Iteration count. Fortran's default max_iter is 2000; the gate test uses 100.
  3. A subtler E-step / responsibility difference.

Suggested next steps

  • Replicate Fortran's exact initialization (seed -> starting A/mu/beta/rho) so both start
    from the same point, then re-measure.
  • Compare NG vs Fortran per-iteration (W, LL, and a couple of components) to localize where the
    trajectories diverge.
  • Consider adopting Fortran's exact EM mu/beta/alpha updates and source-space natural
    gradient in the NG backend regardless (they are more faithful and more numerically stable at
    lrate=0.05, even though they do not close the gap alone).

Part of epic #9.

Activity

  1. added
    bug
    on Jul 3, 2026
  2. neuromechanist commented on Jul 3, 2026

    @neuromechanist
    MemberAuthor

    Fixed by issue #24: the root cause was the natural-gradient A-update being transposed / multiplied on the wrong side (plus exact-EM mixture updates, digamma rho, symmetric-ZCA sphere, Jacobian LL). AMICATorchNG now reaches Fortran parity (LL ~ -3.40, Hungarian component correlation ~0.997 with Newton positive-definite), clearing the >0.95 gate. Delivered to main via the epic #9 close-out (PR #28).

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