一句话:提出推测式自动重构方法,用静态张量与副作用分析将命令式深度学习函数转为图执行以提升性能。
深度学习框架常用延迟执行的图模式支持可扩展的 DNN 计算,但开发错误多、难调试;命令式 eager 执行更自然却牺牲运行时性能。本文受传统系统中并行化顺序代码的启发,提出自动化重构方法,帮助开发者判断哪些 eager 执行的命令式 DL 函数可高效地转为图执行。方法包含针对 Python 的命令式张量与副作用静态分析;因 Python 动态性可能不健全,采用保守的推测式(基于关键字)分析处理困难情形并告知开发者所做假设。作者将其实现为集成 WALA Ariadne 的 PyDev Eclipse 插件,并在 19 个 DL 项目(132 KLOC)上评估:766 个候选函数中 326 个(42.56%)可重构,性能测试平均相对加速 2.16 倍,模型精度差异可忽略。
Efficiency is essential to support ever-growing datasets, especially for Deep Learning (DL) systems. DL frameworks have traditionally embraced deferred execution-style DL code—supporting symbolic, graph-based Deep Neural Network (DNN) computation. While scalable, such development is error-prone, non-intuitive, and difficult to debug. Consequently, more natural, imperative DL frameworks encouraging eager execution have emerged but at the expense of run-time performance. Though hybrid approaches aim for the "best of both worlds," using them effectively requires subtle considerations. Our key insight is that, while DL programs typically execute sequentially, hybridizing imperative DL code resembles parallelizing sequential code in traditional systems. Inspired by this, we present an automated refactoring approach that assists developers in determining which otherwise eagerly-executed imperative DL functions could be effectively and efficiently executed as graphs. The approach features novel static imperative tensor and side-effect analyses for Python. Due to its inherent dynamism, analyzing Python may be unsound; however, the conservative approach leverages a speculative (keyword-based) analysis for resolving difficult cases that informs developers of any assumptions made. The approach is: (i) implemented as a plug-in to the PyDev Eclipse IDE that integrates the WALA Ariadne analysis framework and (ii) evaluated on nineteen DL projects consisting of 132 KLOC. The results show that 326 of 766 candidate functions (42.56%) were refactorable, and an average relative speedup of 2.16x on performance tests was observed with negligible differences in model accuracy. The results indicate that the approach is useful in optimizing imperative DL code to its full potential.
DOI 原文 ·
@inproceedings{paperbot9376,
title = {Speculative Automated Refactoring of Imperative Deep Learning Programs to Graph Execution},
author = {Raffi Khatchadourian and Tatiana Castro Vélez and Mehdi Bagherzadeh and Nan Jia and Anita Raja},
booktitle = {ASE},
year = {2025},
doi = {10.1109/ase63991.2025.00068}
}