feat: modular sync architecture with accorr numba/torch optimizations#250
Open
feat: modular sync architecture with accorr numba/torch optimizations#250
Conversation
- Create hypyp/sync/ module with individual metric files: - plv.py, ccorr.py, accorr.py, coh.py, imaginary_coh.py - pli.py, wpli.py, envelope_corr.py, pow_corr.py - Add base.py with BaseMetric abstract class and helper functions - Add backend support (numpy default, numba/torch for future optimization) - Add get_metric() function for retrieving metrics by name - Update compute_sync() to delegate to sync module - Add deprecation warnings to old helper functions - All implementations verified identical to original code
- Simplify packages config in pyproject.toml (Poetry auto-includes subpackages) - Re-execute tutorial notebooks to refresh outputs
… API Integrate accorr optimizations (numba JIT, PyTorch GPU) from PR #246 into the modular sync architecture. Unify the API around a single `optimization` parameter (None, 'auto', 'numba', 'torch') with graceful fallback and warnings when backends are unavailable. - BaseMetric: add _resolve_optimization() with fallback cascade - ACCorr: numpy/numba/torch backends with precompute optimization - All metrics: remove dead dispatch code for numpy-only metrics - compute_sync: pass optimization directly to get_metric() - Tests: reference-based validation for all backends, mocked fallbacks - Add optional dependency groups (optim_torch, optim_numba) Co-Authored-By: Martín A. Miguel <m2march@users.noreply.github.com>
Collaborator
Author
|
Hi @m2march, This PR integrates your accorr optimizations (numba/torch) from PR #246 into the new modular sync architecture. Your work is credited via co-authorship on the commit and in the accorr.py docstring. Main changes from your original PR:
Could you review the changes before we merge? |
|
I've got one comment and then some less relevant notes: Comment
Notes
|
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
BaseMetric, in its own file underhypyp/sync/optimizationAPI: Single parameter (None,'auto','numba','torch') flows through the entire chain:compute_sync()→get_metric()→ACCorr()→ auto-detects GPU with graceful fallback and warningsOptimization behavior
None'auto''numba''torch'Usage
Optional dependencies
Test plan
compute_sync()test_stats,test_fnirs, etc.) unaffected🤖 Generated with Claude Code
Co-Authored-By: Martín A. Miguel m2march@users.noreply.github.com