Unraveling Attention via Convex Duality: Analysis and Interpretations of Vision Transformers

Arda Sahiner, Tolga Ergen, Batu Ozturkler, John M. Pauly, Morteza Mardani, Mert Pilanci

Introduction

While Vision Transformers (ViTs) have achieved state-of-the-art results across numerous computer vision tasks, they are often treated as "black boxes." Their standard training objectives are highly non-convex, meaning they are prone to getting stuck in local minima and are notoriously difficult to analyze theoretically. Specifically, the "inductive bias"—the set of assumptions a model uses to predict outputs for inputs it hasn't seen—of the attention mechanism remains poorly understood.

This research provides a theoretical breakthrough by proving that self-attention and its popular alternatives (like MLP-Mixer and Fourier Neural Operators) are equivalent to solvable convex optimization problems. By "convexifying" these architectures, the authors reveal that transformers work by implicitly clustering tokens and applying block nuclear-norm regularization. This offers a clear mathematical explanation for why these models generalize so well and bridges the gap between complex, non-linear architectures and classical optimization theory.

Methodology: Convexifying the Black Box

The researchers leverage convex duality and hyperplane arrangements to derive finite-dimensional convex equivalents for three major "token mixing" modules:

  1. Multi-Head Self-Attention (MHSA): The core mechanism of the original Vision Transformer.
  2. MLP-Mixer: An architecture that replaces attention with simple multi-layer perceptrons acting across different dimensions.
  3. Fourier Neural Operator (FNO): A model that performs token mixing in the frequency domain using Fourier transforms.

By applying Fenchel duality, the authors demonstrate that training these models with weight decay is mathematically equivalent to solving a convex problem with a specific type of regularization: the nuclear norm (or a constrained version of it). This regularization encourages the model to find low-rank solutions, effectively "compressing" the information it learns into a more generalizable format.

To validate these theoretical findings, the authors conducted transfer learning experiments. They used ImageNet-1k to pre-train backbone models (gMLP-S and ViT-base). Then, they evaluated the performance of their newly derived convex "heads" on CIFAR-100. During this phase, the pre-trained backbones were kept fixed, and only a single convex block was fine-tuned to perform classification.

Key Insights and Mechanisms

The convex formulation reveals several fundamental properties about how these architectures process information:

  • Implicit Clustering: The analysis shows that self-attention implicitly clusters tokens based on their latent similarity. It acts as a feature-correlation-weighted linear model where the nuclear norm penalty ensures "global cohesiveness" across the network.
Illustration of how self-attention groups latent features into blocks in its equivalent convex form.
  • FNO as Convolution: The mathematical breakdown shows that the Fourier Neural Operator is essentially a form of circular convolution. Slight modifications to the architecture (B-FNO) induce group-wise convolutions, providing a direct, provable link between Fourier-based models and classical Convolutional Neural Networks (CNNs).
  • Structure vs. Non-linearity: For self-attention and MLP-Mixers, the researchers found only a marginal performance gap between linear and ReLU activations. This suggests that the structural mixing mechanism—how tokens interact with one another—is far more fundamental to their success than the specific non-linearity applied.

Empirical Results

The theoretical guarantees of convexity translate into strong empirical performance:

  • Superior Inductive Bias: The convex attention-based heads significantly outperformed standard convex baselines (like simple linear or MLP heads) on CIFAR-100. For example, the MLP-Mixer head (Gated ReLU) achieved 80.22% Top-1 accuracy, compared to only 66.42% for a standard linear head.
  • Global Optimality Guarantees: Because these new formulations are strictly convex, they can be solved to their global optimum. This eliminates the instability often seen in fine-tuning transformers, where different random initializations can lead to wildly different results.
  • Empirical Equivalence: Experiments showed that the performance of these convex models is roughly equivalent to their non-convex counterparts. This proves that the convex transformation preserves the model's expressivity while gaining massive interpretability and stability benefits.

Limitations and Future Work

While this framework provides a powerful new lens for understanding transformers, it does have limitations:

  • Computational Complexity: Solving nuclear norm minimization problems can be computationally expensive for very large datasets. While the authors use the Burer-Monteiro factorization to speed up the process, scaling to massive, industry-scale models remains a challenge.
  • Single-Block Focus: The current analysis focuses on a single block or head. Real-world transformers are deep stacks of many layers. Extending this convex duality framework to deep, multi-layer architectures is a necessary next step.
  • Need for Specialized Solvers: The authors suggest that future work should focus on crafting more efficient approximate solvers that specifically leverage the unique structure of these block nuclear-norm regularizers to improve training speeds.

Summary updated

BibTeX
@inproceedings{sahiner2022unraveling,
  author = {Arda Sahiner and Tolga Ergen and Batu Ozturkler and John M. Pauly and Morteza Mardani and Mert Pilanci},
  title = {{Unraveling Attention via Convex Duality: Analysis and Interpretations of Vision Transformers}},
  booktitle = {International Conference on Machine Learning},
  year = {2022},
  url = {https://openreview.net/forum?id=-BOi40WBYs},
}
Figure