SOLA: A Structured Operator Library for Attention in Pretrained Vision Transformers
Enzo Tartaglione ⋅ Vito Paolo Pastore
Abstract
Vision Transformers dominate modern image benchmarks; however, what trained self-attention computes head by head remains unclear: prior work either injects inductive biases at initialization or clusters attention patterns visually without committing to a closed-form computation. We ask whether the softmax$(QK^\top)$ inside a trained head can be replaced, without further training, by a structured closed-form operator while preserving prediction and the residual-stream trajectory. We answer yes across ten ViTs and seven pretrainings (ImageNet-1k, ImageNet-21k FT, MAE, DINO, DINOv2, CLIP, SigLIP), and package the result as SOLA, a Structured Operator Library for Attention with three entries, each gated by a per-head diagnostic that upper-bounds substitution error. The entries are a fixed 2D convolution kernel for shift heads, a per-image broadcast row for fixed-target heads, and a per-image rank-$k$ SVD of the attention matrix for near-global heads. A rank-adaptive extension picks $k$ per head from the SVD spectrum and extends structural coverage to every head on every backbone, with task-fidelity controlled by a single spectral threshold $\tau$ that trades compression for downstream fidelity. Structural coverage is distinct from verified losslessness: at $\tau{=}0.9$ the full substitution costs $0.9$-$2.2\%$ top-1 on five supervised classifiers and keeps CLS cosine similarity at or above $0.96$ on MAE, DINO, and CLIP, while DINOv2 and SigLIP require a stricter $\tau$; the heads that are both compressed and verified lossless by a standalone test range from $3\%$ (SigLIP) to $84\%$ (MAE) of a backbone. The diagnostics carry over to cross-attention: every decoder cross-attention head in BLIP captioning has effective rank $\approx 1$ and admits the broadcast substitution. The code base is available at [https://github.com/enzotarta/SOLA](https://github.com/enzotarta/SOLA).
Successful Page Load