Discovering Algorithms with Computational Language Processing

Théo Bourdais, Abeynaya Gnanasekaran, Houman Owhadi, Tuhin SahaiarXiv 2025 · DOI

Introduction

Algorithm discovery has traditionally been a human-centric endeavor, relying on intuition, extensive trial-and-error, and informed guesswork. While modern machine learning, particularly Large Language Models (LLMs), has shown promise in code generation, these models often remain anchored to their training data, excelling at remixing known solutions rather than discovering fundamentally new ones. Furthermore, the "No Free Lunch" theorem suggests that no single algorithm is optimal for all problems; yet, most solvers are designed for broad problem classes, missing opportunities for instance-specific optimization.

This paper introduces Computational Language Processing (CLP), a framework that reimagines algorithms as "sentences" composed of discrete computational "tokens." By treating computation as a formal language, the system can autonomously discover, optimize, and generate high-performance algorithms for NP-hard combinatorial problems and quantum circuits.

Methodology: Algorithms as Language

The CLP framework is built upon three core pillars designed to move algorithm discovery toward a hierarchical, instance-adaptive computational abstraction.

1. Computational Alphabet and Primitives

The system defines a "computational alphabet" of primitives—basic operations such as gradients, loops, or matrix assignments. An algorithm is then viewed as a structured sequence of these tokens. This abstraction allows the search space to be treated with the same tools used in natural language processing.

2. Ensemble MCTS and Reinforcement Learning

To navigate the vast space of possible token sequences, CLP employs an architecture inspired by AlphaZero. A Transformer-based policy and value network guides an ensemble Monte Carlo Tree Search (MCTS). Because many algorithms involve stochastic elements (e.g., random restarts), the "ensemble" approach at each node provides a robust estimate of a path's expected quality.

Overview of the CLP framework, illustrating the computational primitives, an example algorithm sequence, and the MCTS search tree.

3. Algorithmic Byte-Pair Encoding (A-BPE)

A key innovation is the adaptation of Byte-Pair Encoding (BPE) from NLP to the algorithmic domain. A-BPE identifies frequently occurring sequences of simple tokens and merges them into higher-level "tokens." This allows the system to evolve its vocabulary, starting with basic mathematical "letters" and eventually operating with complex heuristic "words" like 2-OPT or Frank-Wolfe.

Illustration of the A-BPE process and the hierarchical subdivision of high-level primitives into low-level computational operations.

Experimental Evaluation

The framework was rigorously tested across three challenging domains:

  • Quadratic Assignment Problem (QAP): Evaluated using standard benchmarks like QAPLIB and specialized generators (CQAP, PQAP).
  • Quantum Search: Focused on optimizing Grover’s algorithm for unstructured search.
  • Quantum Optimization: Applied to MAX-CUT problems to optimize the Quantum Approximate Optimization Algorithm (QAOA).

Key Results and Insights

CLP demonstrated significant performance gains over both human-designed heuristics and commercial solvers:

  • Optimization Benchmarks: In QAP tasks, CLP achieved the global optimum in 100% of CQAP instances and outperformed or matched state-of-the-art methods in nearly 95% of QAPLIB instances, including the commercial solver Gurobi.
  • Quantum Circuit Discovery: The system discovered a novel Grover’s circuit that halved the required circuit depth. By identifying a basis transformation (starting from |1⟩ instead of |0⟩), it simplified the diffusion operator—a nuance previously overlooked by human researchers.
  • QAOA Performance: CLP achieved a 35% improvement in error reduction compared to the standard ADAPT-QAOA implementation. This was largely due to the MCTS's ability to look ahead several steps, avoiding greedy choices that lead to local optima.
  • Instance-Adaptivity: Unlike general-purpose solvers, CLP generates unique "sentences" tailored to specific problem instances, allowing it to exploit local structures for greater efficiency.

Conclusion

Computational Language Processing represents a shift from code-centric to computation-centric algorithm discovery. By evolving its own language of heuristics through A-BPE and MCTS, CLP can uncover efficiencies that elude human intuition. Future work will focus on relaxing grammar constraints to allow for more complex nested structures and incorporating hardware-specific noise profiles to design "hardware-native" quantum algorithms.

Summary updated

BibTeX
@misc{bourdais2025discovering,
  author = {Théo Bourdais and Abeynaya Gnanasekaran and Houman Owhadi and Tuhin Sahai},
  title = {{Discovering Algorithms with Computational Language Processing}},
  year = {2025},
  eprint = {2507.03190},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2507.03190},
}
Figure