Skip to main content
QUICK REVIEW

[Paper Review] Fuzzing Automatic Differentiation in Deep-Learning Libraries

Chenyuan Yang, Yinlin Deng|arXiv (Cornell University)|Feb 8, 2023
Adversarial Robustness in Machine LearningComputer Science39 references3 citations
TL;DR

This paper introduces $\nabla$ Fuzz, the first automated, API-level fuzzer specifically designed to test automatic differentiation (AD) in deep learning libraries. By leveraging differential testing across diverse execution scenarios and applying automated filtering to reduce false positives from numerical instability, $\nabla$ Fuzz detects 173 bugs across PyTorch, TensorFlow, JAX, and OneFlow, with 144 confirmed by developers—117 of which were previously unknown and 107 related to AD, including 58.3% of high-priority AD bugs in PyTorch and JAX over a two-month period.

ABSTRACT

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.

Motivation & Objective

  • To address the critical gap in testing automatic differentiation (AD), a foundational component of deep learning systems, which has been largely overlooked in existing deep learning library testing techniques.
  • To develop a fully automated, API-level fuzzer that can systematically test both first-order and high-order gradients in AD engines across major deep learning libraries.
  • To reduce false positives in AD testing caused by numerical instability through an automated filtering strategy based on gradient oracle consistency.
  • To enable comprehensive and practical testing of AD engines without relying on model-level generation or manual input annotation.
  • To demonstrate the effectiveness of differential testing across execution scenarios as a robust oracle for detecting subtle AD implementation bugs.

Proposed method

  • Abstracting each deep learning library API as a function operating on tensors/vectors, enabling systematic differential testing under varied execution scenarios for gradient computation.
  • Generating diverse test inputs via automated API input mining and mutation from open-source code, focusing on valid tensor shapes and values to trigger AD paths.
  • Applying differential testing by comparing gradients computed via different execution paths (e.g., forward vs. reverse mode, different backend implementations) to detect inconsistencies.
  • Implementing a gradient oracle based on numerical stability thresholds ($\delta$) to identify and filter out false positives arising from floating-point precision and instability.
  • Using a sampling-based approach to evaluate the false positive rate (FPR) of the gradient oracle across different $\delta$ values to tune the filtering threshold.
  • Integrating the fuzzer into a fully automated pipeline that supports PyTorch, TensorFlow, JAX, and OneFlow, enabling scalable and repeatable AD testing.
Figure 1 : Crash bug in AD
Figure 1 : Crash bug in AD

Experimental results

Research questions

  • RQ1Can a fully automated, API-level fuzzer effectively detect bugs in the automatic differentiation engines of deep learning libraries?
  • RQ2How effective is differential testing across diverse execution scenarios in uncovering previously unknown AD-related bugs?
  • RQ3To what extent can automated filtering based on gradient oracle consistency reduce false positives caused by numerical instability in AD testing?
  • RQ4How does $\nabla$ Fuzz compare to existing state-of-the-art fuzzers in terms of code coverage and bug detection in AD components?
  • RQ5What proportion of high-priority AD bugs in major deep learning libraries can be attributed to $\nabla$ Fuzz compared to other testing techniques?

Key findings

  • $\nabla$ Fuzz detected a total of 173 bugs across four major deep learning libraries: PyTorch, TensorFlow, JAX, and OneFlow.
  • Of these, 144 bugs were confirmed by developers, including 117 that were previously unknown and 107 specifically related to automatic differentiation.
  • The fuzzer contributed 58.3% (7 out of 12) of all high-priority AD-related bugs reported for PyTorch and JAX during a two-month evaluation period.
  • None of the confirmed AD-related bugs were detected by prior state-of-the-art fuzzers, highlighting the novelty and effectiveness of $\nabla$ Fuzz’s approach.
  • The false positive rate (FPR) of the gradient oracle filter increased with decreasing $\delta$ values, reaching 22.9% for PyTorch and 21.1% for TensorFlow at $\delta = 10^{-5}$, indicating the need for careful threshold tuning.
  • The evaluation confirms that $\nabla$ Fuzz significantly outperforms existing model-level and API-level fuzzers in both code coverage and detection of AD-specific vulnerabilities.
Figure 2 : An example of DL model training and inference
Figure 2 : An example of DL model training and inference

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.