Lune

NeurIPS2024Top-tier venue

Understanding Transformer Reasoning Capabilities via Graph Algorithms

Clayton Sanford, Bahare Fatemi, Ethan Hall, Anton Tsitsulin, Mehran Kazemi, Jonathan Halcrow, Bryan Perozzi, Vahab Mirrokni

Abstract

Which transformer scaling regimes are able to perfectly solve different classes of algorithmic problems? While tremendous empirical advances have been attained by transformer-based neural networks, a theoretical understanding of their algorithmic reasoning capabilities in realistic parameter regimes is lacking. We investigate this question in terms of the network's depth, width, and number of extra tokens for algorithm execution. Our novel representational hierarchy separates 9 algorithmic reasoning problems into classes solvable by transformers in different realistic parameter scaling regimes. We prove that logarithmic depth is necessary and sufficient for tasks like graph connectivity, while single-layer transformers with small embedding dimensions can solve contextual retrieval tasks. We also support our theoretical analysis with ample empirical evidence using the GraphQA benchmark. These results show that transformers excel at many graph reasoning tasks, even outperforming specialized graph neural networks.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

44 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Transformers Provably Learn Chain-of-Thought Reasoning with Length Generalization cites A Little Depth Goes a Long Way: The Expressive Power of Log-Depth Transformers
  • Transformers Provably Learn Chain-of-Thought Reasoning with Length Generalization cites Large Language Models are Zero-Shot Reasoners
  • Transformers Provably Learn Chain-of-Thought Reasoning with Length Generalization cites Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
  • Transformers Provably Learn Chain-of-Thought Reasoning with Length Generalization cites How Far Can Transformers Reason? The Globality Barrier and Inductive Scratchpad
  • A Little Depth Goes a Long Way: The Expressive Power of Log-Depth Transformers cites Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
  • An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale cites Language Models are Few-Shot Learners
  • Large Language Models are Zero-Shot Reasoners cites Language Models are Few-Shot Learners
  • Large Language Models are Zero-Shot Reasoners cites Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
  • Swin Transformer: Hierarchical Vision Transformer using Shifted Windows cites An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
  • How Far Can Transformers Reason? The Globality Barrier and Inductive Scratchpad cites An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
  • How Far Can Transformers Reason? The Globality Barrier and Inductive Scratchpad cites Large Language Models are Zero-Shot Reasoners
  • How Far Can Transformers Reason? The Globality Barrier and Inductive Scratchpad cites Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
  • Reasoning by Superposition: A Theoretical Perspective on Chain of Continuous Thought cites A Little Depth Goes a Long Way: The Expressive Power of Log-Depth Transformers
  • Reasoning by Superposition: A Theoretical Perspective on Chain of Continuous Thought cites Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers44

  1. Reasoning by Superposition: A Theoretical Perspective on Chain of Continuous ThoughtHanlin Zhu, Shibo Hao, Zhiting Hu, Jiantao Jiao et al.NeurIPS 2025 · 86 citations
  2. A Little Depth Goes a Long Way: The Expressive Power of Log-Depth TransformersWilliam Merrill, Ashish SabharwalNeurIPS 2025 · 62 citations
  3. How Far Can Transformers Reason? The Globality Barrier and Inductive ScratchpadEmmanuel Abbe, Samy Bengio, Aryo Lotfi, Colin Sandon et al.NeurIPS 2024 · 52 citations
  4. The Coverage Principle: How Pre-Training Enables Post-TrainingFan Chen, Audrey Huang, Noah Golowich, Sadhika Malladi et al.ICLR 2026 · 28 citations
  5. Transformers Provably Learn Chain-of-Thought Reasoning with Length GeneralizationYu Huang, Zixin Wen, Aarti Singh, Yuejie Chi et al.NeurIPS 2025 · 22 citations

Builds on31

  1. Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
  2. Swin Transformer: Hierarchical Vision Transformer using Shifted WindowsZe Liu, Yutong Lin, Yue Cao, Han Hu et al.ICCV 2021 · 31,683 citations
  3. Chain-of-Thought Prompting Elicits Reasoning in Large Language ModelsJason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma et al.NeurIPS 2022 · 22,562 citations
  4. An Image is Worth 16x16 Words: Transformers for Image Recognition at ScaleAlexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn et al.ICLR 2021 · 21,477 citations
  5. Large Language Models are Zero-Shot ReasonersTakeshi Kojima, Shixiang Shane Gu, Machel Reid, Yutaka Matsuo et al.NeurIPS 2022 · 8,168 citations

Related papers

  1. Depth-Width Tradeoffs for Transformers on Graph TasksGilad Yehudai, Clayton Sanford, Maya Bechler-Speicher, Orr Fischer et al.NeurIPS 2025 · 10 citations
  2. Transformers Learn Shortcuts to AutomataBingbin Liu, Jordan T. Ash, Surbhi Goel, Akshay Krishnamurthy et al.ICLR 2023 · 11 citations
  3. Compositional Reasoning with Transformers, RNNs, and Chain of ThoughtGilad Yehudai, Noah Amsel, Joan BrunaNeurIPS 2025 · 7 citations
  4. What Can Transformer Learn with Varying Depth? Case Studies on Sequence Learning TasksXingwu Chen, Difan ZouICML 2024 · 22 citations
  5. Simulation of Graph Algorithms with Looped TransformersArtur Back de Luca, Kimon FountoulakisICML 2024 · 31 citations
Dusk over the sea between two cliffs drawn in fine vertical lines