Agent Tuning & Optimization 相关度: 5/10

DVM: Real-Time Kernel Generation for Dynamic AI Models

Jingzhi Fang, Xiong Gao, Renwei Zhang, Zichun Ye, Lei Chen, Jie Zhao, Chengnuo Huang, Hui Xu, Xuefeng Jin
arXiv: 2603.24239v1 发布: 2026-03-25 更新: 2026-03-25

AI 摘要

DVM提出一种基于字节码虚拟机的实时编译器,加速动态AI模型的编译和执行效率。

主要贡献

  • 设计了基于字节码虚拟机的运行时算子编译器
  • 提出了基于符号推导的静态图和运行时动态图的算子融合方法
  • 实验证明DVM在算子和模型效率以及编译时间上优于现有方案

方法论

DVM通过CPU上的字节码编码和NPU上的虚拟指令解码加速编译,并结合静态和动态图融合优化。

原文摘要

Dynamism is common in AI computation, e.g., the dynamic tensor shapes and the dynamic control flows in models. Due to the long compilation time, existing runtime compilation damages the model efficiency, while the offline compilers either suffer from the long compilation time and device memory footprint to cover all the possible execution instances of a dynamic model, or sacrifice optimization opportunities for usability. In this paper, we rethink the feasibility of runtime compilation for dynamic models and identify that the key for it to work is to speed up the compilation or hide the compilation overhead. To do this, we propose a real-time compiler, DVM. In DVM, we design a runtime operator compiler based on a bytecode virtual machine to perform effective and efficient compilation for each dynamic operator instance given its input. Specifically, instead of compiling programs into machine code, we encode the operator program into bytecode on the CPU and decode the bytecode into virtual instructions for direct execution on the NPU. Based on the runtime operator compiler, we further propose an operator fuser, which performs symbol-deduction-based fusion on static graphs and runtime fusion on dynamic graphs. Both pattern- and stacking-based fusion are supported to increase fusion opportunities. Evaluation on operators, subgraphs, and models shows that, compared with TorchInductor, PyTorch-eager and MindSpore-graph-O0, we are up to 11.77$\times$ better in terms of the operator/model efficiency and up to 5 orders of magnitude faster in terms of the maximum compilation time.

标签

动态AI模型 运行时编译 字节码虚拟机 算子融合

arXiv 分类

cs.PL cs.AI cs.LG