Skip to content

Epic polish: audit fixes - #316

Merged
neuromechanist merged 9 commits into
feature/issue-278-epic-mlx-parityfrom
feature/issue-278-epic-polish
Sep 1, 2026
Merged

neuromechanist merged 9 commits into
feature/issue-278-epic-mlx-parityfrom
feature/issue-278-epic-polish

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

Part of epic #278

Summary

Polish round for the epic #278 feature-parity audit findings that belong in the epic before it merges to dev.

Ported (not just documented):

  • AMICAMLXNG.variance_order() (issue Drop-in EEGLAB AMICA replacement: equivalent output, no extra interpretation #92) -- the one accessor gap the audit found in an otherwise-complete Phase 3. Mirrors AMICATorchNG.variance_order with MLX's model-major W layout ((n_models, n, n)) and the unfitted RuntimeError. Cross-backend parity test against a float64 AMICATorchNG twin holding identical fitted parameters: component order matches exactly on a 30-iteration multi-model fit chosen for non-degenerate variance gaps (measured minimum gap ~0.47%, well above the ~1e-4-1e-3 float32-vs-float64 noise floor measured for the other accessors); the test documents the tie risk explicitly rather than assuming it away. Module docstring's "every AMICATorchNG-supported feature" claim is now true.

Doc corrections (misattributions / stale claims found by the audit):

  • docs/guides/amica-differences.md row 5: the degenerate-fit refusal is the AMICA wrapper's contract, not the raw AMICATorchNG backend's (raw-backend gap tracked as Guard raw-backend accessors on degenerate fits and bad transform input #306).
  • AGENTS.md Current Status: validate_implementations.py runs torch-vs-Fortran only, not "NG + NumPy" -- NumPy parity lives in pytest, MLX validation in mlx_tests/ + cross-backend suites (harness extension tracked as validate_implementations.py exercises only torch vs Fortran #315).
  • pamica/fortran_params.py: the writestep/do_history/histstep unsupported-key comments said "no pamica equivalent" -- false for the legacy NumPy backend, which implements all three. Kept unsupported here (this module targets the torch wrapper); comment now says NumPy-only, torch/MLX gap tracked as Warm-start, periodic checkpointing, and staged fits on the array backends #312.
  • docs/guides/amica-differences.md: new "Unmapped Fortran keywords" section -- points to FORTRAN_UNSUPPORTED_KEYS as the enumeration, names filter_length/dft_length/decwindow as dead in the reference itself (alongside the already-documented do_choose_pdfs/Spinv2), and records the do_rho-vs-pdftype divergence explicitly (Fortran can freeze the GG shape while keeping pdftype=0; every pamica backend derives the freeze from pdftype directly, so that combination is unreachable). Links Warm-start, periodic checkpointing, and staged fits on the array backends #312/Per-component convergence diagnostics: write_nd trajectory and run log #314 for the live lifecycle/diagnostics keyword clusters.
  • .context/feature_parity.md / .context/progress_summary.md: fixed stale rows -- runtime vs Fortran IS measured and the criterion met/exceeded; issue Test coverage gaps: AMICA.save/load and plot_components #15 (save/load + plot_components coverage) is closed and tested. Added a header note to feature_parity.md pointing to amica-differences.md's table as the live source of truth.
  • numpy_impl/core.py: aligned the inert pdftype default to 0 (matches torch/MLX; the value is never read, so this is surface consistency only, not a behavior change).
  • docs/changelog.md: Unreleased entry summarizing this round.

New tracking issues referenced

Test plan

  • pamica/tests/mlx_tests/ -- 254 passed
  • pamica/tests/mlx_tests/ + pamica/tests/test_mlx_transform_cross_backend.py -- 260 passed (includes the new variance_order cross-backend + MLX-only tests)
  • ruff check . -- all checks passed
  • ruff format --check . -- all files formatted
  • ty check -- all checks passed

Row 5 of the differences table credited the raw PyTorch backend with
refusing transform/get_*/save on a degenerate fit; that guard is the
AMICA wrapper's _check_usable contract. The raw AMICATorchNG backend
has no such guard of its own (tracked as issue #306).
Add a section resolving the page's exhaustiveness contract: points to
fortran_params.py's FORTRAN_UNSUPPORTED_KEYS as the enumeration, names
filter_length/dft_length/decwindow as dead in the reference itself
(alongside the already-documented do_choose_pdfs/Spinv2 dead code),
and records the do_rho-vs-pdftype divergence: Fortran can freeze the
GG shape while keeping pdftype=0, but every pamica backend derives
the freeze from pdftype directly, making that combination unreachable.
Links issues #312/#314 for the live lifecycle/diagnostics gaps.
Adds the EEGLAB back-projected-variance component order (issue #92)
to the MLX backend, mirroring AMICATorchNG.variance_order with MLX's
model-major W layout ((n_models, n, n)) and the unfitted RuntimeError.
Closes the one accessor gap the epic's feature-parity audit found in
an otherwise-complete Phase 3; updates the module docstring's
ported-features claim to match.

Adds cross-backend parity coverage against a float64 AMICATorchNG
twin holding identical fitted parameters (order matches exactly on a
30-iteration multi-model fit with non-degenerate variance gaps, with
a gap-size assertion documenting the tie risk), plus MLX-only
unfitted/invalid-model_idx/permutation tests.
AGENTS.md claimed the harness runs "both implementations (NG +
NumPy)"; validate_implementations.py only exercises torch vs Fortran.
NumPy parity lives in pytest (test_sample_data_numpy_vs_fortran); MLX
validation lives in mlx_tests/ plus the cross-backend suites.
Extending the harness itself is tracked as issue #315.
The FORTRAN_UNSUPPORTED_KEYS entries for writestep/do_history/
histstep said these have no pamica equivalent; false for the legacy
NumPy backend, which implements all three (numpy_impl/core.py's fit
loop and _write_history). Keeps the keys unsupported here (this
module targets the torch wrapper, which has no matching mechanism)
but corrects the reason: NumPy-only, torch/MLX gap tracked as #312.
feature_parity.md and progress_summary.md still claimed the runtime-
vs-Fortran benchmark was unmeasured and issue #15 (save/load and
plot_components test coverage) was open; both landed since. Also
corrects progress_summary.md's validation-harness claim (same fix as
AGENTS.md: torch-vs-Fortran only, not NG + NumPy). Adds a header note
to feature_parity.md pointing to amica-differences.md's table as the
live, maintained backend-parity source of truth.
self.pdftype is never read after assignment (this backend always
runs the GG update; _compute_log_pdf takes no pdftype param), so the
old default of 1 was a harmless but confusing mismatch against
torch/MLX's constructor default of 0. Aligned for surface consistency
only; no behavior change.
Summarizes the audit-driven fixes ahead of merge to dev: MLX
variance_order, the doc corrections, and the new tracking issues
(#312, #314, #315) plus the #306 extension.
@neuromechanist
neuromechanist merged commit 39d732b into feature/issue-278-epic-mlx-parity Sep 1, 2026
8 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-278-epic-polish branch September 1, 2026 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant