Pearl: Automatic Code Optimization Using Deep Reinforcement Learning Conference: 2025 International Conference on Supercomputing; June 8–11, 2025; Salt Lake City, UT, USA 2025 International Conference on Supercomputing (ICS ’25), June 8–11, 2025, Salt Lake City, UT, USA DOI: 10.1145/3721145.3725766
Djamel Rassem Lamouri, Iheb Nassim Aouadj, Smail KOURTA, Riyadh Baghdadi · 2025
Read Pearl: Automatic Code Optimization Using Deep Reinforcement Learning Conference: 2025 International Conference on Supercomputing; June 8–11, 2025; Salt Lake City, UT, USA 2025 International Conference on Supercomputing (ICS ’25), June 8–11, 2025, Salt Lake City, UT, USA DOI: 10.1145/3721145.3725766 by Djamel Rassem Lamouri, Iheb Nassim Aouadj, Smail KOURTA, Riyadh Baghdadi (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2506-01880.txt.
Introduction
Djamel Lamouri, Iheb Aouadj, Smail Kourta, and Riyadh Baghdadi present Pearl, a system that speeds up code with reinforcement learning. Their twenty twenty-five paper deals with compiler optimization: picking the right chain of code transforms to make a program run fast. Past learning methods handled only narrow loop shapes or only programs seen in training.
Pearl's agent chooses both the transform and the part of the loop nest it applies to, through a new action design. It also covers polyhedral optimizations, an advanced class. Caching and pre-training cut the slow training cost. Built into the Tiramisu compiler, Pearl beat prior methods on benchmarks and handled new programs.
Catalog record
| CREATOR | Djamel Rassem Lamouri, Iheb Nassim Aouadj, Smail KOURTA, Riyadh Baghdadi |
|---|---|
| YEAR | 2025 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 57 KB |
| VERSION | 1.0 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2506-01880
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
Pearl: Automatic Code Optimization Using Deep Reinforcement Learning Conference: 2025 International Conference on Supercomputing; June 8–11, 2025; Salt Lake City, UT, USA 2025 International Conference on Supercomputing (ICS ’25), June 8–11, 2025, Salt Lake City, UT, USA DOI: 10.1145/3721145.3725766 ISBN: 979-8-4007-1537-2/2025/06 288 Djamel Rassem Lamouri, Iheb Nassim Aouadj, Smail KOURTA, Riyadh Baghdadi Abstract . Compilers are crucial in optimizing programs and accelerating their execution, particularly for compute-intensive tasks such as training deep learning models and conducting physics simulations. However, optimizing programs automatically using compilers is not trivial. Recent work has attempted to use reinforcement learning (RL) to solve this problem. It has limitations though. Current methods either do not support the optimization of general loop nests or can only be used to optimize loop nests seen during training. In this paper, we propose Pearl, a novel framework that uses deep reinforcement learning to automate compiler code optimization. It uses an RL agent to select the sequence of code optimizations a compiler should apply to make the input code run faster. This agent can optimize general loop nests (i.e., it is not domain-specific) and can generalize to programs unseen during training. To enable the optimization of general loop nests, we propose a novel representation of the action space that allows the RL agent to select on which part of the loop nest a given code optimization should be applied. One of the main challenges that hinder the development of RL agents for optimizing general loop nests is the fact that this task is data-intensive, with each experiment taking weeks. To avoid this problem and enable fast training of the proposed RL agent, we propose two methods: 1) execution time and legality check memoization; and 2) actor-critic pre-training. We implement our approach in Tiramisu, a state-of-the-art polyhedral compiler designed for accelerating compute-intensive programs. Our approach streamlines the optimization process and offers performance improvements compared to existing methods. To the best of our knowledge, Pearl is the first RL-based system to support general programs composed of loop nests manipulating tensors while still being able to generalize to programs unseen during training. It is also the first to support the class of polyhedral optimizations, a class of advanced loop nest optimizations. We evaluate Pearl on a set of benchmarks, and demonstrate competitive performance improvements over state-of-the-art compilers. Notably, Pearl achieves a geometric mean speedup of 2.02 × 2.02\times\ compared to Tiramisu and 3.36 × 3.36\times\ compared to Pluto. 1. Introduction Writing fast and efficient code is a challenging task that requires significant expertise. This is especially true for compute-intensive fields such as deep learning and scientific computing. Optimizing compute-intensive programs can significantly reduce execution time, often achieving speedups by orders of magnitude. However, manual code optimization is time-consuming, error-prone, and demands expertise, making automated compiler optimizations increasingly crucial. The most significant part of the execution time of compute-intensive programs is usually spent in loops. That is why loop optimization has received considerable attention in the context of code optimization. State-of-the-art compilers such as Tiramisu ( Baghdadi et al. 2019 ) , Halide ( Ragan-Kelley et al. 2013 ) , TVM ( Zheng et al. 2020 ) , and Pluto ( Bondhugula et al. 2008a ) all focus on applying loop transformations to accelerate the execution of programs. Nevertheless, the search space of these transformations is considerably large, hindering the usage of exhaustive search methods due to their impracticality. Several techniques have been proposed to solve this challenge, including the leverage of integer linear programming (ILP) to find the best code optimizations ( Bondhugula et al. 2008a ; Bondhugula et al. 2008b ; Verdoolaege et al. 2013 ) . Recently, state-of-the-art optimizing compilers have explored tree-search methods guided by a deep learning cost model, serving as a fitness function to evaluate code optimization candidates during search ( Adams et al. 2019 ; Zheng et al. 2020 ; Baghdadi et al. 2021 ) . To shed light on the size of the search space, let’s take the Tiramisu Autoscheduler ( Baghdadi et al. 2021 ) as an example. Its search space has an estimated number of 10^{170} candidates of loop optimizations ( Baghdadi et al. 2021 ) , where each candidate is a sequence of code optimizations along with their parameters. This is why the Tiramisu Autoscheduler imposes restrictions on how the search space is explored. For example, code optimizations are explored in a fixed order, and many optimizations are explored only once, which is known to be sub-optimal. The Tiramisu Autoscheduler uses beam search to explore the space, limiting its ability to perform global code optimization. In general, tree-search methods tend to restrict the search space to enable efficient exploration. For example, they might explore only a small number of code optimizations, explore code optimizations in a fixed order, and limit the number of times certain code optimizations are explored (e.g., explore them once only). To avoid the limitations of tree-search methods, recent state-of-the-art compilers have attempted to use reinforcement learning. HalideRL ( Pecenin et al. 2019 ) , for example, uses PPO ( Schulman et al. 2017 ) to select code optimizations for image processing applications. SuperSonic ( Huanting et al. 2022 ) , a framework for automating RL architecture design for code optimization, was also demonstrated by building an RL agent for the Halide compiler. However, neither HalideRL nor SuperSonic’s Halide agents are built to generalize over programs unseen during training. In both cases, the RL agent is trained to optimize a set of programs, and then it is deployed to optimize the same programs. This design choice allows fast training of the RL agent since it is trained on a single program only, but it prevents its generality. Additionally, HalideRL has the limitation of being semi-automatic. It requires the user (developer) to specify the list of code optimizations and optimization parameters that will likely help optimize the code. The RL agent then discards the optimizations that are not useful from this list and adjusts the optimization parameters. Other state-of-the-art systems focus on proposing an environment for automatic code optimization using reinforcement learning but do not propose an RL agent that automatically optimizes code. PolyGym ( Brauckmann et al. 2021 ) , for example, introduced an RL environment to search for polyhedral code optimizations (affine code optimizations). It does not propose an RL agent though. It rather uses a random policy to demonstrate the effectiveness of its environment and action space. Such a random policy has the limitation of being slow as it has to randomly sample thousands of actions from the search space, and for each sampled action, it has to compile and run the optimized program to find the most effective ones. Proposing an RL agent that efficiently search for code optimizations in PolyGym was left for future work. AutoPhase ( Huang et al. 2020 ) is another example of using RL for code optimization. It proposes a framework that uses deep reinforcement learning to optimize programs for hardware synthesis (High-Level Synthesis). It only considers the problem of phase reordering (i.e., choosing the best order for the compiler passes). Phase ordering is a sub-problem of the larger problem of automatic code optimization. In automatic code optimization, the goal is to identify