The CLRS Algorithmic Reasoning Benchmark

Petar Velickovic, Adrià Puigdomènech Badia, David Budden, Razvan Pascanu, Andrea Banino, Misha Dashevskiy, Raia Hadsell, Charles Blundell

Abstract

Neural networks excel at pattern recognition and fuzzy perception but often fail to replicate the strict, extrapolative logic inherent in classical algorithms. This paper introduces the CLRS-30 benchmark, a comprehensive suite of 30 classic algorithms derived from the seminal Introduction to Algorithms textbook. By framing algorithmic execution as a graph-based learning task and providing intermediate execution "hints," the benchmark establishes a rigorous framework for evaluating how well neural architectures can learn to execute and generalize algorithmic logic to unseen problem scales.

1. Introduction

Classical algorithms and neural networks represent two distinct paradigms of computation. Algorithms are interpretable, verifiable, and generalize perfectly to inputs of any size, yet they require rigid, manually defined inputs. Conversely, neural networks are flexible and robust to noise but struggle with the kind of systematic generalization required for logical reasoning.

"Algorithmic reasoning" is the pursuit of bridging this gap by training neural models to mimic the step-by-step logic of classical algorithms. Historically, progress in this field has been hindered by fragmented evaluation; researchers often developed bespoke datasets for specific tasks, making cross-model comparison difficult. The CLRS-30 benchmark addresses this by providing a unified, standardized platform to consolidate research and lower the barrier to entry for evaluating neural algorithmic reasoning.

2. The CLRS-30 Benchmark

The benchmark consists of 30 algorithms sourced from the Introduction to Algorithms textbook (Cormen, Leiserson, Rivest, and Stein). These algorithms cover a broad spectrum of computer science fundamentals, categorized into:

  • Sorting and Searching: Including Quicksort, Insertion Sort, and Binary Search.
  • Dynamic Programming: Such as Matrix Chain Multiplication and Longest Common Subsequence.
  • Graph Theory: Including Dijkstra’s algorithm, Depth-First Search (DFS), and Kruskal’s algorithm.
  • String Processing: Featuring Naïve matching and the Knuth-Morris-Pratt (KMP) algorithm.
  • Computational Geometry: Including Graham Scan and Segment Intersection.

To evaluate true reasoning rather than simple memorization, the benchmark emphasizes out-of-distribution (OOD) generalization. Models are trained and validated on small problem instances (e.g., graphs with 16 nodes) and subsequently tested on significantly larger instances (e.g., graphs with 64 nodes).

3. Methodology

The authors frame algorithmic execution as a graph learning problem. Inputs (such as arrays, strings, or sets) are mapped into a graph structure where elements are nodes and relationships are edges.

3.1 Architecture

The primary architecture follows an encode-process-decode framework. The encoder maps input features into a latent space, a processor network (typically a Graph Neural Network) performs several steps of computation, and a decoder maps the latent states back to the output space.

3.2 The Role of "Hints"

A critical innovation in CLRS-30 is the use of hints. Rather than training models solely on input-output pairs, the benchmark provides time-series data of the algorithm's intermediate states—such as the movement of pointers or the current values in a priority queue. These hints force the network to learn the underlying process of the algorithm, discouraging the model from finding statistical shortcuts that do not generalize.

3.3 Baseline Processors

The authors evaluated several processor architectures:

  • Deep Sets: A baseline that treats nodes independently.
  • Graph Attention Networks (GAT): Utilizing self-attention to weigh neighbor interactions.
  • Message-Passing Neural Networks (MPNN): Fully connected GNNs facilitating global communication.
  • Pointer Graph Networks (PGN): Architectures that restrict reasoning to edges identified as relevant by the algorithm's pointers.

4. Key Insights and Results

4.1 The Generalization Gap

The experiments revealed a stark contrast between in-distribution and OOD performance. While MPNNs achieved a high average F1 score of 96.63% on the validation set (size 16), their performance dropped significantly when tested on larger instances (size 64). This suggests that high expressive power can lead to memorization of the training distribution rather than the acquisition of algorithmic logic.

4.2 Architecture Robustness

Pointer Graph Networks (PGNs) proved to be the most robust architecture for OOD tasks, achieving an average F1 score of 50.84% on size-64 instances, outperforming standard MPNNs (44.99%). The success of PGNs suggests that inductive biases—specifically those that align with the pointer-based nature of many algorithms—are essential for generalization.

4.3 Task-Specific Vulnerabilities

Certain classes of algorithms remain extremely challenging for current neural models. Algorithms requiring long-range sequential rollouts (like DFS) or recursive structures (like Quicksort) saw performance plummet to single-digit F1 scores. This indicates that current GNN architectures struggle to maintain state over long horizons or handle nested logic.

5. Conclusion and Future Work

The CLRS-30 benchmark demonstrates that algorithmic reasoning is far from a solved problem. Even the most successful models experience a massive performance degradation when extrapolating to larger problem sizes. The benchmark highlights the need for novel architectures capable of handling recursion, long-range dependencies, and more sophisticated inductive biases. Future iterations of the benchmark may expand to include NP-hard problems and data structures, providing a continuous challenge for the development of truly reasoning-capable AI.

Summary updated

BibTeX
@inproceedings{velickovic2022clrs,
  author = {Petar Velickovic and Adrià Puigdomènech Badia and David Budden and Razvan Pascanu and Andrea Banino and Misha Dashevskiy and Raia Hadsell and Charles Blundell},
  title = {{The CLRS Algorithmic Reasoning Benchmark}},
  booktitle = {International Conference on Machine Learning},
  year = {2022},
}
Figure