A Reinforcement Learning Environment for Automatic Code Optimization in the MLIR Compiler

📅 2024-09-17
🏛️ arXiv.org
📈 Citations: 5
Influential: 0
📄 PDF
🤖 AI Summary
Manual optimization of MLIR-based compilers is labor-intensive and inefficient. Method: This paper introduces the first reinforcement learning (RL)-driven automated optimization framework tailored for MLIR. We propose a multi-action RL modeling approach that decomposes the high-dimensional optimization action space into the Cartesian product of lower-dimensional subspaces, preserving expressiveness while significantly improving policy search efficiency and training stability. Furthermore, we establish the first end-to-end RL-driven compilation optimization loop in MLIR, integrating policy network training, environment interaction, and performance feedback. Contribution/Results: Experiments demonstrate that our method achieves performance comparable to or exceeding hand-tuned TensorFlow optimizations across multiple MLIR operator optimization tasks, thereby validating the feasibility, effectiveness, and practical potential of RL-enabled automated compiler optimization.

Technology Category

Application Category

📝 Abstract
Code optimization is a crucial task aimed at enhancing code performance. However, this process is often tedious and complex, highlighting the necessity for automatic code optimization techniques. Reinforcement Learning (RL), a machine learning technique, has emerged as a promising approach for tackling such complex optimization problems. In this project, we introduce the first RL environment for the MLIR compiler, dedicated to facilitating MLIR compiler research, and enabling automatic code optimization using Multi-Action Reinforcement Learning. We also propose a novel formulation of the action space as a Cartesian product of simpler action subspaces, enabling more efficient and effective optimizations. Experimental results demonstrate that our proposed environment allows for an effective optimization of MLIR operations, and yields comparable performance to TensorFlow, surpassing it in multiple cases, highlighting the potential of RL-based optimization in compiler frameworks.
Problem

Research questions and friction points this paper is trying to address.

Develops a reinforcement learning environment for MLIR compiler to automate code optimization
Proposes a multi-discrete action space formulation and level pointers method to improve learning efficiency
Trains an RL agent to optimize MLIR Linalg code from deep learning and LQCD frameworks for CPU performance
Innovation

Methods, ideas, or system contributions that make the work stand out.

Reinforcement Learning environment for MLIR compiler optimization
Multi-discrete action space formulation with Cartesian product
Level pointers method to reduce loop interchange action space
🔎 Similar Papers
No similar papers found.