PolyJuice: Detecting Mis-compilation Bugs in Tensor Compilers with Equality Saturation Based Rewriting
Chijin Zhou, Bingzhou Qian, Gwihwan Go, Quan Zhang, Shanshan Li, Yu Jiang
Abstract
Tensor compilers are essential for deploying deep learning applications across various hardware platforms. While powerful, they are inherently complex and present significant challenges in ensuring correctness. This paper introduces PolyJuice, an automatic detection tool for identifying mis-compilation bugs in tensor compilers. Its basic idea is to construct semantically-equivalent computation graphs to validate the correctness of tensor compilers. The main challenge is to construct equivalent graphs capable of efficiently exploring the diverse optimization logic during compilation. We approach it from two dimensions. First, we propose arithmetic and structural equivalent rewrite rules to modify the dataflow of a tensor program. Second, we design an efficient equality saturation based rewriting framework to identify the most simplified and the most complex equivalent computation graphs for an input graph. After that, the outcome computation graphs have different dataflow and will likely experience different optimization processes during compilation. We applied it to five well-tested industrial tensor compilers, namely PyTorch Inductor, OnnxRuntime, TVM, TensorRT, and XLA, as well as two well-maintained academic tensor compilers, EinNet and Hidet. In total, PolyJuice detected 84 non-crash mis-compilation bugs, out of which 49 were confirmed with 20 fixed.
CCS Concepts: • Software and its engineering → Software testing and debugging.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext 11f3c2a3-de6e-437c-b251-aa4c15d9e901Cited by top-tier papers5
- Your Compiler is Backdooring Your Model: Understanding and Exploiting Compilation Inconsistency Vulnerabilities in Deep Learning CompilersSimin Chen, Jinjun Peng, Yixin He, Junfeng Yang et al.S&P 2026 · 11 citations
- Improving Deep Learning Framework Testing with Model-Level Metamorphic TestingYanzhou Mu, Juan Zhai, Chunrong Fang, Xiang Chen et al.ISSTA 2025 · 1 citation
- Optimization-Aware Test Generation for Deep Learning CompilersQingchao Shen, Zan Wang, Haoyang Ma, Yongqiang Tian et al.ICSE 2026
- Eidolon: Perform Noise-Aware Fuzzing on FHE Libraries via Equivalence Expression TransformationZhensheng Xian, Zhen Yan, Yuanliang Chen, Xuelian Cao et al.FSE 2026
- VeriEQ: Finding Verilog Simulators and Synthesizers Bugs with Equivalence Circuit TransformationZhen Yan, Yuanliang Chen, Fuchen Ma, Zehong Yu et al.OOPSLA 2026
Builds on44
- Ansor: Generating High-Performance Tensor Programs for Deep LearningLianmin Zheng, Chengfan Jia, Minmin Sun, Zhao Wu et al.OSDI 2020 · 551 citations
- CodeAlchemist: Semantics-Aware Code Generation to Find Vulnerabilities in JavaScript EnginesHyungSeok Han, DongHyeon Oh, Sang Kil ChaNDSS 2019 · 178 citations
- Deep learning library testing via effective model generationZan Wang, Ming Yan, Junjie Chen, Shuang Liu et al.FSE 2020 · 165 citations
- Testing Database Engines via Pivoted Query SynthesisManuel Rigger, Zhendong SuOSDI 2020 · 150 citations
- A comprehensive study of deep learning compiler bugsQingchao Shen, Haoyang Ma, Junjie Chen, Yongqiang Tian et al.FSE 2021 · 123 citations
Related papers
- NNSmith: Generating Diverse and Valid Test Cases for Deep Learning CompilersJiawei Liu, Jinkun Lin, Fabian Ruffy, Cheng Tan et al.ASPLOS 2023 · 90 citations
- Coverage-guided tensor compiler fuzzing with joint IR-pass mutationJiawei Liu, Yuxiang Wei, Sen Yang, Yinlin Deng et al.OOPSLA 2022 · 50 citations
- Fuzzing Deep Learning Compilers with HirGenHaoyang Ma, Qingchao Shen, Yongqiang Tian, Junjie Chen et al.ISSTA 2023 · 24 citations
- Detecting TensorFlow Program Bugs in Real-World Industrial EnvironmentChen Liu, Jie Lu, Guangwei Li, Ting Yuan et al.ASE 2021 · 13 citations
- GenCoG: A DSL-Based Approach to Generating Computation Graphs for TVM TestingZihan Wang, Pengbo Nie, Xinyuan Miao, Yuting Chen et al.ISSTA 2023 · 15 citations
