Abstract
The computation of the matrix product $XX^t$ is a cornerstone of statistical analysis and modern machine learning optimization. We introduce RXTX, a novel algorithm discovered through a hybrid Reinforcement Learning (RL) and Mixed Integer Linear Programming (MILP) pipeline. RXTX reduces the number of multiplications and total operations by 5% compared to the previous state-of-the-art. Beyond theoretical gains, RXTX exhibits practical wall-clock speedups on standard CPU architectures, outperforming highly optimized BLAS-3 routines.
Introduction
Finding faster matrix multiplication algorithms remains a primary goal in computer science. While general-purpose algorithms like Strassen’s have seen significant theoretical and AI-driven advancements, structured matrix products—such as the product of a matrix and its transpose ($XX^t$)—have been less explored. This operation is ubiquitous in computing covariance matrices, linear regression, and the training of Large Language Models (LLMs) via optimizers like Muon, SOAP, and Shampoo.
Historically, the state-of-the-art for $XX^t$ relied on recursive application of Strassen’s algorithm to 2x2 block matrices. We demonstrate that by exploiting the specific symmetry of $XX^t$ and utilizing a 4x4 block structure, significant efficiency gains are possible.
Methodology: AI-Driven Algorithm Discovery
The discovery of RXTX was enabled by an automated pipeline combining Reinforcement Learning with combinatorial optimization. To navigate the vast search space of potential algorithms, we employed a two-level approach:
- RL-guided Large Neighborhood Search: An RL agent proposes candidate "rank-1 bilinear products," which serve as the building blocks for the algorithm.
- Two-Level MILP Pipeline: A Mixed Integer Linear Programming (MILP) solver is used to find linear relations between these products and the target expressions. This offloading reduced the RL agent's action space by a factor of one million compared to previous end-to-end RL methods like AlphaTensor.
Following the discovery of the core multiplication steps, a custom search optimized the addition scheme, reducing the required matrix additions from 139 to 100, thereby ensuring practical utility.
Performance and Results
RXTX provides improvements in both asymptotic complexity and small-matrix performance. For a 4x4 block matrix, RXTX utilizes 8 recursive calls and 26 general products, leading to a 5% asymptotic reduction in multiplications.
As shown in the comparison above, the recursive expression for RXTX ($R(n) = 8R(n/4) + 26M(n/4)$) leads to a non-asymptotic speedup of 10% for $n=4$ matrices, requiring only 34 multiplications compared to the previous best of 38.
In practical benchmarks on an Intel Core i7 CPU, RXTX achieved a 9% wall-clock speedup over standard BLAS-3 routines for $6144 \times 6144$ matrices. While performance is sensitive to hardware at smaller scales, the theoretical crossover point for outperforming recursive Strassen is approximately $n \ge 256$.
Conclusion
RXTX demonstrates that structured matrix operations contain untapped potential for optimization. The hybrid RL-MILP discovery pipeline provides a robust framework for finding hardware-aware, mathematically optimal algorithms. Future work will extend this methodology to other structured bottlenecks in machine learning and scientific computing.
Summary updated