Resource scheduling and allocation is a critical component of many high impact systems ranging from congestion control to cloud computing. Finding more optimal solutions to these problems often has significant impact on resource and time savings, reducing device wear-and-tear, and even potentially improving carbon emissions. In this paper, we focus on a specific instance of a scheduling problem, namely the memory mapping problem that occurs during compilation of machine learning programs: That is, mapping tensors to different memory layers to optimize execution time. We introduce an approach for solving the memory mapping problem using Reinforcement Learning. RL is a solution paradigm well-suited for sequential decision making problems that are amenable to planning, and combinatorial search spaces with high-dimensional data inputs. We formulate the problem as a single-player game, which we call the mallocGame, such that high-reward trajectories of the game correspond to efficient memory mappings on the target hardware. We also introduce a Reinforcement Learning agent, mallocMuZero, and show that it is capable of playing this game to discover new and improved memory mapping solutions that lead to faster execution times on real ML workloads on ML accelerators. We compare the performance of mallocMuZero to the default solver used by the Accelerated Linear Algebra (XLA) compiler on a benchmark of realistic ML workloads. In addition, we show that mallocMuZero is capable of improving the execution time of the recently published AlphaTensor matrix multiplication model.
翻译:资源调度与分配是许多高影响力系统(从拥塞控制到云计算)中的关键组成部分。为这些问题找到更优的解决方案通常能显著节约资源和时间、减少设备磨损,甚至可能改善碳排放。本文聚焦于调度问题的一个具体实例,即在机器学习程序编译过程中出现的内存映射问题:将张量映射到不同内存层以优化执行时间。我们提出了一种使用强化学习解决内存映射问题的方法。强化学习是一种非常适合解决顺序决策问题的范式,这类问题适用于规划,且涉及具有高维数据输入的组合搜索空间。我们将该问题构建为一个单人游戏,称为mallocGame,其中游戏的高奖励轨迹对应于目标硬件上的高效内存映射。我们还引入了一个强化学习智能体mallocMuZero,并证明它能够通过游玩该游戏来发现新的、改进的内存映射解决方案,从而在机器学习加速器上实现真实机器学习工作负载的更短执行时间。我们将mallocMuZero的性能与加速线性代数编译器在真实机器学习工作负载基准上使用的默认求解器进行了比较。此外,我们证明mallocMuZero能够改善近期发布的AlphaTensor矩阵乘法模型的执行时间。