Skip to main content
Back

Australian Researchers Replace Softmax With x Cubed and Match Transformer Accuracy

New theory shows softmax's magic is really Frobenius norm control, and a scaled cubic polynomial matches or beats it across vision, detection, long-range and PDE tasks.

Pro

  • Paper argues softmax works by regularizing the attention matrix's Frobenius norm, not by producing probabilities.
  • Theorem: softmax attention matrix has Frobenius norm bounded by sqrt(N), gradient by 2 sqrt(N).
  • Scaled cubic polynomial x^3 / sqrt(N) matches this bound and drops into standard transformers.
  • On ImageNet-1k with ViT-B, DeiT, Swin, XCiT, polynomial attention matches or slightly beats softmax.
  • Wins carry over to COCO detection, Long Range Arena, and physics-informed PDE transformers.
  • Breaks above degree 6 due to vanishing gradients, and only tested up to 100M parameters.

For years, the story we tell about attention has been the same: softmax turns raw query-key scores into a probability distribution, so each token gets a clean, sparse, positive weight over the others. A new paper from the Australian Institute for Machine Learning argues that this story is largely wrong, and that simple polynomials like x cubed can replace softmax entirely, as long as you scale them correctly.

The claim is not just that polynomials work in practice. The authors provide a theoretical explanation for why softmax is effective in the first place, and it has nothing to do with probabilities.

The three sacred properties, questioned

Softmax self-attention satisfies three key properties: non-negativity of attention weights, row-wise normalization to ensure weights sum to one, and sparsity, promoting focus on a few relevant tokens. These have long been treated as load-bearing. Attention maps are visualized, interpreted as token-to-token probabilities, and used to argue about what a model is looking at.

The paper asks a blunt question: do attention mechanisms in transformers require non-negativity, normalization, and sparsity for effective performance? The answer they arrive at is no. What actually matters, they argue, is a much more boring quantity: how large the attention matrix is allowed to grow during training.

Softmax as a hidden regularizer

The central theoretical result is a bound on the Frobenius norm (the square root of the sum of squared entries) of the softmax attention matrix. For an input sequence of length N, the authors prove that the softmax attention matrix has Frobenius norm bounded by the square root of N, and its gradient by twice the square root of N. In other words, softmax controls the size of the attention matrix in a way that grows sub-linearly with sequence length.

Why does that matter? During training of a transformer with softmax self-attention, the Frobenius norm of each softmax self-attention matrix remains bounded by a value that grows as O(sqrt(N)), which ensures that backpropagation through the weights of the self-attention matrix does not lead to excessively large gradients. Softmax, in this view, is a stability trick disguised as a probability function.

The polynomial recipe

Once you accept that framing, the design problem becomes: find any activation that keeps the attention matrix's Frobenius norm on the order of sqrt(N). The authors show that raw polynomial attention, meaning the matrix (XQK^T X^T)^p, has expected Frobenius norm growing like N. To bring it back down to sqrt(N), you just divide by sqrt(N).

That leads to the surprisingly simple prescription:

def poly_attention(Q, K, V, N, p=3):
    scores = (Q @ K.transpose(-2, -1)) / math.sqrt(d)
    attn = (scores ** p) / math.sqrt(N)   # replaces softmax
    return attn @ V

The cubic case is the one they study most carefully, because x cubed introduces both positive and negative values, does not normalize rows to sum to 1, and generally produces dense attention matrices, violating all three traditional softmax conditions. If polynomial attention works, it kills the probabilistic interpretation cleanly.

They test two flavors:

  • Fixed scale: divide by sqrt(N) where N is the sequence length, exactly as theory suggests.
  • Dynamic scale: initialize the scale to 1/sqrt(N) and learn it during training, since the i.i.d. Gaussian assumption in the proof only holds at initialization.

Does the theory actually predict behavior?

Before the main benchmarks, the authors run a sanity check on ViT-Tiny with Tiny-ImageNet. They sweep the scale k in the activation (1/k) x^3 across sequence lengths from 8 to 256. The prediction from theory is that the best accuracy should occur when k is roughly sqrt(N). The sweep confirms this: as sequence length grows, the optimal k grows with it, and mis-scaled versions degrade sharply.

They also plot the Frobenius norm of the attention matrix through training. Plain x cubed blows up. Softmax stays bounded. And x cubed divided by 16, which is 1 over sqrt(256), tracks softmax almost exactly. On Tiny-ImageNet, softmax hits 50.26 percent top-1, the scaled cubic hits 50.5, and the unscaled cubic drops to 45.3.

Full-scale experiments

The interesting part is that this holds up beyond toy settings. On ImageNet-1k, the authors swap softmax for scaled x cubed inside four different architectures: ViT-B, DeiT, Swin Transformer, and XCiT. Top-1 accuracy comparisons:

ActivationViT-BDeiT-BSwin-BXCiT-M
softmax80.381.583.582.7
x^3 + fixed scale80.281.483.682.8
x^3 + dynamic scale80.381.683.682.9
x^3 (no scale)78.178.579.979.5

The pattern is consistent across other tests. Fine-tuning an XCiT backbone into Mask R-CNN on COCO, the dynamically scaled cubic reaches 45.1 box AP versus 44.9 for softmax. On the Long Range Arena benchmark with a Nystromformer backbone, scaled x cubed matches or slightly beats softmax across ListOps, Text, Retrieval, Image, and Pathfinder tasks, while unscaled x cubed drops by up to 5 points. On PDE modeling with a PINNsformer, the scaled polynomial cuts relative MAE on the convection equation from 4.1e-2 to 3.5e-2.

What the attention maps look like

Because the activation can go negative, the learned attention matrices genuinely stop looking like probability distributions. Visualizing ViT-B heads trained with scaled x cubed, the authors find heads with clear band structure around the diagonal (attending to the same row of image patches as the query) and heads with vertical stripes (attending to certain key positions regardless of query). The patterns are as interpretable as softmax heads, just not probabilistic.

Where it breaks

The theory has real caveats worth flagging:

  • The i.i.d. Gaussian assumption on Q, K, and X only strictly holds at initialization, which is why the dynamic-scale variant tends to outperform the fixed one.
  • Polynomials of degree 6 or higher fail to train. Around zero-initialized weights, x^6 shrinks values by orders of magnitude and produces vanishing gradients.
  • The analysis is specific to dot-product self-attention. Additive or kernelized attention variants are not covered.
  • All experiments cap out at around 100 million parameters. Whether the scaling trick survives at billion-parameter scale is genuinely unknown.

Why it matters

The immediate practical payoff is that polynomial attention is a drop-in replacement for softmax that avoids exponentials entirely. That is attractive for hardware where exp is expensive, for linearized attention variants where the softmax normalizer is the whole obstacle to linear-time attention, and for anyone building custom kernels. The bigger contribution is conceptual: the reason attention is hard to replace is not that transformers need probability distributions over tokens, but that they need their attention matrices to stay a certain size. Once you know the actual constraint, the design space opens up considerably.

No public code repository is linked from the paper itself, though the experiments rely on standard open-source stacks including timm and the original Nystromformer and PINNsformer codebases.