NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Discrete Neural Algorithmic Reasoning

Gleb Rodionov, Liudmila Prokhorenkova

TL;DR

By forcing neural networks to operate through a finite set of discrete states and separating continuous "scalar" data from logical flow, researchers have created a neural reasoner that achieves 100% accuracy on complex algorithmic tasks. Unlike standard models that fail when tested on larger data, this "Discrete Neural Algorithmic Reasoner" (DNAR) generalizes perfectly and is mathematically provable.

The Problem: Out-of-Distribution Collapse in Neural Reasoners

Neural Algorithmic Reasoning (NAR) is the quest to make neural networks execute classical algorithms, such as Dijkstra’s shortest path or Breadth-First Search (BFS). While modern architectures like Transformers are expressive enough to "contain" these algorithms in their weights, they are notoriously bad at out-of-distribution (OOD) generalization.

A model trained on graphs with 16 nodes might work perfectly, but when tested on 1600 nodes, its performance often collapses to zero. This happens because neural networks operate in continuous weight spaces where small errors accumulate, and attention mechanisms "anneal" (blur) when faced with massive neighborhoods. In contrast, classical algorithms are robust because they are discrete state machines: a "visited" node is a binary state, regardless of whether the graph has ten nodes or ten million.

Methods: The DNAR Architecture

The authors propose DNAR (Discrete Neural Algorithmic Reasoning), which introduces three specific architectural constraints to mimic the discrete nature of classical logic.

DNAR Architecture separating discrete states and scalars
  1. Feature Discretization (Discrete Bottlenecks): Instead of continuous hidden vectors, node and edge features are projected into a fixed, finite set of "states" using a discretization bottleneck (like Gumbel-Softmax during training and Argmax during inference).
  2. Hard Attention: Standard "soft" attention averages information from all neighbors. DNAR uses hard attention to ensure a node receives a message from exactly one neighbor (the "best" one), preventing the signal from being diluted in large graphs.
  3. Separation of Discrete and Continuous Flows: Algorithms often need to handle continuous values (like edge weights or distances). DNAR keeps these "scalars" separate. Scalars are used to determine priorities in the attention block but do not mix with the discrete logical states. A dedicated ScalarUpdate module handles arithmetic (adding, moving, or incrementing values) based on the current discrete state.

By combining these, the model functions as a learnable, discrete state machine that can be trained via gradient descent.

Key Insights and Ideas

  • Provable Correctness: Because the state space is finite and the transitions are discrete, the authors can "unit test" every possible state transition. If the model learns the correct transition table for a few nodes, it is mathematically guaranteed to work for any number of nodes.
  • The "Scalar" Problem: The paper identifies that the "fuzziness" of neural networks is particularly damaging when handling continuous inputs. By restricting scalars to a "read-only" priority role or a strictly controlled update module, they prevent the "drift" that usually kills OOD performance.
  • Minimal Training Data: Surprisingly, the model doesn't need much data. For BFS, a graph with just 4 or 5 nodes is enough for the model to learn the universal logic of the algorithm.
  • Multitask Mastery: A single DNAR model can be trained to perform all six algorithms simultaneously without any loss in performance, suggesting that discrete bottlenecks help the model organize distinct logical subroutines effectively.

Key Results

The researchers evaluated their model using the SALSA-CLRS benchmark, a more challenging version of the standard CLRS-30. Models were trained on tiny graphs (up to 16 nodes) and tested on graphs up to 1600 nodes (a 100x scale increase).

The results are strikingly binary compared to traditional deep learning:

Performance comparison on SALSA-CLRS showing DNAR's perfect generalization
  • Perfect Scores: DNAR achieved 100.0% node-level and graph-level accuracy across all SALSA-CLRS tasks at all test sizes (up to 1600 nodes).
  • Baseline Collapse: Traditional models like Graph Isomorphism Networks (GIN) and Pointer Graph Networks (PGN) saw their graph-level scores drop to 0.0% as the test graph size increased.
  • State-of-the-Art: On the CLRS-30 benchmark, DNAR outperformed recent high-performance models (like G-ForgetNet), which typically hover around 95-99% accuracy but fail to reach the "perfect" 100% mark.

Limitations and Future Work

  • Expressivity Trade-offs: The use of hard attention means the model cannot easily compute "averages" or "sums" across all neighbors in a single step. While this is fine for many classical algorithms, it might limit the model's ability to learn more "heuristic" or fuzzy reasoning tasks.
  • Hint Dependency: The best results were achieved using "hints" (supervision on intermediate execution steps). Training these discrete models without hints (end-to-end) remains a significant challenge, as the discrete bottlenecks make the loss landscape difficult to navigate for standard optimizers.
  • Future Directions: The authors suggest exploring "Discrete Neural Turing Machines" to expand the range of manipulations the model can perform, potentially moving toward learning more complex, nested subroutines.

Summary updated

BibTeX
@inproceedings{rodionov2025discrete,
  author = {Gleb Rodionov and Liudmila Prokhorenkova},
  title = {{Discrete Neural Algorithmic Reasoning}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=Inrv8EXylW},
}
Figure