arrow
Return

Enhancing Differential Testing with LLMs for Testing Deep Learning Libraries

delete2026-04-01
delete1
PRE
AI
M
Meiziniu Li
D
D. Li
J
J. Liu
J
Jialun Cao
Y
Yongqiang Tian
S
Shing-Chi Cheung *
DOI:10.1145/3735637delete
deleteOriginal
deleteOriginal request for help
deleteShare
deleteSave
Abstract

Abstract

En 中文
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 article introduces DLLENs, a large language model (LLM)-enhanced differential testing technique for DL libraries. The first challenge is addressed by an observation that DL libraries are commonly designed to support the computation of a similar set of DL algorithms. Therefore, the counterpart of a given API's computation could be successfully synthesized through certain composition and adaptation of the APIs from another DL library. DLLENs incorporates a novel counterpart synthesis workflow, leveraging a LLM to search for valid counterparts for differential testing. 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. DLLENs incorporates validation mechanisms to manage the LLM's hallucinations in counterpart synthesis and path constraint extraction. 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.
Keywords:
Large Language Model
Differential Testing
Static Analysis
Deep Learning Library Testing

Journal

A
ACM Transactions on Software Engineering and Methodology
IF:
6.2
Papers:
1.2K
Citations:
3.4K

Organization

M
monash university
Scholars:
8.7K
Papers: 3.9K
Citations: 0
H
hong kong university of science & technology
Scholars:
586
Papers: 323
Citations: 0