Skip to content

Slice 4: GPU temporal filter — chunked cuFFT #15

Description

@joeljose

Context

Parent: #11 | PRD: #10 | Design: docs/design/gpu-acceleration.md Section B, Temporal Filtering

Goal

Implement GPU-accelerated temporal filtering using torch.fft with coefficient-dimension chunking to fit in VRAM.

Acceptance Criteria

  • _gpu_temporal_filter(phase_arrays, magnification, width, device) modifies phase arrays in-place
  • Large window (width=80, 344 samples): uses torch.fft.rfft/irfft along time axis
  • Small window (width=2, 9 samples): also uses cuFFT (overhead is negligible)
  • Chunk size auto-tuned: free_vram * 0.7 / (num_frames * 80 bytes FFT overhead)
  • Phase modification: phase = phase0 + (phase - phase0) * magnification
  • Smoothing pass: second filter with width=2
  • Per-level processing (largest levels first), each level chunked independently
  • OOM caught per-chunk with actionable error
  • Works correctly for all 8 DTCWT levels (tiny levels may have fewer coeffs than chunk size — handle gracefully)

Blocked by

#14 (Slice 3) — needs phase arrays from forward pass to filter.

Files likely involved

  • motion_mag.py_gpu_temporal_filter() function

Testing approach

  • Unit test: filter output has same shape as input, finite values
  • Unit test: DC signal (constant phase) passes through unchanged
  • Unit test: chunked filter produces same result as single-chunk (small data that fits in one chunk)
  • Speed test: verify GPU filter is faster than CPU flattop_filter_1d on L0 data

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions