Repository navigation
Description
Background
Follow-up to #144. While re-verifying Table 1's single-model correlation
claim on a properly data-adequate real recording (OpenNeuro ds002718
sub-002, 70 channels, full 747,750 frames, k=152.6 -- well above the
project's own k>=60 threshold, #90), a consistent pattern emerged across
every dataset tested (the original bundled 32ch/30504-frame data at k=29.8,
a 32ch/147k-frame ds002718 subset at k=144, and the full 70ch recording at
k=152.6): short iteration budgets (200-300) reliably give 0.98-0.999
Fortran-vs-AMICATorchNG correlation; the full 2000-iteration budget (do_newton=True
in both) consistently gives lower, more variable correlation (0.87-0.97
mean), typically driven by one or two components dropping to 0.5-0.6 while
the rest stay well-matched.
This is not inherent data ambiguity -- it's an NG-specific divergence
Two independent Fortran fits of the same data (different random inits --
confirmed the randomness is real: amica15_header.f90:97 hardcodes
seed(2) = (123456, 654321), never read from input.param, but
amica15.f90:219-220 mixes in system_clock(c1), so the effective RNG
state differs on every invocation) agree with each other at
mean=0.9997, min=0.9983 (all 70/70 components >0.998) at 2000 iterations,
do_newton=1. If the low components were inherent non-identifiability
(as in the genuinely non-identifiable multi-model case), independent
Fortran runs should show the same spread on their weak components. They
don't -- Fortran is extremely self-consistent.
This within-Fortran number (0.9997) is higher than the project's own
prior k=152 cross-backend sweep (.context/issue-90/ksweep_findings.md:
native-fortran-f64 vs torch-cuda-f64 at 0.995, mean cross-backend 0.9817)
-- but that sweep explicitly ran with do_newton=0 on every backend
(benchmark_decompose.py's _write_fortran_param/_fit_torch, forced off
for benchmark fairness). Newton's quadratic convergence near an optimum
likely sharpens/resolves directions that plain natural gradient leaves
loose, which is consistent with both observations: without Newton, even
same-algorithm cross-device agreement plateaus at ~0.98; with Newton,
independent Fortran random inits converge to essentially the same sharp
optimum (0.9997).
Given Newton demonstrably can resolve the true optimum this sharply
(proven by Fortran's self-consistency), AMICATorchNG's failure to land in
that same optimum for a handful of components at the full 2000-iteration
budget (down to 0.55 correlation) is not explained by problem ambiguity --
it points to a genuine difference between AMICATorchNG's Newton-step
implementation and Fortran's, that only manifests/compounds after extended
optimization (200-300 iterations is fine; by 2000 it isn't).
What was ruled out
- Not data inadequacy: reproduces on 3 different datasets/k-factors
(29.8, 144, 152.6), including one far above the documented k>=60
saturation point. - Not the
do_approx_sphereregression (Fix do_approx_sphere regression and data-inadequate headline parity dataset #144, already fixed): tested
after that fix. - Not Fortran's early-stopping asymmetry (
use_min_dll/use_grad_norm):
forcing Fortran to also run the full un-early-stopped 2000-iteration
budget (matchingbenchmark_dimsweep.py's existing convention) gave an
essentially identical result (0.9694 vs 0.9706 mean, 0.55 vs 0.56 min). - Not a measurement/caching bug: the two within-Fortran W matrices are
confirmed genuinely different (max abs diff ~0.021), not an accidental
file-path collision. - Not Fortran's own random-init instability: within-Fortran agreement
at the same iteration count and Newton setting is 0.9997/0.998
(min), a completely different regime from the 0.97/0.55 Fortran-vs-NG
numbers.
Suggested investigation
Compare AMICATorchNG's Newton-step implementation
(pyAMICA/torch_impl/core.py) against the literal Fortran Newton
expressions in amica15.f90 for numerical divergence that would only
compound over many iterations (e.g. a subtly different Hessian
approximation, damping/regularization difference, or a per-component
convergence check Fortran has that NG lacks). Reproduction data and W
matrices from this investigation are on the hallu workstation under
/tmp/ds002718_full_parity_* and /tmp/fortran_only_* (not committed --
large binary artifacts); the raw ds002718 data and native Fortran build
used are described in benchmarks/README_dimsweep.md.
Relation to Table 1 / the JOSS paper
Given this is a real, non-trivial, not-yet-root-caused divergence, Table 1's
single-model correlation claim needs to be reported honestly reflecting
what was actually measured (short-budget parity is excellent; long-budget
parity is real but has a disclosed, open gap on a subset of components) --
not a single point estimate implying uniform 0.997 agreement at 2000
iterations. See #144 for the tracking issue on updating the paper/docs
text itself.
Activity
Add do_newton toggle to the split parity test scripts
Report single-model conformity with Newton disabled
neuromechanist commentedon Jul 15, 2026
Ran the controlled
do_newton=0vsdo_newton=1comparison at a full, forced 2000-iteration budget, 5 seeds each, on two datasets. Summary:do_newton=0 (Newton disabled), 5 seeds, 2000 iters each:
do_newton=1 (default), earlier 5-seed sweep at the same forced 2000-iteration budget: mean corr ~0.97, min ~0.55 -- a much larger and more variable gap, on the same data.
With Newton off,
pyAMICA-vs-Fortran agreement lands right next to Fortran's own run-to-run self-consistency on both datasets. This rules out (again) data inadequacy and early-stopping asymmetry as the cause of thedo_newton=1gap (both were already tested and ruled out earlier in this issue), and confirms the divergence is specific toAMICATorchNG's Newton step under the default setting.One additional lead for the root-cause work:
test_end_to_end_correlation_vs_fortranintest_ng_backend.pyruns withdo_newton=Truebut onlymax_iter=100, and has passed at ~0.997 correlation as its documented baseline.newt_start=50/newt_ramp=10means Newton barely has time to engage in a 100-iteration run. That the short-budget Newton-on test looks fine while the full 2000-iteration Newton-on run degrades to ~0.55 min correlation suggests the divergence accumulates over many Newton steps rather than being present from the first few -- i.e. a slow drift/instability in the NG Newton update relative to Fortran's, not a one-shot formula bug. Might be a useful starting point when this issue gets picked up.Interim resolution:
paper.md/docs/guides/validation.md/README.mdnow report thedo_newton=0single-model conformity number (0.998/0.006), which is honestly reproducible end to end. Thedo_newton=1(default-setting) discrepancy stays open here as the thing to root-cause and fix.Address JOSS reviewer feedback on paper and Figure 1 (#138)
neuromechanist commentedon Jul 19, 2026
Resolved: init-basin sensitivity, not a dynamics divergence
The definitive same-init test settles this. Running BOTH
AMICATorchNG(CUDA f64) and native Fortranamica15from an IDENTICAL deterministic start (A=identity, mu=[-1,0,1], sbeta=1, rho=1.5; fed to Fortran viaload_A/load_mu/load_beta/load_rho), 2000 iters,do_newtonon, on the full 70ch/k=152 data:From an identical init, torch and Fortran agree (0.9974, 0/70 collapsed). The residual ~0.003 vs within-Fortran is float summation-order / BLAS noise over 2000 iters on the flat weak-component directions, not a basin difference. Fortran-from-A=I matching the random refs at 0.9999 proves A=identity is a normal init and Fortran is init-robust. The ONLY collapse is torch's specific random seed 42; that init lands in a different (equal/higher-LL) basin, but the same deterministic init does not.
So there is no per-step dynamics divergence to fix: identical start -> matching answer. The earlier near-singular-Hessian hypothesis was refuted (Newton is well-conditioned the whole run; the Newton math is algebraically identical to amica15.f90;
minhessis declared-but-unused so there is no damping lever). Torch is simply more sensitive to certain random inits than Fortran, which converges to one basin from any init.Resolution: document, do not "fix" the optimizer. The
do_newton=0single-model conformity (0.998, reproducible end to end) is the parity claim, already in the paper/docs via #144. Thedo_newton=1weak-component spread is disclosed init-basin sensitivity on under-determined components, the same posture as multi-model non-identifiability (#27) and the best-iterate safeguard (#51). Optional init-robustness enhancement tracked in #198.Full analysis:
.context/issue-145/{diagnostic,full_data_reproduction,same_init_result}.md.Document #145 investigation (init-basin sensitivity) (#199)