You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Found in review of #217. Diagnostic-only, does not affect fitted parameters.
The divergence
Fortran's gm is a module-level array that is not reassigned until update_params (amica15.f90:1789+), which runs afteraccum_updates_and_likelihood builds dAk (:1731-1743). So Fortran's ndtmpsum is computed with the previous iteration's gm.
In numpy_impl, self.gm is reassigned at core.py:1124/1126, before the nd block at :1271-1288. So ours uses the current iteration's gm.
When it matters
Not for num_models=1, where gm == 1.
Not for the default disjoint comp_list multi-model case either: each column belongs to exactly one model, so the gm[h] numerator cancels exactly against zeta[idx] = gm[h].
It matters only under share_comps with a genuinely shared column across two models, where the weighted average of directions is taken with different weights than Fortran would use.
Scope
self.nd is a diagnostic and a convergence-check input; it is not used to update A, mu, or beta. So this cannot change a fitted decomposition. It can change when use_grad_norm fires, though min_nd is separately unreachable on small data (#218).
There is currently no test covering numpy_impl + share_comps + nd; the sharing tests are torch-only (tests/torch_tests/test_ng_sharing.py).
Work
Decide whether to snapshot gm before the mixture update in numpy_impl so the ordering matches Fortran, or to accept the deviation and document it as a known diagnostic-only difference.
Add a numpy_impl + share_comps test that exercises nd, whichever way the above goes.
Check whether AMICATorchNG has the same ordering question, since it computes ndtmpsum in the same region.
Fixed in #241. Both backends now snapshot gm before the mixture update, matching Fortran's ordering (dAk built at amica15.f90:1753, gm reassigned at :1788).
One correction to this issue's framing, surfaced by review: the change is diagnostic-only in numpy_impl, but not in AMICATorchNG, where the same dAk is the A-update, so the ordering reaches fitted parameters there. Single-model stays bit-identical (gm == 1); multi-model shifts ~1e-6, which is floating-point association rather than semantics, since gm cancels against zeta for a disjoint comp_list.
Both backends have discriminating tests, each verified to fail when its own fix is reverted.
Two deeper share_comps gaps in numpy_impl came out of the same work and are tracked separately: #240 (NaN mu/beta reported as a successful fit) and #242 (a shared column's A-update applied twice instead of once as a weighted average).
Activity
Address PR review on the gradient-norm fix
Address PR review on the gradient-norm fix
Fix numpy_impl weight-gradient norm to Fortran's formula (#217)
neuromechanist commentedon Aug 16, 2026
Fixed in #241. Both backends now snapshot
gmbefore the mixture update, matching Fortran's ordering (dAk built at amica15.f90:1753, gm reassigned at :1788).One correction to this issue's framing, surfaced by review: the change is diagnostic-only in
numpy_impl, but not inAMICATorchNG, where the samedAkis the A-update, so the ordering reaches fitted parameters there. Single-model stays bit-identical (gm == 1); multi-model shifts ~1e-6, which is floating-point association rather than semantics, sincegmcancels againstzetafor a disjointcomp_list.Both backends have discriminating tests, each verified to fail when its own fix is reverted.
Two deeper
share_compsgaps innumpy_implcame out of the same work and are tracked separately: #240 (NaNmu/betareported as a successful fit) and #242 (a shared column's A-update applied twice instead of once as a weighted average).Fix torch comp_used guard and dAk citation
Scope the MLX gm claim in the changelog
Phase 2: port share_comps to the MLX backend (#268)
Complete 0.3.3 changelog for release (#302)