Manuscript Offprint
arXiv:2609.00748Measuring Optimal Transport in Transformer Depth
Abstract
A transformer carries each token's state from layer to layer, and the whole vocabulary carried together forms a cloud that moves with depth. We ask whether a trained network moves this cloud the way optimal transport would: at the cheapest cost, and along the map that pairs each token with its optimal destination. We measure both on Pythia-160m and Pythia-410m, with an exact assignment between consecutive layer clouds, a measured sampling floor, calibration on couplings known to be optimal, and a split of the cost into the common shift of the cloud and the token-specific moves. At the last layer, both models move their tokens where the optimal-transport map sends them, at the optimal cost for Pythia-410m and slightly above it for Pythia-160m. At the first layer they do not. In between, single layers can be judged on cost at only two of ten transitions, and blocks of several layers move the cloud at close to the optimal cost. The agreement at the last layer is much weaker at initialisation (0.64 against 0.86) and grows with training.
1 Introduction
A transformer with layers turns each token vector into . At layer 0 the state is the embedding of the current token, so there are as many distinct points as the vocabulary cardinality. From layer 1 on, states depend on context, so there are as many points as token occurrences. Taken together, the states of a corpus form a cloud at layer . The network moves the first cloud onto the second with a specific pairing, token goes from to .
Optimal transport asks what the cheapest way to move onto would be if the pairing were free, paying squared distance per point:
For this cost, the optimal pairing is unique and is the gradient of a convex function, [Brenier, 1991].
In this paper, we ask whether the network's own pairing is that particular one. To do so, we study the transport efficiency of Pythia-160m and Python 410M, layer per layer, over a sample of token positions obtained on a subset of WikiText-103 and Piles datasets. A following question we study is whether the move of token from layer to matches the optimal-transport displacement .
There are several practical interests in answering these questions. If a layer follows that map, its action on all tokens is summarised by a single convex potential, so the layer can be replaced by a (possibly) cheap optimal-transport surrogate for analysis [Makkuva et al., 2020, Korotin et al., 2023], and the methods that merge models [Singh and Jaggi, 2020] or align their representations [Alvarez-Melis and Jaakkola, 2018] with optimal transport can be applied with the guarantee that the network's own map is of the same kind. In addition, the distance to the cheapest move is a label-free measure of wasted motion [Finlay et al., 2020, Kan et al., 2025], usable to compare layers and models, and the agreement with the optimal map across training checkpoints [Biderman et al., 2023] shows when and where a layer's function forms.
Preprint.
We make three contributions. The first is the question itself. To our knowledge, this is the first empirical test of whether the layer-to-layer map of a trained transformer acts as optimal transport between its own consecutive layer clouds, using the coupling the network defines, both in cost and in the pairing it induces. The second is a measurement protocol for optimal transport between layer transitions: the sampling error is measured and subtracted, the readings are calibrated on couplings known to be optimal, the common shift of the cloud is separated from the token-specific moves, and a lower bound that needs no calibration is provided. The third is the result: on Pythia-160m and Pythia-410m, the last layer moves its tokens along the optimal-transport map, this agreement appears with training, and the cost of the network's moves is optimal wherever it can be measured, with one exception at the exit of the smaller model.
The rest of the paper is organized as follows. Section 2 discusses related work. Section 3 studies the cost of the network's moves and Section 4 their agreement with the optimal-transport map. We conclude in Section 5.
Attention and optimal transport. Doubly stochastic attention is read as a Wasserstein gradient flow [Sander et al., 2022], and attention formulated as semi-relaxed entropic OT inside a layer, with GPT-2 drift profiles [Wang and Wang, 2025]. Both place optimal transport inside the attention operation, at a fixed regularisation. We place it between consecutive layer clouds, unregularised, and test the network's coupling against the exact optimal one; neither work contains an efficiency or map test.
OT-regularised flows. OT-Transformer [Kan et al., 2025] and rectified flows [Liu et al., 2023] add a kinetic-energy penalty so that the learned flow takes optimal paths. They impose the property we measure: our question is whether a transformer trained with no such penalty sits near the optimal coupling anyway.
Depth as dynamics. Linear-drift SDEs fitted to layer trajectories [Sarfati et al., 2025] and linear cross-layer lenses [Belrose et al., 2023] describe depth by a fitted linear map. Our linear baseline is the optimal-transport member of that family, and our control asks what the network does beyond it: at the 160m exit one third of the move is beyond any linear map, and 61% beyond the optimal linear map , and still follows optimal transport.
3 Transport efficiency
When a layer moves the cloud of token states from layer to , does it pay the smallest possible price for that change of cloud? The smallest possible price is the optimal-transport cost between the two clouds:
the minimum being over all pairings of the two clouds. Since the network's pairing is one candidate, , and means the network is a perfect mover. Because a common shift of the whole cloud is exactly optimal (and in fact dominates most transitions), the question is asked on the token-specific part:
Write for token 's move and for the mean move. Then
Table 1: Transport efficiency of Pythia-160m (16-d camera, , three seeds). Each efficiency is shown next to what an optimal coupling reads through the same instrument; is the lower bound from all types; block rows pair layer with directly. n.r.: not resolvable.
| transition | raw | token-specific | |||||
|---|---|---|---|---|---|---|---|
| floor / | optimal reads | [seed range] | optimal reads | ||||
| 0→1 | 0.08 | 3.8 | 0.98 | 1.00 | 1.02 [1.00–1.04] | 1.01 | 0.94 |
| 1→2 | 0.51 | 3.4 | 0.90 | 0.99 | n.r. | – | 0.32 |
| 2→3 | 0.50 | 0.7 | 0.82 | 0.99 | n.r. | – | 0.60 |
| 3→4 | 0.09 | 0.1 | 0.99 | 0.93 | 1.07 [1.03–1.15] | 1.13 | 0.78 |
| 4→5 | 2.73 | 1.2 | n.r. | – | n.r. | – | 0.36 |
| 5→6 | 2.92 | 5.3 | n.r. | – | n.r. | – | 0.22 |
| 6→7 | 2.47 | 1.4 | n.r. | – | n.r. | – | 0.18 |
| 7→8 | 0.73 | 3.7 | 0.90 | 0.94 | n.r. | – | 0.21 |
| 8→9 | 0.59 | 6.3 | 0.92 | 0.96 | n.r. | – | 0.24 |
| 9→10 | 0.58 | 3.1 | 0.86 | 0.94 | n.r. | – | 0.29 |
| 10→11 | 0.13 | 1.5 | 0.94 | 0.99 | 0.99 [0.97–1.02] | 1.09 | 0.46 |
| 11→12 | 0.11 | 99.0 | 1.00 | 1.00 | 0.86 [0.85–0.87] | 1.00 | 0.73 |
| 3→9, six layers as a block | 0.08 | 1.3 | 0.95 | 1.00 | 0.97 | 0.95 | 0.67 |
| 8→11, three layers as a block | 0.06 | 2.4 | 0.98 | 1.01 | 0.96 | – | 0.48 |
with the cost of the common shift.
We use the two following objects throughout this paper:
-
The mean flow: one point per token type, its residual-stream state averaged over all occurrences in a corpus.
-
The raw states: one point per occurrence, the state at an actual position in an actual document.
We studied Pythia-160m (12 layers) and Pythia-410m (24 layers) [Biderman et al., 2023] and used WikiText-103 and Pile as corpora. On WikiText, we collected 242,015 positions in the full 768-d space, i.e. raw per-occurrence states, leading to 25,268 token types for the corpus-mean token trajectories. On Pile, we collected 46,542 corpus-mean token trajectories only.
We then split the study into two: one in reduced dimension, and one the full space.
3.1 Exact efficiency in a 16-d camera
Protocol We sample 4,000 tokens at layer and an independent 4,000 at , form and solve the assignment exactly using the network simplex of POT [Flamary et al., 2021], the implementation of Bonneel et al. [2011]. This is the of the two samples with no regularisation.
It is computed in a balanced 16-d PCA camera because the error of an empirical Wasserstein distance decays like [Fournier and Guillin, 2015, Weed and Bach, 2019]. Note that because the two samples are independent, the numerator carries a finite-sample floor that the paired denominator does not. As a result, the raw ratio can exceed 1.
To make the number honest, we subtract the assignment cost between two independent samples of the same layer. This is the self-term correction that defines the Sinkhorn divergence [Feydy et al., 2019, Chizat et al., 2020], applied here to the exact assignment and to the target layer only. Where the floor exceeds 30% of the cost in question, the transition is reported as unresolvable. It essentially means that the token-specific moves at that transition are smaller than the typical distance between neighbouring sampled tokens, so we cannot separate them from the sampling gap.
In addition, to calibrate the reading, we feed the same pipeline two couplings that are optimal by construction: 1) a shift with and 2) a radius-matched expansion , built from independent samples of layer . Their reading, 0.85–1.00 across the resolvable transitions, is what looks like through our instrument. Efficiency is reported raw () and on the centered clouds (), with . The whole protocol is repeated over 3 seeds.
Table 2: Transport efficiency of Pythia-410m (16-d camera, , one seed), same columns as Table 1; from all 11,937 types. The block row pairs layer 4 with layer 20 directly, the only resolvable block of this model. Only the transitions resolvable on at least one cost are shown.
| transition | floor / | raw | token-specific | ||||
|---|---|---|---|---|---|---|---|
| optimal reads | optimal reads | ||||||
| 0→1 | 0.06 | 4.3 | 0.98 | 0.98 | 1.01 | 1.01 | 0.99 |
| 5→6 | 0.02 | 0.2 | 1.11 | 0.99 | 0.97 | 1.09 | 0.83 |
| 6→7 | 0.09 | 0.2 | 1.24 | 1.17 | 0.93 | 0.92 | 0.99 |
| 22→23 | 0.08 | 0.5 | 0.87 | 1.23 | 1.02 | 0.93 | 0.85 |
| 23→24 (exit) | 0.05 | 1.6 | 0.98 | 0.98 | 0.99 | 1.09 | 0.49 |
| 4→20, sixteen layers as a block | 0.02 | 1.0 | 0.97 | 1.00 | 0.96 | 1.03 | 0.86 |
Table 3: in the full 768-d space and in the 16-d camera, Pythia-160m WikiText mean flow, with the share of the common-shift energy and of the token-specific energy that the camera keeps.
| transition | 0→1 | 1→2 | 2→3 | 3→4 | 4→5 | 5→6 | 6→7 | 7→8 | 8→9 | 9→10 | 10→11 | 11→12 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| , full space | 1.5 | 1.5 | 0.7 | 0.3 | 1.0 | 1.8 | 1.0 | 1.8 | 2.5 | 2.1 | 1.6 | 84 |
| , camera | 3.7 | 3.1 | 0.6 | 0.1 | 1.2 | 5.2 | 1.4 | 3.7 | 6.2 | 3.1 | 1.5 | 109 |
| kept by camera | 0.74 | 0.55 | 0.29 | 0.30 | 0.24 | 0.46 | 0.24 | 0.64 | 0.70 | 0.36 | 0.49 | 0.84 |
| kept by camera | 0.30 | 0.26 | 0.30 | 0.83 | 0.20 | 0.16 | 0.17 | 0.32 | 0.28 | 0.24 | 0.52 | 0.65 |
Results We report the results in Tables 1 and 2, respectively for Pythia-160m and Pythia-410m and in Table 3 the ratio in the full space next to its camera value, which shows how the camera changes that ratio.
A shift of the whole cloud is optimal for free, and it dominates the cost: is 1.5–2.5 in the full space at most transitions and 84 at the 160m exit. The camera changes by up to a factor of three either way, since it keeps different shares of the shift and of the token-specific movement at each transition (Table 3), but the full-space values, computed without a camera, show the same behavior. Therefore, we are confidence that using the reduced space does not alter the general conclusions.
Once the common shift is removed, the network’s move can be compared with the cheapest move properly. At three of the four measurable transitions in Pythia-160m (entry, 3→4, 10→11) and at every measurable transition in Pythia-410m, the network coupling is optimal, within the instrument’s precision of 10–15%. In particular, at the entry, the sliced bound says the true efficiency is at least 0.94, so the network is within 6% of optimal there.
One measured gap: the 160m exit. The token-specific efficiency reads 0.86 where the calibration reads 1.00. The network pays between 14% and 27% more than the cheapest move there. The 410m exit shows no gap. It remains an open question to know if this is a property of the model or the scale.
Between layers 4 and 10 the token-specific moves are tiny compared with the distance between tokens. The token-specific moves there are too small for 4,000 samples to resolve, and the sliced bound only says the efficiency is above 0.2–0.4. No cost verdict either way at the single-layer scale. However, pairing layer directly with layer makes the accumulated step resolvable once it is large enough: six layers in the early middle (3→9 reads against a calibration of 0.95) and three in the late middle (8→11 reads 0.96).
Similarly, most transitions of Pythia-410m are not resolvable. With twice the depth, each layer moves its tokens less relative to their spacing (the token-specific movement is 3–6% of the cost in the middle, against 16–32% for Pythia-160m), and a larger sample would help only slowly. Our hypothesis is that those small moves are linear, as the 410m exit is to within resolution but testing it is left for future work.
3.2 A lower bound without calibration
Protocol We use the sliced Wasserstein construction [Bonneel et al., 2015]. For a random unit direction , we project every point on , sort, and compute the sorted cost , which is the exact optimal transport in one dimension. Since and sorting is the minimum over all pairings of the projected points, , with equality for a shift or a uniform scaling and a strict inequality in general. Averaging over 2,000 directions on the centered clouds

Figure 1: Rank agreement between the network's move and the optimal-transport move, against depth, both models, 16-d camera, exact assignment on the centered clouds, with the shuffled-pairing null (grey). Agreement rises from the entry to the exit on both models.
inside the camera, with all 25,268 types on both sides and no sampling, gives
a lower bound on the token-specific efficiency that needs no sampling, no floor and no calibration.
Because it is a lower bound, the true efficiency is at least (Tables 1 and 2): 0.94 at the entry and 0.73 at the exit of Pythia-160m, and 0.86 over the sixteen-layer block of Pythia-410m, with no assumption.
In conclusion, wherever the cost can be measured, the network moves its tokens at the price of an optimal coupling, with one exception, the exit of Pythia-160m, which pays 14 to 27% more.
4 Agreement with the Brenier map
The second question is whether token 's actual move matches the Brenier route . On the centered clouds, the exact assignment sends each sampled token to the destination an optimal mover would choose. We compare the network's move with the optimal move by the Spearman rank agreement of the pooled components and by the median cosine between the two moves. Because both clouds are centered, a common shift cannot create agreement.
We present the results in Table 4, including a null shuffle as control. Agreement between the network's move and the optimal-transport move rises with depth (Figure 1). The 410m curve dips near 0.4 of depth, at the transitions where its tokens move least. At the 160m exit the common shift is 99% of the cost ( 84 in the full space), so the map result concerns the remaining 1%, which is resolvable (floor 0.11 of ). On Pythia-160m, is 0.41 at the entry, 0.38–0.62 in the middle, 0.80 at and 0.89 at the exit, where the median cosine is 0.95 (Figure 2, and Figure 3 for all twelve transitions). Pile mean flows and raw states follow the same profile (exit 0.85 and 0.74). Pythia-410m ends at 0.88, median cosine 0.95. Seed ranges are , and the shuffled-pairing null stays at . The network's move is the optimal-transport move at the last layer, partly so in the middle, and barely at the first.
Is the agreement with the optimal-transport map more than a linear change? To answer this, we fitted a linear optimal map, the Gaussian Brenier map , from means and covariances (definition and full table in Appendix A). It explains 39% of the token-specific move at the 160m exit, and the remaining 61% still agrees with the exact optimal transport ( 0.83, median cosine 0.94, null 0.01). At the 410m exit and at 160m the linear map explains 90% and 73% and the remainder is below the floor. Elsewhere the linear map fits the network's moves at least as well as the full OT map and the remainder agrees at 0.27–0.36. In conclusion, the answer is yes for the 160m exit and no for every other transition we can resolve.

Figure 2: For each token, the displacement prescribed by the exact optimal transport between the two layer clouds (horizontal) against the displacement the network actually applied (vertical), all 16 camera coordinates pooled, shown as a density. Agreement is the diagonal. is the rank agreement of the pooled components.
Table 4: Map agreement, 16-d camera, exact assignment on the centered clouds. : rank agreement of the network's move with the optimal-transport move, per object; median cosine on WikiText; null from the shuffled pairing, the largest of the three objects. Seed ranges of are . Pythia-410m rows: WikiText only.
| transition | WikiText | Pile | raw states | median cos | null |
|---|---|---|---|---|---|
| 0→1 | 0.41 | 0.17 | 0.21 | 0.58 | 0.02 |
| 1→2 | 0.48 | 0.45 | 0.38 | 0.60 | 0.01 |
| 2→3 | 0.57 | 0.63 | 0.48 | 0.62 | 0.02 |
| 3→4 | 0.59 | 0.62 | 0.56 | 0.92 | 0.16 |
| 4→5 | 0.60 | 0.54 | 0.40 | 0.65 | 0.03 |
| 5→6 | 0.38 | 0.29 | 0.26 | 0.40 | 0.00 |
| 6→7 | 0.46 | 0.38 | 0.27 | 0.48 | 0.01 |
| 7→8 | 0.62 | 0.56 | 0.40 | 0.71 | 0.01 |
| 8→9 | 0.61 | 0.52 | 0.38 | 0.69 | 0.01 |
| 9→10 | 0.57 | 0.51 | 0.36 | 0.65 | 0.01 |
| 10→11 | 0.80 | 0.76 | 0.50 | 0.87 | 0.04 |
| 11→12 | 0.89 | 0.85 | 0.74 | 0.95 | 0.08 |
| 410m 0→1 | 0.50 | - | - | 0.66 | 0.01 |
| 410m 5→6 | 0.59 | - | - | 0.97 | 0.10 |
| 410m 6→7 | 0.46 | - | - | 0.95 | 0.10 |
| 410m 22→23 | 0.70 | - | - | 0.86 | 0.09 |
| 410m 23→24 | 0.88 | - | - | 0.95 | 0.06 |
Is the exit agreement learned? We repeat the measurement on Pythia-160m untrained (checkpoint step0), early in training (step4000) and fully trained, all from the same 5,000 documents. Exit rank agreement goes from 0.64 to 0.67 to 0.86 (median cosine 0.74, 0.75, 0.94), and at from 0.18 to 0.42 to 0.77. At the entry the order reverses: 0.52 untrained against 0.37 trained. Therefore, the rise to 0.86 is learned, and mostly after step 4000. Training does not push the whole network toward optimal transport. It pushes the exit toward it () and the entry away from it (). The linear control explains the 0.64: at initialisation the exit move is linear (a linear map explains 97% of it), and a linear map agrees with optimal transport by construction. Training replaces it by a move that is almost entirely non-linear, and that part follows optimal transport ( 0.81).
5 Conclusion
In this paper, we asked whether a trained transformer moves its token states the way optimal transport would. Two questions: does each layer pay the cheapest cost, and does each token go where the optimal map sends it? To answer these questions, we compared the moves of Pythia-160m and Pythia-410m with exact optimal transport between consecutive layers, on two corpora, in a 16-dimensional projection.

Figure 3: For each transition of Pythia-160m, the network's move (blue) and the optimal-transport move (orange) for the token sample, drawn as bin means in the leading plane of the layer- cloud (16-d camera, centered clouds, exact assignment). One arrow scale per panel. is the rank agreement of the pooled 16-d components.
On cost, the token-specific move of the network is at the optimal reading at every transition we could resolve, except the last transition of Pythia-160m. On the map, the agreement between the network's move and the optimal-transport move increases with depth and reaches 0.89 at the last transition of Pythia-160m and 0.88 for Pythia-410m. This agreement is much weaker at initialisation and grows with training, while at the entry it decreases. For Pythia-160m it holds beyond any linear transformation of the cloud and for Pythia-410m it is accounted for by a linear map.
Our study suffers from several limitations, the main one being the resolution. With 4,000 tokens per sample, only the transitions where tokens move further than the sampling gap can be resolved: four of twelve in Pythia-160m and five of twenty-four in Pythia-410m. The middle layers could only be assessed in blocks of several layers. We can address this with larger sample and the required compute power. Another obvious limitation is that the study covers only two small models of one family on two small corpora. Finally, the mean flow averages each token over its contexts, which raises the agreement relative to raw states.
Despite these limitations, the picture that emerges is that the last layer of a trained transformer acts as an optimal-transport map on its cloud of states, the first layer does not, and the middle layers move each token too little to be judged one layer at a time. Several questions remain open. The middle layers may be linear, as the last layer of Pythia-410m is, but an instrument with finer resolution is needed to tell. The cost gap at the last layer of Pythia-160m, absent in Pythia-410m, may close with scale or may just be an artifact of Pythia's models. Finally, nothing in our results says whether the agreement with optimal transport is a property of language models or of trained transformers in general.
References
David Alvarez-Melis and Tommi Jaakkola. Gromov-Wasserstein alignment of word embedding spaces. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pages 1881–1890, 2018.
Nora Belrose, Igor Ostrovsky, Lev McKinney, Zach Furman, Logan Smith, Danny Halawi, Stella Biderman, and Jacob Steinhardt. Eliciting latent predictions from transformers with the tuned lens. arXiv preprint arXiv:2303.08112, 2023.
Stella Biderman, Hailey Schoelkopf, Quentin Gregory Anthony, Herbie Bradley, Kyle O'Brien, Eric Hallahan, Mohammad Aflah Khan, Shivanshu Purohit, USVSN Sai Prashanth, Edward Raff, Aviya Skowron, Lintang Sutawika, and Oskar van der Wal. Pythia: A suite for analyzing large language models across training and scaling. In ICML, volume 202 of PMLR, pages 2397–2430, 2023.
Nicolas Bonneel, Michiel van de Panne, Sylvain Paris, and Wolfgang Heidrich. Displacement interpolation using Lagrangian mass transport. ACM Transactions on Graphics, 30(6):158:1–158:12, 2011.
Nicolas Bonneel, Julien Rabin, Gabriel Peyré, and Hanspeter Pfister. Sliced and radon wasserstein barycenters of measures. Journal of Mathematical Imaging and Vision, 51(1):22–45, 2015.
Yann Brenier. Polar factorization and monotone rearrangement of vector-valued functions. Communications on Pure and Applied Mathematics, 44(4):375–417, 1991.
Lénaïc Chizat, Pierre Roussillon, Flavien Léger, François-Xavier Vialard, and Gabriel Peyré. Faster Wasserstein distance estimation with the Sinkhorn divergence. In Advances in Neural Information Processing Systems, volume 33, 2020.
Jean Feydy, Thibault Séjourné, François-Xavier Vialard, Shun-ichi Amari, Alain Trouvé, and Gabriel Peyré. Interpolating between optimal transport and mmd using sinkhorn divergences. In AISTATS, volume 89 of PMLR, pages 2681–2690, 2019.
Chris Finlay, Jörn-Henrik Jacobsen, Levon Nurbekyan, and Adam Oberman. How to train your neural ODE: the world of Jacobian and kinetic regularization. In Proceedings of the 37th International Conference on Machine Learning, volume 119, 2020.
Rémi Flamary, Nicolas Courty, Alexandre Gramfort, Mokhtar Z. Alaya, Aurélie Boisbunon, Stanislas Chambon, Laetitia Chapel, Adrien Corenflos, Kilian Fatras, Nemo Fournier, Léo Gautheron, Nathalie T. H. Gayraud, Hicham Janati, Alain Rakotomamonjy, Ievgen Redko, Antoine Rolet, Antony Schutz, Vivien Seguy, Danica J. Sutherland, Romain Tavenard, Alexander Tong, and Titouan Vayer. POT: Python optimal transport. Journal of Machine Learning Research, 22(78):1–8, 2021.
Nicolas Fournier and Arnaud Guillin. On the rate of convergence in wasserstein distance of the empirical measure. Probability Theory and Related Fields, 162(3–4):707–738, 2015.
Takashi Furuya, Maarten V. de Hoop, and Matti Lassas. Transformers through the lens of support-preserving maps between measures. arXiv preprint arXiv:2509.25611, 2025.
Borjan Geshkovski, Cyril Letrouit, Yury Polyanskiy, and Philippe Rigollet. A mathematical perspective on transformers. Bulletin of the American Mathematical Society, 62(3):427–479, 2025.
Kelvin Kan, Xingjian Li, and Stanley Osher. OT-Transformer: A continuous-time transformer architecture with optimal transport regularization. arXiv preprint arXiv:2501.18793, 2025.
Alexander Korotin, Daniil Selikhanovych, and Evgeny Burnaev. Neural optimal transport. In International Conference on Learning Representations, 2023.
Xingchao Liu, Chengyue Gong, and Qiang Liu. Flow straight and fast: Learning to generate and transfer data with rectified flow. In ICLR, 2023.
Ashok Makkuva, Amirhossein Taghvaei, Sewoong Oh, and Jason Lee. Optimal transport mapping via input convex neural networks. In Proceedings of the 37th International Conference on Machine Learning, volume 119, 2020.
Michael E. Sander, Pierre Ablin, Mathieu Blondel, and Gabriel Peyré. Sinkformers: Transformers with doubly stochastic attention. In AISTATS, volume 151 of PMLR, pages 3515–3530, 2022.
Raphaël Sarfati, Toni J. B. Liu, Nicolas Boullé, and Christopher J. Earls. Lines of thought in large language models. In ICLR, 2025.
Sidak Pal Singh and Martin Jaggi. Model fusion via optimal transport. In Advances in Neural Information Processing Systems, volume 33, 2020.
James Vuckovic, Aristide Baratin, and Remi Tachet des Combes. A mathematical theory of attention. arXiv preprint arXiv:2007.02876, 2020.
Hong Wang and Kelly Wang. Transformers as optimal transport: Stability, geometry, and gauge symmetry. OpenReview submission 2A2vRGHW16 to ICLR 2026, 2025. Not accepted; unpublished at the time of writing.
Jonathan Weed and Francis Bach. Sharp asymptotic and finite-sample rates of convergence of empirical measures in Wasserstein distance. Bernoulli, 25(4A):2620–2648, 2019.
A Linear map and remainder
This appendix gives the numbers behind the linear-map control of Section 4. The question is whether the agreement between the network's move and the optimal-transport move could come from a linear transformation of the whole cloud, a shift and a stretch, rather than from a token-by-token rearrangement.
The linear map is the Gaussian Brenier map . For two clouds with means and covariances , it is the optimal transport between the two Gaussians with those statistics,
with symmetric positive definite, so that is the gradient of a convex quadratic and hence a Brenier map. It maps the first cloud onto one with exactly the mean and covariance of the second, and it is fitted from those statistics alone. We measure two things. First, how much of the network's token-specific move the linear map explains, as the and the rank agreement between the linear move and the network's move. Second, what is left: we push the layer- cloud through , take the move that remains from the pushed cloud to the target cloud, and compare it with the exact optimal transport between those two clouds, with the same floor and the same shuffled-pairing null as in the main text. The null reads at every transition.
Table 5 reports both. At the exit of Pythia-160m the linear map explains 39% of the move and the remainder, 61% of the cost, still agrees with optimal transport at 0.83. At the exit of Pythia-410m and at of Pythia-160m the linear map explains 90% and 73%, and the remainder is smaller than its own floor, so its agreement cannot be measured. This last point matters for reading the table: a low remainder agreement next to a floor above one means "not resolvable", not "weak".
Table 5: Linear-map control, 16-d camera, . Linear map: and of the move prescribed by against the network's token-specific move. Remainder: its share of the cost, its floor relative to its own cost, and its agreement with the exact optimal transport (, median cosine). Last column: of the full optimal-transport map, for comparison.
| transition | linear map | remainder | full map | ||||
|---|---|---|---|---|---|---|---|
| share of cost | floor | median cos | |||||
| 160m 0→1 | -0.15 | 0.35 | 1.15 | 0.07 | 0.27 | 0.30 | 0.40 |
| 160m 1→10 | 0.07–0.51 | 0.48–0.76 | 0.49–0.93 | 0.8–4.5 | 0.27–0.36 | 0.32–0.51 | 0.38–0.63 |
| 160m 10→11 | 0.73 | 0.81 | 0.27 | 0.47 | 0.44 | 0.52 | 0.80 |
| 160m 11→12 | 0.39 | 0.62 | 0.61 | 0.26 | 0.83 | 0.94 | 0.89 |
| raw states 11→12 | 0.57 | 0.66 | 0.43 | 0.28 | 0.51 | 0.71 | 0.74 |
| 410m 22→23 | 0.96 | 0.82 | 0.04 | 2.3 | 0.35 | 0.36 | 0.70 |
| 410m 23→24 | 0.90 | 0.91 | 0.10 | 0.54 | 0.47 | 0.54 | 0.88 |