arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2409.11068cs.LGcs.DCcs.SE
收藏

为MLIR编译器自动代码优化设计的一种强化学习环境

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

New York University Abu Dhabi(纽约大学阿布扎赫尔分校);ESI(埃斯国际研究所);USTHB(阿尔及利亚国家技术与高等理工学院)

Mohammed Tirichine, Nassim Ameur, Nazim Bendib, Iheb Nassim Aouadj, Bouchama Djad, Rafik Bouloudene, Riyadh Baghdadi

AI总结:

本文提出MLIR RL,一种为MLIR编译器设计的强化学习环境,用于自动代码优化,通过多离散动作空间和level pointers方法提升策略学习效率。

摘要:

代码优化是提升代码性能的关键任务,但这一过程往往繁琐复杂,凸显了自动代码优化技术的必要性。强化学习(RL)已出现作为解决此类复杂优化问题的有前途的方法。在本项目中,我们介绍了MLIR RL,这是一种为MLIR编译器设计的RL环境,旨在促进MLIR编译器研究并实现自动代码优化。我们提出了一种多离散的动作空间形式化,其中动作空间是更简单动作子空间的笛卡尔积。我们还提出了一种新的方法,称为level pointers,用于减少与循环交换变换相关的动作空间大小。这使得策略的学习更加高效和有效。为了证明MLIR RL的有效性,我们训练了一个RL代理来优化MLIR Linalg代码,目标是CPU。代码由两个领域特定框架生成:来自PyTorch的深度学习模型,以及由LQCD编译器生成的LQCD代码。这项工作的结果是一个研究环境,使社区能够尝试RL驱动的循环巢优化中的新想法。

英文摘要:

Code optimization is a crucial task that aims to enhance code performance. However, this process is often tedious and complex, highlighting the necessity for automatic code optimization techniques. Reinforcement Learning (RL) has emerged as a promising approach for tackling such complex optimization problems. In this project, we introduce MLIR RL, an RL environment for the MLIR compiler, dedicated to facilitating MLIR compiler research and enabling automatic code optimization. We propose a multi-discrete formulation of the action space where the action space is the Cartesian product of simpler action subspaces. We also propose a new method, called level pointers, to reduce the size of the action space related to the loop interchange transformation. This enables more efficient and effective learning of the policy. To demonstrate the effectiveness of MLIR RL, we train an RL agent to optimize MLIR Linalg code, targeting CPU. The code is generated from two domain-specific frameworks: deep-learning models generated from PyTorch, and LQCD (Lattice Quantum Chromodynamics) code generated from an LQCD compiler. The result of this work is a research environment that allows the community to experiment with novel ideas in RL-driven loop-nest optimization.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑