Simulation of Graph Algorithms with Looped Transformers
Artur Back de Luca, Kimon Fountoulakis

TL;DR
This paper demonstrates that looped transformer networks with additional attention heads can theoretically simulate various graph algorithms, including Dijkstra's and DFS, with fixed parameters regardless of graph size, and establishes their Turing completeness.
Contribution
It provides a theoretical proof that looped transformers can simulate multiple graph algorithms simultaneously with fixed parameters, and shows their Turing completeness.
Findings
Transformers can simulate algorithms like Dijkstra's and DFS.
Simulation is possible with fixed network size regardless of graph size.
Finite precision imposes limits on simulation accuracy.
Abstract
The execution of graph algorithms using neural networks has recently attracted significant interest due to promising empirical progress. This motivates further understanding of how neural networks can replicate reasoning steps with relational data. In this work, we study the ability of transformer networks to simulate algorithms on graphs from a theoretical perspective. The architecture we use is a looped transformer with extra attention heads that interact with the graph. We prove by construction that this architecture can simulate individual algorithms such as Dijkstra's shortest path, Breadth- and Depth-First Search, and Kosaraju's strongly connected components, as well as multiple algorithms simultaneously. The number of parameters in the networks does not increase with the input graph size, which implies that the networks can simulate the above algorithms for any graph. Despite…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsGraph Theory and Algorithms
