TL;DR
The Polynomial Mixer (PoM) is a novel, linear-time drop-in replacement for self-attention that eliminates the quadratic bottleneck of Transformers. By aggregating tokens into a compact global state via a learned polynomial function, PoM maintains the universal approximation capabilities of standard attention while delivering massive speedups on long sequences across text, vision, and 3D data.
What Problem Does This Paper Address?
Multi-Head Attention (MHA) is the engine behind modern AI, but it suffers from a fundamental flaw: its computational and memory complexity scales quadratically ($O(n^2)$) with the sequence length ($n$). This makes processing long documents, high-resolution images, or dense 3D point clouds incredibly expensive.
While researchers have proposed sub-quadratic alternatives, they usually force tough trade-offs. For example, Linformer requires a fixed sequence length, and State Space Models (SSMs) like Mamba impose a strict causal (one-directional) ordering. This causal constraint works well for text but is unnatural for multi-directional modalities like 2D images or 3D spaces.
The authors of this paper ask: Can we achieve linear-time complexity without sacrificing the bidirectional flexibility and universal expressivity of standard attention?
Methods
The authors introduce the Polynomial Mixer (PoM). Instead of calculating expensive pairwise interactions between every single token, PoM summarizes the entire sequence into a single, shared global memory state $H(X)$.
Here is how the token-mixing pipeline works:
- Projection & Expansion: Input tokens are projected into a higher-dimensional space.
- Polynomial Aggregation: The tokens are passed through a learned polynomial function of degree $k$ (the authors find $k=2$ or $3$ is usually sufficient). This step collapses the sequence dimension via summation, creating the global state $H(X)$.
- Gating & Retrieval: Each individual token generates a gating coefficient (via a sigmoid function) to query this global state using element-wise multiplication.
- Output Projection: The result is projected back down to the original token dimension.
By embedding PoM within standard Transformer blocks alongside feed-forward networks, they create PolyMorpher blocks. The authors also introduce a causal variant of PoM that allows for efficient $O(1)$ autoregressive inference during text generation.
Datasets
The authors rigorously evaluate PoM across five distinct domains using standard benchmarks:
- Natural Language Processing (NLP): Trained 125M parameter GPT-2 style models on 15 billion tokens from the FineWeb dataset.
- Optical Character Recognition (OCR): Evaluated on the Ludovico Antonio Muratori (LAM) handwritten text dataset for single-line and multi-line page recognition.
- Earth Observation (EO): Tested on the PASTIS dataset for crop-type mapping from satellite image time series.
- 3D Point Cloud Segmentation: Evaluated on ScanNet (indoor scenes) and SemanticKITTI (autonomous driving).
- Class-Conditional Image Generation: Trained on ImageNet at $256 \times 256$ resolution.
Key Insights and Ideas
- The Contextual Mapping Property: Why do polynomials work where other linear methods fail? The authors mathematically prove that a sufficiently high-degree polynomial satisfies the "contextual mapping property." This means PoM can uniquely compress the entire context into a single vector without losing the identity of individual tokens, preserving the universal approximation traits of Transformers.
- True Bidirectionality: Unlike SSMs, PoM does not rely on a recurrent scan order. It treats sequences globally and symmetrically, making it naturally suited for vision and spatial data.
- The Power of Hybrids: The authors discover that alternating PoM layers with a small window of local attention (e.g., focusing only on the nearest 128 tokens) yields the best results. This hybrid approach captures fine-grained local details while PoM handles the broad, global context linearly.
Key Results
PoM achieves performance on par with standard Transformers while scaling linearly as sequence lengths grow.
- Earth Observation: On the PASTIS dataset, TSViPoM matched the accuracy of the state-of-the-art TSViT baseline while delivering a 300% faster inference throughput.
- Image Generation: For ImageNet synthesis, the PoM variant (SiPoM-XL/2) achieved the exact same Frechet Inception Distance (FID) of 17.2 as the attention-based baseline but ran twice as fast at higher resolutions.
- NLP: The hybrid model (GPPoM2-S Hyb) matched or slightly outperformed standard GPT-2 on benchmarks like HellaSwag (33.8 vs 33.3 accuracy) while scaling effortlessly to $32k$ token contexts without running out of memory (OOM).
Limitations and Future Work
Despite its impressive scaling, PoM has a few limitations in its current state:
- Short-Sequence Overhead: Because the current implementation is written in high-level PyTorch without custom, low-level hardware optimizations, highly optimized attention kernels like FlashAttention can still be faster for short sequences (under 1,000 tokens).
- Scale Constraints: The experiments were capped at relatively small model sizes (up to 125M parameters for text). Testing PoM's stability and capabilities in multi-billion parameter large language models remains an open area for future research.
Summary updated