WhiteFox: White-Box Compiler Fuzzing Empowered by Large Language Models

📄 arXiv: 2310.15991v3 📥 PDF

作者: Chenyuan Yang, Yinlin Deng, Runyu Lu, Jiayi Yao, Jiawei Liu, Reyhaneh Jabbarvand, Lingming Zhang

分类: cs.SE, cs.LG, cs.PL

发布日期: 2023-10-24 (更新: 2024-09-04)

备注: Published in OOPSLA 2024

期刊: Proc. ACM Program. Lang., Vol. 8, No. OOPSLA2, Article 296. Publication date: October 2024

DOI: 10.1145/3689736


💡 一句话要点

提出WhiteFox以解决编译器模糊测试中的深层逻辑错误问题

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 编译器测试 模糊测试 大型语言模型 深度学习编译器 逻辑错误检测 白盒测试 代码生成

📋 核心要点

  1. 现有的编译器模糊测试方法主要集中在黑盒和灰盒测试,缺乏对编译器内部逻辑的深入理解,导致测试效果有限。
  2. WhiteFox通过引入大型语言模型,结合源代码信息,采用多代理框架来生成高质量的测试程序,旨在检测深层逻辑错误。
  3. 在对三种主流深度学习编译器的评估中,WhiteFox的测试程序生成能力比现有最先进的模糊测试工具提高了8倍,并发现了大量之前未知的错误。

📝 摘要(中文)

编译器的正确性至关重要,因为错误的编译可能导致程序行为失真,造成严重后果。尽管模糊测试已被研究用于发现编译器缺陷,但现有方法主要集中在黑盒和灰盒模糊测试,缺乏对编译器内部行为的充分理解。本文提出了WhiteFox,这是第一个利用大型语言模型(LLMs)和源代码信息的白盒编译器模糊测试工具,重点检测深度学习编译器中的深层逻辑错误。WhiteFox采用多代理框架,通过LLM分析代理和生成代理协同工作,显著提高了测试程序的生成质量,并在三种流行的深度学习编译器中发现了101个错误,其中92个为之前未知,70个已被修复。

🔬 方法详解

问题定义:本文旨在解决编译器模糊测试中对内部逻辑理解不足的问题,现有的黑盒和灰盒方法无法有效发现深层逻辑错误。

核心思路:WhiteFox结合大型语言模型与源代码信息,通过多代理框架实现对编译器优化的测试,特别关注深度学习编译器中的深层逻辑错误。

技术框架:WhiteFox的整体架构包括两个主要模块:分析代理和生成代理。分析代理负责检查低级优化源代码并生成高层次测试程序的需求,而生成代理则基于这些需求生成测试程序。

关键创新:WhiteFox的创新在于首次将大型语言模型应用于编译器的白盒模糊测试,利用源代码信息指导测试程序的生成,显著提升了测试的有效性。

关键设计:在设计中,WhiteFox通过优化触发测试作为反馈,动态增强生成过程,确保生成的测试程序能够有效触发编译器的深层优化。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

WhiteFox在对三种流行的深度学习编译器(PyTorch Inductor、TensorFlow-XLA和TensorFlow Lite)的评估中,生成的测试程序能够触发深层优化,测试效果比现有最先进的模糊测试工具提高了8倍,发现了101个错误,其中92个为之前未知,70个已被修复。

🎯 应用场景

WhiteFox的研究成果具有广泛的应用潜力,尤其是在深度学习编译器的开发和测试中。其方法可以被适用于不同领域的编译器,提升编译器的可靠性和安全性,减少因编译错误导致的潜在风险。

📄 摘要(原文)

Compiler correctness is crucial, as miscompilation can falsify program behaviors, leading to serious consequences. Fuzzing has been studied to uncover compiler defects. However, compiler fuzzing remains challenging: Existing arts focus on black- and grey-box fuzzing, which generates tests without sufficient understanding of internal compiler behaviors. Meanwhile, traditional white-box techniques, like symbolic execution, are computationally inapplicable to the giant codebase of compilers. Recent advances demonstrate that Large Language Models (LLMs) excel in code generation/understanding tasks. Nonetheless, guiding LLMs with compiler source-code information remains a missing piece of research in compiler testing. To this end, we propose WhiteFox, the first white-box compiler fuzzer using LLMs with source-code information to test compiler optimization, with a spotlight on detecting deep logic bugs in the deep learning (DL) compilers. WhiteFox adopts a multi-agent framework: an LLM-based analysis agent examines the low-level optimization source code and produces requirements on the high-level test programs that can trigger the optimization; an LLM-based generation agent produces test programs based on the summarized requirements. Additionally, optimization-triggering tests are used as feedback to enhance the generation on the fly. Our evaluation on the three most popular DL compilers (i.e., PyTorch Inductor, TensorFlow-XLA, and TensorFlow Lite) shows WhiteFox can generate high-quality test programs to exercise deep optimizations, practicing up to 8X more than state-of-the-art fuzzers. WhiteFox has found 101 bugs for the DL compilers, with 92 confirmed as previously unknown and 70 fixed. WhiteFox has been acknowledged by the PyTorch team and is being incorporated into its development workflow. Beyond DL compilers, WhiteFox can also be adapted for compilers in different domains.