Skip to content

Improve DIM performance using padding in FFT - #92

Merged
MatthewFilipovich merged 4 commits into
mainfrom
fix/conv2d_fft
Apr 1, 2026
Merged

Improve DIM performance using padding in FFT#92
MatthewFilipovich merged 4 commits into
mainfrom
fix/conv2d_fft

Conversation

@MatthewFilipovich

@MatthewFilipovich MatthewFilipovich commented Apr 1, 2026

Copy link
Copy Markdown
Owner

Optimize conv2d() to improve performance for power-of-two grid shapes. Adds padding in FFT.

Closes #68

Copilot AI review requested due to automatic review settings April 1, 2026 10:24
@codecov

codecov Bot commented Apr 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.92%. Comparing base (52d9eef) to head (748dbe0).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #92   +/-   ##
=======================================
  Coverage   99.92%   99.92%           
=======================================
  Files          38       38           
  Lines        1304     1305    +1     
=======================================
+ Hits         1303     1304    +1     
  Misses          1        1           

☔ 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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to improve Direct Integration Method (DIM) propagation performance by allowing FFT-size padding in conv2d_fft, and enabling it in DIM.

Changes:

  • Extend conv2d_fft with an extra FFT-size padding parameter and adjust FFT sizing logic.
  • Use padding=1 in DIM propagation to potentially get faster FFT sizes.
  • Add a new functional test covering a larger-kernel convolution scenario.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
tests/functional/test_conv2d.py Adds a new “large kernel” correctness test for conv2d_fft.
src/torchoptics/propagation/direct_integration_method.py Enables FFT padding in DIM by calling conv2d_fft(..., padding=1).
src/torchoptics/functional/functional.py Adds padding parameter to conv2d_fft and uses it to set FFT sizes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/functional/test_conv2d.py Outdated
Comment thread tests/functional/test_conv2d.py
Comment thread src/torchoptics/functional/functional.py Outdated
Comment thread src/torchoptics/functional/functional.py Outdated
Comment thread src/torchoptics/propagation/direct_integration_method.py
@MatthewFilipovich
MatthewFilipovich merged commit f2472b1 into main Apr 1, 2026
6 checks passed
@MatthewFilipovich MatthewFilipovich changed the title Improve FFT performance using padding in DIM Improve DIM performance using padding in FFT Apr 1, 2026
@MatthewFilipovich
MatthewFilipovich deleted the fix/conv2d_fft branch April 1, 2026 10:49
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.

Calculation of grid shape

2 participants