Skip to content

[CUDA] Add FFT support - #3243

Merged
zcbenz merged 13 commits into
ml-explore:mainfrom
lucasnewman:cuda-fft
Mar 14, 2026
Merged

zcbenz merged 13 commits into
ml-explore:mainfrom
lucasnewman:cuda-fft

Conversation

@lucasnewman

Copy link
Copy Markdown
Contributor

Proposed changes

This adds CUDA parity with Metal for FFT ops, as requested in #2561

The implementation uses cufft and is inspired by nvmath-python which is referenced in that issue. I tried to make this as minimal as possible, and I verified all the tests for both python and cpp pass as expected, including the disabled-in-CI exhaustive one, test_fft_exhaustive.

I only had access to an H200 with CUDA 12.4 for testing -- if there's an easy way to test on other hardware, let me know and I can try it.

Checklist

Put an x in the boxes that apply.

  • I have read the CONTRIBUTING document
  • I have run pre-commit run --all-files to format my code / installed pre-commit prior to committing changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the necessary documentation (if needed)

@zcbenz zcbenz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is overall very nice, thanks a lot writing this!

Comment thread mlx/backend/cuda/cuda_utils.h Outdated
Comment thread mlx/backend/cuda/fft.cu Outdated
Comment thread mlx/backend/cuda/fft.cu Outdated
Comment thread mlx/backend/cuda/fft.cu Outdated
Comment thread mlx/backend/cuda/fft.cu Outdated
Comment thread mlx/backend/cuda/fft.cu Outdated
Comment thread mlx/backend/cuda/fft.cu Outdated
@zcbenz

zcbenz commented Mar 12, 2026

Copy link
Copy Markdown
Member

Can you enable the FFT tests in python/tests/cuda_skip.py and .github/actions/test-linux/action.yml?

@lucasnewman
lucasnewman requested a review from zcbenz March 12, 2026 02:37
@lucasnewman

Copy link
Copy Markdown
Contributor Author

@zcbenz Thank you for the review! I think I've addressed everything you mentioned, and tests are passing for me on my CUDA setup. Let me know if there's anything else needed.

@zcbenz zcbenz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just a few more nitpickings, and this looks good to me!

Comment thread mlx/backend/cuda/fft.cu Outdated
Comment thread mlx/backend/cuda/fft.cu
Comment thread mlx/backend/gpu/copy.cpp Outdated
Comment thread mlx/backend/gpu/copy.cpp Outdated
Comment thread mlx/backend/cuda/fft.cu Outdated
Comment thread mlx/backend/gpu/copy.cpp Outdated
@zcbenz
zcbenz merged commit 5d17004 into ml-explore:main Mar 14, 2026
16 checks passed
@BrewTestBot BrewTestBot mentioned this pull request Apr 22, 2026
1 task done
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