Understanding Bugs in Multi-Language Deep Learning Frameworks

Zengyang Li, Sicheng Wang, Wenshuo Wang, Peng Liang, Ran Mo, Bing Li · DOI

Abstract

Deep learning frameworks (DLFs) like PyTorch and TensorFlow are complex, multi-language systems that serve as the backbone of modern AI. This paper manually analyzes nearly 1,500 bugs across three major frameworks to reveal that bugs spanning multiple programming languages (MPL bugs) are significantly more complex to fix and often require more developer coordination than those confined to a single language.

Introduction

Most popular deep learning frameworks are "multi-language programming" (MPL) systems. They typically offer a user-friendly Python interface while relying on high-performance C++ or CUDA for the heavy lifting. While this "best of both worlds" approach is great for performance, it creates a massive headache for maintenance. The authors identify a gap in our understanding of how these cross-language boundaries contribute to software defects. Debugging a system where a Python error might actually be caused by a memory leak in a C++ backend is notoriously difficult. By systematically categorizing these bugs and measuring their impact, the researchers aim to provide a roadmap for better bug prevention and resolution in the AI infrastructure space.

Methods

The researchers conducted an empirical study using a four-step manual analysis process:

  1. Case Selection: They chose three massive, popular DLFs: MXNet, PyTorch, and TensorFlow, based on criteria like popularity (10k+ stars) and project maturity.
  2. Data Collection: They extracted 1,497 bug-fixing pull requests and their associated issues from GitHub.
  3. Bug Classification: Using "grounded theory," they manually categorized bugs into 12 distinct types based on developer labels and code characteristics.
  4. Impact Analysis: They measured the "cost" of these bugs using six indicators: Open Time (OT), Lines of Code Modified (LOCM), Number of Files Modified (NOFM), Code Entropy (complexity of the change), Number of Developers Participating (NODP), and Number of Comments (NOC).
Taxonomy of bug classifications in deep learning frameworks.

Datasets

The study analyzed a curated dataset of 1,497 bugs and their corresponding fixes:

  • MXNet: 189 units
  • PyTorch: 926 units
  • TensorFlow: 382 units

The authors have made this dataset available online to support further research into DLF reliability.

Key Insights and Ideas

  • The Python/C++ Marriage: In all three frameworks, the combination of Python and C/C++ accounted for over 92% of all multi-language bugs. This confirms that the primary "friction point" in AI infrastructure is the interface between high-level logic and low-level performance code.
  • Memory Bugs are "Social" Bugs: Memory-related bugs (leaks, corruption) required the highest number of developers and comments to resolve. They are the most communication-intensive, likely because they require deep expertise in how the framework manages resources across language boundaries.
  • Deployment is the Bottleneck: Deployment bugs (errors during model export or transformation) take the longest to close. This suggests that the "last mile" of moving a model from training to production is one of the most fragile parts of the DLF ecosystem.
  • MPL vs. SPL Complexity: Multi-language (MPL) bug fixes are consistently more complex than single-language (SPL) fixes. They involve more files and more lines of code, proving that "cross-language communication" is a significant tax on developer productivity.

Key Results

The analysis revealed significant differences in bug prevalence and complexity across the studied frameworks.

Distribution of bug types across MXNet, PyTorch, and TensorFlow.
  • Prevalence: MPL bugs make up a significant portion of the total bug count: 31.4% in PyTorch, 28.6% in MXNet, and 16.0% in TensorFlow.
  • Dominant Bug Types: "Data bugs" (errors in data preprocessing or loading) were the most common overall, accounting for nearly 20% of the dataset.
  • Complexity Gap: In PyTorch, MPL bug fixes had significantly longer "open times" and higher communication complexity (more comments and developers) compared to SPL fixes.
  • Fix Effort: Across all frameworks, the number of files and lines of code modified for an MPL fix was significantly higher than for SPL fixes, highlighting the "sprawl" of cross-language defects.

Limitations and Future Work

The authors acknowledge a few limitations:

  • Scope: The study only looked at three frameworks. While they are the most popular, results might differ for smaller or more specialized frameworks (like JAX).
  • Manual Bias: Although they used a "pilot tagging" process to ensure consistency between researchers, manual classification always carries some subjective risk.
  • GitHub Centricity: The study relies on explicit links between issues and pull requests on GitHub; bugs discussed in private or on other platforms (like Slack or internal forums) were not captured.

Future Work: The authors plan to expand their dataset and use these insights to build automated bug prediction models specifically designed to catch multi-language defects before they reach production.

Summary updated

BibTeX
@inproceedings{li2023understanding,
  author = {Zengyang Li and Sicheng Wang and Wenshuo Wang and Peng Liang and Ran Mo and Bing Li},
  title = {{Understanding Bugs in Multi-Language Deep Learning Frameworks}},
  booktitle = {ICPC},
  year = {2023},
  doi = {10.1109/icpc58990.2023.00047},
}
Figure