Skip to content

feat: GPU array processing with Cupy#24

Merged
PinkShnack merged 19 commits into
RI-imaging:masterfrom
PinkShnack:feat/3d_gpu_array_processing
Apr 22, 2026
Merged

feat: GPU array processing with Cupy#24
PinkShnack merged 19 commits into
RI-imaging:masterfrom
PinkShnack:feat/3d_gpu_array_processing

Conversation

@PinkShnack
Copy link
Copy Markdown
Collaborator

@PinkShnack PinkShnack commented Apr 15, 2026

As done in qpretrieve, I would like to enable nrefocus to process 3D arrays, and have the option to process them on the GPU. Therefore, this will reflect qpretrieve's changes quick closely as described in #23.

To-do

  • update changelog
  • add docs describing cupy additions
  • Add cupy backend with xp syntax
  • make sure the expected backend attributes are present
  • import protections for pyfftw and cupy
  • simple ndarray backend swap for user, as done in qpretrieve
  • Add 3D array processing in separate PR
    • Decide if autof.py needs changing

@PinkShnack PinkShnack changed the title feat: 3D GPU array processing feat: GPU array processing with Cupy Apr 16, 2026
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 20, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 67.54967% with 49 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.96%. Comparing base (3422d02) to head (3c7d565).
⚠️ Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
nrefocus/iface/rf_cupy.py 0.00% 25 Missing ⚠️
nrefocus/legacy.py 0.00% 12 Missing ⚠️
nrefocus/_ndarray_backend.py 71.87% 9 Missing ⚠️
nrefocus/iface/__init__.py 77.77% 2 Missing ⚠️
nrefocus/iface/rf_numpy_1d.py 85.71% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #24      +/-   ##
==========================================
- Coverage   84.46%   79.96%   -4.50%     
==========================================
  Files          21       22       +1     
  Lines         502      569      +67     
==========================================
+ Hits          424      455      +31     
- Misses         78      114      +36     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@PinkShnack PinkShnack marked this pull request as ready for review April 20, 2026 14:11
@PinkShnack
Copy link
Copy Markdown
Collaborator Author

@paulmueller I have added Cupy to nrefocus here. The 3D array processing I will do in another PR. Unfortunately the branch name is therefore a little off, but I feel like that's ok. Please review if you have the time. Very similar to the qpretrieve setup

Comment thread .github/workflows/check.yml Outdated
Comment thread examples/refocus_cell_fftw.py Outdated
Comment thread nrefocus/iface/base.py
@PinkShnack
Copy link
Copy Markdown
Collaborator Author

tests fresnel dataset created via:

def test_2d_refocus1_fresnel():
    pixel_size = 1e-6
    rf = nrefocus.RefocusNumpy(field=np.arange(256).reshape(16, 16),
                               wavelength=8.25*pixel_size,
                               pixel_size=pixel_size,
                               medium_index=1.533,
                               distance=0,
                               kernel="fresnel",
                               padding=False)

    refocused = rf.propagate(distance=2.13*pixel_size)
    refocused_flat = np.array(refocused).flatten().view(float)
    np.savetxt(data_path / "test_2d_refocus1_fresnel.txt", refocused_flat)

@PinkShnack PinkShnack merged commit ebd7427 into RI-imaging:master Apr 22, 2026
6 checks passed
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.

3 participants