Rewrite systems [6, 10, 12] have been widely employing equality saturation [9], which is an optimisation methodology that uses a saturated e-graph to represent all possible sequences of rewrite simultaneously, and then extracts the optimal one. As such, optimal results can be achieved by avoiding the phase-ordering problem. However, we observe that when the e-graph is not saturated, it cannot represent all possible rewrite opportunities and therefore the phase-ordering problem is re-introduced during the construction phase of the e-graph. To address this problem, we propose MCTS-GEB, a domain-general rewrite system that applies reinforcement learning (RL) to e-graph construction. At its core, MCTS-GEB uses a Monte Carlo Tree Search (MCTS) [3] to efficiently plan for the optimal e-graph construction, and therefore it can effectively eliminate the phase-ordering problem at the construction phase and achieve better performance within a reasonable time. Evaluation in two different domains shows MCTS-GEB can outperform the state-of-the-art rewrite systems by up to 49x, while the optimisation can generally take less than an hour, indicating MCTS-GEB is a promising building block for the future generation of rewrite systems.
翻译:重写系统广泛应用等式饱和的优化方法,在其中使用饱和的 E 图同时表示所有可能的重写序列,然后提取最优序列,以避免阶段排序问题。然而,当 E 图未饱和时,它无法表示所有可能的重写机会,因此在 E 图构建阶段重新引入了阶段排序问题。为了解决这个问题,我们提出了 MCTS-GEB,一种将强化学习应用于 E 图构建的领域通用重写系统。MCTS-GEB 的核心利用蒙特卡罗树搜索高效地规划最优 E 图构建,因此可以在构建阶段有效消除阶段排序问题,并在合理时间内实现更好的性能。在两个不同领域的评估中,MCTS-GEB 可以比最先进的重写系统提高最多 49 倍,同时优化通常需要不到一小时的时间,表明 MCTS-GEB 是未来重写系统的有希望的基石。