On the Markov Property of Neural Algorithmic Reasoning: Analyses and Methods

Montgomery Bohde, Meng Liu, Alexandra Saxton, Shuiwang Ji

Introduction

Neural Algorithmic Reasoning (NAR) focuses on training neural networks to execute classical algorithms, such as sorting or shortest-path finding, in a step-by-step manner. The standard architectural paradigm for NAR is the encoder-processor-decoder framework. In this setup, the model encodes the current algorithmic state (hints) into a latent space, processes it via a Graph Neural Network (GNN), and decodes the result to predict the subsequent state.

A critical observation made in this research is that classical algorithms are inherently Markovian: the current state contains all necessary information to determine the next step. Despite this, many existing NAR models rely on "historical embeddings"—concatenating hidden states from previous time steps with current inputs. This paper argues that such reliance on history is not only theoretically redundant but practically detrimental to out-of-distribution (OOD) generalization.

The Markov Property and the "History Crutch"

In a Markovian process, the transition to the next state depends only on the current state. For example, in a sorting algorithm, the current arrangement of elements and the pointers to the elements being compared are sufficient to decide the next swap. Knowing the state of the list several steps ago provides no additional utility for the current operation.

Existing models often incorporate historical embeddings to stabilize training. However, this creates a "history crutch." During inference, especially on larger problem sizes (OOD), the errors in these historical embeddings accumulate, leading to "noise" that degrades performance. The authors hypothesize that for a neural model to truly learn an algorithm, its architecture must align with the task's mathematical properties—specifically, its Markovian nature.

Proposed Architectures: ForgetNet and G-ForgetNet

To address this misalignment, two architectures are introduced to enforce Markovian reasoning:

1. ForgetNet

ForgetNet is a "purist" Markovian model. It eliminates the dependency on previous hidden states entirely, forcing the processor to rely solely on the encoded features of the current step. While this aligns perfectly with the Markov property, it presents a "cold start" problem during training. Because early-stage predictions are inaccurate, the computational pathway is often too unstable for the model to converge effectively on complex tasks like the Floyd-Warshall algorithm.

2. G-ForgetNet

G-ForgetNet introduces a regularized gating mechanism to bridge the gap between training stability and Markovian inference:

  • Gating Mechanism: A learnable gate decides how much of the historical embedding to let through to the processor.
  • Regularization: An L2 regularization term is added to the loss function to penalize the magnitude of this gate.
  • Training Strategy: Early in training, the gate stays "open" to provide stable computational pathways and help backpropagation. As training progresses, the L2 penalty forces the gate to "close." By the time the model is tested, it has learned to ignore the history and rely solely on the current state, honoring the Markov property.

Experimental Evaluation

The models were evaluated using the CLRS-30 benchmark, the gold standard for neural algorithmic reasoning. The benchmark consists of 30 classical algorithms spanning sorting, searching, graphs, and dynamic programming. Models were trained on small input sizes (e.g., length 16) and tested on much larger sizes (e.g., length 64) to measure true OOD generalization.

Key Results

G-ForgetNet established a new state-of-the-art (SOTA) on the CLRS-30 benchmark:

  • Superior Generalization: G-ForgetNet achieved an overall average score of 82.89%, significantly outperforming the previous SOTA, Triplet-GMPNN (75.98%).
  • Algorithm Mastery: The model surpassed the 99% accuracy threshold on 9 out of 30 algorithms; the previous best model only managed this for a single algorithm.
  • Massive Gains in Specific Tasks: In tasks like Depth First Search (DFS), the improvement was staggering—jumping from a baseline of ~30% to over 74%.
  • Gate Behavior Analysis: Empirical analysis confirmed that the gate magnitude in G-ForgetNet naturally declines toward zero. This validates the intuition that once the model learns to interpret the current state correctly, it no longer finds historical data useful.

Conclusion

The success of G-ForgetNet highlights the importance of architecture-task alignment in neural reasoning. By enforcing the Markov property through a scheduled gating mechanism, the model avoids the pitfalls of historical noise while maintaining training stability. While the current regularization schedule is based on a simple heuristic, future work may involve more sophisticated automated tuning or combining G-ForgetNet with self-supervised learning objectives to create even more robust neural subroutines.

Summary updated

BibTeX
@inproceedings{bohde2024markov,
  author = {Montgomery Bohde and Meng Liu and Alexandra Saxton and Shuiwang Ji},
  title = {{On the Markov Property of Neural Algorithmic Reasoning: Analyses and Methods}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=Kn7tWhuetn},
}
Figure