Instructions to use jburtoft/fnet-neuron-kernels with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Kernels
How to use jburtoft/fnet-neuron-kernels with Kernels:
# !pip install kernels from kernels import get_kernel kernel = get_kernel("jburtoft/fnet-neuron-kernels") - Notebooks
- Google Colab
- Kaggle
DEPRECATED -- moved to jburtoft/fnet-fast-fourier-transform-neuron-kernels
This repository is deprecated and frozen at v1. It is kept only so existing
KernelConfig references keep resolving.
New location:
jburtoft/fnet-fast-fourier-transform-neuron-kernels
Why the move
- Repo type. This is a
modelrepo, so it never appeared at huggingface.co/kernels and does not resolve throughget_kernel. The new repository is a first-classkernel-type repo. - Name. "Fast Fourier transform" is now spelled out in the repository name.
- v2 is substantially faster and more accurate -- see below.
What changed in v2
| Area | Improvement |
|---|---|
| Tensor Engine matmuls | 25-50% fewer per tile |
| Total ISA operations | 36-45% fewer per tile |
| Numerical accuracy | ~84x better end-to-end (2.6e-05 -> 3.1e-07 relative) |
Principal changes:
r2c/c2rspecialization. FNet's pass 1 has a real input and pass 2 needs only a real output. v1 ran a full complex-to-complex transform in both passes, so half its matmuls either multiplied a zero imaginary input or produced an imaginary result that was discarded.- No DFT-matrix transpose.
W[k,n] = exp(-2*pi*i*k*n/N)is exactly symmetric. Reducing the integer productk*nmoduloNbefore scaling makes the float32 matrix symmetric to 0 ULP, removing 2nc_transposeplus 2 PSUM copies per DFT. - Cached constants. v1 rebuilt the DFT and twiddle matrices in NumPy and
re-uploaded them on every call -- 144 separate host-to-device transfers for a
single
B=4, S=512, D=768forward pass. - Batch folding instead of a serial Python loop over the batch.
- Real-only final butterfly and fused output assembly.
Migration
The public class was renamed. Update the KernelConfig value:
kernel_config = KernelConfig({
- "FNetBasicFourierTransform":
- "jburtoft/fnet-neuron-kernels:NeuronFNetFourierForward",
+ "FNetBasicFourierTransform":
+ "jburtoft/fnet-fast-fourier-transform-neuron-kernels:NeuronFNetFastFourierTransformForward",
})
Other renames:
| v1 | v2 |
|---|---|
NeuronFNetFourierForward |
NeuronFNetFastFourierTransformForward |
NeuronFNetFourierLayout |
NeuronFNetFastFourierTransformLayout |
nki_fft2d_real |
nki_fast_fourier_transform_2d_real |
_fft1d_{128,256,512} |
_fast_fourier_transform_{128,256,512}_{r2c,c2r} |
The input and output contract is unchanged: (B, S, D) in, (B, S, D) out,
equivalent to torch.fft.fftn(x, dim=(1, 2)).real.
Correction to the v1 documentation
The v1 README stated that non-power-of-two hidden sizes were "padded to the next power of 2 (1024) and the result truncated." That description was wrong. Zero-padding an FFT changes the frequency grid, so truncating a 1024-point transform does not yield a 768-point transform (the two differ by ~116 in absolute terms on unit-scale input).
The v1 implementation was correct -- it computed a true N-point DFT via
_torch_fft1d. Only the documentation was wrong. v2 documents the actual behavior
and asserts it in test_e2e.py.
Relatedly, v1 reported accuracy as "cosine similarity 1.000001-1.000007". Cosine
similarity cannot exceed 1.0, and it is insensitive to the broadband errors this
kernel can produce. v2 reports max_abs_err against a float64 torch.fft
reference instead.
License
Apache 2.0
- Downloads last month
- -
# !pip install kernels from kernels import get_kernel kernel = get_kernel("jburtoft/fnet-neuron-kernels")