Sakana AI's AutoDiscoLS Evolves Custom Math Solvers That Run 2x Faster
Sakana AI's new framework uses LLM-guided program evolution to rewrite least squares solvers for specific workloads, hitting up to 2x speedups over tuned baselines.
Takeaways
- Sakana AI released AutoDiscoLS, an LLM-guided search that discovers faster least squares solvers tailored to a workload.
- On a 1M-row SUSY kernel regression, discovered algorithms ran 2.0x faster than the best baseline at medium accuracy.
- Built on ShinkaEvolve, candidates are timed against a frozen anchor program to control for machine noise.
- Different accuracy targets produced structurally different algorithms, including a provably correct new stopping rule for an iterative solver.
- LLM-guided search beat TPE Bayesian optimization even on a hand-crafted expert search space (1.46x vs 1.39x).
- Limitations: no worst-case guarantees, poor transfer to much tighter accuracy or very different matrix structure, single-CPU tests only.
Sakana AI has released AutoDiscoLS, a system that uses LLM-guided program evolution to tailor least-squares solvers to a recurring family of matrices and a specified accuracy target. On a held-out particle-physics workload, its discovered programs ran 2.0× and 1.5× faster than the strongest randomized baseline at two accuracy levels.
Least squares finds the vector x that minimizes the residual ||Ax − b||₂, often for a system with more equations than unknowns. Gauss applied an early form of the method to celestial-orbit calculations in 1795. Subsequent algorithms, including Householder QR and randomized sketch-and-precondition methods, have emphasized numerical stability across broad classes of input.
The release includes a project repository, a technical post, and a paper by Marco Pirazzini and Robert Tjarko Lange. A developer supplies representative matrices and an accuracy threshold, runs the search overnight on a workstation, and receives short Python solvers optimized for similar future problems.
One workload, one target
General-purpose routines such as SciPy’s lstsq and torch.linalg.lstsq prioritize stability across many matrix structures. Their CPU implementations commonly rely on LAPACK routines designed to handle inputs whose size, conditioning, and numerical properties are unknown in advance. That generality can leave performance available when the same kind of problem arrives repeatedly.
Randomized numerical linear algebra offers faster options by compressing a matrix with a random sketch, constructing a preconditioner that makes the system easier to solve, and finishing with an iterative method. Runtime depends heavily on the sketch type and size, preconditioner, iterative algorithm, stopping rule, and several numerical constants.
AutoDiscoLS fits those choices to examples from a specific workload. Candidate programs train on one set of matrices and are evaluated on held-out problems, using the same train-and-validation structure common in machine learning. The optimization objective is measured runtime subject to a fixed residual-accuracy requirement.
Code search with an accuracy gate
The search runs on ShinkaEvolve, Sakana AI’s open-source program-evolution framework. It begins with a roughly 30-line sketch-preconditioned iterative solver. During each step, an LLM receives a promising program from the archive and a concise task description, then proposes an edit. Changes can adjust a constant, replace a stopping rule, alter control flow, or switch to another algorithm family.
A candidate enters the archive only if every training problem and repeated run meets the required residual bound. If x* is an exact least-squares solution and x̂ is the candidate’s result, the condition is ||A x̂ − b||₂ ≤ (1 + ε) ||A x* − b||₂. A target of ε = 10−4 permits a residual 0.01% above the optimum, while ε = 10−12 approaches the practical limits of double-precision arithmetic.
Timing without fooling the search
Measured runtime determines which accurate candidates survive, so the evaluation protocol must prevent noisy hardware measurements from steering the search toward lucky runs. The paper uses four controls:
- Each candidate runs against a frozen copy of the starting program, called the anchor.
- Candidate and anchor executions are interleaved on the same problem to reduce differences in cache and thermal state.
- Each problem runs multiple times, with the median runtime ratio suppressing outliers and favorable random seeds.
- Ratios are combined using a geometric mean, while warm-up programs and physical-core pinning reduce machine-level variance.
A physics workload drops to 20.7 seconds
The largest reported test uses SUSY, a particle-physics dataset for classifying signals from high-energy collisions. The researchers converted it into a kernel-regression problem with 2,000 features, searched on matrices containing 100,000 rows, and evaluated the resulting programs on held-out matrices with one million rows.
| Algorithm | ε = 10−4 |
ε = 10−12 |
|---|---|---|
| QR using LAPACK | 242.7 s | 243.2 s |
| Cholesky | 45.6 s | Target missed |
| Best sketch-and-precondition baseline | 41.4 s | 73.7 s |
| AutoDiscoLS program | 20.7 s | 48.3 s |
The discovered program was 2.0× faster than the best baseline at medium accuracy and about 1.5× faster at high accuracy. The two targets produced different designs: the looser target favored a randomized iterative method, while the tighter target produced a direct factorization followed by correction steps.
Readable code yields a new stopping rule
Each output is a short Python program, allowing researchers to inspect the numerical operations and identify the source of a speedup. In one experiment, the search created a stopping rule based on quantities already computed by the iterative solver. For the specific sketch it constructs, the authors prove in exact arithmetic that the rule guarantees the requested residual bound.
The new stopping rule made the solver 1.11× faster than the textbook criterion. Its components were already known, but the authors report that the particular combination appears to be new.
A synthetic sweep used 20,000-by-2,000 matrices with condition number 106, a measure of substantial numerical difficulty. The discovered solver was fastest at every tested accuracy target. Across nine additional tasks covering different sizes and condition numbers, it tied or beat the strongest baseline each time, with speedups reaching 1.7×.
Code search outruns fixed knobs
Hyperparameter optimization can tune randomized solvers when experts define a search space in advance. The researchers compared AutoDiscoLS with Tree-structured Parzen Estimator, the default Bayesian optimizer in Optuna, using both an expert-designed search space and one adapted from prior work.
| Search method | Mean speedup |
|---|---|
| LLM-guided program evolution | 1.46× |
| TPE with expert search space | 1.39× |
| TPE with prior-work search space | 0.88× |
Fixed-space tuning can explore only the parameters and alternatives encoded by its designer. AutoDiscoLS edits executable code, which lets it alter control flow, introduce new calculations, and move between iterative and direct methods. The 0.88× result shows how a poorly matched search space can finish below the baseline.
Where specialization breaks
These solvers carry no worst-case performance or accuracy guarantee beyond the candidate checks and any proof established for a specific discovered component. Passing finite training and validation tests does not guarantee correct behavior for every matrix structure or random seed.
The reported programs transferred to new matrix sizes, different condition numbers, and looser accuracy targets. They failed when asked to meet tighter targets than those used during search. They also failed on matrices with substantially different structure unless examples of those matrices were added to the training workload.
All experiments used one CPU thread on an Intel Xeon Platinum 8481C. Memory layout, parallelism, accelerators, and library implementations can change which algorithm wins, so GPU and multicore deployments require a fresh search on the target hardware.
Who can amortize the search
Recurring pipelines provide the clearest use case: nightly physics analyses, models retrained on fresh data, or inverse problems generated by a fixed sensor arrangement. The matrix dimensions and statistical structure need to remain similar enough for the specialized solver to transfer. Teams must also compare the one-time search and API expense with the aggregate runtime saved across later solves.
One-off problems, frequently changing matrix distributions, and applications that require formal worst-case guarantees continue to favor established general-purpose solvers. Production users should test discovered programs on representative held-out matrices and retain an accuracy check or fallback solver for distribution shifts.
Repository, compute, and API costs
AutoDiscoLS is available under the Apache 2.0 license. The repository includes a small example that runs on a laptop in minutes, SLURM scripts for cluster searches, and the paper’s generated programs in the discovered/ directory.
The search makes paid model API calls, with spending capped through pipeline.total_budget_usd. This configuration bounds API charges, while local compute time remains dependent on the workload, candidate count, and evaluation hardware. The shipped programs can be inspected and benchmarked before they enter an application pipeline.