Repository navigation
Add full-fit NumPy<->NG parity test (#37) - #38
Merged
neuromechanist merged 2 commits intoJul 4, 2026
Merged
neuromechanist merged 2 commits into
neuromechanist merged 2 commits into
Conversation
Independently fits AMICA_NumPy and AMICATorchNG on the real sample data (single model, matched config) and asserts they converge to the same solution: Hungarian-matched total-spatial-filter correlation ~1.0 (32/32 bijective) and the same per-sample-per-channel LL. Locks the NumPy<->NG relationship end-to-end, on top of the existing per-block sufficient-stat tests (1e-8). Marked slow (two full 150-iter fits, ~2.5 min). Note: NumPy reports the un-normalized total LL; NG reports it normalized by (n_samples * n_channels), so the NumPy value is normalized before the comparison. Thresholds set from a measured run (min corr 1.000000, LL diff ~1e-5), not guessed.
- Pass do_opt_block=False to AMICA_NumPy so the shared block_size=512 actually takes effect. NumPy defaults do_opt_block=True, which retunes block_size from data timing at fit() (to 128 here), overriding the constructor value; NG has no auto-tune, so the two backends were not block-matched and NumPy's block size was machine-dependent. - Remove the tautological bijective assert (linear_sum_assignment on a square matrix always returns a full permutation); the min-correlation gate is the real check. Still passes (min matched corr ~1.0, LL within 1e-2).
Member
Author
Review (code-reviewer, Sonnet) + resolutionsRan an independent reviewer + two live runs. Findings addressed in the follow-up commit:
Reviewer confirmed the compared quantities are apples-to-apples ( |
neuromechanist
deleted the
37-lock-full-fit-numerical-parity-between-amica_numpy-and-amicatorchng
branch
July 4, 2026 18:52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Locks the numerical relationship between the two kept implementations (
AMICA_NumPyandAMICATorchNG). We keep both — NumPy is NG's fast, readable oracle (the per-block parity tests copy params between them) and the CLI backend — so this adds the missing full-fit head-to-head check.What it does
test_full_fit_parity_numpy_vs_ng(slow) fits both backends independently on the real sample EEG data with a matched single-model config, then asserts they converge to the same solution:unmixing @ sphere) correlation, bijective 32/32,min > 0.99.|diff| < 1e-2).Measured (thresholds set from data, not guessed)
n_samples * n_channelsthat is −3.40389, matching NG's −3.403887 to ~1e-5.This complements the existing per-block sufficient-stat parity tests (which pin the update math to 1e-8) with an end-to-end convergence check. A full fit is intentionally not asserted bit-identical (float reduction order / BLAS vs ATen differ across NumPy and PyTorch); the bar is same converged solution.
Related
self.llis the un-normalized total while NGll_historyis normalized — a reporting inconsistency worth a small follow-up if we want them to print the same number.Testing
test_full_fit_parity_numpy_vs_ngpasses (150s, two full 150-iter fits). ruff clean.