Downloads · 30 days
0
chaiya1962/fft-ia-transformer
fft-ia-transformer is a machine learning model from chaiya1962. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
--- tags: - transformer - attention-mechanism - long-sequence - n-log-n-complexity - research license: apache-2.0 ---
Downloads · 30 days
0
Access
Public
Updated Nov 21, 2025
Repo size
1.6 MB
Likes
0
Public
Click a slice to open those files.
.jpg1.3 MB · 81%
From the Hugging Face model README
tags:
The FFT-Inspired Attention ($\text{FFT}$-$\text{IA}$) framework is a novel architecture designed to fundamentally solve the $\mathcal{O}(N^2)$ quadratic complexity bottleneck of the Multi-Head Self-Attention (MHSA) mechanism. Inspired by the computational principles of the Fast Fourier Transform (FFT) and the Cooley-Tukey algorithm, $\text{FFT}$-$\text{IA}$ achieves an $\mathbf{\mathcal{O}(N \log N)}$ asymptotic complexity by structurally factoring the attention matrix.
Unlike approximation methods, $\text{FFT}$-$\text{IA}$ achieves efficiency through fixed structural pruning while maintaining Softmax Fidelity and content dynamism.
The architecture replaces the single, dense attention matrix with a cascade of $L = \log_2 N$ sequential sparse projection factors, $P_i$.
The attention operation is decomposed into $L$ sequential stages: $$ \hat{O} = V_L = P_L \cdot P_{L-1} \cdots P_1 \cdot V $$
Each factor $P_i$ is a fixed, sparse matrix defined by a radix-2 butterfly connection pattern.
The core unit, the BAB, performs a local attention operation between two tokens $j$ and $k$ (where $k = j \pm 2^{i-1}$) in $\mathbf{\mathcal{O}(d^2)}$ time per token.
The framework guarantees $\mathbf{\mathcal{O}(N \log N)}$ asymptotic complexity in sequence length $N$. The total computational cost is: $$ \text{Total FLOPs} = \mathbf{\mathcal{O}(N \cdot (\log N) \cdot (d^2 + d_k))} $$
The primary practical barrier to achieving wall-clock speedup is the $\mathbf{\mathcal{O}(N d^2 \log N)}$ overhead from $\log_2 N$ sequential $Q/K$ re-projection and kernel launches. Dedicated Kernel Fusion (e.g., in CUDA or Triton) is the necessary condition to realize the full theoretical speed advantage.
| Feature | Standard MHSA ($\mathcal{O}(N^2)$) | $\text{FFT}$-$\text{IA}$ ($\mathcal{O}(N \log N)$) |
|---|---|---|
| Complexity | Quadratic $\mathcal{O}(N^2)$ | Near-linear $\mathcal{O}(N \log N)$ |
| Efficiency Mechanism | None (Dense matrix) | Fixed Structural Pruning (FFT-inspired) |
| Softmax | Global $\mathcal{O}(N)$ scope | Local $\mathcal{O}(1)$ scope (Softmax Fidelity) |
| Dynamism | Direct content-based interaction | Dynamic Q/K re-projection on fixed graph |
An open idea to researchers