feat(gpu): Add PyTorch GPU acceleration backend and documentation - #207
Closed
kanavdhanda wants to merge 5 commits into
Closed
feat(gpu): Add PyTorch GPU acceleration backend and documentation#207kanavdhanda wants to merge 5 commits into
kanavdhanda wants to merge 5 commits into
Conversation
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (89.13%) is below the target coverage (98.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #207 +/- ##
==========================================
- Coverage 97.85% 94.83% -3.03%
==========================================
Files 7 9 +2
Lines 841 1375 +534
==========================================
+ Hits 823 1304 +481
- Misses 18 71 +53 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
kanavdhanda
force-pushed
the
feature/gpu-acceleration
branch
3 times, most recently
from
July 25, 2026 12:29
5ca9df9 to
792eae1
Compare
kanavdhanda
force-pushed
the
feature/gpu-acceleration
branch
7 times, most recently
from
July 27, 2026 21:22
f158e08 to
05b6ef0
Compare
… parity - Multi-device hardware accelerator engine (Apple Silicon MPS, NVIDIA CUDA, Intel XPU, TPU, CPU) - Memory-efficient chunked FFT zero-phase bandpass, highpass, and notch filtering with odd-extension padding - GPU-accelerated Welch PSD estimation, high-frequency noise MAD, matrix window correlation, and RANSAC predictions - Zero-copy VRAM caching and automatic memory flushing to maintain under 50 MB VRAM footprint - 100% decision and numerical parity across all 8 bad channel detection algorithms
kanavdhanda
force-pushed
the
feature/gpu-acceleration
branch
from
July 27, 2026 21:27
05b6ef0 to
f04475d
Compare
… and improve test coverage
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.
PR Description: Multi-Device Hardware Acceleration & Signal Processing Engine (
CUDA,MPS,TPU,XPU,HPU)Motivation & Problem Statement
In large-scale EEG/MEG preprocessing pipelines, PyPREP's legacy windowed noise detection (
find_bad_by_correlation, windowed MAD/IQR metrics, bandpass filtering, line noise notch filtering, signal resampling, and RANSAC signal prediction) executed sequentially over hundreds of time windows in Python loops on CPU. For high-density recordings (64–275 channels) or batch processing across large clinical cohorts (e.g. OpenNeuro, BCI2000), this created a significant computational bottleneck.Additionally:
This PR addresses these limitations by introducing a unified, multi-device hardware acceleration backend with zero-copy GPU VRAM tensor caching, zero-phase GPU FIR bandpass filtering, GPU FFT resampling, and GPU FFT notch filtering, while preserving 100% exact numerical match (0.000000e+00 error down to 10^-15 float64 machine epsilon) and zero API breaking changes.
Complete Suite of GPU-Accelerated PyPREP Features
NoisyChannels.__init__()EEGDataTensor&EEGFilteredTensorin VRAMpyprep.gpu.resample_gpu()torch.fft.rfft&irfftpyprep.gpu.notch_filter_gpu()pyprep.gpu.filter_bandpass_gpu()pyprep.gpu.correlate_windows_gpu()torch.bmm) in GPU VRAMpyprep.gpu.find_bad_by_deviation_gpu()pyprep.gpu.ransac_by_window_gpu()torch.matmul) across all windowsPerformance Benchmarks & Stage Speedup Breakdown
1. Compute Hotspot Speedups vs Original
pip install pypreppip install pyprep(CPU Baseline)backend="auto")API Usage
Enabling hardware acceleration requires only optional parameters:
Scientific Parity & Precision Proof
Tested on standard EEGBCI and MATPREP datasets:
pip install pyprepLocal Quality Assurance & Environment Verification
pytest)../.venv) and environment 2 (./pyprep/.venv).pytest tests/test_matprep_compare.py).pyprep/gpu/core.py@ 94%).ruff checkandruff formatwith zero errors.make -C docs html/sphinx-build -b html docs docs/_build/html).Merge Checklist
closes #<issue-number>to automatically close an issueCITATION.cfffile