Repository navigation
Conversation
Add reusable Torch and native CUDA backends with bounded optical preparation, compact inverse filters, and reusable cuFFT workspaces. Include numerical and lifecycle regression coverage, usage documentation, and optional native build dependencies.
srivarra
force-pushed
the
perf/low-memory-phase-recon
branch
from
September 21, 2026 23:32
7434afb to
816c6e2
Compare
srivarra
marked this pull request as draft
September 21, 2026 23:33
Implement reusable Wiener–Butterworth RL and matched-adjoint RL-GC with optimized Torch and native CUDA backends. Cover original-solver parity, package the CUDA sources, and document synthetic and real-tile measurements.
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.
NOT READY FOR REVIEW, JUST EXPERIMENTING HERE.
Summary
This adds an opt-in reusable 3D phase reconstruction operator for large GPU-resident volumes. Create
waveorder.reconstruction.PhaseReconstructiononce, then calloperator(volume, out=buffer)for repeated reconstructions. Existing model, xarray, and CLI interfaces remain unchanged.The original path allocates large transfer-function arrays and rebuilds the inverse filter for each solve. The new path builds a compact inverse filter in 32-plane Z slabs and 4096-frequency batches, reducing intermediate allocations while keeping one global Fourier-domain reconstruction. Fixed Python-scalar settings reuse the filter across calls. The Torch path supports autograd and rebuilds preparation for tensor-valued parameters. The optional native CUDA path is Linux-only inference. It shares Torch optical preparation, then uses fused kernels with reusable cuFFT plans and workspace.
Changes
waveorder/reconstruction/_phase.pydefines the public API, parameter lifetime,out=handling, and Torch or native dispatch.waveorder/reconstruction/_torch.pyandwaveorder/optics.pyimplement bounded preparation, compact inverse filtering, and real FFT reconstruction.waveorder/reconstruction/_cuda.py,waveorder/csrc/reconstruction.cpp, andwaveorder/csrc/reconstruction.cuprovide the optional loader, cuFFT plans, fused kernels, and reusable workspace.tests/test_reconstruction.pycovers the operator and numerical behavior.docs/guide/reconstruction-guide.mddocuments usage.pyproject.tomlanduv.lockadd the optional native build dependency.Benchmarks
Compared with the original implementation, these are arithmetic means over per-size comparisons for the two matching ZYX volumes of shape$2372 \times 46 \times 256$ and $2372 \times 93 \times 512$ , on an NVIDIA H100 80GB. Inputs were GPU-resident, with disk I/O and transfers excluded.
Both optimized paths passed all-voxel original-reference checks on the two matching sizes. Larger optimized cases remain reference-unverified because the original method ran out of vram. The gains include preparation, caching, and execution changes.
Performance comparison
Full scaling results
This is very much WIP, and I haven't quite figured out how I want these 2 paths glued into WaveOrder. and how we can reuse components to create accelerated versions of all the major reconstruction workflows.