Depth-Width tradeoffs in Algorithmic Reasoning of Graph Tasks with Transformers

Gilad Yehudai, Clayton Sanford, Maya Bechler-Speicher, Orr Fischer, Ran Gilad-Bachrach +1 more
3/3/2025
cs.LGcs.AIcs.CL

No confident code implementation found for this paper.

Abstract

Transformers have revolutionized the field of machine learning. In particular, they can be used to solve complex algorithmic problems, including graph-based tasks. In such algorithmic tasks a key question is what is the minimal size of a transformer that can implement a task. Recent work has begun to explore this problem for graph-based tasks, showing that for sub-linear embedding dimension (i.e., model width) logarithmic depth suffices. However, an open question, which we address here, is what happens if width is allowed to grow linearly. Here we analyze this setting, and provide the surprising result that with linear width, constant depth suffices for solving a host of graph-based problems. This suggests that a moderate increase in width can allow much shallower models, which are advantageous in terms of inference time. For other problems, we show that quadratic width is required. Our results demonstrate the complex and intriguing landscape of transformer implementations of graph-based algorithms. We support our theoretical results with empirical evaluations.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{yehudai2025depthwidth,
  title  = {Depth-Width tradeoffs in Algorithmic Reasoning of Graph Tasks with Transformers},
  author = {Gilad Yehudai and Clayton Sanford and Maya Bechler-Speicher and Orr Fischer and Ran Gilad-Bachrach and Amir Globerson},
  year   = {2025},
  eprint = {2503.01805},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2503.01805v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2503.01805.svg)](https://codeofpaper.com/paper/2503.01805)

Discussion