Polynomial Activations for Transformers

Hemanth Saratchandran, Jianqiao Zheng, Yiping Ji, Wenbo Zhang, Simon LuceyNeurIPS 2026

TL;DR

Everyone assumes Transformers work so well because the softmax function turns raw attention scores into neat, positive, sparse probability distributions. This paper challenges that dogma: softmax’s real superpower might simply be keeping the mathematical "size" of the attention matrix from exploding during training. By scaling a simple cubic polynomial ($x^3$) to mimic this stabilizing effect, the authors match—and often beat—softmax across vision and language tasks, breaking every rule of probabilistic attention along the way.

What Problem Does This Paper Address?

At the heart of every modern Transformer is the self-attention mechanism, which lets tokens weigh the importance of other tokens in a sequence. Standard attention passes raw dot-product similarity scores through a softmax function.

Softmax enforces three classic properties:

  1. Non-negativity: All weights are zero or positive.
  2. Row-wise normalization: Weights sum to 1, allowing us to interpret them as probabilities.
  3. Sparsity: Exponential scaling pushes the model to focus sharply on just a few relevant tokens.

Machine learning lore holds that these probabilistic traits are the secret sauce of attention. Yet, this belief rests mostly on empirical habit rather than hard theory. The authors ask a bold, foundational question: Do Transformers actually need non-negativity, normalization, and sparsity to perform well, or is softmax doing something else entirely under the hood?

Methods

Instead of viewing softmax through probability theory, the authors analyze its matrix mechanics—specifically looking at the Frobenius norm (essentially the Euclidean "magnitude" of a matrix, calculated as the square root of the sum of its squared entries).

  • Theoretical Insight: They prove mathematically that for a sequence of length $N$, softmax implicitly bounds both the Frobenius norm of the attention matrix and its gradients to grow sub-linearly, at a rate of $\mathcal{O}(\sqrt{N})$. This acts as a built-in shock absorber during backpropagation.
  • The Polynomial Alternative: To test if norm control is what really matters, they replace softmax with a scaled polynomial activation: $\phi(x) = \frac{1}{\sqrt{N}}x^3$. Why $x^3$? Because it violates all three softmax rules—it outputs negative numbers, its rows don't sum to 1, and it produces dense matrices (meanwhile, higher powers like $p > 3$ suffer from vanishing gradients near zero).
  • Scaling Strategies: Without scaling, an $x^3$ attention matrix grows as $\mathcal{O}(N)$, causing training to blow up. Dividing by $\sqrt{N}$ brings its expected Frobenius norm right back down to softmax's $\mathcal{O}(\sqrt{N})$ sweet spot. The authors test two variants: a fixed scale ($\frac{1}{\sqrt{N}}$) and a learnable scale initialized at $\frac{1}{\sqrt{N}}$ and optimized during training.
As sequence length N grows, the scaling divisor k required to stabilize cubic attention and achieve high accuracy shifts rightward, matching the theoretical sqrt(N) prediction.

Datasets

No new benchmarks are introduced; instead, the authors evaluate their activations across standard vision and language datasets:

  • Image Classification: Tiny-ImageNet (for initial theory testing) and ImageNet-1k.
  • Object Detection & Instance Segmentation: COCO 2017.
  • Autoregressive Language Modeling: TinyStories, WikiText, and The Pile.
  • Masked Language Modeling & Downstream NLP: Crammed BERT evaluated on the GLUE benchmark.

Key Insights and Ideas

  • Attention doesn't need to be a probability distribution: Models can attend with negative weights and unnormalized rows and still learn rich representations. Even without softmax, visualizations show cubic attention heads naturally learning structured, interpretable patterns—like focusing on image patches in the same horizontal row.
  • Scaling with sequence length is make-or-break: Raw $x^3$ attention causes massive Jacobian norms and frequently fails to converge. Dividing by $\sqrt{N}$ tames the gradients to look remarkably like softmax's throughout training.
Figure 3: Frobenius norm of the jacobian of the self-attention matrix with three different activations in layer 2, 7 and 12 of the ViT-Tiny architecture during training.

Key Results

Across every domain tested, scaled $x^3$ matches or outperforms standard softmax, while unscaled $x^3$ lags behind or crashes completely:

  • ImageNet-1k: Tested on ViT-B, DeiT-B, Swin-B, and XCiT-M, $x^3$ + learnable scale wins across the board (e.g., reaching 84.8% Top-1 accuracy on XCiT-M vs. 84.2% for softmax, while unscaled $x^3$ drops to 79.7%).
  • COCO Detection/Segmentation: Fine-tuning XCiT-S12 with Mask R-CNN, $x^3$ + learnable scale edges out softmax on bounding box AP (45.1 vs. 44.9) and mask AP (40.3 vs. 40.1). Unscaled $x^3$ failed to converge.
  • GPT-2 Language Modeling: Tested at 37M (TinyStories), 303M (WikiText), and 1.3B parameters (The Pile, sequence length 2048), cubic attention consistently lowers perplexity (lower is better). On the 1.3B model, $x^3$ + learnable scale hits 7.1 perplexity compared to softmax's 9.0. Unscaled $x^3$ was too unstable to train.
  • BERT on GLUE: Crammed BERT with $x^3$ + learnable scale achieves an average score of 78.9 across GLUE tasks, beating softmax (78.6).

Limitations and Future Work

The mathematical proofs bounding the polynomial norms rely on assuming inputs and query/key weights are independent and identically distributed (i.i.d.) Gaussian variables. While this holds true at random initialization, it breaks down as weights correlate during training (which helps explain why making the scale learnable gives an extra boost). Consequently, the theory explains initialization stability and regularization rather than the full optimization trajectory. Developing a complete training-dynamics theory to track how cubic activations shape weights and gradients over time remains an open avenue for future work.

Summary updated

Abstract

Softmax attention is typically viewed as effective because it produces a normalized probability distribution over input tokens. In this paper, we challenge this view by showing that a key mechanism behind softmax attention is its implicit control of the Frobenius norm of the attention matrix, which stabilizes training. Motivated by this observation, we study alternative attention activations, focusing on polynomial maps that provide a similar regularization effect without satisfying the usual softmax constraints. Our theoretical analysis shows that certain polynomial activations can replace softmax despite violating positivity, row-wise normalization, and sparsity. Extensive experiments across transformer applications show that these alternatives achieve strong performance, suggesting that the success of softmax attention is not inherently tied to its probabilistic interpretation.
BibTeX
@inproceedings{saratchandran2026polynomial,
  author = {Hemanth Saratchandran and Jianqiao Zheng and Yiping Ji and Wenbo Zhang and Simon Lucey},
  title = {{Polynomial Activations for Transformers}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=GFLgVpdI1N},
}
Figure