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

MatRL: Provably Generalizable Iterative Algorithm Discovery via Monte-Carlo Tree Search

Sungyoon Kim, Rajat Vadiraj Dwaraknath, Longling Geng, Mert Pilanci · DOI

Introduction

Computing matrix functions—such as the inverse ($A^{-1}$), square root ($A^{1/2}$), or sign ($\text{sign}(A)$)—is a fundamental operation in scientific computing and machine learning. These operations are critical for tasks ranging from control theory to second-order optimization in deep neural networks. While classical iterative methods like Newton’s or Halley’s method exist, selecting the optimal sequence of iterations is a non-trivial task. The "best" algorithm often depends on the specific hardware (CPU vs. GPU), numerical precision (float32 vs. float64), and the underlying distribution of the matrix data.

Table showing the variation in operation costs across different hardware and precisions.

As shown in the table above, the relative cost of matrix inversion versus multiplication can vary significantly. For instance, on a GPU, switching from float32 to float64 nearly triples the relative cost ratio. Manually tuning algorithms for every possible environment is inefficient. MatRL addresses this by framing algorithm discovery as a reinforcement learning problem.

Methodology: Algorithm Design as Planning

MatRL utilizes Monte-Carlo Tree Search (MCTS) to automatically discover optimal iterative algorithms. The framework treats the design process as a sequential decision-making task where an agent "plays" a game to find the fastest path to convergence.

State and Action Space

To make the search tractable, MatRL represents the state of a matrix not by its full $n \times n$ entries, but by its spectrum (eigenvalues). The authors prove that for a broad class of congruence-invariant iterations, the algorithm's progress is entirely determined by the evolution of these eigenvalues.

At each step in the search tree, the agent selects an action consisting of:

  1. Iteration Type: Choosing from a library of known methods (e.g., Newton-Schulz, Visser, Halley).
  2. Parameters: Determining specific step sizes or scaling factors using Progressive Widening to handle the continuous parameter space.

Reward and Generalization

The agent is rewarded based on the negative wall-clock time required to reach a target error tolerance ($\epsilon_{tol}$). This objective function ensures the discovered algorithms are optimized for speed on the target hardware. Furthermore, leveraging Random Matrix Theory, the authors demonstrate that algorithms discovered for smaller matrices (e.g., $1000 \times 1000$) generalize to much larger matrices, provided they share the same limiting eigenvalue distribution.

Key Results and Insights

MatRL consistently discovers "hybrid" algorithms that outperform standard library implementations and classical baselines. These hybrids often start with computationally "cheap" iterations to reach a rough neighborhood of the solution before switching to "expensive" but quadratically converging iterations to achieve high precision.

Performance comparison of MatRL against classical baselines for Matrix Sign and Square Root functions.

As illustrated in the plots above, MatRL (green line) achieves the target relative error significantly faster than classical methods like Newton or Halley. In practical applications like ZCA Whitening on the CIFAR-10 dataset, MatRL-discovered algorithms reached machine precision approximately 1.8x faster than the best standard baseline.

Hardware and Precision Adaptivity

One of the most powerful features of MatRL is its ability to adapt to the computing environment. When moved from a CPU to a GPU, or when precision is increased, MatRL automatically shifts its strategy. For example, it may favor operations that are more parallelizable on GPUs or iterations that converge in fewer steps when the cost of individual matrix multiplications increases in float64.

Conclusion and Future Work

MatRL demonstrates that reinforcement learning, specifically MCTS, is a potent tool for mathematical algorithm discovery. By automating the tuning process, it provides a path toward hardware-optimal scientific computing.

Current limitations include a restriction to symmetric matrices and occasional numerical instability due to the spectrum-based state representation. Future research aims to extend the framework to non-symmetric matrices via Singular Value Decomposition (SVD) and to enable the agent to discover entirely new iteration formulas from scratch, rather than selecting from a predefined library.

Summary updated

BibTeX
@misc{kim2025matrl,
  author = {Sungyoon Kim and Rajat Vadiraj Dwaraknath and Longling Geng and Mert Pilanci},
  title = {{MatRL: Provably Generalizable Iterative Algorithm Discovery via Monte-Carlo Tree Search}},
  year = {2025},
  eprint = {2507.03833},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2507.03833},
}
Figure