用神经符号方法自动跨平台翻译深度学习张量程序,提升开发效率96倍。
QiMeng-Xpiler: Transcompiling Tensor Programs for Deep Learning Systems with a Neural-Symbolic Approach
- 结合大模型生成与符号合成,用LLM降低代码搜索复杂度。
- 平均95%准确率,翻译后性能最高达厂商优化库的2.0倍。
- 适合需跨GPU/ASIC部署的开发者,显著减少重复编码工作。
异构深度学习系统(DLS)如GPU和ASIC已在工业数据中心广泛部署,需为不同平台编写多个底层张量程序。缓解编程负担的一种可行方案是将某一平台的旧代码自动转译至其他平台。然而,现有转译技术要么需要大量人工干预,要么存在功能错误,导致张量程序的“一次编写,随处运行”仍是一个开放问题。本文提出新型转译器QiMeng-Xpiler,通过大语言模型(LLMs)与符号程序合成相结合的神经符号方法,实现跨DLS的自动张量程序翻译。核心思路是利用LLM强大的代码生成能力,使代价高昂的基于搜索的符号合成在计算上变得可行。具体而言,我们设计了基于预定义元提示的多阶段LLM辅助编译流程,每阶段采用高效符号合成修复小规模错误代码片段。为获得高性能,提出分层自动调优方法,系统探索变换步骤的参数与顺序。在四种具有不同编程接口的DLS(Intel DL Boost with VNNI、NVIDIA GPU with CUDA、AMD MI with HIP、Cambricon MLU with BANG)上的实验表明,QiMeng-Xpiler平均以95%准确率成功转译各类张量程序,且翻译后程序性能最高达厂商提供手动优化库的2.0倍。由此,通过转译遗留张量程序,深度学习系统的编程生产力最高提升96.0倍。
原文摘要 · Abstract (English)
Heterogeneous deep learning systems (DLS) such as GPUs and ASICs have been widely deployed in industrial data centers, which requires to develop multiple low-level tensor programs for different platforms. An attractive solution to relieve the programming burden is to transcompile the legacy code of one platform to others. However, current transcompilation techniques struggle with either tremendous manual efforts or functional incorrectness, rendering "Write Once, Run Anywhere" of tensor programs an open question. We propose a novel transcompiler, i.e., QiMeng-Xpiler, for automatically translating tensor programs across DLS via both large language models (LLMs) and symbolic program synthesis, i.e., neural-symbolic synthesis. The key insight is leveraging the powerful code generation ability of LLM to make costly search-based symbolic synthesis computationally tractable. Concretely, we propose multiple LLM-assisted compilation passes via pre-defined meta-prompts for program transformation. During each program transformation, efficient symbolic program synthesis is employed to repair incorrect code snippets with a limited scale. To attain high performance, we propose a hierarchical auto-tuning approach to systematically explore both the parameters and sequences of transformation passes. Experiments on 4 DLS with distinct programming interfaces, i.e., Intel DL Boost with VNNI, NVIDIA GPU with CUDA, AMD MI with HIP, and Cambricon MLU with BANG, demonstrate that QiMeng-Xpiler correctly translates different tensor programs at the accuracy of 95% on average, and the performance of translated programs achieves up to 2.0x over vendor-provided manually-optimized libraries. As a result, the programming productivity of DLS is improved by up to 96.0x via transcompiling legacy tensor programs.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。