Repository navigation
Add MKL backends for numpy.fft and scipy.fft and minor fixes - #22
Merged
Merged
Conversation
- fft_bench.py: add --numpy-backend {stock,mkl}. "mkl" routes numpy.fft
through mkl_fft.patch_numpy_fft() and exits with an error if mkl_fft is
missing or the patch does not take. Rows are tagged python-numpy-mkl.
- perf.py: print numpy, mkl_fft and oneMKL versions in the TAG lines.
- fft_bench.c: fix inverted assertion on the real-input, non-rfft path,
which only runs for 1-D shapes.
- README.md: install mkl_fft and mkl-service in the Python environment,
document --numpy-backend and --scipy-backend, correct the description
of the printed measurements, explain descriptor caching with -c, and
add guidance for comparing platforms.
jharlow-intel
previously approved these changes
Sep 28, 2026
jharlow-intel
left a comment
Collaborator
There was a problem hiding this comment.
I think approving this sooner rather than later is important, LGTM
Skip patch_numpy_fft() when the installed NumPy already routes numpy.fft to mkl_fft, and exit with an error when mkl_fft has no patch_numpy_fft(). Replace a non-ASCII dash in a comment.
Contributor
Author
Fully tested this PR and updated in description. |
jharlow-intel
approved these changes
Sep 29, 2026
jharlow-intel
left a comment
Collaborator
There was a problem hiding this comment.
super appreciate your thorough testing, lgtm
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.
Summary
On the current conda stack, NumPy is the stock conda-forge build, so
fft_bench.pymeasured pocketfft for bothnumpy.fftandscipy.ffteven in an environment with mkl_fft installed. The README environment recipe also resolved to an older oneMKL and mkl_fft generation. This PR adds explicit MKL backend options, records the library versions with every run, and updates the README.Changes
fft_bench.py--scipy-backend {stock,mkl}.mklruns the timed region insidescipy.fft.set_backend(mkl_fft.interfaces.scipy_fft). Rows are taggedpython-scipy-stockorpython-scipy-mkl.--numpy-backend {stock,mkl}.mklroutesnumpy.fftthroughmkl_fft.patch_numpy_fft(). Rows are taggedpython-numpy-mkl.len(shape) < 0could never be true).numpy.random.default_rngfor input generation.perf.pyTAG:lines.NamedTupletimer, and move environment printing intoprint_environment_info().fft_bench.cndims != 1on a path that only runs for 1-D shapes). It was hidden by-DNDEBUG.breakaftercase 't'.win_compile_all.bat: useCORE-AVX512instead ofCOMMON-AVX512.README.mdmkl_fftandmkl-servicewith--override-channels, so it resolves to the current oneMKL and mkl_fft releases.--numpy-backendand--scipy-backend, with examples.-cchanges in the native benchmark timing.Test plan
Linux (Xeon Gold 6338, socket 0 pinned), before = master 298491f, after = this PR. Python env: Intel channel mkl_fft 2.3.2, MKL 2026.1.0, conda-forge NumPy. Native: icx 2026.1.1, MKL 2026.1.0. Timings are medians of 5 samples over 3 interleaved rounds.
--numpy-backend mkl/--scipy-backend mklrejected by master, accepted by this PRnumpy.fftc128 1024, T=1: master 13.5 us, PR default 13.5 us,--numpy-backend mkl4.2 usscipy.fftc128 1024, T=1: master 10.3 us, PR default 10.3 us,--scipy-backend mkl6.7 usnumpy.fftrows;scipy.fftprefix is nowpython-scipy-stockTAG:lines report NumPy, mkl_fft and oneMKL versions,Nonewhen absentNDEBUGbuilds match master (c128 1024, 512x512, f64 rfft 1024 with-c)-P -rexample from -P flag appears to be broken in example README command #18-c, 2.7 us with-cwin_compile_all.batnot tested (no Windows build environment)