一句话:提出可微分 E-graph 提取算法 SmoothE,将离散提取松弛为连续优化,支持任意可微代价模型并针对 GPU 加速。
E-graph 在编译器优化、程序合成与定理证明中日益流行,它能紧凑表示大量等价表达式并借助重写规则探索巨大等价空间,从而提取最符合特定代价模型的目标表达式。然而现有 E-graph 提取方法常面临可扩展性与解质量之间的不利折中,且仅支持简单线性代价函数,限制了其处理更现实优化问题的能力。本文提出 SmoothE:一种面向复杂代价模型、并为 GPU 加速优化的可微分 E-graph 提取算法。作者从概率视角建模提取问题,将原离散优化松弛为连续可微形式,从而支持任意可微代价函数,并可用梯度下降高效搜索解。SmoothE 在 PyTorch 中实现,以利用现代机器学习生态,并引入利用稀疏性与数据并行的性能优化技术。实验在来自五个不同应用的多种真实 E-graph 上、使用三种代价模型(含线性与非线性)进行评估,表明 SmoothE 能稳定地在可扩展性与解质量之间取得良好折中。
E-graphs have gained increasing popularity in compiler optimization, program synthesis, and theorem proving tasks. They enable compact representation of many equivalent expressions and facilitate transformations via rewrite rules without phase ordering limitations. A major benefit of using e-graphs is the ability to explore a large space of equivalent expressions, allowing the extraction of an expression that best meets certain optimization objectives (or cost models). However, current e-graph extraction methods often face unfavorable scalability-quality trade-offs and only support simple linear cost functions, limiting their applicability to more realistic optimization problems. In this work, we propose SmoothE, a differentiable e-graph extraction algorithm designed to handle complex cost models and optimized for GPU acceleration. More specifically, we approach the e-graph extraction problem from a probabilistic perspective, where the original discrete optimization is relaxed to a continuous differentiable form. This formulation supports any differentiable cost functions and enables efficient searching for solutions using gradient descent. We implement SmoothE in PyTorch to leverage the advancements of the modern machine learning ecosystem. Additionally, we introduce performance optimization techniques to exploit sparsity and data parallelism. We evaluate SmoothE on a variety of realistic e-graphs from five different applications using three distinct cost models, including both linear and non-linear ones. Our experiments demonstrate that SmoothE consistently achieves a favorable trade-off between scalability and solution quality.