feat(sync): GPU (torch/Metal/CUDA) and numba backends for all 9 metrics#264
Merged
Ramdam17 merged 1 commit intoppsp-team:masterfrom Apr 17, 2026
Merged
Conversation
Add hardware-accelerated backends to all connectivity metrics: - numba JIT (prange): PLV, CCorr, Coh, ImCoh, PLI, wPLI, EnvCorr, PowCorr - PyTorch MPS/CUDA/CPU (einsum): all 9 metrics - Metal compute shaders: PLI, wPLI, ACCorr (Apple Silicon) - CUDA raw kernels (CuPy): all 9 metrics (NVIDIA GPUs) Benchmark-driven AUTO_PRIORITY compiled from Mac M4 Max (131 runs) and Narval A100 (111 runs). The 'auto' optimization selects the best GPU backend per metric and platform: - MPS: torch for einsum metrics, Metal for sign-based + ACCorr - CUDA: cuda_kernel first (OOM-safe at 512ch), torch as fallback Add `priority` parameter on get_metric() and compute_sync() for custom backend ordering. New optional deps: pyobjc-framework-Metal, cupy-cuda12x. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
Add hardware-accelerated backends to all 9 connectivity metrics in
hypyp.sync:prange): PLV, CCorr, Coh, ImCoh, PLI, wPLI, EnvCorr, PowCorrBackend Support Matrix
Benchmark Highlights
Benchmarked on Mac M4 Max (131 runs) and Narval A100 (111 runs). Key speedups at medium profile (64ch, 20ep, 5 freq bands):
Full benchmark data: Ramdam17/hypyp-sync-benchmarks
optimization='auto'— Benchmark-Driven DispatchThe new
AUTO_PRIORITYtable selects the best GPU backend per metric and platform:cuda_kernelfirst (pairwise, OOM-safe at 512+ channels), torch fallbackCUDA kernels are kept for all metrics as a safety net —
torch.cudaOOMs at ≥512 channels due to large intermediate tensors, while custom kernels compute pairwise without materializing the full(E,F,C,C,T)tensor.New
priorityParameterCustom backend ordering per-call:
New Optional Dependencies
Breaking Changes
None beyond what was already introduced in the
hypyp.syncmodule refactor (ACCorr shape change).Test Plan
rtol=1e-9for CPU/CUDA,rtol=1e-5for MPS/Metal,rtol=1e-2for sign-based on MPS🤖 Generated with Claude Code