arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2406.07944cs.SEcs.AI
收藏

利用大语言模型增强差分测试以测试深度学习库

Enhancing Differential Testing With LLMs For Testing Deep Learning Libraries

The Hong Kong University of Science and Technology(香港科学与技术大学);Monash University(墨尔本大学)

Meiziniu Li, Dongze Li, Jianmeng Liu, Jialun Cao, Yongqiang Tian, Shing-Chi Cheung

AI总结:

本文提出DLLens,一种LLM增强的深度学习库差分测试技术,通过LLM合成API对应实现并结合静态分析提取路径约束来生成多样化测试输入,在TensorFlow和PyTorch上显著提升了对应实现合成数量、分支覆盖率和缺陷检测能力。

摘要:

差分测试通过比较替代实现之间的测试结果,为缓解测试预言问题提供了一种有前景的策略。然而,现有的针对深度学习(DL)库的差分测试技术受限于两个关键挑战:为给定API寻找替代实现(称为对应实现)以及随后生成多样化的测试输入。为解决这两个挑战,本文提出了DLLens,一种面向深度学习库的LLM增强差分测试技术。针对第一个挑战,DLLens引入了一个基于LLM的对应实现合成工作流,其核心洞察在于:给定深度学习库API的计算对应实现可以通过对另一个深度学习库的API进行一定的组合与适配来成功合成。针对第二个挑战,DLLens引入了一种静态分析技术,从给定API及其对应实现的实现中提取路径约束,以指导多样化测试输入的生成。该提取过程借助LLM对相关深度学习库及其上游库的知识来完成。我们在两个流行的深度学习库TensorFlow和PyTorch上对DLLens进行了评估。评估结果表明,DLLens为这些库合成的对应实现数量是现有最先进技术所找到的1.84倍。此外,在相同时间预算下,DLLens在200个随机采样的API上比现有最先进技术多覆盖7.23%的分支,并检测到1.88倍的缺陷。DLLens已在最新的TensorFlow和PyTorch库中成功检测到71个缺陷。其中59个已得到开发者确认,包括46个被确认为此前未知的缺陷,并且这些此前未知缺陷中有10个已在TensorFlow和PyTorch的最新版本中被修复。

英文摘要:

Differential testing offers a promising strategy to alleviate the test oracle problem by comparing the test results between alternative implementations. However, existing differential testing techniques for deep learning (DL) libraries are limited by the key challenges of finding alternative implementations (called counterparts) for a given API and subsequently generating diverse test inputs. To address the two challenges, this paper introduces DLLens, an LLM-enhanced differential testing technique for DL libraries. To address the first challenge, DLLens incorporates an LLM-based counterpart synthesis workflow, with the insight that the counterpart of a given DL library API's computation could be successfully synthesized through certain composition and adaptation of the APIs from another DL library. To address the second challenge, DLLens incorporates a static analysis technique that extracts the path constraints from the implementations of a given API and its counterpart to guide diverse test input generation. The extraction is facilitated by LLM's knowledge of the concerned DL library and its upstream libraries. We evaluate DLLens on two popular DL libraries, TensorFlow and PyTorch. Our evaluation shows that DLLens synthesizes counterparts for 1.84 times as many APIs as those found by state-of-the-art techniques on these libraries. Moreover, under the same time budget, DLLens covers 7.23% more branches and detects 1.88 times as many bugs as state-of-the-art techniques on 200 randomly sampled APIs. DLLens has successfully detected 71 bugs in recent TensorFlow and PyTorch libraries. Among them, 59 are confirmed by developers, including 46 confirmed as previously unknown bugs, and 10 of these previously unknown bugs have been fixed in the latest version of TensorFlow and PyTorch.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑