DVM: A Bytecode Virtual Machine Approach for Dynamic Tensor Computation

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Fang, Jingzhi, Gao, Xiong, Zhang, Renwei, Ye, Zichun, Chen, Lei, Zhao, Jie, Huang, Chengnuo, Xu, Hui, Jin, Xuefeng
Format: Preprint
Published: 2026
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866914439079395328
author Fang, Jingzhi
Gao, Xiong
Zhang, Renwei
Ye, Zichun
Chen, Lei
Zhao, Jie
Huang, Chengnuo
Xu, Hui
Jin, Xuefeng
author_facet Fang, Jingzhi
Gao, Xiong
Zhang, Renwei
Ye, Zichun
Chen, Lei
Zhao, Jie
Huang, Chengnuo
Xu, Hui
Jin, Xuefeng
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2603_24239
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle DVM: A Bytecode Virtual Machine Approach for Dynamic Tensor Computation
Fang, Jingzhi
Gao, Xiong
Zhang, Renwei
Ye, Zichun
Chen, Lei
Zhao, Jie
Huang, Chengnuo
Xu, Hui
Jin, Xuefeng
Programming Languages
Artificial Intelligence
Machine Learning
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.
title DVM: A Bytecode Virtual Machine Approach for Dynamic Tensor Computation
topic Programming Languages
Artificial Intelligence
Machine Learning
url https://arxiv.org/abs/2603.24239