Skip to content

Slice 3: GPU Pass 1 — batched forward DTCWT + phase extraction #14

Description

@joeljose

Context

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

Goal

Implement the first GPU pass: batch frames through DTCWTForward, extract phase deltas on GPU, transfer to CPU, and cumsum into cumulative phase arrays.

Acceptance Criteria

  • _gpu_forward_pass(data, nlevels, biort, qshift, device) function returns phase_arrays (list of numpy arrays per level, shape (num_frames, num_coeffs), float32)
  • Batch size auto-tuned from available VRAM: free_vram * 0.7 / (frame_vram_estimate)
  • Phase deltas computed via vectorized conjugate multiply within each batch (not per-frame loop)
  • Cross-batch boundary: last frame's normalized coefficients carried to next batch, verified bitwise-identical to single-batch
  • Phase deltas accumulated via np.cumsum(axis=0) on CPU (float32)
  • OOM caught with actionable error message
  • Progress reporting (% frames processed)
  • Standalone testable: can extract phases and verify shapes/finiteness without Pass 2

Blocked by

#13 (Slice 2) — needs --gpu flag and import infrastructure.

Files likely involved

  • motion_mag.py_gpu_forward_pass() function

Testing approach

  • Unit test: forward pass on 10-frame synthetic data, verify phase array shapes and finiteness
  • Unit test: batched (bs=5) produces identical phases to single batch (bs=10)
  • Unit test: OOM handling with artificially small batch size

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