# Poster 31064

- Kind: Poster
- Talk page and recording: https://iclr.cc/virtual/2025/poster/31064

> Transcript of the talk's recording (session_asr), made by speech recognition or taken from the host's captions. It may contain errors. The words are the speakers'; listen to the recording on the talk's page before quoting it.

Hello, my name is Veronika Hermannitz and I'm going to present our paper. What does it mean to be a transformer? Insights from a theoretical hash in analysis. This is a joint work with Elise Van Gellen and Gilles Lapaz. Let's start with motivating why we want to analyze the transformer model through the lens of the hashing.
So compared to classical architectures like MLPs and CNNs, transformers are unique in several ways. For example, the data enters a transformer through a self -attention mechanism multiple times and the softmax nonlinearity inside self -attention differs from more common piecewise linear activations like ReLU. And these architectural differences make practical approaches for training a transformer distinct compared to MLPs and CNNs.
For example, transformers are usually trained with adaptive optimizers like AdamW instead of plain SGD and require using warmup. And since the Hessian is a fundamental object for optimization and tells us a lot about the local properties of the loss landscape, we want to formally characterize it. Even from just looking at the Hessian of a simple transformer, we can clearly see some appearing structures in the magnitude of the Hessian entries.
We can set attention layer. We can distinguish the blocks corresponding to the queries and keys, which are smaller matrices. In this work, we want to formally understand what makes the transformer Hessian look this way and what makes it special. In order to do that, we derive the exact structure of the self-attention Hessian and thanks to that we are able to explicitly characterize the impact of transformer design components.
And Oh. we are also able to contract the transformer with other models. Now we are just going to focus on the conclusions from the formal analysis, but the full hashing expressions can be found in the paper.
Let's move to discussing our setup. As mentioned, we derived the Hessian of a classical set attention layer with respect to its query key and value parameters and we break down our analysis by splitting the Hessian into two parts, the eigenproduct and the functional Hessian based on the Gaussian decomposition. And then we analyze their blocks with respect to parameter matrices.
Having set the stage, let's just jump to discussing some of the results. In this presentation we will focus on the conclusions related to the dependence on the input matrix size, and for other interesting observations I invite you to read the full paper or to check out our poster. The first conclusion we can draw is that the dependence on the input matrix X varies across the Hessian blocks. We present that using the big O notation, where we omitted the bounded terms that depend on X.
For the other quadratic Hessian we can see that the blocks with respect to the query and key weights are more data dependent than the ones with respect to the value weight matrix. A similar thing holds for the functional Hessian. We also verify our derivations empirically. Here on the x-axis you can see the standard deviation of the entries of X and on the y-axis the Frobenius norm of the Hessian blocks and the dashed lines correspond to trends even where there are theoretical predictions.
For a singular transformer, their empirical growth rates with respect to the magnitude of x match our theoretical predictions quite well. Also for deeper networks and smaller magnitudes of the input magnitude x, our theoretical predictions hold. We have experimentally showed that distribution of the Hessian magnitudes is much better between blocks if we remove the softmax from the attention mechanism.
The intuition here is that without softmax the forms of heterogeneous, like for example dependence on data, disappear. We also derive the Hessian of this linear self-attention and can formally state that without the softmax the data dependence is homogeneous across blocks of both the outer product and functional Hessian.
Having the expressions for the Hessian of the linear attention, we can also fairly compare the transformer Hessian with the linear-MLP Hessian we find in related literature. We find that the Hessian of an MLP is generally less data dependent than the Hessian of a transformer. This also holds with depth, so for MLPs the growth rates of the norm of a Hessian block do not depend on the depth.
But for a transformer, they depend super exponentially on the depth of the network and this sheds some light onto why we need a properly placed normalization layers in transformers in order to successfully train them. To summarize, in our work we derived the exact expressions for the self-attention Hessian, we showed block heterogeneity in terms of data dependence and proved that it's caused by the softmax activation. We also described the difference between the Hessian of an MLP and the Hessian of a transformer.
And in the paper you can also find more insights on the transformer hashing, for example a discussion of the block heterogeneity in terms of weights and attention moments. And thank you very much for watching and listening and I invite you to read the paper and to check out our poster at the conference.
