[论文解读] Equivalence of Dataflow Graphs via Rewrite Rules Using a Graph-to-Sequence Neural Model
本论文提出 pe-graph2seq,这是首个用于程序等价性的图到序列神经网络,能够生成可证明正确的重写序列,将一个数据流图转换为另一个。该模型在包含100多个等价公理的线性代数语言上进行训练,对10,000对测试样本的正确率达到96%,推理时间为16ms,且所有输出均可在可忽略时间内确定性验证。
In this work we target the problem of provably computing the equivalence between two programs represented as dataflow graphs. To this end, we formalize the problem of equivalence between two programs as finding a set of semantics-preserving rewrite rules from one into the other, such that after the rewrite the two programs are structurally identical, and therefore trivially equivalent. We then develop the first graph-to-sequence neural network system for program equivalence, trained to produce such rewrite sequences from a carefully crafted automatic example generation algorithm. We extensively evaluate our system on a rich multi-type linear algebra expression language, using arbitrary combinations of 100+ graph-rewriting axioms of equivalence. Our system outputs via inference a correct rewrite sequence for 96% of the 10,000 program pairs isolated for testing, using 30-term programs. And in all cases, the validity of the sequence produced and therefore the provable assertion of program equivalence is computable, in negligible time.
研究动机与目标
- 利用机器学习解决通过图重写序列对两个数据流图进行可证明等价性检查的挑战。
- 通过生成确定性、可检查的证明序列,而非二元预测,克服传统随机神经网络在程序等价性检查中的局限性。
- 开发一种神经网络系统,输出一系列保持语义的图重写规则,使两个等价程序在结构上完全一致。
- 通过确保所有输出均可在可忽略时间内验证,避免误报,实现高效且正确的等价性检查。
- 在具有丰富代数重写公理的复杂多类型线性代数表达式语言上验证该方法。
提出的方法
- 将程序表示为有向、有根的数据流图,节点表示操作和值,边表示数据依赖关系。
- 将程序等价性形式化为:存在一系列保持语义的图重写规则,可将一个图转换为另一个图。
- 将100多个等价公理(例如,1*x → x,a*(b+c) → a*b + a*c)定义为可应用于子图的重写规则。
- 训练一个图到序列神经网络(pe-graph2seq),从输入图预测此类重写规则的序列。
- 使用自定义的自动示例生成流水线,合成10,000对已知正确重写序列的训练样本。
- 通过将预测的重写序列应用于一个图,并利用深度优先遍历检查结构一致性来验证输出。
实验结果
研究问题
- RQ1能否训练一个神经网络,使其生成一组图重写规则序列,可证明地将一个数据流图转换为另一个等价图?
- RQ2该系统能否确保所有非等价输入均被正确拒绝,避免误报?
- RQ3神经网络的输出能否在可忽略时间内被确定性验证,从而支持实际部署?
- RQ4该模型在学习涉及子树操作、节点删除和重排的复杂重写序列方面效果如何?
- RQ5具有注意力机制的图到序列模型在多大程度上能学习导航等价保持变换空间的启发式规则?
主要发现
- pe-graph2seq 模型在多类型线性代数语言的10,000对测试程序对中,成功生成了正确且可验证的重写序列,正确率达96%。
- 通过应用重写序列并比较结构一致性,所有输出均可在可忽略时间内确定性验证。
- 该系统从设计上不会产生误报:能正确识别非等价程序为非等价。
- 每对程序的平均推理时间为16ms,证明了其在实际应用中的高效性。
- 该模型在复杂变换(包括子树重排、节点删除和代数简化)上表现出良好的泛化能力。
- 该方法表明图神经网络能够有效学习导航等价保持重写组合空间的启发式规则。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。