Attention: the part of a transformer with no weights

A transformer contains two kinds of matrix multiply. One uses fixed weights and is most of the parameters and most of the arithmetic at ordinary context lengths. The other is built from the input at run time and has no weights at all. That distinction decides what a weight-stationary architecture can do for a language model and what it cannot, and we would rather state it than be asked.

21 November 2026CurrentNot yet4 references

The claim

The convolution post ended on a convenient fact: a layer holds a small number of weights and does an enormous amount of arithmetic with them, each weight reused thousands of times. That fact is the argument for putting weights inside the array.

A transformer complicates it. There are two kinds of matrix multiply in an attention layer, and only one of them has weights.

This post is about the other one, because a reader who takes our architecture seriously will find it eventually and it is better found here.

What attention computes

Each token is a vector. Attention lets every token look at every other token and build a new version of itself from what it finds.

Three vectors are derived from each token by multiplying it with learned matrices: a query — what this token is looking for; a key — what this token offers; and a value — what it passes on if selected.

Compare one token's query against every token's key, and you get a score per pair. Normalise the scores so they sum to one. Take that weighted combination of the values. That is the output for that token, and the mechanism is the one introduced by Vaswani and colleagues [1].

Convolution asks what is in this small neighbourhood. Attention asks what in the entire sequence is relevant to this position. The second question is more powerful and much more expensive, and the expense has a different shape.

The two multiplies

The projections have weights. Producing the queries, keys and values, projecting the output, and the feed-forward network that follows each attention block — these are multiplications by learned matrices that are fixed once the model is trained. For a layer of hidden size d, they come to roughly 12 d² parameters, and they are the overwhelming majority of a model's weights.

These are exactly the case the crossbar is built for: fixed, reused for every token, and worth never moving.

The attention product does not. The score matrix is the queries multiplied by the keys — and both were computed from the input moments earlier. Nothing in that multiplication is a stored parameter. There is no weight to hold resident, because there is no weight.

A weight-stationary array has nothing to offer that step. It is a matrix multiply with no fixed operand, and it has to be performed by something that reads both sides from memory.

How much of the work is which

The projection cost per token is fixed by d, and does not change with context length. The attention cost grows linearly with how many previous tokens are being attended to.

Figure 1Arithmetic per token per layer, hidden size 4096
Arithmetic per token per layer, hidden size 4096Where the work sits as context grows. The fixed-weight projections cost the same per token at any context length; attention grows with it, and the two meet at roughly six times the hidden size — about 24,000 tokens here. Below that, most of the arithmetic is in the part that has weights. Note the logarithmic axis.1000000050000000200000000600000000MULTIPLY-ACCUMULATES PER TOKEN, PER LAYER (MAC)Projectionsfixed weights, any context201326592Attention at 2k contextno weights16777216Attention at 8k contextno weights67108864Attention at 24k contextno weights — the crossover201326592Attention at 64k contextno weights536870912
modelled

Where the work sits as context grows. The fixed-weight projections cost the same per token at any context length; attention grows with it, and the two meet at roughly six times the hidden size — about 24,000 tokens here. Below that, most of the arithmetic is in the part that has weights. Note the logarithmic axis.

Measured: Nothing. No hardware was measured for this figure. Modelled: All five bars, computed from the layer dimensions: 12d² for the projections and 2·d·s for attention against s previous tokens. The arithmetic is in the text.

The crossover is at about six times the hidden size. For a model with d = 4096 that is roughly 24,000 tokens of context. Below it — which is most practical use — the fixed-weight matrices are most of the arithmetic, and the weight-stationary argument holds.

That is the favourable reading, and it is not the whole picture.

Why arithmetic is the wrong thing to count here

During generation a model produces one token at a time, and each new token attends to every previous one. The keys and values of those previous tokens are kept so they need not be recomputed — the key-value cache. It grows with every token, and every step reads all of it.

So the attention step does little arithmetic per byte it touches. It is limited by moving data, not by computing, which is the distinction that governs most accelerator design [4]. FlashAttention makes the point directly, framing the problem as accounting for reads and writes between levels of memory rather than as reducing operations [2]. Architectural responses target the same thing: sharing key and value heads across queries lowers the memory requirement and is what allows much longer contexts [3].

For us this is the honest limit. Resident non-volatile weights remove weight traffic completely, and weight traffic is most of the traffic in a vision model. In a language model at generation time, the traffic that remains is the cache, and holding weights in the array does nothing about it. How much that costs, and what can be done about it, is the language model post.

What we claim, and what we do not

We claim that the fixed-weight matrices of a transformer — the large majority of its parameters, and most of its arithmetic below very long contexts — are the case a resident-weight array serves well, for the same reason it serves a convolution well.

We do not claim that compute-in-memory solves attention. The score computation has no stored operand to be stationary about, the generation-time bottleneck is cache traffic rather than arithmetic, and an architecture whose advantage is never moving weights has no advantage over a quantity that is not a weight.

Anyone who tells you their in-memory part makes attention cheap has either solved something they should publish, or is counting the projections and calling it attention.

What to take from this

A transformer is mostly fixed-weight matrix multiplication with an expensive weightless step inside it. The first part is what our architecture is for. The second part is a real constraint that we model, report at a boundary that includes it, and do not pretend away.

References

  1. A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, L. Kaiser and I. Polosukhin, “Attention is all you need,” arXiv:1706.03762; presented at the Conference on Neural Information Processing Systems, 2017, 2017. arxiv.org/abs/1706.03762reviewCited as the arXiv record, which is what we verified. The proceedings version's page range and DOI could not be confirmed from any source we could reach, so neither is asserted here.
  2. T. Dao, D. Y. Fu, S. Ermon, A. Rudra and C. Ré, “FlashAttention: fast and memory-efficient exact attention with IO-awareness,” arXiv:2205.14135, 2022. arxiv.org/abs/2205.14135measured siliconCited for its framing of attention's cost as reads and writes between levels of memory rather than as arithmetic. Author list and arXiv id verified; the conference record was not reachable, so it is cited as the preprint.
  3. R. Pope, S. Douglas, A. Chowdhery, J. Devlin, J. Bradbury, A. Levskaya, J. Heek, K. Xiao, S. Agrawal and J. Dean, “Efficiently scaling transformer inference,” arXiv:2211.05102, 2022. arxiv.org/abs/2211.05102measured siliconCited only for the point its abstract makes directly, that sharing key and value heads lowers the memory requirement and so allows much longer context. Venue and page range unverified.
  4. V. Sze, Y.-H. Chen, T.-J. Yang and J. S. Emer, “Efficient processing of deep neural networks: a tutorial and survey,” Proceedings of the IEEE, vol. 105, no. 12, pp. 2295–2329, 2017. doi:10.1109/JPROC.2017.2761740reviewFor the general distinction between work limited by arithmetic and work limited by moving operands.

Corrections. If a figure here is wrong, or a citation does not support the sentence it is attached to, tell us. The post gets corrected in place and says what changed.

All research notes