When your kernel is huge, multiply instead of convolve
A small PyTorch library that swaps direct convolution for the FFT trick, winning big once kernels pass ~100 elements.

What it does
It provides fft_conv as a functional API plus FFTConv1d-style modules that mirror PyTorch’s own convolution layers, in 1D, 2D, and 3D. Under the hood it uses the convolution theorem: convolution in the spatial domain is pointwise multiplication in the frequency domain, so you FFT, multiply, and inverse FFT. The result is numerically the same operation, just computed a different way.
The interesting bit The crossover point is the whole story — the README’s own benchmarks show FFT convolution is slower than PyTorch’s direct convolution for small kernels, and only wins past roughly 100 kernel elements. That honesty is refreshing; most repos bury the tradeoff in a footnote.
Key highlights
- Functional
fft_convand drop-in module classes for 1D/2D/3D convolution. - Supports bias, padding, stride, and dilation like the native layers.
- Same relative scaling across machines; absolute times vary with hardware and PyTorch version.
- Backed by a step-by-step blog article explaining the Fourier math.
Caveats
- The ~100-element threshold is from the author’s local tests, not a guarantee — benchmark your own case.
- Small kernels (the common case in most CNNs) will be slower, not faster.
Verdict Worth a look if you’re doing large-kernel convolution — long 1D signals, big image filters, 3D volumes. If your kernels are 3×3, this is the wrong tool and the README will tell you so.
Frequently asked
- What is fkodom/fft-conv-pytorch?
- A small PyTorch library that swaps direct convolution for the FFT trick, winning big once kernels pass ~100 elements.
- Is fft-conv-pytorch open source?
- Yes — fkodom/fft-conv-pytorch is open source, released under the MIT license.
- What language is fft-conv-pytorch written in?
- fkodom/fft-conv-pytorch is primarily written in Python.
- How popular is fft-conv-pytorch?
- fkodom/fft-conv-pytorch has 524 stars on GitHub.
- Where can I find fft-conv-pytorch?
- fkodom/fft-conv-pytorch is on GitHub at https://github.com/fkodom/fft-conv-pytorch.