[论文解读] Fuzzing Automatic Differentiation in Deep-Learning Libraries
该论文提出了 $\nabla$ Fuzz,这是首个专门针对深度学习库中自动微分(AD)的自动化、API 级模糊测试工具。通过在多种执行场景下进行差异测试,并应用自动化过滤策略以减少由数值不稳定性引起的误报,$\nabla$ Fuzz 在 PyTorch、TensorFlow、JAX 和 OneFlow 中检测到 173 个错误,其中 144 个经开发者确认——包括 117 个此前未知的错误,以及 107 个与 AD 相关的错误,涵盖 PyTorch 和 JAX 在两个月内 58.3% 的高优先级 AD 错误。
Deep learning (DL) has attracted wide attention and has been widely deployed in recent years. As a result, more and more research efforts have been dedicated to testing DL libraries and frameworks. However, existing work largely overlooked one crucial component of any DL system, automatic differentiation (AD), which is the basis for the recent development of DL. To this end, we propose $ abla$Fuzz, the first general and practical approach specifically targeting the critical AD component in DL libraries. Our key insight is that each DL library API can be abstracted into a function processing tensors/vectors, which can be differentially tested under various execution scenarios (for computing outputs/gradients with different implementations). We have implemented $ abla$Fuzz as a fully automated API-level fuzzer targeting AD in DL libraries, which utilizes differential testing on different execution scenarios to test both first-order and high-order gradients, and also includes automated filtering strategies to remove false positives caused by numerical instability. We have performed an extensive study on four of the most popular and actively-maintained DL libraries, PyTorch, TensorFlow, JAX, and OneFlow. The result shows that $ abla$Fuzz substantially outperforms state-of-the-art fuzzers in terms of both code coverage and bug detection. To date, $ abla$Fuzz has detected 173 bugs for the studied DL libraries, with 144 already confirmed by developers (117 of which are previously unknown bugs and 107 are related to AD). Remarkably, $ abla$Fuzz contributed 58.3% (7/12) of all high-priority AD bugs for PyTorch and JAX during a two-month period. None of the confirmed AD bugs were detected by existing fuzzers.
研究动机与目标
- 解决现有深度学习库测试技术中长期被忽视的关键问题:自动微分(AD)作为深度学习系统的基础组件,缺乏有效测试。
- 开发一种完全自动化的、基于 API 的模糊测试工具,可系统性地测试主流深度学习库中 AD 引擎的一阶和高阶梯度。
- 通过基于梯度原理解的一致性策略,实现自动化过滤,减少由数值不稳定性导致的 AD 测试误报。
- 在不依赖模型级生成或手动输入注释的前提下,实现 AD 引擎的全面且实用的测试。
- 证明跨执行场景的差异测试是一种可靠原理解,可用于检测 AD 实现中的细微错误。
提出的方法
- 将每个深度学习库的 API 抽象为在张量/向量上操作的函数,支持在不同执行场景下系统性地进行梯度计算的差异测试。
- 通过从开源代码中自动挖掘和变异 API 输入,生成多样化的测试输入,重点关注有效的张量形状和数值,以触发 AD 路径。
- 通过比较不同执行路径(如前向模式与反向模式、不同后端实现)计算出的梯度,实施差异测试以检测不一致性。
- 基于数值稳定性阈值 ($\delta$) 实现一个梯度原理解,用于识别并过滤由浮点精度和不稳定性引起的误报。
- 采用基于采样的方法,在不同 $\delta$ 值下评估梯度原理解的误报率(FPR),以调优过滤阈值。
- 将模糊测试器集成到完全自动化的流水线中,支持 PyTorch、TensorFlow、JAX 和 OneFlow,实现可扩展且可重复的 AD 测试。

实验结果
研究问题
- RQ1完全自动化、基于 API 的模糊测试工具能否有效检测深度学习库 AD 引擎中的错误?
- RQ2跨多样化执行场景的差异测试在发现先前未知的 AD 相关错误方面有多有效?
- RQ3基于梯度原理解一致性的自动化过滤策略,在多大程度上能减少 AD 测试中由数值不稳定性引起的误报?
- RQ4$\nabla$ Fuzz 在代码覆盖率和 AD 组件错误检测方面与现有最先进模糊测试工具相比如何?
- RQ5与其它测试技术相比,$\nabla$ Fuzz 能够识别出多大比例的主要深度学习库中的高优先级 AD 错误?
主要发现
- $\nabla$ Fuzz 在四个主要深度学习库(PyTorch、TensorFlow、JAX 和 OneFlow)中总共检测到 173 个错误。
- 其中 144 个错误经开发者确认,包括 117 个此前未知的错误,以及 107 个与自动微分直接相关的错误。
- 在为期两个月的评估期内,该工具贡献了 PyTorch 和 JAX 所有高优先级 AD 相关错误的 58.3%(12 个中的 7 个)。
- 所有已确认的 AD 相关错误均未被先前最先进的模糊测试工具检测到,凸显了 $\nabla$ Fuzz 方法的新颖性与有效性。
- 随着 $\delta$ 值降低,梯度原理解过滤器的误报率(FPR)上升,在 $\delta = 10^{-5}$ 时,PyTorch 的 FPR 达到 22.9%,TensorFlow 达到 21.1%,表明需谨慎调优阈值。
- 评估结果证实,$\nabla$ Fuzz 在代码覆盖率和 AD 特异性漏洞检测方面显著优于现有的基于模型级和 API 级的模糊测试工具。

阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。