Skip to content

gpu: introduce mintpy.gpu subpackage and migrate ifgram_inversion_gpu#18

Merged
s-sasaki-earthsea-wizard merged 1 commit into
mainfrom
chore/gpu-subpackage-refactor
May 12, 2026
Merged

gpu: introduce mintpy.gpu subpackage and migrate ifgram_inversion_gpu#18
s-sasaki-earthsea-wizard merged 1 commit into
mainfrom
chore/gpu-subpackage-refactor

Conversation

@s-sasaki-earthsea-wizard

@s-sasaki-earthsea-wizard s-sasaki-earthsea-wizard commented May 12, 2026

Copy link
Copy Markdown
Owner

Summary

Pure refactor: relocate src/mintpy/ifgram_inversion_gpu.py into a new src/mintpy/gpu/ subpackage. No behaviour change.

  • src/mintpy/ifgram_inversion_gpu.pysrc/mintpy/gpu/ifgram_inversion.py
  • tests/test_ifgram_inversion_gpu.pytests/test_gpu_ifgram_inversion.py
  • New empty src/mintpy/gpu/__init__.py
  • Import-path updates in 3 sites (dispatch caller in ifgram_inversion.py:819, docstring self-reference, test import) + CUDA-skip reason message

Why

src/mintpy/ currently holds 66 flat modules. As GPU acceleration extends to further steps (next target: correct_topography, tracked in #17), keeping new *_gpu.py modules flat would noise up the namespace. MintPy already uses subpackage conventions (cli/, objects/, defaults/, legacy/, utils/), so adding gpu/ is consistent. docs/gpu.md aligns with the directory name.

Out of scope

Extracting reusable helpers (_get_torch_device, _auto_chunk_size, etc.) into src/mintpy/gpu/_common.py. Deferred until the next GPU module surfaces concrete duplication (avoid premature DRY).

Validation

  • pytest tests/test_gpu_ifgram_inversion.py: 6 passed on RTX 5080 / torch 2.11+cu128
  • CUDA_VISIBLE_DEVICES="" pytest tests/test_gpu_ifgram_inversion.py: 6 skipped with updated reason CUDA-capable GPU required for mintpy.gpu.ifgram_inversion tests
  • Old import path mintpy.ifgram_inversion_gpu no longer resolves (ModuleNotFoundError)
  • pre-commit hooks pass (13 hooks ran via commit gate, 3 skipped for no matching files)
  • pyproject.toml unchanged: [tool.setuptools.packages.find] auto-discovery picks up src/mintpy/gpu/

End-to-end smallbaselineApp.py on FernandinaSenDT128 was intentionally out of scope per session agreement (unit-test parity is sufficient for a pure file-move + import rewrite).

Upstream PR insarlab#1490 interaction

This branch does not touch gpu_torch_solver (the upstream PR branch). PR insarlab#1490 stays with the current flat layout. When/if insarlab#1490 merges, we will decide separately whether to surface the subpackage refactor upstream as (a) a standalone refactor PR, or (b) bundled with the next GPU step PR.

Closes #16

Test plan

  • pytest tests/test_gpu_ifgram_inversion.py passes on CUDA box
  • pytest tests/test_gpu_ifgram_inversion.py skips cleanly with no CUDA
  • Old import path no longer resolves
  • pre-commit hooks pass on commit
  • Reviewer (user) merges; PR perf: GPU acceleration of correct_topography (pixelwise path) #17 (correct_topography GPU) branches from refactored main

🤖 Generated with Claude Code

Move src/mintpy/ifgram_inversion_gpu.py to src/mintpy/gpu/ifgram_inversion.py
and rename tests/test_ifgram_inversion_gpu.py to tests/test_gpu_ifgram_inversion.py.
Update the three import sites (dispatch caller, docstring self-reference, test
import) and the CUDA-skip reason message. CPU and GPU paths stay byte-for-byte
identical; this is a pure relocation.

Rationale: src/mintpy/ holds 66 flat modules. As GPU acceleration extends to
further steps (next: correct_topography), keeping new *_gpu.py modules flat
would noise up the namespace. MintPy already uses cli/, objects/, defaults/,
legacy/, utils/ subpackage conventions, so adding gpu/ is consistent.

Helper extraction into src/mintpy/gpu/_common.py is intentionally deferred
until the next GPU module surfaces concrete duplication (avoid premature DRY).

Closes #16

Assisted-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore: introduce mintpy.gpu subpackage and migrate ifgram_inversion_gpu

1 participant